:root {
  --navy: #0A0F2C; --navy-2: #141B45; --navy-3: #1E2759; --gold: #C9A84C; --gold-d: #A98A33;
  --bg: #EEF1F7; --card: #fff; --line: #DDE2EE; --text: #1B2038; --muted: #6A728F;
  --green: #1E9E57; --red: #D6383F; --yellow: #E0A800; --orange: #F07F1A;
  --radius: 12px; --shadow: 0 1px 2px rgba(10,15,44,.06), 0 4px 14px rgba(10,15,44,.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; background: var(--bg); color: var(--text); }
h1, h2, h3 { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
.pos { color: var(--green); } .neg { color: var(--red); } .warn { color: var(--yellow); } .muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }

/* layout */
.shell { display: flex; min-height: 100vh; }
.side { width: 240px; background: var(--navy); color: #fff; display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh; flex: none; }
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 8px 18px; border-bottom: 1px solid rgba(255,255,255,.1); margin-bottom: 12px; }
.brand .logo { width: 36px; height: 36px; border-radius: 9px; background: var(--gold); color: var(--navy); display: grid; place-items: center; font-weight: 800; }
.brand b { display: block; line-height: 1.1; } .brand small { color: var(--gold); letter-spacing: .08em; font-size: 11px; text-transform: uppercase; }
.nav { display: flex; flex-direction: column; gap: 2px; overflow: auto; }
.nav a { color: #C8CEE8; text-decoration: none; padding: 10px 12px; border-radius: 8px; display: flex; gap: 10px; align-items: center; cursor: pointer; }
.nav a:hover { background: var(--navy-2); color: #fff; }
.nav a.active { background: var(--navy-3); color: #fff; box-shadow: inset 3px 0 0 var(--gold); }
.side .who { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid rgba(255,255,255,.1); font-size: 13px; }
.side .who small { color: var(--gold); display: block; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top { background: var(--navy); color: #fff; padding: 12px 24px; display: flex; align-items: center; gap: 14px; position: sticky; top: 0; z-index: 5; }
.top h1 { font-size: 19px; flex: 1; font-weight: 650; }
.top .burger { display: none; }
.content { padding: 22px 24px 40px; max-width: 1400px; width: 100%; margin: 0 auto; }

/* controls */
.btn { background: var(--navy); color: #fff; border: 0; padding: 9px 16px; border-radius: 8px; cursor: pointer; font-weight: 600; display: inline-flex; gap: 6px; align-items: center; text-decoration: none; }
.btn:hover { background: var(--navy-3); }
.btn.gold { background: var(--gold); color: var(--navy); } .btn.gold:hover { background: #D8B95C; }
.btn.ghost { background: transparent; color: var(--navy); border: 1px solid var(--line); } .btn.ghost:hover { background: #F2F4FA; }
.top .btn.ghost { color: #fff; border-color: rgba(255,255,255,.3); } .top .btn.ghost:hover { background: var(--navy-2); }
.btn.danger { background: var(--red); } .btn.sm { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
input, select, textarea { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 9px 11px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold); outline-offset: -1px; border-color: var(--gold); }
label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.field { margin-bottom: 12px; } .field .hint { font-size: 12px; color: var(--muted); margin-top: 3px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 14px; }
.toolbar .field { margin: 0; min-width: 150px; flex: 1 1 150px; max-width: 220px; } .toolbar .spacer { flex: 1 1 auto; }

/* cards */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; border: 1px solid var(--line); }
.card h2 { font-size: 16px; margin-bottom: 12px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: #fff; border-radius: var(--radius); border: 1px solid var(--line); border-top: 3px solid var(--gold); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .l { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.stat .v { font-size: 22px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.row2 { display: grid; grid-template-columns: minmax(300px, 420px) 1fr; gap: 18px; margin-bottom: 18px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
.chartbox { position: relative; height: 280px; }

/* KPI hero */
.hero { background: radial-gradient(120% 120% at 20% 0%, var(--navy-3), var(--navy)); color: #fff; border-radius: 16px; padding: 22px; text-align: center; box-shadow: var(--shadow); border: 1px solid var(--gold); }
.hero h2 { color: var(--gold); font-size: 13px; text-transform: uppercase; letter-spacing: .1em; margin-bottom: 8px; }
.gauge { position: relative; width: min(100%, 320px); margin: 0 auto; aspect-ratio: 1; }
.gauge svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.gauge .track { stroke: rgba(255,255,255,.12); } .gauge .bar { transition: stroke-dashoffset .8s ease, stroke .4s; }
.gauge .mid { position: absolute; inset: 0; display: grid; place-content: center; }
.gauge .pct { font-size: 56px; font-weight: 800; line-height: 1; }
.gauge .cap { font-size: 12px; color: #B6BDDD; margin-top: 4px; }
.hero .amounts { font-size: 18px; font-weight: 600; margin-top: 10px; font-variant-numeric: tabular-nums; }
.hero .badge { display: inline-block; margin-top: 8px; padding: 3px 12px; border-radius: 99px; font-size: 12px; font-weight: 700; color: #fff; }
.lv-red { --c: #FF4D55; } .lv-yellow { --c: #FFD23F; } .lv-orange { --c: #FF8A1F; } .lv-green { --c: #3DD27A; } .lv-deepgreen { --c: #00E05A; }
.lv-deepgreen .bar { filter: drop-shadow(0 0 7px #00E05A); }
.gauge .bar { stroke: var(--c); } .gauge .pct { color: var(--c); } .hero .badge { background: var(--c); color: #0A0F2C; }

/* tables */
.tablewrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th { background: #F4F6FB; text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 10px 12px; white-space: nowrap; border-bottom: 1px solid var(--line); }
th.num { text-align: right; }
td { padding: 9px 12px; border-bottom: 1px solid #EEF0F6; vertical-align: top; }
tbody tr:hover { background: #FAFBFE; }
tfoot td { background: #FBF6E6; font-weight: 700; border-top: 2px solid var(--gold); }
.tag { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; }
.tag.ok { background: #DDF5E7; color: #137A41; } .tag.wait { background: #FFF1CC; color: #8A6500; } .tag.off { background: #E9EBF3; color: #5B6280; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.empty { padding: 30px; text-align: center; color: var(--muted); }
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; color: var(--muted); font-size: 13px; }

/* modal & toast */
.overlay { position: fixed; inset: 0; background: rgba(10,15,44,.55); display: grid; place-items: center; z-index: 50; padding: 14px; }
.modal { background: #fff; border-radius: 14px; width: min(560px, 100%); max-height: 94vh; overflow: auto; padding: 22px; box-shadow: 0 20px 60px rgba(0,0,0,.35); border-top: 4px solid var(--gold); }
.modal h2 { margin-bottom: 14px; } .modal .foot { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; }
.err { background: #FDE8E9; color: #9C1C22; padding: 8px 12px; border-radius: 8px; margin-bottom: 10px; font-size: 14px; }
.note { background: #FFF8E1; border: 1px solid #F1DFA0; color: #6B5300; padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 14px; }
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--navy); color: #fff; padding: 10px 16px; border-radius: 8px; border-left: 4px solid var(--gold); box-shadow: var(--shadow); max-width: 340px; }
.toast.bad { border-left-color: var(--red); }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(100% 100% at 50% 0%, var(--navy-3), var(--navy)); padding: 16px; }
.login .box { background: #fff; width: min(400px, 100%); border-radius: 16px; padding: 28px; border-top: 4px solid var(--gold); box-shadow: 0 20px 60px rgba(0,0,0,.4); }
.login h1 { font-size: 22px; margin-bottom: 4px; } .login p { color: var(--muted); margin: 0 0 18px; }
.login .btn { width: 100%; justify-content: center; padding: 11px; }

.progress { height: 10px; background: #E7EAF4; border-radius: 99px; overflow: hidden; } .progress i { display: block; height: 100%; background: var(--gold); }
.mcard { display: none; }

@media (max-width: 1000px) { .row2, .row3 { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .side { position: fixed; left: 0; top: 0; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; }
  .top .burger { display: inline-flex; }
  .content { padding: 14px 12px 40px; } .top { padding: 10px 12px; }
  .grid2 { grid-template-columns: 1fr; } .cards { grid-template-columns: 1fr 1fr; }
  .stat .v { font-size: 18px; } .gauge .pct { font-size: 46px; }
  .toolbar .field { max-width: none; flex: 1 1 140px; }
}
@media (max-width: 560px) { .cards { grid-template-columns: 1fr 1fr; gap: 10px; } .stat .v { font-size: 16px; } }
@media print { .side, .top, .toolbar, .actions { display: none; } }
