
/* ═══ Токены: палитра ISTOK One (istok-admin app/globals.css) — обсидиан + золото логотипа ═══ */
:root {
  --bg: #26252E;
  --bg-top: #2F2E38;
  --bg-deep: #1C1B22;
  --raised: #302F39;
  --surface: rgba(255, 255, 255, 0.05);
  --surface-2: rgba(255, 255, 255, 0.08);
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.20);

  --ink: #F4F3F6;
  --muted: #ADABB7;
  --subtle: #7D7B87;

  --gold: #E5C68E;
  --gold-hi: #EAD09A;
  --gold-lo: #D4B57C;
  --gold-grad: linear-gradient(180deg, var(--gold-hi), var(--gold-lo));
  --on-gold: #26252E;

  --ok: #7EE787;
  --warn: #E8B339;
  --bad: #FF8A7A;
  --info: #A9B8D8;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;

  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Roboto Flex", "Inter", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --tap: 40px;
  --gutter: 28px;
  --rail: 248px;
  --top-h: 72px;
}

@media (pointer: coarse) {
  :root { --tap: 44px; }
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { color-scheme: dark; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--bg-top) 55%, transparent) 0%, transparent 60%),
    linear-gradient(180deg, var(--bg-top) 0%, var(--bg) 50%, var(--bg-deep) 100%);
  background-attachment: fixed;
  background-color: var(--bg);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
b, strong { font-weight: 600; }
code { font-family: var(--mono); font-size: .92em; color: var(--ink); background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
::selection { background: var(--gold); color: var(--on-gold); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }
.ico { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.ic { display: inline-block; background-color: currentColor; -webkit-mask: var(--m) center / contain no-repeat; mask: var(--m) center / contain no-repeat; vertical-align: middle; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

.c-ok { color: var(--ok); }
.c-warn { color: var(--warn); }
.c-bad { color: var(--bad); }
.c-gold { color: var(--gold); }
.c-sub { color: var(--subtle); }
.c-muted { color: var(--muted); }
.c-info { color: var(--info); }

/* ═══ Оболочка: боковая панель (≥1200) → рельс (768–1199) → нижняя панель (<768) ═══ */
.app { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }

.side {
  position: sticky; top: 0; height: 100vh; height: 100dvh;
  display: flex; flex-direction: column;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg-deep) 70%, transparent);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 24px 22px 22px; }
.brand-mark { width: 40px; height: 31px; flex: none; color: var(--gold); }
.brand-name { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); line-height: 1.2; }
.brand-app { font-size: 17px; font-weight: 650; letter-spacing: -.01em; line-height: 1.2; }

.nav { display: flex; flex-direction: column; gap: 2px; padding: 8px 12px; }
.nav button, .nav a {
  display: flex; align-items: center; gap: 12px; text-decoration: none;
  min-height: var(--tap); padding: 0 12px; border: 0; border-radius: var(--r-sm);
  background: none; color: var(--muted); font-size: 14.5px; font-weight: 500; text-align: left;
  transition: background .15s, color .15s;
}
.nav button:hover, .nav a:hover { color: var(--ink); background: rgba(255, 255, 255, .03); }
.nav button.active { color: var(--gold); background: color-mix(in srgb, var(--gold) 10%, transparent); }
.nav .lock { margin-left: auto; width: 14px; height: 14px; opacity: .55; }
/* «Инвентарь» уводит в новую вкладку — на станции без менеджера сканы ушли бы туда; на проде выключен до Фазы 4. */
.nav a.inventory-link { display: none; }
body.is-manager .nav a.inventory-link.enabled { display: flex; }
.is-manager .lock { display: none; }

.side-foot { margin-top: auto; padding: 16px; border-top: 1px solid var(--line); display: grid; gap: 10px; }
.station { display: grid; gap: 3px; padding: 0 6px; font-size: 13px; color: var(--muted); }
.station b { color: var(--ink); }
.mgr-only { display: none !important; }
.is-manager .mgr-only { display: revert !important; }
.is-manager .btn.mgr-only { display: inline-flex !important; }

.move-banner { display: none; }
body.is-manager .move-banner.show {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 10px 16px;
  color: var(--warn); background: color-mix(in srgb, var(--warn) 10%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); font-size: 14px;
}
.move-banner b { color: var(--ink); }
.move-banner .btn { min-height: var(--tap); display: inline-flex; align-items: center; text-decoration: none; }

