:root {
  --bg: #f5f5f2; --panel: #ffffff; --ink: #1b1d1f; --muted: #6b6f73; --line: #e4e3de;
  --accent: #2f5d50; --accent-soft: #e3ece8; --good: #2f8a5b; --warn: #d49a2a; --bad: #c4493b;
  --head: #fafaf8; --radius: 10px;
  font-family: "Inter", -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 14px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #141617; --panel: #1c1f21; --ink: #e9eaea; --muted: #9a9fa3; --line: #2c3033;
          --accent: #7fb8a5; --accent-soft: #23302c; --head: #202426; --good: #4caf7d; --warn: #e0ae4c; --bad: #e0675a; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
a { color: var(--accent); }
h1 { font-size: 22px; margin: 2px 0 0; letter-spacing: -.01em; }
h2 { font-size: 18px; margin: 0 0 8px; }
h3.sub { font-size: 14px; margin: 24px 0 8px; color: var(--muted); font-weight: 600; }
.muted { color: var(--muted); } .small { font-size: 12px; }

.top { display: flex; align-items: center; gap: 24px; padding: 10px 20px; background: var(--panel);
       border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; flex-wrap: wrap; }
.brand { font-weight: 800; letter-spacing: .04em; color: var(--ink); text-decoration: none; font-size: 16px; }
.brand span { font-weight: 500; letter-spacing: 0; color: var(--muted); margin-left: 6px; }
.brand.big { font-size: 22px; text-align: center; margin-bottom: 8px; }
.nav { display: flex; gap: 18px; flex: 1; flex-wrap: wrap; }
.nav-group { display: flex; align-items: center; gap: 2px; }
.nav-sec { font-size: 11px; text-transform: uppercase; color: var(--muted); margin-right: 6px; letter-spacing: .06em; }
.nav a { text-decoration: none; color: var(--ink); padding: 6px 10px; border-radius: 8px; }
.nav a:hover { background: var(--accent-soft); }
.nav a.active { background: var(--accent); color: var(--panel); }
.me { color: var(--muted); font-size: 13px; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 24px 20px; }
.wide { padding: 20px; }
.center { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.login { width: 100%; max-width: 360px; display: grid; gap: 14px; }
.qr { display: grid; place-items: center; background: #fff; padding: 12px; border-radius: 8px; }
label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
input, select { font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line);
                border-radius: 8px; padding: 8px 10px; }
input:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.alert { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); padding: 8px 12px; border-radius: 8px; }
.ok-msg { background: var(--accent-soft); color: var(--accent); padding: 8px 12px; border-radius: 8px; margin-bottom: 12px; }
.btn { font: inherit; border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 8px;
       padding: 7px 12px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--panel); border-color: var(--accent); }
.btn.danger { color: var(--bad); }
.btn.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
button.link { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }
.pill { font-size: 12px; background: var(--accent-soft); color: var(--accent); padding: 2px 8px; border-radius: 99px; vertical-align: middle; font-weight: 500; }

.head { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 14px; gap: 12px; flex-wrap: wrap; }
.crumb { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.status { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.dot.ok { background: var(--good); } .dot.bad { background: var(--bad); }

.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.filters .spacer { flex: 1; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--panel); }
.seg button { font: inherit; border: 0; background: none; color: var(--ink); padding: 7px 10px; cursor: pointer; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--accent); color: var(--panel); }
.dates { display: flex; flex-direction: row; align-items: center; gap: 6px; color: var(--muted); }
.dates input { padding: 6px 8px; }
.search { min-width: 200px; }
.ms { position: relative; }
.ms-pop { display: none; position: absolute; top: calc(100% + 4px); left: 0; z-index: 30; background: var(--panel);
          border: 1px solid var(--line); border-radius: 10px; width: 280px; box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 8px; }
