/* ============ Тема: токены в духе Notion ============ */
:root {
  color-scheme: light;
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f7f7f5;
  --surface-3: #efefed;
  --grid: #e9e9e7;
  --border: #e9e9e7;
  --border-strong: #cfcdc7;
  --fg: #37352f;
  --fg-2: #5f5e5a;
  --muted-fg: #787774;
  --faint: #9b9a97;
  --row-hover: #f4f4f2;

  --accent: #2383e2;
  --accent-hover: #1b74cc;
  --accent-fg: #2383e2;
  --accent-soft: rgba(35, 131, 226, .10);
  --accent-border: rgba(35, 131, 226, .40);
  --ring: rgba(35, 131, 226, .45);
  --on-accent: #ffffff;

  --ok: #448361;     --ok-soft: #dbeddb;      --ok-fg: #1c3829;
  --warn: #cb912f;   --warn-soft: #fdecc8;    --warn-fg: #402c1b;
  --bad: #d44c47;    --bad-soft: #ffe2dd;     --bad-fg: #5d1715;
  --info: #337ea9;   --info-soft: #d3e5ef;    --info-fg: #183347;
  --neutral-soft: #e3e2e0; --neutral-fg: #32302c;
  --mark: #fbe7a8;

  --logo-bg: #37352f;
  --logo-fg: #ffffff;

  --shadow-sm: rgba(15, 15, 15, .06) 0 0 0 1px, rgba(15, 15, 15, .06) 0 1px 2px;
  --shadow: rgba(15, 15, 15, .05) 0 0 0 1px, rgba(15, 15, 15, .10) 0 2px 4px;
  --shadow-lg: rgba(15, 15, 15, .05) 0 0 0 1px, rgba(15, 15, 15, .10) 0 3px 6px, rgba(15, 15, 15, .20) 0 9px 24px;
  --overlay: rgba(15, 15, 15, .55);
  --toast-bg: #2f2f2f;
  --toast-fg: #ffffff;
  --radius: 4px;
  --radius-lg: 6px;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #191919;
  --surface: #191919;
  --surface-2: #202020;
  --surface-3: #2a2a2a;
  --grid: #2f2f2f;
  --border: #2f2f2f;
  --border-strong: #474747;
  --fg: #d4d4d4;
  --fg-2: #b3b3b3;
  --muted-fg: #9b9b9b;
  --faint: #6f6f6f;
  --row-hover: #222222;

  --accent: #2383e2;
  --accent-hover: #3b92e8;
  --accent-fg: #529cca;
  --accent-soft: rgba(35, 131, 226, .16);
  --accent-border: rgba(82, 156, 202, .45);
  --ring: rgba(82, 156, 202, .50);
  --on-accent: #ffffff;

  --ok: #529e72;     --ok-soft: #2b593f;      --ok-fg: #cfe8d7;
  --warn: #c19138;   --warn-soft: #89632a;    --warn-fg: #f6e4bd;
  --bad: #df5452;    --bad-soft: #6e3630;     --bad-fg: #f8d0cc;
  --info: #529cca;   --info-soft: #28456c;    --info-fg: #d2e4f3;
  --neutral-soft: #373737; --neutral-fg: #d4d4d4;
  --mark: #5c4a1f;

  --logo-bg: #ededeb;
  --logo-fg: #191919;

  --shadow-sm: rgba(255, 255, 255, .055) 0 0 0 1px, rgba(0, 0, 0, .35) 0 1px 2px;
  --shadow: rgba(255, 255, 255, .06) 0 0 0 1px, rgba(0, 0, 0, .40) 0 2px 4px;
  --shadow-lg: rgba(255, 255, 255, .06) 0 0 0 1px, rgba(0, 0, 0, .50) 0 3px 6px, rgba(0, 0, 0, .60) 0 9px 24px;
  --overlay: rgba(0, 0, 0, .60);
  --toast-bg: #ededeb;
  --toast-fg: #191919;
}

/* ============ база ============ */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 14px/1.5 var(--font);
  color: var(--fg); background: var(--bg);
  display: flex; flex-direction: column;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
