:root {
  --ink: #16201b; --muted: #6f6b63; --paper: #faf6ee; --surface: #fff; --sunk: #f1ece1; --line: #e6dfd1;
  --accent: #1f4d36; --accent-deep: #143524; --accent-soft: #e4f1e6; --alert: #c8402f; --alert-soft: #fbe6e1;
  --saffron: #c98a12; --saffron-soft: #faefd8; --ok: #2e7d4f; --control: #8c877d;
}
@media (prefers-color-scheme: dark) {
  :root { --ink: #eef0ec; --muted: #a9a79f; --paper: #121714; --surface: #1a211d; --sunk: #232b26; --line: #2f3933; --accent: #6fcf97; --accent-deep: #8fe0ae; --accent-soft: #1e3a2a; --alert: #ff8a78; --alert-soft: #3a1f1a; --saffron: #f2b45a; --saffron-soft: #3a2e17; --ok: #6fcf97; --control: #6b756e; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.5 "Helvetica Neue", Helvetica, Arial, sans-serif; }
[hidden] { display: none !important; }
h1 { font-size: 22px; margin: 0 0 4px; } h2 { font-size: 16px; margin: 0 0 12px; } h3 { font-size: 14px; margin: 0 0 8px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .mono { font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
.error { color: var(--alert); min-height: 1.2em; margin: 0; }

.brand { font-weight: 700; font-size: 18px; letter-spacing: .2px; } .brand span { font-weight: 400; color: var(--muted); }
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 28px; display: grid; gap: 14px; }
label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--control); border-radius: 10px; padding: 9px 11px; width: 100%; }
input[type=checkbox] { width: 18px; height: 18px; padding: 0; accent-color: var(--accent); }
textarea { min-height: 84px; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn { font: inherit; font-weight: 600; border-radius: 10px; border: 1px solid var(--control); background: var(--surface); color: var(--ink); padding: 9px 14px; cursor: pointer; min-height: 40px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { .btn.primary { color: #0c1a12; } }
.btn.danger { color: var(--alert); border-color: var(--alert); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { padding: 5px 10px; min-height: 32px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; }
#nav { display: grid; gap: 2px; }
#nav a { color: var(--ink); text-decoration: none; padding: 8px 10px; border-radius: 9px; font-weight: 500; }
#nav a:hover { background: var(--sunk); } #nav a[aria-current=page] { background: var(--accent-soft); color: var(--accent-deep); font-weight: 700; }
.side-foot { margin-top: auto; display: grid; gap: 8px; }
main { padding: 28px 32px 64px; max-width: 1100px; width: 100%; }
.banner { padding: 10px 14px; border-radius: 10px; margin-bottom: 16px; background: var(--saffron-soft); color: var(--ink); border: 1px solid var(--saffron); }
.banner.alert { background: var(--alert-soft); border-color: var(--alert); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px; margin-bottom: 16px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.kpi b { display: block; font-size: 26px; line-height: 1.2; } .kpi span { color: var(--muted); font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; } .row.end { justify-content: flex-end; } .spread { justify-content: space-between; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }

.fields { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.field { display: grid; gap: 4px; align-content: start; } .field .name { font-weight: 600; font-size: 14px; } .field .hint { color: var(--muted); font-size: 12.5px; }
.field.check { grid-template-columns: auto 1fr; align-items: start; column-gap: 10px; } .field.check .hint, .field.check .actions { grid-column: 2; }
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--sunk); color: var(--muted); }
.badge.ok { background: var(--accent-soft); color: var(--accent-deep); } .badge.warn { background: var(--saffron-soft); color: var(--saffron); } .badge.bad { background: var(--alert-soft); color: var(--alert); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; } tr:last-child td { border-bottom: 0; }
.empty { padding: 18px; color: var(--muted); text-align: center; }

dialog { border: 1px solid var(--line); border-radius: 16px; padding: 22px; background: var(--surface); color: var(--ink); width: min(560px, calc(100vw - 24px)); max-height: 90vh; overflow: auto; }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog form { display: grid; gap: 14px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translate(-50%, 20px); background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 10px; opacity: 0; pointer-events: none; transition: .2s; max-width: 90vw; z-index: 50; }
.toast.show { opacity: 1; transform: translate(-50%, 0); } .toast.bad { background: var(--alert); color: #fff; }

@media (max-width: 800px) {
  .shell { grid-template-columns: 1fr; } .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  #nav { display: flex; flex-wrap: wrap; } .side-foot { margin: 0 0 0 auto; } main { padding: 18px 14px 64px; }
}
