:root {
  --accent: #0E7490; --accent-dark: #0B5C73; --accent-soft: rgba(14,116,144,.10); --accent-text: #fff;
  --bg: #F2F7F9; --surface: #fff; --surface-2: #F7FBFC; --border: #D5E3E8;
  --text: #12303A; --muted: #5A7680; --danger: #C8372D; --danger-bg: #FCEBEA; --ok: #1F8A4C; --ok-bg: #E3F4EA; --warn: #B7791F; --warn-bg: #FBF1DC;
  --radius: 10px; --shadow: 0 2px 10px rgba(18,48,58,.08);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0F1A1E; --surface: #16262C; --surface-2: #1B2F36; --border: #2A4650; --text: #E6F1F4; --muted: #8FB0B9; --accent: #3BB6D3; --accent-dark: #2A97B3; --accent-text: #06232B; --accent-soft: rgba(59,182,211,.14);
    --danger-bg: #3A1B19; --ok-bg: #153023; --warn-bg: #3A2F14; --shadow: none; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 "Segoe UI", system-ui, sans-serif; }
h1 { font-size: 22px; margin: 0 0 4px; } h2 { font-size: 17px; margin: 0 0 10px; } h3 { font-size: 15px; margin: 18px 0 8px; }
.muted { color: var(--muted); } .error { color: var(--danger); min-height: 1.4em; margin: 6px 0 0; }
a, .link { color: var(--accent); cursor: pointer; text-decoration: none; background: none; border: 0; padding: 0; font: inherit; }
a:hover, .link:hover { text-decoration: underline; }

#login-view { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow); display: grid; gap: 12px; }

#app-view { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
#side { background: var(--surface); border-inline-end: 1px solid var(--border); display: flex; flex-direction: column; padding: 14px 10px; gap: 2px; position: sticky; top: 0; height: 100vh; }
.brand { font-size: 22px; font-weight: 800; color: var(--accent); padding: 4px 10px 14px; letter-spacing: .04em; } .brand span { font-weight: 400; font-size: 12px; margin-inline-start: 6px; color: var(--muted); }
.nav { text-align: start; background: none; border: 0; padding: 9px 12px; border-radius: 8px; color: var(--text); font: inherit; cursor: pointer; }
.nav:hover { background: var(--accent-soft); } .nav.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; } .nav.danger { color: var(--danger); }
.grow { flex: 1; } .who { padding: 8px 12px; font-size: 12px; color: var(--muted); word-break: break-all; }
main { padding: 24px; max-width: 1200px; width: 100%; outline: none; }
.head { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 14px; } .head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.card .n { font-size: 26px; font-weight: 700; } .card.warn .n { color: var(--warn); } .card.bad .n { color: var(--danger); }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 16px; }

table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
th, td { padding: 9px 12px; text-align: start; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { background: var(--surface-2); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
tr:last-child td { border-bottom: 0; } td.num { text-align: end; } .scroll { overflow-x: auto; }
code { font-family: Consolas, monospace; font-size: 13px; }

.btn { border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 7px 14px; border-radius: 8px; font: inherit; cursor: pointer; }
.btn:hover { border-color: var(--accent); } .btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); } .btn.primary:hover { background: var(--accent-dark); }
.btn.danger { color: var(--danger); } .btn.sm { padding: 3px 10px; font-size: 13px; } .btn:disabled { opacity: .5; cursor: not-allowed; }
.badge { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 12px; background: var(--accent-soft); color: var(--accent); }
.badge.ok { background: var(--ok-bg); color: var(--ok); } .badge.warn { background: var(--warn-bg); color: var(--warn); } .badge.bad { background: var(--danger-bg); color: var(--danger); } .badge.grey { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }

input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; width: 100%; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, .nav:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); } label input, label select, label textarea { color: var(--text); font-size: 15px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; } .row > * { flex: 1 1 160px; } .checks { display: flex; gap: 14px; flex-wrap: wrap; } .checks label { display: flex; gap: 6px; align-items: center; color: var(--text); font-size: 14px; } .checks input { width: auto; }
.filters { display: flex; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; } .filters input, .filters select { width: auto; min-width: 200px; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 10px; }

dialog { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 20px; width: min(560px, calc(100vw - 24px)); box-shadow: 0 10px 40px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(8,20,24,.5); } dialog form { display: grid; gap: 12px; } dialog .foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; }
textarea.token { font-family: Consolas, monospace; font-size: 12px; height: 130px; word-break: break-all; }
#toast { position: fixed; bottom: 18px; inset-inline-start: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 8px; z-index: 50; max-width: 90vw; }
#toast.err { background: var(--danger); color: #fff; }

@media (max-width: 760px) {
  #app-view { grid-template-columns: 1fr; } #side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; border-inline-end: 0; border-bottom: 1px solid var(--border); }
  .grow { display: none; } .brand { padding-bottom: 4px; } main { padding: 14px; }
}

.upper { text-transform: uppercase; }
