/* Отмечалка — стили. Цвета задаются токенами; тёмная тема переопределяет их. */
:root {
  --bg: #F5F6F8; --surface: #FFFFFF; --track: #E9EBEF; --text: #15171C; --muted: #5A6170; --border: #E2E5EA;
  --accent: #4F46E5; --accent-soft: #ECEBFD; --accent-text: #4338CA; --on-accent: #FFFFFF;
  --ok-bg: #DDF4E4; --ok: #166534; --no-bg: #FDE4E4; --no: #B42318; --ex-bg: #FEF0D7; --ex: #8A4206;
  --radius: 16px; --shadow: 0 8px 24px rgba(20, 20, 60, .18);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0E1014; --surface: #181B21; --track: #22262D; --text: #ECEEF2; --muted: #A0A8B6; --border: #2A2F38;
  --accent: #8E88FF; --accent-soft: #25234A; --accent-text: #C9C6FF; --on-accent: #0E1014;
  --ok-bg: #173A25; --ok: #86E5A8; --no-bg: #45191A; --no: #FFA39B; --ex-bg: #43300F; --ex: #F7C46B;
  --shadow: 0 8px 24px rgba(0, 0, 0, .45);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0E1014; --surface: #181B21; --track: #22262D; --text: #ECEEF2; --muted: #A0A8B6; --border: #2A2F38;
    --accent: #8E88FF; --accent-soft: #25234A; --accent-text: #C9C6FF; --on-accent: #0E1014;
    --ok-bg: #173A25; --ok: #86E5A8; --no-bg: #45191A; --no: #FFA39B; --ex-bg: #43300F; --ex: #F7C46B;
    --shadow: 0 8px 24px rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
}