.ms.open .ms-pop { display: block; }
.ms-q { width: 100%; margin-bottom: 6px; }
.ms-list { max-height: 280px; overflow: auto; display: grid; }
.ms-list label { display: flex; flex-direction: row; gap: 8px; align-items: center; padding: 5px 4px; color: var(--ink); font-size: 13px; cursor: pointer; border-radius: 6px; }
.ms-list label:hover { background: var(--accent-soft); }
.ms-foot { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 6px; text-align: right; }

.table-wrap { overflow: auto; padding: 0; max-height: calc(100vh - 210px); }
table.data { border-collapse: separate; border-spacing: 0; width: 100%; font-variant-numeric: tabular-nums; }
table.data th, table.data td { padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data th { position: sticky; top: 0; background: var(--head); font-weight: 600; font-size: 12px; color: var(--muted);
                cursor: pointer; white-space: normal; min-width: 84px; vertical-align: bottom; z-index: 2; }
table.data th.asc::after { content: " ▲"; } table.data th.desc::after { content: " ▼"; }
table.data .l { text-align: left; }
table.data td.l:first-child, table.data th.l:first-child { position: sticky; left: 0; background: var(--panel); z-index: 1; max-width: 280px; white-space: normal; }
table.data th.l:first-child { background: var(--head); z-index: 3; }
table.data tbody tr:hover td { background: var(--accent-soft); }
table.data tr.click { cursor: pointer; }
table.data tfoot td { position: sticky; bottom: 0; background: var(--head); font-weight: 700; border-top: 1px solid var(--line); }
table.data td.empty { text-align: center; color: var(--muted); padding: 32px; }
table.data td.warn { color: var(--bad); font-weight: 600; }
table.compact td, table.compact th { padding: 6px 10px; }
.chart-card { margin-bottom: 14px; padding: 12px; } .chart { height: 260px; }

dialog { border: 1px solid var(--line); border-radius: 12px; padding: 0; width: min(1100px, 96vw); background: var(--panel); color: var(--ink); }
dialog::backdrop { background: rgba(0,0,0,.35); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.dlg-head h3 { margin: 0; font-size: 15px; }
dialog .table-wrap { max-height: 70vh; }

/* админка */
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.admin-table th { font-size: 12px; color: var(--muted); font-weight: 600; }
.admin-table tr.off td { opacity: .5; }
.perm { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center; }
.perm select { padding: 4px 6px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.row > label { flex: 1; min-width: 160px; }
.checks { display: flex; gap: 16px; flex-wrap: wrap; }
.checks label { display: flex; flex-direction: row; align-items: center; gap: 6px; color: var(--ink); }
details.user { border: 1px solid var(--line); border-radius: 10px; padding: 0 14px; margin-bottom: 8px; background: var(--panel); }
details.user summary { cursor: pointer; padding: 12px 0; display: flex; gap: 12px; align-items: center; list-style: none; }
details.user summary::-webkit-details-marker { display: none; }
details.user[open] summary { border-bottom: 1px solid var(--line); margin-bottom: 12px; }
details.user form.edit { display: grid; gap: 12px; padding-bottom: 14px; }
.tag { font-size: 11px; padding: 2px 7px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); }
.tag.grey { background: var(--line); color: var(--muted); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; }
code { background: var(--head); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
@media (max-width: 700px) { .top { gap: 10px; } .nav { gap: 8px; } .wide { padding: 12px; } .table-wrap { max-height: none; } }
table.data td.l:first-child { min-width: 190px; }
#tbl td.l:not(:first-child) { white-space: normal; min-width: 240px; max-width: 420px; }
@media (max-width: 700px) {
  .nav-group { flex-wrap: wrap; }
  .seg { max-width: 100%; overflow-x: auto; }
  .seg button { white-space: nowrap; }
  table.data td.l:first-child { min-width: 120px; }
}
@media (max-width: 700px) {
  .top { flex-direction: column; align-items: flex-start; gap: 6px; padding: 10px 12px; }
  .nav { width: 100%; gap: 4px 12px; }
  .nav a { padding: 4px 8px; }
  #tbl td.l:not(:first-child) { min-width: 140px; }
}
