:root {
  --bg: #f5f6fa; --surface: #ffffff; --surface-2: #f0f2f8; --text: #1b1f2e; --muted: #5d6478; --line: #e1e4ee;
  --accent: #3b4fd8; --accent-ink: #ffffff; --accent-soft: #e8ebfd;
  --ok: #17794a; --ok-soft: #e1f5ea; --warn: #9a5b00; --warn-soft: #fff1d6; --bad: #b3261e; --bad-soft: #fde6e4; --info: #1f5fa8; --info-soft: #e3effc;
  --radius: 12px; --shadow: 0 1px 2px rgba(20,25,50,.06), 0 4px 16px rgba(20,25,50,.06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11131b; --surface: #1a1d28; --surface-2: #222636; --text: #e8eaf3; --muted: #9aa1b8; --line: #2e3347;
    --accent: #7c8cff; --accent-ink: #0f1220; --accent-soft: #2a3057;
    --ok: #5fd59a; --ok-soft: #163a2a; --warn: #f0b95a; --warn-soft: #3d2f12; --bad: #ff8f87; --bad-soft: #43201e; --info: #7db8f5; --info-soft: #172e47;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.3);
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font-size: 16px; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; } h2 { font-size: 1.15rem; margin: 0 0 .75rem; } h3 { font-size: 1rem; margin: 0 0 .5rem; }
p { margin: 0 0 .75rem; } a { color: var(--accent); }
.muted { color: var(--muted); } .small { font-size: .85rem; } .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; }
.boot { padding: 2rem; color: var(--muted); }

/* layout */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 1rem .75rem; display: flex; flex-direction: column; gap: .25rem; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1.05rem; padding: .25rem .5rem 1rem; }
.brand img { width: 28px; height: 28px; }
.nav a { display: block; padding: .55rem .75rem; border-radius: 8px; color: var(--text); text-decoration: none; font-weight: 500; }
.nav a:hover { background: var(--surface-2); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.nav .group { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: .9rem .75rem .25rem; }
.side-foot { margin-top: auto; padding: .75rem .5rem 0; border-top: 1px solid var(--line); font-size: .85rem; }
.side-foot .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main { padding: 1.5rem clamp(1rem, 3vw, 2.25rem) 3rem; max-width: 1180px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.banner { padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; display: flex; gap: .75rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.banner.warn { background: var(--warn-soft); color: var(--warn); } .banner.info { background: var(--info-soft); color: var(--info); } .banner.bad { background: var(--bad-soft); color: var(--bad); }
.menu-btn { display: none; }

/* cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.25rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.stat { display: flex; flex-direction: column; gap: .15rem; }
.stat .num { font-size: 2rem; font-weight: 700; line-height: 1.1; } .stat .label { color: var(--muted); font-size: .85rem; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: .25rem 1rem; margin: 0 0 .75rem; } .kv dt { color: var(--muted); } .kv dd { margin: 0; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; } .row.between { justify-content: space-between; } .stack > * + * { margin-top: .75rem; }

/* forms and buttons */
.field { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .85rem; } .field-label { font-weight: 600; font-size: .88rem; } .hint { color: var(--muted); font-size: .8rem; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: .55rem .7rem; width: 100%; }
input[type=checkbox] { width: auto; } input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.check { display: flex; gap: .5rem; align-items: flex-start; margin-bottom: .85rem; } .check input { margin-top: .25rem; }
button { font: inherit; cursor: pointer; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text); padding: .5rem .9rem; font-weight: 600; }
button:hover:not(:disabled) { background: var(--surface-2); } button:disabled { opacity: .55; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); } button.primary:hover:not(:disabled) { filter: brightness(1.08); background: var(--accent); }
button.danger { color: var(--bad); border-color: var(--bad); background: transparent; } button.link { border: 0; background: none; color: var(--accent); padding: .25rem; }
.form-narrow { max-width: 420px; }
.error { color: var(--bad); background: var(--bad-soft); border-radius: 8px; padding: .5rem .75rem; margin-bottom: .75rem; }

/* tables and chips */
.table-wrap { overflow-x: auto; } table { width: 100%; border-collapse: collapse; } th, td { text-align: left; padding: .6rem .6rem; border-bottom: 1px solid var(--line); vertical-align: middle; } th { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); white-space: nowrap; }
.empty { color: var(--muted); padding: .75rem 0; }
.chip { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.chip.ok { background: var(--ok-soft); color: var(--ok); } .chip.warn { background: var(--warn-soft); color: var(--warn); } .chip.bad { background: var(--bad-soft); color: var(--bad); } .chip.info { background: var(--info-soft); color: var(--info); }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; flex-wrap: wrap; }
.tabs button { border: 0; border-bottom: 3px solid transparent; border-radius: 0; background: none; color: var(--muted); } .tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.thumb { width: 72px; height: 54px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); background: var(--surface-2); }
.rating { font-weight: 700; }

/* login */
.center { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login { width: 100%; max-width: 400px; } .login .brand { justify-content: center; padding-bottom: 1.25rem; font-size: 1.3rem; }
.secret { font-size: 1.1rem; letter-spacing: .08em; padding: .6rem; background: var(--surface-2); border-radius: 8px; word-break: break-all; }

/* pop-ups and toasts */
.popups { position: fixed; top: 1rem; right: 1rem; z-index: 50; display: flex; flex-direction: column; gap: .6rem; width: min(380px, calc(100vw - 2rem)); }
.popup { background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--info); border-radius: 10px; padding: .8rem 1rem; box-shadow: 0 8px 28px rgba(10,15,40,.25); animation: slide .25s ease-out; }
.popup.WARNING { border-left-color: var(--warn); } .popup.HIGH { border-left-color: var(--bad); }
.popup .t { font-weight: 700; margin-bottom: .2rem; } .popup .actions { display: flex; gap: .5rem; margin-top: .5rem; }
.toasts { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: .5rem; align-items: center; }
.toast { background: var(--text); color: var(--bg); padding: .6rem 1rem; border-radius: 8px; box-shadow: var(--shadow); } .toast.error { background: var(--bad); color: #fff; }
@keyframes slide { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .popup { animation: none; } }

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: .25rem .5rem; } .menu-btn { display: inline-block; margin-left: auto; }
  .nav { display: none; width: 100%; } .nav.open { display: block; } .side-foot { display: none; width: 100%; margin-top: 0; } .nav.open ~ .side-foot { display: block; }
}
.banner.ok { background: var(--ok-soft); color: var(--ok); }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .4rem .8rem; margin: .5rem 0 1rem; }
fieldset.field { border: 0; padding: 0; margin: 0 0 1rem; }
textarea { resize: vertical; }
td select { min-width: 8rem; }

details.card { padding: 12px 20px; }
details.card > summary { cursor: pointer; font-weight: 600; margin-bottom: 8px; }