body.modal { overflow: hidden; }
a { color: var(--accent-fg); text-decoration: none; }
a:hover { text-decoration: underline; }
mark { background: var(--mark); color: inherit; border-radius: 2px; padding: 0 1px; }
svg { width: 1em; height: 1em; flex: none; }
.mono { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--muted-fg); }
.pad { padding: 12px 0; }
.hint { color: var(--muted-fg); margin: 0 0 12px; font-size: 13px; }

.pill {
  display: inline-flex; align-items: center; height: 18px; padding: 0 6px; border-radius: 3px;
  background: var(--neutral-soft); color: var(--neutral-fg); font-size: 12px; font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.pill.accent { background: var(--accent-soft); color: var(--accent-fg); }
.pill:empty { display: none; }

/* чекбокс */
.cb {
  appearance: none; -webkit-appearance: none; width: 16px; height: 16px; margin: 0; flex: none;
  border: 1.5px solid var(--border-strong); border-radius: 3px; background: var(--surface);
  display: inline-grid; place-content: center; cursor: pointer; transition: background .12s, border-color .12s;
}
.cb::before {
  content: ''; width: 9px; height: 9px; transform: scale(0); transition: transform .12s; background: var(--on-accent);
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}
.cb:checked { background: var(--accent); border-color: var(--accent); }
.cb:checked::before { transform: scale(1); }
.cb:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.cb:disabled { opacity: .5; cursor: default; }

/* кнопки */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 30px; padding: 0 10px;
  border-radius: var(--radius); border: 1px solid var(--border-strong); background: var(--surface); color: var(--fg);
  font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { background: var(--surface-3); }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--fg-2); }
.btn.ghost:hover { background: var(--surface-3); color: var(--fg); }
.btn.sm { height: 26px; padding: 0 8px; font-size: 13px; }
.btn.wide { width: 100%; margin-top: 8px; }
.btn:disabled { opacity: .4; cursor: default; pointer-events: none; }
.btn svg { width: 15px; height: 15px; }
.icon-btn {
  width: 28px; height: 28px; border-radius: var(--radius); border: 0; background: transparent; color: var(--muted-fg);
  display: grid; place-items: center; cursor: pointer; flex: none; transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--fg); }
.icon-btn svg { width: 16px; height: 16px; }
.icon-sun, .icon-moon { display: none; }
:root[data-theme="dark"] .icon-sun { display: block; }
:root[data-theme="light"] .icon-moon { display: block; }
.link { background: none; border: 0; padding: 0; margin-left: 10px; font: inherit; color: var(--accent-fg); cursor: pointer; }
.link:hover { text-decoration: underline; }

/* ============ шапка ============ */
.topbar { padding: 10px 16px 8px; display: flex; flex-direction: column; gap: 8px; }
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.brand { display: inline-flex; align-items: center; gap: 9px; margin-right: 8px; }
.logo { width: 24px; height: 24px; display: block; }
.logo svg { width: 100%; height: 100%; display: block; }
.brand-name { font-weight: 600; font-size: 15px; letter-spacing: -.01em; }

.search { position: relative; flex: 1 1 320px; max-width: 620px; }
.search input {
  width: 100%; height: 32px; padding: 0 40px 0 32px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface-2); color: var(--fg); font: inherit; outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.search input::placeholder { color: var(--faint); }
.search input:focus-visible { background: var(--surface); border-color: var(--accent-border); box-shadow: 0 0 0 2px var(--accent-soft); }
.search input::-webkit-search-cancel-button { cursor: pointer; }
.search > svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--muted-fg); pointer-events: none; }
.search kbd {
  position: absolute; right: 9px; top: 50%; transform: translateY(-50%);
  font: 11px var(--mono); color: var(--faint); border: 1px solid var(--border); border-radius: 3px;
  padding: 0 5px; line-height: 17px; background: var(--surface); pointer-events: none;
}
.search input:focus ~ kbd { opacity: 0; }
.actions { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; height: 28px; padding: 0 10px 0 8px; border-radius: 999px;
  border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer; user-select: none; white-space: nowrap;
  font-size: 13px; color: var(--fg-2); transition: background .12s, border-color .12s, color .12s;
}
.chip:hover { background: var(--surface-2); }
.chip .cb { width: 14px; height: 14px; border-radius: 3px; }
.chip .cb::before { width: 8px; height: 8px; }
.chip b { font-weight: 400; color: var(--muted-fg); font-variant-numeric: tabular-nums; font-size: 12px; }
.chip:has(.cb:checked) { background: var(--accent-soft); border-color: var(--accent-border); color: var(--accent-fg); }
.chip:has(.cb:checked) b { color: var(--accent-fg); }
.meta { margin-left: auto; color: var(--muted-fg); white-space: nowrap; font-variant-numeric: tabular-nums; font-size: 13px; }

