
:root {
  color-scheme: light;
  --bg: #f4f6fb;
  --panel: #ffffff;
  --line: #e4e8f0;
  --text: #151a24;
  --muted: #657083;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --danger: #dc2626;
  --ok: #177245;
  --shadow: 0 12px 34px rgba(24, 35, 58, .08);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  display: grid;
  grid-template-columns: 212px minmax(0, 1fr);
  min-height: 100vh;
}
header {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 100vh;
  padding: 22px 14px;
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.brand {
  padding: 0 10px 12px;
  font-weight: 850;
  font-size: 20px;
  letter-spacing: .2px;
}
nav { display: grid; gap: 6px; }
nav a, .button {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 38px;
  padding: 0 12px;
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
}
nav a:hover, .button:hover { background: #eef4ff; color: var(--accent); }
.logout { margin-top: auto; }
.user { color: var(--muted); white-space: nowrap; padding: 0 10px; }
main {
  width: calc(100% - 24px);
  max-width: none;
  margin: 16px 12px 48px;
}
.public {
  min-height: 100vh;
  display: grid;
  place-items: center;
  grid-template-columns: 1fr;
}
.public main { width: min(520px, calc(100vw - 32px)); margin: 0; }
section, .auth {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
  overflow-x: auto;
}
.auth h1 { margin: 0 0 10px; font-size: 24px; }
.auth p { color: var(--muted); margin: 0 0 18px; }
.auth.wide { width: min(760px, calc(100vw - 32px)); }
.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}
h2 { margin: 0; font-size: 18px; }
.section-title span, .section-title a { color: var(--muted); text-decoration: none; }
.grid.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stats article {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}
.stats span { display: block; color: var(--muted); }
.stats strong { display: block; margin-top: 8px; font-size: 30px; }
form { margin: 0; }
label { display: grid; gap: 7px; margin-bottom: 12px; color: var(--muted); }
.checkline {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}
.checkline input {
  width: 16px;
  height: 16px;
  min-height: 16px;
  padding: 0;
}
input, select, textarea {
  width: 100%;
  min-height: 36px;
  border: 1px solid #cbd3df;
  border-radius: 6px;
  padding: 7px 10px;
  background: #fff;
  color: var(--text);
  font: inherit;
}
textarea { resize: vertical; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
button {
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  padding: 0 14px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
button:hover { background: var(--accent-dark); }
button.danger { background: var(--danger); }
button.ghost {
  background: #fff;
  color: var(--danger);
  border: 1px solid #fecaca;
}
button.ghost:hover { background: #fff1f2; }
.toolbar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)) auto;
  gap: 10px;
  align-items: center;
}
.filterbar {
  grid-template-columns: minmax(220px, 2fr) repeat(4, minmax(112px, 1fr)) auto auto;
  margin-bottom: 12px;
}
.filterbar textarea {
  min-height: 36px;
  resize: vertical;
}
.project-picker {
  display: grid;
  grid-template-columns: minmax(240px, 420px) max-content;
  align-items: end;
  gap: 12px;
  margin: 0 0 10px;
}
.all-card-total {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  color: var(--muted);
  white-space: nowrap;
}
.all-card-total strong {
  color: var(--text);
  font-size: 16px;
}
.view-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
}
.project-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
}
.project-nav .button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: #fff;
}
.project-nav .button strong {
  margin-left: 6px;
  color: var(--muted);
}
.project-nav .button.active {
  background: #eef4ff;
  border-color: #b7cdfa;
  color: var(--accent);
}
.project-nav .button.active strong {
  color: var(--accent);
}
.card-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 10px;
}
.card-summary span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  color: var(--muted);
}
.card-summary strong {
  color: var(--text);
  font-size: 16px;
}
.view-tabs .button {
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: #fff;
}
.view-tabs .button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.appbar {
  display: grid;
  grid-template-columns: minmax(170px, 1.1fr) minmax(210px, 1.4fr) 108px 108px 96px;
  gap: 10px;
  align-items: end;
  margin-bottom: 16px;
}
.createbar {
  display: grid;
  grid-template-columns: minmax(190px, 1.4fr) 86px 106px 92px 132px 120px minmax(150px, 1fr) 82px;
  gap: 10px;
  align-items: end;
  margin-top: 4px;
}
.field {
  gap: 5px;
  margin: 0;
  font-size: 12px;
}
.field span {
  color: var(--muted);
  font-weight: 700;
}
.createbar button { width: 100%; }
.appbar button { width: 100%; }
.bulkbar {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 10px 0 14px;
  color: var(--muted);
}
.bulkbar input.tiny {
  width: 54px;
  min-height: 32px;
  padding: 3px 8px;
}
.card-check,
#checkAllCards {
  width: 16px;
  height: 16px;
  min-height: 16px;
  padding: 0;
  margin: 0;
}
.inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 6px 0 0;
  vertical-align: middle;
}
.inline button,
.inline input,
.inline select {
  min-height: 26px;
  padding: 2px 7px;
  font-size: 12px;
}
.inline select { width: auto; }
.inline input.small { width: 82px; }
.inline input.tiny { width: 52px; }
.edit-cell select,
.edit-cell input {
  min-height: 28px;
  padding: 3px 7px;
  font-size: 12px;
}
.edit-cell input.tiny { width: 54px; }
.actions {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 292px;
  white-space: nowrap;
}
.actions > button,
.actions .inline button,
.actions .inline input {
  height: 28px;
  min-height: 28px;
  padding: 0 8px;
  font-size: 12px;
}
.actions .inline {
  margin: 0;
  font-size: 12px;
  line-height: 1;
  gap: 4px;
}
.logout button {
  background: #eef2f7;
  color: var(--text);
}
.secret {
  padding: 14px;
  margin: 14px 0;
  border: 1px dashed #9aa7b8;
  border-radius: 8px;
  background: #f7fafc;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 18px;
  word-break: break-all;
}
.result-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.generated-output textarea {
  min-height: 360px;
  line-height: 1.65;
}
table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.apps-table { min-width: 1040px; }
.cards-table {
  min-width: 1696px;
  table-layout: fixed;
}
.cards-table col.check-col { width: 36px; }
.cards-table col.card-col { width: 230px; }
.cards-table col.app-col { width: 106px; }
.cards-table col.status-col { width: 60px; }
.cards-table col.time-col { width: 122px; }
.cards-table col.online-col { width: 64px; }
.cards-table col.expires-col { width: 122px; }
.cards-table col.mode-col { width: 94px; }
.cards-table col.device-col { width: 96px; }
.cards-table col.note-col { width: 96px; }
.cards-table col.edit-status-col { width: 76px; }
.cards-table col.edit-mode-col { width: 98px; }
.cards-table col.edit-limit-col { width: 64px; }
.cards-table col.action-col { width: 292px; }
th, td {
  padding: 4px 7px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}
th { color: var(--muted); font-weight: 700; background: #f8fafc; }
tbody tr:hover { background: #f9fbff; }
td code {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
  white-space: nowrap;
}
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 12px;
}
.badge.ok { background: #e7f5ee; color: var(--ok); }
.badge.off { background: #f8e8e6; color: var(--danger); }
.badge.neutral { background: #eef2f7; color: #435066; }
.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 14px;
  color: var(--muted);
}
.pager .button.disabled {
  pointer-events: none;
  opacity: .45;
}
@media (max-width: 860px) {
  body { display: block; }
  header {
    min-height: auto;
    position: sticky;
    padding: 12px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  nav {
    display: flex;
    overflow-x: auto;
  }
  .user { display: none; }
  main { width: calc(100vw - 24px); margin: 14px 12px 40px; }
  .grid.stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toolbar, .filterbar, .createbar, .appbar, .project-picker { grid-template-columns: 1fr; }
  .bulkbar { flex-wrap: wrap; }
  .result-actions { flex-wrap: wrap; }
  table { display: block; overflow-x: auto; white-space: nowrap; }
}