/* Inter хранится у нас, без запросов к Google */
@font-face {
  font-family: "Inter"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("fonts/inter-cyrillic.de93fdc85e3d.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Inter"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("fonts/inter-latin.260c81a4759b.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+20BD, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.45 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-text); }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
h2 { font-size: 17px; font-weight: 600; }
svg { flex-shrink: 0; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- Каркас ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px; flex-shrink: 0; padding: 20px 14px; display: flex; flex-direction: column; gap: 16px;
  background: var(--surface); border-right: 1px solid var(--border);
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; font-size: 18px; font-weight: 700; text-decoration: none; color: var(--text); }
.brand-mark { width: 36px; height: 36px; border-radius: 11px; background: var(--accent); color: var(--on-accent); display: flex; align-items: center; justify-content: center; }
.menu { display: flex; flex-direction: column; gap: 2px; }
.menu a {
  min-height: 44px; padding: 0 12px; border-radius: 12px; display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: var(--text); font-weight: 500;
}
.menu a:hover { background: var(--bg); }
.menu a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.who { display: flex; flex-direction: column; min-width: 0; }
.who small { color: var(--muted); font-size: 12px; }

.main { flex: 1; min-width: 0; padding: 28px 32px 48px; display: flex; flex-direction: column; gap: 20px; }
.topbar { display: none; }
.bottom-nav { display: none; }

@media (max-width: 899px) {
  .sidebar { display: none; }
  .main { padding: 8px 16px 100px; gap: 14px; }
  .topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 10px 16px; position: sticky; top: 0; z-index: 5;
    background: var(--bg);
  }
  .topbar .center-name { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
    background: var(--surface); border-top: 1px solid var(--border);
    padding: 6px 4px calc(8px + env(safe-area-inset-bottom));
  }
  .bottom-nav a {
    flex: 1; min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    text-decoration: none; color: var(--muted); font-size: 12px; font-weight: 500;
  }
  .bottom-nav a[aria-current="page"] { color: var(--accent-text); font-weight: 600; }
}

/* ---------- Элементы ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
.page-head .eyebrow { display: block; color: var(--muted); font-size: 13px; margin-bottom: 2px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

.btn {
  min-height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 14px; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { filter: brightness(1.06); border-color: var(--accent); }
.btn-soft { background: var(--accent-soft); border-color: transparent; color: var(--accent-text); }
.btn-block { width: 100%; min-height: 52px; font-size: 16px; border-radius: 16px; }
.icon-btn { width: 44px; min-height: 44px; padding: 0; }
.btn:focus-visible, .menu a:focus-visible, .chip:focus-visible, .row-link:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 2px;
}

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.card-flush { padding: 0; overflow: hidden; }
.card h2 { margin-bottom: 12px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.kpi { display: flex; flex-direction: column; gap: 4px; }
.kpi .label { color: var(--muted); font-size: 13px; }
.kpi .value { font-size: 28px; font-weight: 700; letter-spacing: -.02em; }
.kpi .note { font-size: 13px; color: var(--muted); }

.muted { color: var(--muted); }
.tone-muted { color: var(--muted); }
.tone-warn { color: var(--ex); }
.tone-danger { color: var(--no); }
.small { font-size: 13px; }

.tag { display: inline-block; padding: 4px 10px; border-radius: 9px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.tag-ok { background: var(--ok-bg); color: var(--ok); }
.tag-no, .tag-debt { background: var(--no-bg); color: var(--no); }
.tag-ex, .tag-ending { background: var(--ex-bg); color: var(--ex); }
.tag-accent { background: var(--accent-soft); color: var(--accent-text); }
.tag-plain { background: var(--track); color: var(--muted); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chip {
  flex-shrink: 0; min-height: 40px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); display: inline-flex; align-items: center;
  font-size: 14px; font-weight: 600; text-decoration: none; white-space: nowrap;
}
.chip[aria-current="true"] { background: var(--text); border-color: var(--text); color: var(--bg); }

.list { display: flex; flex-direction: column; gap: 8px; }
.row {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
}
.row-link { text-decoration: none; color: var(--text); }
.row-link:hover { border-color: var(--muted); }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.row-main strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-main span { font-size: 13px; }
.avatar {
  width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent-text); font-weight: 600; font-size: 14px;
}
.avatar-lg { width: 64px; height: 64px; font-size: 22px; font-weight: 700; }

.summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; }


/* Абонемент */
.sub-card { background: var(--accent); color: var(--on-accent); border-radius: 20px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.sub-card .big { font-size: 40px; font-weight: 700; letter-spacing: -.02em; line-height: 1; }
.segments { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; }
.segments i { height: 8px; border-radius: 4px; background: currentColor; }
.segments i.used { opacity: .35; }
.tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; padding: 4px; border-radius: 14px; background: var(--track); }
.tabs a { min-height: 40px; border-radius: 11px; display: flex; align-items: center; justify-content: center; text-decoration: none; color: var(--muted); font-weight: 600; font-size: 14px; }
.tabs a[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.lines > div { min-height: 52px; padding: 8px 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid var(--border); }
.lines > div:first-child { border-top: 0; }

/* Расписание */
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.week a {
  min-height: 60px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-decoration: none;
}
.week a small { font-size: 12px; opacity: .8; }
.week a b { font-size: 17px; }
.week a[aria-current="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.bar { height: 6px; border-radius: 3px; background: var(--track); overflow: hidden; flex: 1; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }

/* Таблицы */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
th, td { padding: 12px 14px; border-top: 1px solid var(--border); }
td.num, th.num { text-align: right; }

/* Формы */
.form { display: flex; flex-direction: column; gap: 14px; max-width: 560px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 14px; font-weight: 600; }
.field input:not([type="checkbox"]), .field select, .field textarea, .search input {
  min-height: 48px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus, .search input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.field .help { color: var(--muted); font-size: 13px; }
.errorlist { margin: 0; padding: 0; list-style: none; color: var(--no); font-size: 13px; }
.checks { display: flex; flex-direction: column; gap: 8px; }
.checks div { display: contents; }
.checks label, .check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 500; }
input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--accent); }
.search { display: flex; gap: 8px; }
.search input { flex: 1; min-width: 0; }
.slot-row { display: grid; grid-template-columns: 1.4fr 1fr 1fr auto; gap: 8px; align-items: center; }
.slot-row select, .slot-row input:not([type="checkbox"]) { min-height: 44px; padding: 8px 10px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); width: 100%; }

.messages { display: flex; flex-direction: column; gap: 8px; }
.message { padding: 12px 14px; border-radius: 12px; background: var(--ok-bg); color: var(--ok); font-weight: 500; }
.message.error { background: var(--no-bg); color: var(--no); }
.empty { padding: 32px 16px; text-align: center; color: var(--muted); }

.fab {
  position: fixed; right: 16px; bottom: 92px; z-index: 9; min-height: 56px; padding: 0 20px; border-radius: 18px;
  box-shadow: var(--shadow);
}
@media (min-width: 900px) { .fab { display: none; } }

.btn-danger { color: var(--no); border-color: var(--no-bg); background: transparent; }
.btn-danger:hover { background: var(--no-bg); border-color: var(--no-bg); }

/* Кнопка темы: луна в светлой, солнце в тёмной */
.i-sun { display: none; }
:root[data-theme="dark"] .i-sun { display: inline-flex; }
:root[data-theme="dark"] .i-moon { display: none; }
.i-moon, .i-sun { align-items: center; }
.i-moon { display: inline-flex; }

/* Отметка в процессе сохранения */

/* Строки истории, по которым можно нажать */
.lines > .line-link {
  min-height: 52px; padding: 8px 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border-top: 1px solid var(--border); text-decoration: none; color: var(--text);
}
.lines > .line-link:first-child { border-top: 0; }
.lines > .line-link:hover { background: var(--bg); }

/* Всплывающее уведомление */

/* Вход / регистрация */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth .card { width: 100%; max-width: 420px; padding: 28px 24px; display: flex; flex-direction: column; gap: 18px; }
.auth .brand { padding: 0; }

/* Посетители: фильтры и строка с отметкой за сегодня */
.filters { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px; }
.filters input[type="search"] { flex: 1 1 220px; }
.filters input, .filters select {
  min-height: 44px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface);
}
.filters select { flex: 0 1 200px; }
.visitor { flex-wrap: wrap; }
.visitor-link { display: flex; align-items: center; gap: 12px; flex: 1 1 260px; min-width: 0; text-decoration: none; color: var(--text); }
.row-num { min-width: 2.2em; text-align: right; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; flex: none; }
.visitor-link:hover strong { text-decoration: underline; }
.visitor-facts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.visitor-action .btn { white-space: nowrap; }
@media (max-width: 899px) {
  .visitor-link { flex-basis: 100%; }
  .visitor-facts { flex: 1 1 0; min-width: 0; padding-left: 54px; }
  .visitor-action .btn { min-height: 40px; padding: 0 12px; }
  .filters select { flex: 1 1 140px; }
}