.main { min-width: 0; display: flex; flex-direction: column; }
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 16px var(--gutter);
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}
.top-mark { display: none; }
.top-text { min-width: 0; }
.top h1 { font-size: 22px; font-weight: 650; letter-spacing: -.015em; line-height: 1.15; }
.top .sub { font-size: 13px; color: var(--muted); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

main { width: 100%; max-width: 1360px; padding: 24px var(--gutter) 56px; }
.tab { display: none; }
.tab.active { display: block; }

.tabbar { display: none; }

/* ═══ Мелкие компоненты ═══ */
.chip {
  display: inline-flex; align-items: center; gap: 8px; min-height: 32px; padding: 0 12px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  font-size: 13px; color: var(--muted); white-space: nowrap;
}
.chip b { color: var(--ink); font-variant-numeric: tabular-nums; }
.chip .ico { width: 15px; height: 15px; }
button.chip:hover { border-color: var(--line-strong); color: var(--ink); }
.chip.net-ok { color: var(--ok); }
.chip.net-off { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); background: color-mix(in srgb, var(--bad) 10%, transparent); }
.chip.net-queue, .chip.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); background: color-mix(in srgb, var(--warn) 10%, transparent); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }

.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--bg-deep); border: 1px solid var(--line); max-width: 100%; }
.seg button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: calc(var(--tap) - 8px); padding: 0 12px; border: 0; border-radius: 7px;
  background: transparent; color: var(--muted); font-size: 13.5px; font-weight: 500; white-space: nowrap;
  transition: background .15s, color .15s;
}
.seg button:hover { color: var(--ink); }
.seg button.active { background: var(--raised); color: var(--ink); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06), 0 1px 2px rgba(0, 0, 0, .3); }
.seg .ico { width: 15px; height: 15px; }
.loc-toggle button.active { color: var(--gold); cursor: default; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-size: 14px; font-weight: 550; white-space: nowrap; text-decoration: none;
  transition: background .15s, border-color .15s, filter .15s;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--gold-grad); color: var(--on-gold); border-color: transparent; font-weight: 650; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--ink); background: var(--surface); }
.btn.danger { background: transparent; border-color: color-mix(in srgb, var(--bad) 35%, transparent); color: var(--bad); }
.btn.danger:hover { background: color-mix(in srgb, var(--bad) 10%, transparent); }
.btn.icon { width: var(--tap); padding: 0; }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
.btn.sm.icon { width: 34px; padding: 0; }
.btn.block { width: 100%; }
.btn .ico { width: 17px; height: 17px; }
.btn.saved, .btn-save.saved { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, transparent); filter: none; }
.btn.has-sound { color: var(--info); border-color: color-mix(in srgb, var(--info) 45%, transparent); background: color-mix(in srgb, var(--info) 10%, transparent); }

.field, .settings-card input:not([type=checkbox]):not([type=file]), .form-row select, .form-row input:not([type=checkbox]) {
  min-height: var(--tap); width: 100%; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--line-strong); background: var(--bg-deep); color: var(--ink);
  font-size: 15px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.field:focus, .form-row select:focus, .form-row input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 22%, transparent); }
.field::placeholder, input::placeholder { color: var(--subtle); }
select.field, .form-row select {
  appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23ADABB7' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.field.auto { width: auto; }
input[type=date].field, input[type=time].field { font-variant-numeric: tabular-nums; }
input[type=file] { font-size: 14px; color: var(--muted); max-width: 100%; }
input[type=file]::file-selector-button { margin-right: 10px; min-height: 36px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font: inherit; font-weight: 550; cursor: pointer; }
.check, .emp-checkbox { width: 20px; height: 20px; accent-color: var(--gold); cursor: pointer; flex: none; }

.search { position: relative; flex: 1 1 150px; min-width: 0; display: block; }
.search > .ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--subtle); width: 17px; height: 17px; pointer-events: none; }
.search .field, .form-row .search .field { padding-left: 38px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 16px; }
.toolbar .spacer { flex: 1 1 0; }
.only-phone, .only-compact { display: none !important; }