/* ============ сетка ============ */
main { flex: 1; min-height: 0; display: flex; padding: 0 16px 16px; }
.grid-card {
  flex: 1; min-height: 0; overflow: auto; position: relative;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
}
table { width: 100%; min-width: 1100px; border-collapse: separate; border-spacing: 0; table-layout: fixed; font-size: 13px; }
.c-no { width: 68px; } .c-company { width: 23%; } .c-contacts { width: 24%; } .c-prod { width: 25%; } .c-activity { width: 25%; } .c-approved { width: 96px; }

thead th {
  position: sticky; top: 0; z-index: 2; height: 34px; padding: 0 10px; text-align: left;
  background: var(--surface-2); color: var(--muted-fg); font-size: 12px; font-weight: 500;
  border-bottom: 1px solid var(--grid); border-right: 1px solid var(--grid); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  cursor: pointer; user-select: none; transition: color .12s, background .12s;
}
thead th:last-child { border-right: 0; }
thead th:hover { color: var(--fg); background: var(--surface-3); }
thead th[aria-sort] { color: var(--fg); }
.th { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; }
.th svg { width: 14px; height: 14px; opacity: .8; }
.th-text { overflow: hidden; text-overflow: ellipsis; }
thead th[aria-sort="ascending"] .th-text::after { content: " ↑"; color: var(--muted-fg); }
thead th[aria-sort="descending"] .th-text::after { content: " ↓"; color: var(--muted-fg); }
.th-approved .th, .th-no .th { justify-content: center; width: 100%; }
.th-no { padding: 0 8px; }

tbody td {
  padding: 9px 10px; vertical-align: top;
  border-bottom: 1px solid var(--grid); border-right: 1px solid var(--grid);
}
tbody td:last-child { border-right: 0; }
tbody tr.row { cursor: pointer; }
tbody tr.row:hover td { background: var(--row-hover); }
tbody tr.row.approved td.no { box-shadow: inset 3px 0 0 var(--ok); }
td.no { color: var(--faint); text-align: center; padding-left: 6px; padding-right: 6px; }
td.center { text-align: center; }
td.center .cb { margin-top: 1px; }

.name { font-weight: 600; margin-bottom: 1px; }
.inn { color: var(--muted-fg); margin-bottom: 4px; }
.txt {
  white-space: pre-line; overflow-wrap: anywhere; color: var(--fg-2);
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
}
.txt.muted { color: var(--muted-fg); }
.tags { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 6px; }
.badge {
  display: inline-flex; align-items: center; height: 20px; padding: 0 6px; border-radius: 3px;
  font-size: 12px; font-weight: 500; white-space: nowrap; line-height: 1;
}
.badge.ok { background: var(--ok-soft); color: var(--ok-fg); }
.badge.warn { background: var(--warn-soft); color: var(--warn-fg); }
.badge.bad { background: var(--bad-soft); color: var(--bad-fg); }
.badge.accent { background: var(--info-soft); color: var(--info-fg); }
.badge.neutral { background: var(--neutral-soft); color: var(--neutral-fg); }

/* шкала активности 0–5 */
.score { display: inline-flex; align-items: center; gap: 2px; height: 20px; }
.score i { display: block; width: 6px; height: 12px; border-radius: 1.5px; background: var(--surface-3); }
.score i.on { background: currentColor; }
.score b { margin-left: 6px; font: 500 12px var(--mono); }
.score.lvl-ok { color: var(--ok); } .score.lvl-warn { color: var(--warn); } .score.lvl-bad { color: var(--bad); }

