:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --ink: #17212b;
  --muted: #5f6b78;
  --line: #dfe4ea;
  --brand: #1f4e79;
  --brand-2: #2c6aa3;
  --accent: #f6a623;
  --ok: #1e7b4a;
  --ok-bg: #e5f4ec;
  --warn: #9a5b00;
  --warn-bg: #fff3dd;
  --bad: #b3261e;
  --bad-bg: #fdeceb;
  --info-bg: #e8f0f8;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  font-size: 14px;
  color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
a { color: var(--brand-2); }
.boot { padding: 40px; color: var(--muted); }

/* layout */
.shell { display: grid; grid-template-columns: 228px 1fr; min-height: 100vh; }
.side { background: #12324f; color: #dbe7f3; padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 8px 18px; font-weight: 700; font-size: 15px; color: #fff; }
.brand small { display: block; font-weight: 400; color: #9fb7cf; font-size: 12px; }
.brand .logo { width: 32px; height: 32px; border-radius: 8px; background: var(--brand-2); display: grid; place-items: center; color: var(--accent); font-size: 18px; }
.nav a { display: block; padding: 9px 12px; border-radius: 8px; color: #dbe7f3; text-decoration: none; margin-bottom: 2px; }
.nav a:hover { background: rgba(255,255,255,.07); }
.nav a.active { background: var(--brand-2); color: #fff; }
.nav .sep { height: 1px; background: rgba(255,255,255,.1); margin: 10px 4px; }
.side .who { margin-top: auto; padding: 10px 8px 0; border-top: 1px solid rgba(255,255,255,.12); font-size: 12px; color: #9fb7cf; }
.side .who b { color: #fff; display: block; font-size: 13px; }
.side .who button { margin-top: 8px; }
.main { padding: 22px 26px 60px; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
h1 { font-size: 21px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { text-align: right; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* cards */
.grid { display: grid; gap: 14px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; min-width: 0; }
.kpi .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-size: 24px; font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi .sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.kpi.alert { border-color: #f0b45a; background: var(--warn-bg); }
.mt { margin-top: 14px; }
.mb { margin-bottom: 14px; }

/* calc lines */
.calc { width: 100%; border-collapse: collapse; }
.calc td { padding: 6px 0; border-bottom: 1px dashed var(--line); }
.calc td:last-child { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.calc tr.total td { border-bottom: none; border-top: 2px solid var(--ink); font-weight: 700; padding-top: 8px; }
.calc tr.minus td:first-child::before { content: "− "; color: var(--muted); }
.calc tr.plus td:first-child::before { content: "+ "; color: var(--muted); }
.calc tr.sub td { color: var(--muted); font-size: 12px; }

/* tables */
.tablewrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
table.t { width: 100%; border-collapse: collapse; }
.t th { background: #f0f3f7; text-align: left; font-weight: 600; font-size: 12px; color: #3c4855; padding: 8px 10px; position: sticky; top: 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
.t td { padding: 7px 10px; border-bottom: 1px solid #eef1f4; vertical-align: top; }
.t tr:hover td { background: #fafbfd; }
.t tfoot td { font-weight: 700; background: #f7f9fb; border-top: 2px solid var(--line); }
.t .acts { white-space: nowrap; text-align: right; }

/* chips */
.chip { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; margin: 1px 2px 1px 0; white-space: nowrap; }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip.info { background: var(--info-bg); color: var(--brand); }
.chip.grey { background: #eef1f4; color: var(--muted); }

/* forms */
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
input, select, textarea { width: 100%; padding: 8px 10px; border: 1px solid #c9d2dc; border-radius: 8px; font: inherit; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid #bcd3ea; border-color: var(--brand-2); }
input[type=checkbox] { width: auto; }
.field { margin-bottom: 12px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.row > .field { flex: 1 1 160px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 600; color: var(--ink); font-size: 13px; cursor: pointer; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 12px; }
.filters .field { margin: 0; min-width: 160px; }

button, .btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid #c9d2dc; background: #fff; color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
button:hover { background: #f3f6f9; }
button.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
button.primary:hover { background: var(--brand-2); }
button.danger { color: var(--bad); border-color: #e7b3af; }
button.danger:hover { background: var(--bad-bg); }
button.ghost { border-color: transparent; background: transparent; padding: 4px 8px; }
button.ghost:hover { background: #eef1f4; }
button:disabled { opacity: .5; cursor: not-allowed; }
.side button { background: transparent; color: #dbe7f3; border-color: rgba(255,255,255,.25); padding: 5px 10px; font-size: 12px; }

/* banners */
.banner { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid; }
.banner.warn { background: var(--warn-bg); border-color: #f0c47a; color: #6b3f00; }
.banner.info { background: var(--info-bg); border-color: #bcd3ea; color: #173e62; }
.banner.bad { background: var(--bad-bg); border-color: #efb4af; color: #7a1712; }
.banner.ok { background: var(--ok-bg); border-color: #a9dbbf; color: #14532f; }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(15, 25, 35, .45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: #fff; border-radius: 12px; width: min(620px, 100%); max-height: 92vh; overflow: auto; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal header { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal header h2 { margin: 0; }
.modal .body { padding: 18px 20px; }
.modal footer { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.err { color: var(--bad); font-weight: 600; margin-top: 6px; min-height: 18px; }

/* toast */
#toast-root { position: fixed; bottom: 18px; right: 18px; z-index: 60; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #17212b; color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow); max-width: 380px; }
.toast.bad { background: var(--bad); }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(160deg, #12324f 0%, #1f4e79 60%, #2c6aa3 100%); }
.login { width: min(380px, 100%); background: #fff; border-radius: 14px; padding: 28px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.login h1 { margin-bottom: 4px; }
.login p { margin-top: 0; color: var(--muted); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { border: none; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 8px 12px; color: var(--muted); }
.tabs button.on { color: var(--brand); border-bottom-color: var(--brand); }

.mobile-nav { display: none; }

@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; align-content: flex-start; padding: 10px 12px; gap: 6px; }
  .brand { padding: 0 8px 0 0; flex: 1 1 auto; }
  .nav { display: flex; flex-wrap: wrap; gap: 2px; }
  .nav .sep { display: none; }
  .side .who { margin: 0 0 0 auto; border: none; padding: 0; }
  .main { padding: 16px; }
  .g3, .g2, .g4 { grid-template-columns: 1fr; }
}
@media print {
  .side, .no-print, button { display: none !important; }
  .shell { display: block; }
  .card, .tablewrap { box-shadow: none; }
}

.ghid { max-width: 920px; line-height: 1.55; }
.ghid h2 { margin-top: 18px; color: var(--brand); }
.ghid h2:first-child { margin-top: 0; }
.ghid li { margin-bottom: 4px; }