.card { border: 1px solid var(--line); background: var(--surface); border-radius: var(--r-lg); }
.card-h { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.card-h h2, .card-h h3 { font-size: 15px; font-weight: 650; letter-spacing: -.005em; display: flex; align-items: center; gap: 10px; }
.card-h h2 .ico, .card-h h3 .ico { color: var(--gold); }
.card-h .meta { margin-left: auto; font-size: 13px; color: var(--muted); }
.card-b { padding: 18px; }
.empty { padding: 36px 18px; text-align: center; color: var(--muted); font-size: 14px; }
#grid-content.grid-loading { opacity: .5; pointer-events: none; }
.tag { display: inline-flex; align-items: center; min-height: 26px; padding: 0 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.tag.in { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.tag.out { color: var(--gold); background: color-mix(in srgb, var(--gold) 12%, transparent); }
.badge { display: inline-flex; align-items: center; min-height: 20px; padding: 0 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; vertical-align: middle; }
.badge.manual { color: var(--info); background: color-mix(in srgb, var(--info) 12%, transparent); }
.badge.inactive { color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, transparent); }
.badge.temp { color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent); white-space: normal; }
.shift { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13.5px; white-space: nowrap; }
.shift .ico { width: 15px; height: 15px; }
.meta-line { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.meta-line .ico { width: 15px; height: 15px; }
.id { font-family: var(--mono); font-size: 12px; color: var(--subtle); }
.notice { padding: 12px 16px; border-radius: var(--r-md); font-size: 14px; margin-bottom: 14px; border: 1px solid var(--line); }
.notice.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 9%, transparent); border-color: color-mix(in srgb, var(--ok) 28%, transparent); }
.notice.err { color: var(--bad); background: color-mix(in srgb, var(--bad) 9%, transparent); border-color: color-mix(in srgb, var(--bad) 28%, transparent); }
.notice.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 9%, transparent); border-color: color-mix(in srgb, var(--warn) 28%, transparent); }
.notice[hidden] { display: none; }