/* скелетон и статусы */
tr.skeleton td { padding: 12px 10px; }
tr.skeleton span {
  display: block; height: 10px; border-radius: 3px; margin: 4px 0; width: 90%;
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%);
  background-size: 200% 100%; animation: shimmer 1.2s infinite;
}
tr.skeleton span.w60 { width: 60%; } tr.skeleton span.w70 { width: 70%; } tr.skeleton span.w80 { width: 80%; } tr.skeleton span.w50 { width: 50%; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.sentinel { height: 1px; }
.status { padding: 14px; text-align: center; color: var(--muted-fg); font-size: 13px; }
.empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 48px 16px; color: var(--muted-fg); }
.empty svg { width: 28px; height: 28px; opacity: .5; }
.empty.small { padding: 24px 0; align-items: flex-start; }

/* ============ выезжающая панель ============ */
.backdrop { position: fixed; inset: 0; z-index: 40; background: var(--overlay); }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 50; width: min(640px, 100vw);
  background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; transform: translateX(100%); transition: transform .2s cubic-bezier(.2,.8,.2,1);
}
.drawer.open { transform: none; }
.drawer-head { display: flex; align-items: flex-start; gap: 12px; padding: 16px 20px 12px; }
.drawer-heading { flex: 1; min-width: 0; }
.drawer-title { font-size: 18px; font-weight: 700; line-height: 1.3; letter-spacing: -.01em; overflow-wrap: anywhere; }
.drawer-sub { color: var(--muted-fg); margin-top: 3px; }
.drawer-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.drawer-tags:empty { display: none; }
.tabs { display: flex; gap: 2px; padding: 0 12px; border-bottom: 1px solid var(--border); flex: none; }
.tab {
  position: relative; height: 36px; padding: 0 8px; border: 0; background: transparent; font: inherit; font-size: 13px; font-weight: 500;
  color: var(--muted-fg); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; border-radius: var(--radius) var(--radius) 0 0;
}
.tab:hover { color: var(--fg); background: var(--surface-2); }
.tab.active { color: var(--fg); }
.tab.active::after { content: ''; position: absolute; left: 6px; right: 6px; bottom: -1px; height: 2px; background: var(--fg); }
.panel { display: none; flex: 1; min-height: 0; overflow: auto; padding: 16px 20px; }
.panel.active { display: flex; flex-direction: column; }

/* форма */
.fields { display: flex; flex-direction: column; gap: 14px; }
.field span { display: block; font-size: 12px; font-weight: 500; color: var(--muted-fg); margin-bottom: 5px; }
.field textarea {
  display: block; width: 100%; min-height: 64px; resize: vertical; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface-2); color: var(--fg); font: inherit; font-size: 13px; line-height: 1.5; outline: none; transition: border-color .15s, box-shadow .15s, background .15s;
}
.field textarea:focus { border-color: var(--accent-border); box-shadow: 0 0 0 2px var(--accent-soft); background: var(--surface); }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; font-size: 13px; margin-top: 2px; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track { position: relative; width: 32px; height: 18px; border-radius: 999px; background: var(--border-strong); transition: background .15s; flex: none; }
.switch-track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgb(0 0 0 / .25); transition: transform .15s; }
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(14px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--ring); outline-offset: 2px; }
.drawer-actions {
  position: sticky; bottom: 0; display: flex; align-items: center; gap: 8px; margin: 16px -20px -16px; padding: 12px 20px;
  background: var(--surface); border-top: 1px solid var(--border);
}
.drawer-actions .muted { flex: 1; font-size: 12px; }

/* исходник */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 13px; }
.kv .k { color: var(--muted-fg); white-space: nowrap; padding-top: 1px; }
.kv .v { white-space: pre-line; overflow-wrap: anywhere; }

