:root {
  --paper: #F4F6F5;
  --surface: #FFFFFF;
  --ink: #16292C;
  --muted: #5E7275;
  --line: #DCE3E1;
  --teal: #0F6E6A;
  --teal-ink: #0B5451;
  --signal: #F5C518;
  --signal-soft: #FFF6D1;
  --ok: #1E8E5E;
  --err: #C4323A;
  --err-soft: #FDE7E4;
  --late: #B35C00;
  --late-soft: #FFE8C7;
  --font: 'Onest', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --r: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.5 var(--font); }
h1, h2, h3 { line-height: 1.2; margin: 0; }
.muted { color: var(--muted); }
.error { color: var(--err); min-height: 1.5em; margin: 0; }
[hidden] { display: none !important; }

/* Кнопки и поля */
.btn {
  font: 500 15px var(--font);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 9px 16px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: #B9C5C3; }
.btn.primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.primary:hover { background: var(--teal-ink); }
.btn.danger { color: var(--err); }
.btn.small { padding: 5px 10px; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: default; }
.link { background: none; border: 0; color: var(--teal); font: inherit; cursor: pointer; padding: 0; }
:is(.btn, .link, a, input, select, textarea, summary):focus-visible { outline: 3px solid var(--signal); outline-offset: 2px; }

label { display: grid; gap: 6px; font-weight: 500; font-size: 14px; }
input, select, textarea {
  font: 15px var(--font);
  color: var(--ink);
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  width: 100%;
}
input[type="checkbox"] { width: auto; }
textarea { resize: vertical; min-height: 70px; }

/* Вход */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card {
  width: min(400px, 100%);
  background: var(--surface);
  padding: 32px;
  border-radius: 16px;
  border: 1px solid var(--line);
  display: grid;
  gap: 16px;
}
.auth-card h1 { font-size: 24px; }

/* Каркас */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side {
  background: var(--ink);
  color: #E4ECEA;
  display: flex;
  flex-direction: column;
  padding: 24px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { font-weight: 700; font-size: 17px; padding: 0 10px 24px; line-height: 1.25; }
.brand img { display: block; width: 100%; max-width: 180px; height: auto; margin-bottom: 6px; }
.brand small { display: block; font-weight: 400; color: #93A9A6; font-size: 13px; margin-top: 4px; }
nav { display: grid; gap: 2px; }
nav a {
  color: #C9D6D3;
  text-decoration: none;
  padding: 9px 10px;
  border-radius: 8px;
  border-left: 3px solid transparent;
}
nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
nav a.active { background: rgba(255,255,255,.08); color: #fff; border-left-color: var(--signal); }
.side-foot { margin-top: auto; padding: 0 10px; display: grid; gap: 4px; font-size: 14px; color: #93A9A6; }
.side-foot .link { color: #E4ECEA; justify-self: start; }

.main { padding: 32px 40px 64px; min-width: 0; max-width: 1400px; }
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.head h1 { font-size: 28px; font-weight: 700; }
.head .sub { color: var(--muted); margin-top: 4px; }
.tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.tools label { font-size: 13px; }
.tools input, .tools select { width: auto; }

/* Сводка «Сегодня» — главная цифра одна, остальное тихо */
.pulse { display: flex; align-items: baseline; gap: 14px; margin: 4px 0 28px; flex-wrap: wrap; }
.pulse .big { font-size: 72px; font-weight: 700; line-height: 1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.pulse .of { font-size: 22px; color: var(--muted); }
.flags { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 28px; }
.flag { background: var(--signal-soft); border: 1px solid #EBD689; border-radius: 8px; padding: 8px 12px; font-size: 14px; }
.flag button { margin-left: 6px; }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 32px; }
.cols > * { min-width: 0; }
.cols h2 { font-size: 17px; margin-bottom: 10px; }

/* Таблицы */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-weight: 600; font-size: 13px; color: var(--muted); background: #FAFBFB; position: sticky; top: 0; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td .actions { display: flex; gap: 6px; justify-content: flex-end; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty .btn { margin-top: 12px; }

.tag { display: inline-block; font-size: 12.5px; padding: 2px 8px; border-radius: 20px; background: #EEF2F1; color: var(--muted); }
.tag.in { background: #E3F4EC; color: var(--ok); }
.tag.out { background: #E4EEF9; color: #2F6FB0; }
.tag.warn { background: var(--signal-soft); color: #7A5E00; }
.tag.bad { background: var(--err-soft); color: var(--err); }
.tag.late { background: var(--late-soft); color: var(--late); }
.tag.off { background: #E3EFEE; color: var(--teal-ink); }
.tag.unoff { background: #EFE7F6; color: #6B3E8E; }
.seg { display: inline-flex; margin-top: 12px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg a { padding: 7px 14px; font-size: 14px; color: var(--ink); text-decoration: none; border-right: 1px solid var(--line); white-space: nowrap; }
.seg a:last-child { border-right: 0; }
.seg a.on { background: var(--teal); color: #fff; }
.seg a:focus-visible { outline: 3px solid var(--signal); outline-offset: -3px; }
tr.deleted td { color: #A0ADAB; text-decoration: line-through; }

/* Табель */
.sheet { font-size: 13px; }
.sheet th, .sheet td { padding: 6px 6px; text-align: center; border-right: 1px solid #EEF2F1; }
.sheet th.name, .sheet td.name { text-align: left; min-width: 200px; position: sticky; left: 0; background: var(--surface); z-index: 1; }
.sheet th.name { background: #FAFBFB; z-index: 2; }
.sheet td.we, .sheet th.we { background: #F6F8F8; }
.sheet td.issue { background: var(--err-soft); color: var(--err); font-weight: 600; cursor: pointer; }
.sheet td.onshift { background: var(--signal-soft); }
.sheet td.late { background: var(--late-soft); color: var(--late); cursor: pointer; }
.sheet td.absent { color: var(--err); font-weight: 600; cursor: pointer; }
.sheet td.total { font-weight: 600; }
.legend { display: flex; gap: 16px; color: var(--muted); font-size: 13px; margin-top: 10px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-right: 6px; }

/* Окна */
dialog { border: 0; border-radius: 14px; padding: 0; width: min(520px, calc(100vw - 32px)); color: var(--ink); }
dialog::backdrop { background: rgba(22, 41, 44, .45); }
.dlg header { display: flex; justify-content: space-between; align-items: center; padding: 20px 24px 0; }
.dlg header h2 { font-size: 20px; }
.dlg .x { border: 0; background: none; font-size: 26px; line-height: 1; cursor: pointer; color: var(--muted); }
#dlgBody { padding: 16px 24px; display: grid; gap: 14px; }
.dlg footer { padding: 0 24px 20px; display: flex; justify-content: flex-end; gap: 8px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Запись лица */
.enroll { position: relative; border-radius: 12px; overflow: hidden; background: #0F2F33; aspect-ratio: 4 / 3; }
.enroll video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); display: block; }
.enroll .msg { position: absolute; left: 0; right: 0; bottom: 0; padding: 12px 16px; background: rgba(15, 47, 51, .82); color: #fff; font-weight: 500; }
.dots { display: flex; gap: 8px; justify-content: center; }
.dots span { width: 12px; height: 12px; border-radius: 50%; background: var(--line); }
.dots span.on { background: var(--teal); }

.ph-list { display: grid; gap: 8px; }
.ph-row { display: grid; grid-template-columns: 48px 1fr auto; gap: 10px; align-items: center; font-size: 14px; }
.ph-row img { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; background: var(--paper); }
.ph-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ph-row .ok { color: var(--ok); font-weight: 500; }
.ph-row .bad { color: var(--err); font-weight: 500; }
.ph-row .warnc { color: var(--late); font-weight: 500; }
.imp-table { max-height: 280px; overflow: auto; }
.imp-table td, .imp-table th { padding: 6px 10px; font-size: 13.5px; }
.days { display: flex; gap: 6px; flex-wrap: wrap; }
.day { display: inline-flex; font-weight: 500; }
.day input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.day span { padding: 7px 11px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; min-width: 42px; text-align: center; }
.day input:checked + span { background: var(--teal); border-color: var(--teal); color: #fff; }
.day input:focus-visible + span { outline: 3px solid var(--signal); outline-offset: 2px; }
dialog:has(.imp-table) { width: min(720px, calc(100vw - 32px)); }
.code-big { font-size: 48px; font-weight: 700; letter-spacing: .18em; text-align: center; font-variant-numeric: tabular-nums; padding: 8px 0; }
.note { background: #EEF4F3; border-radius: 8px; padding: 12px 14px; font-size: 14px; }

.settings { display: grid; gap: 28px; max-width: 620px; }
.settings section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 20px 22px; display: grid; gap: 14px; }
.settings h2 { font-size: 17px; }
.range-row { display: flex; align-items: center; gap: 12px; }
.range-row input { flex: 1; }
.range-row output { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 3em; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
.check input { margin-top: 4px; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 10px; z-index: 50;
  max-width: calc(100vw - 32px);
}
.toast.err { background: var(--err); }

@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side, .main { min-width: 0; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px; }
  .brand { padding: 0 8px; flex: 1 0 100%; }
  .brand img { max-width: 120px; }
  nav { display: flex; overflow-x: auto; gap: 4px; flex: 1 0 100%; }
  nav a { white-space: nowrap; border-left: 0; border-bottom: 3px solid transparent; }
  nav a.active { border-bottom-color: var(--signal); }
  .side-foot { flex-direction: row; display: flex; gap: 12px; margin: 0; }
  .main { padding: 20px 16px 48px; }
  .cols { grid-template-columns: minmax(0, 1fr); }
  html, body { overflow-x: hidden; }
  .head h1 { font-size: 24px; }
  .pulse .big { font-size: 56px; }
}