/* ═══ Таблицы ═══ */
.tbl-card { overflow: clip; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; table-layout: fixed; }
/* Фиксированные ширины колонок: браузеру не нужно мерить все 800 строк, чтобы разложить таблицу. */
.tbl.people th:nth-child(1) { width: 52px; }
.tbl.people th:nth-child(3) { width: 150px; }
.tbl.people th:nth-child(4) { width: 330px; }
.tbl.people th:nth-child(5) { width: 236px; }
.grid-table th:nth-child(1) { width: 52px; }
.grid-table th:nth-child(3), .grid-table th:nth-child(4) { width: 96px; }
.grid-table th:nth-child(5), .grid-table th:nth-child(6) { width: 92px; }
.grid-table th:nth-child(7) { width: 160px; }
.grid-table th:nth-child(8) { width: 130px; }
.grid-table th:nth-child(9) { width: 140px; }
.tbl td { overflow: hidden; text-overflow: ellipsis; }
.tbl td.c-acts, .tbl td.c-check { overflow: visible; }
.tbl th {
  position: sticky; top: var(--top-h); z-index: 2;
  text-align: left; font-weight: 500; font-size: 12.5px; color: var(--muted);
  padding: 10px 14px; background: #2B2A33; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.tbl th.sortable { cursor: pointer; user-select: none; }
.tbl th.sortable:hover, .tbl th.sorted { color: var(--ink); }
.tbl th .sort-arrow { margin-left: 4px; font-size: 10px; opacity: .45; }
.tbl th.sorted .sort-arrow { opacity: 1; color: var(--gold); }
.tbl td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: rgba(255, 255, 255, .025); }
.tbl .r { text-align: right; }
.tbl .w-idx { width: 48px; color: var(--subtle); font-variant-numeric: tabular-nums; }
.tbl .t { font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl .name { font-weight: 550; }
.status { display: inline-flex; align-items: center; gap: 7px; font-size: 13.5px; white-space: nowrap; }

/* ═══ Сканер / киоск ═══ */
.kiosk { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr); gap: 20px; margin-bottom: 28px; }
.kiosk-main {
  position: relative; overflow: hidden;
  border-radius: var(--r-xl); border: 1px solid var(--line);
  background:
    radial-gradient(700px 360px at 85% 0%, color-mix(in srgb, var(--gold) 9%, transparent), transparent 70%),
    linear-gradient(180deg, var(--raised), var(--bg-deep));
  padding: 34px 40px; min-height: 360px;
  display: flex; flex-direction: column;
}
.kiosk-loc { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; }
.kiosk-loc b { color: var(--gold); }
.clock {
  margin-top: auto;
  font-family: var(--display); font-stretch: 151%; font-weight: 700; font-variant-numeric: tabular-nums;
  font-size: clamp(72px, 10vw, 156px); line-height: .9; letter-spacing: -.01em;
}
.clock .sec { color: var(--subtle); font-size: .3em; font-weight: 600; letter-spacing: 0; margin-left: .2em; }
.kiosk-date { margin-top: 12px; color: var(--muted); font-size: 16px; }
.kiosk-window { margin-top: 4px; color: var(--muted); font-size: 15px; }
.kiosk-window b { color: var(--ink); }
.kiosk-cta { display: flex; align-items: center; gap: 14px; margin-top: 26px; font-size: 18px; font-weight: 500; }
.pulse { position: relative; width: 14px; height: 14px; flex: none; }
.pulse::before, .pulse::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--gold); }
.pulse::after { animation: ring 2.4s ease-out infinite; }
@keyframes ring { from { transform: scale(1); opacity: .55; } to { transform: scale(3.2); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .pulse::after { animation: none; } }

.feed .card-b { padding: 4px 0; }
.feed-row { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 11px 18px; }
.feed-row + .feed-row { border-top: 1px solid var(--line); }
.feed-row .tm { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.feed-row .who { min-width: 0; }
.feed-row .who div:first-child { font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed-row .who div:last-child { font-size: 13px; color: var(--muted); }
.feed .empty { padding: 28px 18px; }

.board-h { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; margin-bottom: 14px; }
.board-h h2 { font-size: 17px; font-weight: 650; margin-right: 4px; }
.board-h .filters { margin-left: auto; display: flex; flex-wrap: wrap; gap: 8px; }
#status-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.status-group-header { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; margin: 14px 0 2px; font-size: 13.5px; font-weight: 600; }
.status-group-header:first-child { margin-top: 0; }
.status-group-header .group-count { color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.tile { content-visibility: auto; contain-intrinsic-size: auto 62px; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 11px 14px; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface); }
.tile .nm { font-weight: 550; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .st { font-size: 12.5px; color: var(--muted); }
.tile .shift { font-size: 12.5px; }
.tile.none { background: transparent; border-style: dashed; }
.tile.none .nm { color: var(--muted); font-weight: 500; }

/* ═══ Вспышка после скана: цельное цветное поле, читается с 3 метров ═══ */
#flash-overlay { position: fixed; inset: 0; z-index: 9999; display: none; place-items: center; text-align: center; padding: 32px; pointer-events: none; }
#flash-overlay.show { display: grid; animation: flashIn .18s ease-out; }
@keyframes flashIn { from { opacity: 0; transform: scale(1.02); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { #flash-overlay.show { animation: none; } }
#flash-overlay[data-type="in"] { background: var(--ok); color: #0E2410; }
#flash-overlay[data-type="out"] { background: var(--gold-grad); color: var(--on-gold); }
#flash-overlay[data-type="bad"] { background: var(--bad); color: #2B0D09; }
#flash-overlay[data-type="wait"] { background: var(--raised); color: var(--ink); }
#flash-box { max-width: 1200px; }
#flash-check { width: clamp(96px, 13vw, 140px); height: clamp(96px, 13vw, 140px); margin: 0 auto 20px; border-radius: 50%; display: grid; place-items: center; background: rgba(0, 0, 0, .12); }
#flash-overlay[data-type="wait"] #flash-check { background: rgba(255, 255, 255, .06); color: var(--info); }
#flash-check svg { width: 55%; height: 55%; stroke: currentColor; fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
#flash-action-big { font-family: var(--display); font-stretch: 151%; font-weight: 800; text-transform: uppercase; font-size: clamp(48px, 10vw, 140px); line-height: .95; overflow-wrap: anywhere; }
#flash-name { margin-top: 22px; font-size: clamp(34px, 5vw, 60px); font-weight: 700; letter-spacing: -.015em; line-height: 1.08; overflow-wrap: anywhere; }
#flash-detail { margin-top: 14px; font-size: clamp(18px, 2.2vw, 24px); opacity: .8; white-space: pre-line; line-height: 1.4; font-variant-numeric: tabular-nums; }

/* ═══ Сотрудники ═══ */
.emp-row.selected td { background: color-mix(in srgb, var(--gold) 6%, transparent); }
.emp-row.inactive .name, .emp-row.inactive .shift { opacity: .6; }
.emp-actions { display: flex; gap: 6px; justify-content: flex-end; }
.emp-edit-input { min-height: 36px; padding: 0 10px; border-radius: 9px; border: 1px solid var(--gold); background: var(--bg-deep); color: var(--ink); font-size: 15px; outline: none; min-width: 0; }
.emp-edit-input:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 22%, transparent); }
#csv-hint { margin-bottom: 16px; }
#csv-hint .card-b { display: grid; gap: 12px; }
#csv-result { display: none; }

.selbar {
  position: sticky; bottom: 16px; z-index: 30; margin-top: 16px;
  display: none; align-items: center; gap: 10px;
  padding: 10px 12px 10px 18px; border-radius: 14px;
  background: var(--raised); border: 1px solid var(--line-strong); box-shadow: 0 16px 40px rgba(0, 0, 0, .45);
}
.selbar.visible { display: flex; }
.selbar #selected-count { font-weight: 650; white-space: nowrap; margin-right: auto; }
.selbar #bulk-transfer-loc { min-width: 8.5em; }

/* ═══ Журнал ═══ */
.day-h { font-size: 13px; color: var(--muted); padding: 14px 16px 8px; border-bottom: 1px solid var(--line); background: rgba(255, 255, 255, .02); }
.log-row { display: grid; grid-template-columns: 58px 92px minmax(0, 1fr) auto 40px; align-items: center; gap: 14px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.log-group:last-child .log-row:last-child { border-bottom: 0; }
.log-row .tm { font-weight: 600; font-variant-numeric: tabular-nums; font-size: 15px; }
.log-row .nm { min-width: 0; display: flex; align-items: center; gap: 8px; }
.log-row .nm span:first-child { font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.log-row .meta { display: flex; gap: 14px; justify-content: flex-end; }

/* ═══ Табель (сетка за день) ═══ */
.grid-shift-section { margin-bottom: 18px; }
.grid-table td.editable-time { cursor: pointer; border-radius: 6px; }
.grid-table td.editable-time:hover { background: color-mix(in srgb, var(--gold) 9%, transparent) !important; }
/* Карандаш при наведении — псевдоэлементом, без лишних узлов в каждой из ~1600 ячеек. */
.grid-table td.editable-time:hover .cell-val::after { content: ""; display: inline-block; width: 13px; height: 13px; margin-left: 6px; vertical-align: -1px; background: var(--gold); -webkit-mask: var(--pen) center / contain no-repeat; mask: var(--pen) center / contain no-repeat; }
.grid-table td.editable-time .cell-val:empty::before { content: "—"; color: var(--subtle); }
.grid-table tr.absent .name { color: var(--muted); font-weight: 450; }
.grid-table tr.missing td { background: color-mix(in srgb, var(--warn) 5%, transparent); }
.grid-cell-input { width: 110px; min-height: 34px; padding: 0 8px; font-size: 14px; background: var(--bg-deep); border: 1px solid var(--gold); border-radius: 8px; color: var(--ink); outline: none; font-variant-numeric: tabular-nums; }
.grid-status-OK { color: var(--ok); }
.grid-status-MISSING_OUT, .grid-status-MISSING_IN { color: var(--warn); }
.grid-status-IN_PROGRESS { color: var(--gold); }
.grid-status-NO_SHOW { color: var(--subtle); }
.filters-panel { display: flex; flex-wrap: wrap; gap: 10px; width: 100%; }
.filters-panel .sheet-only { display: none; }
#filters-scrim { display: none; }

/* ═══ Настройки ═══ */
.settings { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.settings .wide { grid-column: 1 / -1; }
.help { color: var(--muted); font-size: 13.5px; margin-bottom: 14px; max-width: 70ch; }
.lbl, .form-row > label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.row-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.win { display: grid; grid-template-columns: minmax(150px, 1fr) minmax(0, 150px) 20px minmax(0, 150px); gap: 10px 12px; align-items: center; max-width: 640px; }
.win .w-l { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; }
.win .w-l .ico { width: 16px; height: 16px; color: var(--muted); }
.win .arrow { color: var(--subtle); text-align: center; }
.add-row { display: flex; gap: 8px; margin-bottom: 12px; }
#sites-list { display: grid; gap: 8px; }
.site-row { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 14px; border-radius: 10px; background: var(--bg-deep); border: 1px solid var(--line); }
.site-row .nm { flex: 1; min-width: 0; }
.site-row .nm div:first-child { font-weight: 550; }
/* Кладовщики инвентаря: строка — имя (правится), роль, склад, действия; на телефоне — карточка в две колонки. */
.keeper-add { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 8px; }
#keepers-status:empty { display: none; }
.help.c-bad { color: var(--bad); }
#keepers-undecided div + div { margin-top: 6px; }
.keeper-row .row-note { grid-column: 1 / -1; margin: 0; }
#keepers-list { display: grid; gap: 8px; }
.keeper-row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr) auto; gap: 8px 10px; align-items: center;
  padding: 10px 10px 10px 14px; border-radius: 10px; background: var(--bg-deep); border: 1px solid var(--line); }
.keeper-row.off { opacity: .72; }
.keeper-row .id { margin-top: 4px; font-size: 12.5px; color: var(--subtle); }
.keeper-row .acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.keeper-row .pw { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; }
.keeper-row .pw .field { flex: 1 1 220px; }
@media (max-width: 1199px) { .keeper-add { grid-template-columns: 1fr 1fr; } .keeper-row { grid-template-columns: 1fr 1fr; } .keeper-row .nm, .keeper-row .acts { grid-column: 1 / -1; } .keeper-row .acts { justify-content: flex-start; } }
@media (max-width: 767px) { .keeper-add, .keeper-row { grid-template-columns: 1fr; } .keeper-row .acts .btn { flex: 1 1 auto; } }
.danger-zone { border-color: color-mix(in srgb, var(--bad) 28%, transparent); }
.danger-zone .card-h h3 { color: var(--bad); }

/* ═══ Диалоги: по центру на компьютере, шторка снизу на телефоне ═══ */
.scrim {
  position: fixed; inset: 0; z-index: 1000; display: none; place-items: center; padding: 24px;
  background: rgba(12, 11, 16, .62); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.scrim.show { display: grid; }
.dialog {
  /* svh, а не dvh: панель Safari прячется при прокрутке — от dvh окно меняло высоту и дёргалось. */
  width: min(420px, 100%); max-height: calc(100vh - 48px); max-height: calc(100svh - 48px); overflow-y: auto; overscroll-behavior: contain;
  border-radius: var(--r-xl); border: 1px solid var(--line-strong); background: var(--raised);
  padding: 26px; box-shadow: 0 30px 80px rgba(0, 0, 0, .5);
}
.dialog.wide { width: min(560px, 100%); }
.dialog.xwide { width: min(700px, 100%); }
.dialog h2 { font-size: 19px; font-weight: 650; letter-spacing: -.01em; margin-bottom: 6px; }
.dialog .lead { color: var(--muted); font-size: 14px; margin-bottom: 18px; }
.dialog .lead b { color: var(--ink); }
.dialog .ic-badge { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; margin-bottom: 14px; background: color-mix(in srgb, var(--gold) 12%, transparent); color: var(--gold); }
.dialog .ic-badge .ico { width: 22px; height: 22px; }
.dialog .err { color: var(--bad); font-size: 13.5px; margin-bottom: 10px; display: none; }
.dialog .stack { display: grid; gap: 10px; margin-top: 14px; }
.dialog .actions { display: flex; gap: 10px; margin-top: 22px; }
.dialog .actions .btn.primary { flex: 1; }
.form-row { margin-bottom: 14px; }
/* minmax(0, …): широкое поле (дата в iOS) не раздвигает колонку за край окна. */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
.grab { display: none; }

#qr-box { text-align: center; }
#qr-box .qr-id { font-family: var(--mono); font-size: 12px; color: var(--subtle); margin-bottom: 20px; word-break: break-all; }
#qr-img-wrap { background: #fff; padding: 14px; border-radius: 14px; display: inline-block; margin-bottom: 16px; }
#qr-box .qr-hint { color: var(--muted); font-size: 13px; }
#qr-box .actions { justify-content: center; }

.manual-emp-search { margin-bottom: 8px; }
.manual-emp-select-all-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.manual-shift-quick { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.manual-shift-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line-strong); background: transparent; color: var(--muted); font-size: 13px; }
.manual-shift-btn .ico { width: 14px; height: 14px; }
.manual-shift-btn.active { color: var(--gold); border-color: color-mix(in srgb, var(--gold) 45%, transparent); background: color-mix(in srgb, var(--gold) 10%, transparent); }
.manual-selected-count { font-size: 13px; color: var(--gold); font-weight: 600; }
.manual-emp-list { max-height: 280px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--bg-deep); padding: 4px 0; overscroll-behavior: contain; }
.manual-checkbox-label { display: flex; align-items: center; gap: 12px; padding: 9px 14px; font-size: 14px; cursor: pointer; }
.manual-checkbox-label:hover { background: rgba(255, 255, 255, .04); }
.manual-checkbox-label input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--gold); flex: none; }
.manual-emp-select-all-row .manual-checkbox-label { padding: 0 6px 0 0; font-size: 13px; color: var(--muted); }
.manual-emp-select-all-row .manual-checkbox-label:hover { background: none; color: var(--ink); }
.manual-emp-name { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.manual-emp-shift { color: var(--subtle); display: inline-flex; }
.manual-emp-shift .ico { width: 15px; height: 15px; }
.manual-emp-state { font-size: 12px; }
.manual-emp-state.open { color: var(--ok); }
.manual-emp-state.stale { color: var(--warn); }
.manual-emp-state.closed { color: var(--muted); }
.manual-emp-state.none { color: var(--subtle); }
.manual-emp-loc { color: var(--info); font-weight: 600; white-space: nowrap; }
.manual-empty-search { padding: 16px; text-align: center; color: var(--muted); font-size: 13px; }

#sync-box { padding: 0; display: flex; flex-direction: column; overflow: hidden; }
#sync-box h2 { padding: 22px 24px 12px; margin: 0; }
.sync-summary { padding: 0 24px 14px; font-size: 13.5px; color: var(--muted); border-bottom: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 6px 16px; }
.sync-summary b { color: var(--warn); }
.sync-list { overflow-y: auto; flex: 1; padding: 8px 16px 16px; min-height: 80px; }
.sync-row { padding: 10px 12px; margin-top: 6px; border-radius: 10px; background: var(--bg-deep); border: 1px solid var(--line); font-size: 13px; }
.sync-row .sr-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-weight: 500; }
.sync-row .sr-err { color: var(--bad); margin-top: 4px; font-size: 12px; word-break: break-word; }
.sync-row .sr-att { color: var(--warn); font-weight: 400; }
.sync-actions { display: flex; gap: 10px; padding: 14px 24px; border-top: 1px solid var(--line); }
.sync-actions .btn.primary { flex: 1; }

.sheet-list { display: grid; gap: 4px; margin-top: 8px; }
.sheet-list button, .sheet-list a { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 14px; border: 0; border-radius: 10px; background: transparent; color: var(--ink); font-size: 15px; text-align: left; text-decoration: none; }
.sheet-list button:hover, .sheet-list a:hover { background: var(--surface-2); }
.sheet-list button .ico, .sheet-list a .ico { color: var(--muted); }
.sheet-list button.danger, .sheet-list button.danger .ico { color: var(--bad); }

/* ═══ Планшет (768–1199): рельс с иконками ═══ */
@media (max-width: 1199px) {
  :root { --rail: 84px; --gutter: 22px; }
  .brand { justify-content: center; padding: 20px 0 18px; }
  .brand > div { display: none; }
  .nav { padding: 6px 8px; }
  .nav button, .nav a { flex-direction: column; justify-content: center; gap: 5px; min-height: 62px; padding: 6px 2px; font-size: 11.5px; text-align: center; }
  .nav button .ico, .nav a .ico { width: 21px; height: 21px; }
  .nav .lock { display: none; }
  .side-foot { padding: 12px 8px; }
  .station, .side-foot .btn span { display: none; }
  .side-foot .btn { padding: 0; }
  .kiosk { grid-template-columns: 1fr; }
  .settings { grid-template-columns: 1fr; }
  .col-wide { display: none; }
  .only-compact { display: inline-flex !important; }
  .wide-only { display: none !important; }
  .toolbar .search-row { flex-basis: 100%; }
}

/* ═══ Телефон (<768): компактная шапка, нижняя панель, карточки вместо таблиц ═══ */
@media (max-width: 767px) {
  :root { --gutter: 16px; }
  body { font-size: 15.5px; }
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { display: none; }
  .top { padding: 10px var(--gutter); padding-top: max(10px, env(safe-area-inset-top)); gap: 10px; flex-wrap: nowrap; }
  .top-mark { display: block; width: 30px; height: 23px; flex: none; color: var(--gold); }
  .top h1 { font-size: 18px; }
  .top .sub { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .top-right { flex-wrap: nowrap; gap: 6px; }
  .top-right .loc-toggle, .top-right .chip .lbl-wide { display: none; }
  .top-right .chip { padding: 0 10px; }
  .only-phone { display: inline-flex !important; }
  .not-phone { display: none !important; }
  .only-phone[hidden] { display: none !important; }
  main { padding: 16px var(--gutter) calc(96px + env(safe-area-inset-bottom)); }
  .field, .form-row select, .form-row input:not([type=checkbox]), .settings-card input:not([type=checkbox]):not([type=file]), .emp-edit-input, .grid-cell-input { font-size: 16px; } /* <16px — iOS зумит при фокусе */

  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    display: grid; grid-template-columns: repeat(5, 1fr);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--bg-deep) 92%, transparent);
    -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
    border-top: 1px solid var(--line);
  }
  .tabbar button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 52px; border: 0; background: none; color: var(--subtle); font-size: 11px; font-weight: 500; border-radius: 10px; }
  .tabbar button .ico { width: 22px; height: 22px; }
  .tabbar button.active { color: var(--gold); }

  .kiosk-main { padding: 22px; min-height: 0; }
  .clock { margin-top: 26px; font-size: 21vw; }
  .kiosk-cta { font-size: 16px; margin-top: 18px; }
  #status-grid { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .board-h .filters { margin-left: 0; width: 100%; }
  .board-h .seg { flex: 1; }
  .board-h .seg button { flex: 1; }

  .toolbar { gap: 8px; }
  .toolbar .search { flex-basis: 100%; }
  .toolbar input[type=date].field { flex: 1 1 130px; min-width: 0; }
  .toolbar .seg.grow { flex: 1; }
  .toolbar .seg.grow button { flex: 1; }

  /* таблица → карточки (одна разметка) */
  .tbl-card { background: transparent; border: 0; overflow: visible; }
  .tbl-card > .card-h { padding: 4px 2px 10px; border: 0; }
  .tbl, .tbl tbody { display: block; }
  .tbl thead { display: none; }
  .tbl tr { content-visibility: auto; contain-intrinsic-size: auto 96px; display: grid; gap: 6px 12px; align-items: center; padding: 14px 16px; margin-bottom: 8px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
  .tbl td { padding: 0; border: 0; }
  .tbl tbody tr:hover td { background: none; }
  .tbl td.ph-hide { display: none; }
  .tbl td.empty { padding: 24px 0; }

  .tbl.people tr { grid-template-columns: auto minmax(0, 1fr) auto; }
  .tbl.people td.c-check { grid-row: 1 / span 2; }
  .tbl.people td.name { grid-column: 2; font-size: 16px; }
  .tbl.people td.c-shift { grid-column: 2; grid-row: 2; }
  .tbl.people td.c-acts { grid-column: 3; grid-row: 1 / span 2; }
  .tbl.people .emp-actions .ph-hide { display: none; }

  .grid-table tr { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-table td.name { grid-column: 1 / span 2; font-size: 16px; }
  .grid-table td.c-status { grid-column: 3; grid-row: 1; justify-self: end; }
  .grid-table td.editable-time, .grid-table td.c-hours { display: grid; gap: 1px; min-height: 44px; align-content: center; padding: 4px 8px; margin: 0 -8px; }
  .grid-table td[data-label]::before { content: attr(data-label); font-size: 11.5px; color: var(--subtle); }
  .grid-table td.editable-time:hover .cell-val::after { display: none; }

  .log-row { grid-template-columns: 54px minmax(0, 1fr) auto; gap: 4px 12px; padding: 12px 14px; }
  .log-row .tm { grid-row: 1 / span 2; }
  .log-row .tag { grid-column: 3; grid-row: 1; }
  .log-row .nm { grid-column: 2; grid-row: 1; }
  .log-row .meta { grid-column: 2 / span 2; grid-row: 2; justify-content: flex-start; flex-wrap: wrap; gap: 4px 12px; }
  .log-row .btn { display: none; }
  .log-row .nm .badge { display: none; }
  .log-row.can-delete { grid-template-columns: 54px minmax(0, 1fr) auto 36px; }
  .log-row.can-delete .btn { display: inline-flex; grid-column: 4; grid-row: 1 / span 2; }

  .win { grid-template-columns: 1fr 1fr; }
  .win .w-l { grid-column: 1 / -1; margin-top: 6px; }
  .win .arrow { display: none; }

  .filters-panel {
    display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1001;
    padding: 12px 20px calc(20px + env(safe-area-inset-bottom));
    background: var(--raised); border-top: 1px solid var(--line-strong); border-radius: 22px 22px 0 0;
    box-shadow: 0 -20px 60px rgba(0, 0, 0, .45); gap: 12px;
  }
  .filters-panel.open { display: grid; animation: sheetUp .22s ease-out; }
  .filters-panel .sheet-only { display: block; }
  .filters-panel .field { width: 100%; }
  #filters-scrim.show { display: block; position: fixed; inset: 0; z-index: 1000; background: rgba(12, 11, 16, .62); }

  .scrim { place-items: end stretch; padding: 0; }
  .dialog, .dialog.wide, .dialog.xwide { width: 100%; max-height: 92vh; max-height: 92svh; border-radius: 22px 22px 0 0; border-bottom: 0; padding: 12px 20px calc(20px + env(safe-area-inset-bottom)); animation: sheetUp .22s ease-out; }
  #sync-box { padding: 12px 0 env(safe-area-inset-bottom); }
  .grab { display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--line-strong); margin: 0 auto 14px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .selbar { bottom: calc(76px + env(safe-area-inset-bottom)); padding-left: 14px; gap: 8px; flex-wrap: wrap; }
  #flash-check { width: 120px; height: 120px; }
  #flash-name { font-size: 40px; }
  #flash-detail { font-size: 19px; }
}
@keyframes sheetUp { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .dialog, .filters-panel.open { animation: none !important; } }

@media print {
  body * { visibility: hidden; }
  #qr-box, #qr-box * { visibility: visible; }
  #qr-box { position: fixed; inset: 0; display: flex !important; flex-direction: column; align-items: center; justify-content: center; background: #fff; color: #000; border: 0; box-shadow: none; }
  #qr-box .actions { display: none; }
}
  #locations-admin-list .site-row { display: grid; grid-template-columns: 1fr auto 4.5em auto auto; gap: 8px; align-items: center; }
@media (max-width: 767px) { #locations-admin-list .site-row { grid-template-columns: 1fr 1fr; } }
  .legacy-stations { margin-top: 16px; }
  .legacy-stations h4 { margin: 0 0 4px; }
  .legacy-stations .site-row { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