/* история версий */
.timeline { list-style: none; margin: 0; padding: 0 0 8px; font-size: 13px; }
.tl { position: relative; padding: 0 0 18px 24px; }
.tl::before { content: ''; position: absolute; left: 5px; top: 18px; bottom: 0; width: 2px; background: var(--grid); }
.tl:last-child::before { display: none; }
.tl-dot { position: absolute; left: 0; top: 4px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--fg-2); background: var(--surface); }
.tl.act-approve .tl-dot { border-color: var(--ok); }
.tl.act-rollback .tl-dot { border-color: var(--warn); }
.tl.act-import .tl-dot { border-color: var(--border-strong); }
.tl.current .tl-dot { background: var(--fg-2); }
.tl.current.act-approve .tl-dot { background: var(--ok); }
.tl.current.act-rollback .tl-dot { background: var(--warn); }
.tl.current.act-import .tl-dot { background: var(--border-strong); }
.tl-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.tl-head b { font-weight: 600; }
.tl-action { color: var(--fg-2); }
.tl-head time { margin-left: auto; }
.tl-note, .tl-changed { margin-top: 3px; font-size: 12px; }
.tl .btn { margin-top: 10px; }
.diff-line { margin-top: 6px; font-size: 12px; }
.diff { margin-top: 8px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.diff summary { padding: 6px 10px; cursor: pointer; font-weight: 500; font-size: 12px; background: var(--surface-2); list-style: none; display: flex; gap: 8px; align-items: center; }
.diff summary::before { content: '▸'; font-size: 10px; color: var(--muted-fg); transition: transform .12s; }
.diff[open] summary::before { transform: rotate(90deg); }
.diff-old, .diff-new { padding: 8px 10px; font-size: 12px; white-space: pre-line; overflow-wrap: anywhere; }
.diff-old { background: var(--bad-soft); color: var(--bad-fg); border-top: 1px solid var(--border); }
.diff-new { background: var(--ok-soft); color: var(--ok-fg); border-top: 1px solid var(--border); }
.diff-old::before, .diff-new::before { display: block; font-size: 10px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; opacity: .7; margin-bottom: 3px; }
.diff-old::before { content: 'Было'; } .diff-new::before { content: 'Стало'; }
.diff-old i, .diff-new i { opacity: .6; }

/* журнал */
.log-item {
  display: flex; gap: 12px; text-align: left; padding: 10px 8px; margin: 0 -8px; width: calc(100% + 16px);
  border: 0; border-bottom: 1px solid var(--grid); background: transparent; font: inherit; font-size: 13px; color: inherit; cursor: pointer; border-radius: var(--radius);
}
.log-item:hover { background: var(--surface-2); }
.log-item .dot { flex: none; width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; background: var(--fg-2); }
.log-item.act-approve .dot { background: var(--ok); }
.log-item.act-rollback .dot { background: var(--warn); }
.log-item.act-import .dot { background: var(--border-strong); }
.log-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.log-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.log-head b { font-weight: 600; overflow-wrap: anywhere; }
.log-sub { color: var(--fg-2); font-size: 12px; }
.log-action { font-weight: 500; }

/* тост */
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 60;
  padding: 8px 14px; border-radius: var(--radius-lg); background: var(--toast-bg); color: var(--toast-fg); font-size: 13px; font-weight: 500; box-shadow: var(--shadow-lg);
  animation: toast-in .18s ease-out;
}
.toast.ok { background: var(--ok); color: #fff; }
.toast.bad { background: var(--bad); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ============ пользователь в шапке ============ */
.user {
  display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 2px 0 3px; border-radius: var(--radius);
  max-width: 280px; color: var(--fg-2);
}
.user:hover { background: var(--surface-3); }
.user[hidden] { display: none; }
.avatar {
  width: 22px; height: 22px; border-radius: 4px; display: grid; place-items: center; flex: none;
  background: var(--fg); color: var(--bg); font-size: 11px; font-weight: 600; text-transform: uppercase;
}
.user-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.user .icon-btn { width: 26px; height: 26px; }
.user .icon-btn svg { width: 14px; height: 14px; }

/* ============ вход ============ */
body.auth-page { align-items: center; justify-content: center; padding: 24px; background: var(--bg); }
.auth-theme { position: fixed; top: 12px; right: 12px; }
.auth-card {
  flex: 0 0 auto; width: min(380px, 100%); min-height: 0;
  display: flex; flex-direction: column; gap: 24px;
}
.auth-brand { display: flex; flex-direction: column; align-items: flex-start; gap: 14px; }
.auth-brand .logo { width: 40px; height: 40px; }
.auth-title { font-size: 22px; font-weight: 700; letter-spacing: -.01em; line-height: 1.2; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.field input {
  display: block; width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--fg); font: inherit; outline: none; transition: border-color .15s, box-shadow .15s;
}
.field input::placeholder { color: var(--faint); }
.field input:focus { border-color: var(--accent-border); box-shadow: 0 0 0 2px var(--accent-soft); }
.auth-error { padding: 8px 10px; border-radius: var(--radius); background: var(--bad-soft); color: var(--bad-fg); font-size: 13px; }
.auth-note { margin: 0; font-size: 12px; line-height: 1.5; }
.btn.lg { height: 36px; font-size: 14px; width: 100%; margin-top: 4px; }

/* ============ адаптив ============ */
.sort-mobile { display: none; }

@media (max-width: 1100px) {
  table { min-width: 900px; }
  thead th, tbody td { padding-left: 8px; padding-right: 8px; }
}

@media (max-width: 768px) {
  /* шапка */
  .topbar { padding: 8px 12px 6px; gap: 8px; }
  .bar { gap: 8px; }
  .brand { margin-right: 0; }
  .brand .pill { display: none; }
  .search { order: 3; flex: 1 1 100%; max-width: none; }
  .search input { height: 36px; font-size: 16px; } /* 16px — iOS не масштабирует страницу при фокусе */
  .search kbd { display: none; }
  .actions { margin-left: auto; gap: 2px; }
  .actions .btn .label { display: none; }
  .actions .btn { width: 32px; height: 32px; padding: 0; }
  .user { padding: 0; gap: 0; }
  .user-email { display: none; }
  .chips { flex: 1 1 auto; min-width: 0; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { height: 32px; }
  .sort-mobile { display: inline-flex; align-items: center; gap: 4px; flex: none; }
  .sort-mobile select {
    height: 32px; max-width: 150px; padding: 0 6px; border: 1px solid var(--border-strong); border-radius: var(--radius);
    background: var(--surface); color: var(--fg); font: inherit; font-size: 13px;
  }
  .sort-mobile .icon-btn { width: 32px; height: 32px; border: 1px solid var(--border-strong); font-size: 15px; color: var(--fg); }
  .meta { flex: 1 1 100%; margin-left: 0; font-size: 12px; white-space: normal; }

  /* таблица → карточки */
  main { padding: 0; }
  .grid-card { border-radius: 0; border-left: 0; border-right: 0; }
  table { min-width: 0; display: block; }
  colgroup, thead { display: none; }
  tbody, tbody tr, tbody td { display: block; }
  tbody tr.row { position: relative; padding: 12px 14px; border-bottom: 1px solid var(--grid); }
  tbody tr.row:hover td { background: transparent; }
  tbody tr.row:active { background: var(--row-hover); }
  tbody tr.row.approved { box-shadow: inset 3px 0 0 var(--ok); }
  tbody tr.row.approved td.no { box-shadow: none; }
  tbody td { padding: 0; border: 0; }
  tbody td.no { position: absolute; top: 13px; right: 50px; font-size: 12px; padding: 0; }
  tbody td.no::before { content: '№ '; }
  tbody td.center { position: absolute; top: 11px; right: 14px; text-align: right; }
  tbody td.center .cb { width: 20px; height: 20px; margin: 0; }
  tbody td.center .cb::before { width: 11px; height: 11px; }
  td .name { padding-right: 96px; font-size: 15px; line-height: 1.3; }
  td[data-label]::before {
    content: attr(data-label); display: block; margin: 10px 0 3px;
    font-size: 11px; font-weight: 500; letter-spacing: .02em; text-transform: uppercase; color: var(--faint);
  }
  .tags { margin-bottom: 4px; }
  .txt { -webkit-line-clamp: 3; }
  tr.skeleton { display: block; padding: 12px 14px; border-bottom: 1px solid var(--grid); }
  tr.skeleton td { display: block; padding: 0; }
  tr.skeleton td.no, tr.skeleton td:last-child { display: none; }
  .status { font-size: 12px; }

  /* панели */
  .drawer { width: 100vw; border-left: 0; }
  .drawer-head { padding: 12px 14px 10px; }
  .drawer-title { font-size: 17px; }
  .tabs { padding: 0 6px; overflow-x: auto; scrollbar-width: none; }
  .panel { padding: 14px; }
  .drawer-actions { margin: 14px -14px -14px; padding: 10px 14px; }
  .kv { grid-template-columns: 1fr; gap: 0; }
  .kv .k { margin-top: 10px; }
  .tl-head time { margin-left: 0; flex-basis: 100%; }
  .log-item { margin: 0; width: 100%; padding: 10px 0; }
  .toast { left: 12px; right: 12px; bottom: 12px; transform: none; text-align: center; animation: none; }
}
