:root {
  --bg:#F4F5F7; --surface:#FFFFFF; --surface-2:#F8F9FB; --surface-3:#EFF1F5;
  --border:#E5E8EE; --border-2:#ECEFF3;
  --text:#0B1220; --text-2:#4C5563; --text-3:#8A93A1; --text-4:#B7BEC9;
  --brand:#1F4866; --brand-2:#2A6FA0; --brand-soft:#E6EEF5;
  --pv:#16A34A; --pv-soft:#DCFCE7;
  --grid:#475569; --grid-soft:#E2E8F0;
  --charge:#D97706; --charge-soft:#FEF3C7;
  --export:#65A30D; --export-soft:#ECFCCB;
  --danger:#DC2626; --danger-soft:#FEE2E2;
  --warn:#CA8A04; --info:#2563EB;
  --c1:#1F4866; --c2:#2A6FA0; --c3:#4F8FBF; --c4:#16A34A; --c5:#65A30D;
  --c6:#D97706; --c7:#B45309; --c8:#475569; --c9:#64748B; --c10:#94A3B8;
  --c11:#A16207; --c12:#7C3AED;
  --r-sm:6px; --r-md:10px; --r-lg:14px; --r-xl:18px;
  --shadow-sm:0 1px 2px rgba(15,23,42,.04),0 1px 1px rgba(15,23,42,.03);
  --shadow-md:0 4px 14px rgba(15,23,42,.06),0 1px 2px rgba(15,23,42,.04);
}
[data-theme="dark"] {
  --bg:#0A0F18; --surface:#121A28; --surface-2:#0E1622; --surface-3:#1A2435;
  --border:#1E2A3F; --border-2:#182335;
  --text:#F1F5F9; --text-2:#A6B0BF; --text-3:#6B7585; --text-4:#4A5363;
  --brand:#5BA3D8; --brand-2:#4A90C2; --brand-soft:#15263A;
  --pv:#34D399; --pv-soft:#062b1d;
  --grid:#94A3B8; --grid-soft:#1B2331;
  --charge:#F59E0B; --charge-soft:#2A1d05;
  --export:#A3E635; --export-soft:#14210A;
  --danger:#F87171; --danger-soft:#2A1212;
  --c1:#5BA3D8; --c2:#4A90C2; --c3:#7AB7DE; --c4:#34D399; --c5:#A3E635;
  --c6:#F59E0B; --c7:#FB923C; --c8:#94A3B8; --c9:#CBD5E1; --c10:#64748B;
  --c11:#FBBF24; --c12:#A78BFA;
  --shadow-sm:0 1px 2px rgba(0,0,0,.4);
  --shadow-md:0 4px 14px rgba(0,0,0,.35);
}
*,*::before,*::after{box-sizing:border-box;}
html,body{margin:0;padding:0;}
body{
  background:var(--bg); color:var(--text);
  font:14px/1.45 'Geist',-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;
  font-feature-settings:"ss01","cv11";
  -webkit-font-smoothing:antialiased; text-rendering:optimizeLegibility;
  min-height:100vh; overflow-x:hidden;
}
.mono{font-family:'Geist Mono',ui-monospace,monospace; font-variant-numeric:tabular-nums;}
.num{font-variant-numeric:tabular-nums; font-feature-settings:"tnum";}

.app{display:grid; grid-template-columns:232px 1fr; min-height:100vh;}

.sidebar{
  background:var(--surface); border-right:1px solid var(--border);
  padding:20px 14px 16px; display:flex; flex-direction:column;
  position:sticky; top:0; height:100vh;
}
.brand{display:flex; align-items:center; gap:10px; padding:6px 8px 18px; font-weight:700; font-size:18px;}
.brand .logo{
  width:32px; height:32px; border-radius:8px;
  background:linear-gradient(135deg,var(--brand),var(--brand-2));
  color:#fff; display:flex; align-items:center; justify-content:center; font-weight:800;
}
.nav-group-label{
  font-size:11px; letter-spacing:.08em; text-transform:uppercase;
  color:var(--text-3); padding:14px 10px 6px; font-weight:500;
}
.nav-item{
  display:flex; align-items:center; gap:10px;
  padding:8px 10px; border-radius:var(--r-md);
  color:var(--text-2); cursor:pointer;
  font-size:13.5px; font-weight:500;
  transition:background .15s,color .15s;
  user-select:none;
}
.nav-item:hover{background:var(--surface-3); color:var(--text);}
.nav-item.active{background:var(--brand-soft); color:var(--brand); font-weight:600;}
.nav-item .ico{width:18px; height:18px; flex:none; opacity:.9;}
.nav-item .badge{
  margin-left:auto; background:var(--danger); color:#fff;
  font-size:10px; font-weight:700; padding:1px 6px; border-radius:999px; line-height:1.4;
}
.sidebar-foot{
  margin-top:auto; padding-top:12px; border-top:1px solid var(--border-2);
  display:flex; align-items:center; gap:10px; font-size:12.5px; color:var(--text-2);
}
.avatar{
  width:30px; height:30px; border-radius:50%;
  background:linear-gradient(135deg,var(--brand) 0%,var(--brand-2) 100%);
  color:#fff; display:flex; align-items:center; justify-content:center;
  font-weight:700; font-size:12px;
}

.main{display:flex; flex-direction:column; min-width:0;}
.topbar{
  height:60px; background:var(--surface); border-bottom:1px solid var(--border);
  display:flex; align-items:center; padding:0 28px; gap:16px;
  position:sticky; top:0; z-index:10;
}
.topbar h1{margin:0; font-size:16px; font-weight:600; letter-spacing:-0.01em;}
.topbar .crumb{color:var(--text-3); font-size:12px; font-weight:500;}
.topbar-right{margin-left:auto; display:flex; align-items:center; gap:10px;}

.chip{
  display:inline-flex; align-items:center; gap:6px;
  padding:5px 10px; border-radius:999px;
  background:var(--surface-3); color:var(--text-2);
  font-size:12px; font-weight:500; border:1px solid var(--border-2);
}
.chip .dot{
  width:7px; height:7px; border-radius:50%; background:var(--pv);
  box-shadow:0 0 0 0 var(--pv); animation:pulse 2s ease-out infinite;
}
.chip.off .dot{background:var(--danger); animation:none;}
@keyframes pulse{
  0%{box-shadow:0 0 0 0 color-mix(in srgb,var(--pv) 60%,transparent);}
  100%{box-shadow:0 0 0 8px transparent;}
}
.icon-btn{
  width:36px; height:36px; display:inline-flex; align-items:center; justify-content:center;
  border-radius:var(--r-md); border:1px solid var(--border);
  background:var(--surface); color:var(--text-2); cursor:pointer; position:relative;
}
.icon-btn:hover{color:var(--text); border-color:var(--text-3);}
.icon-btn .pip{
  position:absolute; top:8px; right:9px; width:7px; height:7px;
  border-radius:50%; background:var(--danger); border:2px solid var(--surface);
}

.seg{
  display:inline-flex; background:var(--surface-3); padding:3px;
  border-radius:var(--r-md); border:1px solid var(--border-2);
}
.seg button{
  border:0; background:transparent; padding:5px 12px;
  font-size:12.5px; font-weight:500; color:var(--text-2);
  border-radius:7px; cursor:pointer; font-family:inherit;
}
.seg button.on{background:var(--surface); color:var(--text); box-shadow:var(--shadow-sm);}

.content{padding:24px 28px 80px; display:flex; flex-direction:column; gap:18px;}

.card{
  background:var(--surface); border:1px solid var(--border);
  border-radius:var(--r-lg); overflow:hidden;
}
.card-h{
  display:flex; align-items:center; padding:14px 18px; gap:10px;
  border-bottom:1px solid var(--border-2);
}
.card-h h3{margin:0; font-size:13px; font-weight:600; color:var(--text); letter-spacing:-0.005em;}
.card-h .sub{color:var(--text-3); font-size:12px; margin-left:6px; font-weight:400;}
.card-h .right{margin-left:auto; display:flex; gap:8px; align-items:center; color:var(--text-3); font-size:12px;}
.card-b{padding:18px;}
.card-b.tight{padding:14px;}
.card-b.flush{padding:0;}

.kpi-row{display:grid; grid-template-columns:repeat(4,1fr); gap:14px;}
.kpi{
  background:var(--surface); border:1px solid var(--border); border-radius:var(--r-lg);
  padding:16px 18px; display:flex; flex-direction:column; gap:10px;
  min-height:130px; position:relative; overflow:hidden;
}
.kpi .row1{display:flex; align-items:center; gap:8px;}
.kpi .label{font-size:12.5px; color:var(--text-2); font-weight:500;}
.kpi .ico-pill{width:26px; height:26px; border-radius:8px; display:flex; align-items:center; justify-content:center;}
.kpi .value{font-size:28px; font-weight:600; letter-spacing:-0.02em; line-height:1.1; font-variant-numeric:tabular-nums;}
.kpi .value .u{font-size:14px; color:var(--text-3); font-weight:500; margin-left:4px;}
.kpi .foot{font-size:11.5px; color:var(--text-3); display:flex; align-items:center; gap:6px;}

table.t{width:100%; border-collapse:collapse; font-size:13px;}
table.t th{
  text-align:left; font-weight:500; color:var(--text-3);
  font-size:11.5px; padding:10px 18px; text-transform:uppercase; letter-spacing:.04em;
  border-bottom:1px solid var(--border-2); background:var(--surface-2);
}
table.t td{padding:10px 18px; border-bottom:1px solid var(--border-2); color:var(--text);}
table.t tr:last-child td{border-bottom:0;}
table.t tbody tr:hover{background:var(--surface-2);}
table.t .muted{color:var(--text-3);}

.badge{
  display:inline-flex; align-items:center; gap:5px;
  padding:2px 8px; border-radius:999px;
  font-size:11.5px; font-weight:500;
  background:var(--surface-3); color:var(--text-2);
  border:1px solid var(--border-2);
}
.badge.ok{background:var(--pv-soft); color:var(--pv); border-color:transparent;}
.badge.warn{background:var(--charge-soft); color:var(--charge); border-color:transparent;}
.badge.bad{background:var(--danger-soft); color:var(--danger); border-color:transparent;}
.badge.info{background:var(--brand-soft); color:var(--brand); border-color:transparent;}
.badge .d{width:6px; height:6px; border-radius:50%; background:currentColor;}

.legend{display:flex; flex-wrap:wrap; gap:6px 14px; font-size:12px; color:var(--text-2);}
.legend .it{display:inline-flex; align-items:center; gap:6px;}
.legend .sw{width:9px; height:9px; border-radius:2px;}

.row{display:flex; gap:14px;}
.col{display:flex; flex-direction:column; gap:14px;}
.grow{flex:1; min-width:0;}
.muted{color:var(--text-3);}
.h-stack{display:flex; align-items:center; gap:8px;}
.v-stack{display:flex; flex-direction:column; gap:4px;}
.right{margin-left:auto;}
.sep{height:1px; background:var(--border-2); margin:4px 0;}

.grid-2{display:grid; grid-template-columns:1fr 1fr; gap:14px;}
.grid-3{display:grid; grid-template-columns:repeat(3,1fr); gap:14px;}
.grid-4{display:grid; grid-template-columns:repeat(4,1fr); gap:14px;}

.alert-item{
  display:grid; grid-template-columns:auto 1fr auto; gap:14px;
  padding:12px 18px; border-bottom:1px solid var(--border-2); align-items:flex-start;
}
.alert-item:last-child{border-bottom:0;}
.alert-dot{width:8px; height:8px; border-radius:50%; margin-top:7px;}

.page{animation:fadeUp .25s ease both;}
@keyframes fadeUp{from{opacity:0; transform:translateY(4px);} to{opacity:1; transform:translateY(0);}}

.setting-row{
  display:grid; grid-template-columns:1fr auto;
  align-items:center; padding:14px 18px;
  border-bottom:1px solid var(--border-2);
}
.setting-row:last-child{border-bottom:0;}
.setting-row .t{font-size:13.5px; font-weight:500;}
.setting-row .d{font-size:12px; color:var(--text-3); margin-top:2px;}

.switch{
  width:36px; height:20px; background:var(--surface-3);
  border:1px solid var(--border); border-radius:999px;
  position:relative; cursor:pointer;
}
.switch::after{
  content:''; position:absolute; top:1px; left:1px;
  width:16px; height:16px; background:var(--surface);
  border-radius:50%; box-shadow:0 1px 2px rgba(0,0,0,.15);
  transition:left .15s,background .15s;
}
.switch.on{background:var(--brand); border-color:var(--brand);}
.switch.on::after{left:17px; background:#fff;}

.ph{
  background:var(--surface-3); border-radius:6px;
  color:var(--text-3); display:flex; align-items:center; justify-content:center;
  font-size:12px;
}

input[type="text"],input[type="number"],input[type="datetime-local"],input[type="email"],input[type="password"],select,textarea{
  font:inherit; padding:7px 10px;
  background:var(--surface); color:var(--text);
  border:1px solid var(--border); border-radius:var(--r-sm);
  outline:none; transition:border-color .15s;
}
input:focus,select:focus,textarea:focus{border-color:var(--brand);}

.btn{
  display:inline-flex; align-items:center; gap:6px;
  padding:7px 14px; border-radius:var(--r-md);
  background:var(--brand); color:#fff;
  border:1px solid var(--brand); cursor:pointer;
  font:inherit; font-weight:500; font-size:13px;
}
.btn:hover{background:var(--brand-2); border-color:var(--brand-2);}
.btn.ghost{background:transparent; color:var(--text-2); border-color:var(--border);}
.btn.ghost:hover{background:var(--surface-3); color:var(--text);}
.btn.danger{background:var(--danger); border-color:var(--danger);}
.btn.danger:hover{background:#B91C1C; border-color:#B91C1C;}

.loading{
  display:inline-block; width:12px; height:12px;
  border:2px solid var(--text-3); border-top-color:transparent;
  border-radius:50%; animation:spin .6s linear infinite;
}
@keyframes spin{to{transform:rotate(360deg);}}

.error-box{
  padding:12px 16px; border-radius:var(--r-md);
  background:var(--danger-soft); color:var(--danger);
  border:1px solid var(--danger); font-size:13px;
}

.empty-state{
  padding:40px 20px; text-align:center; color:var(--text-3); font-size:13px;
}

/* simple chart styles */
svg.chart{display:block; width:100%; height:auto;}
.axis text{fill:var(--text-3); font-size:10.5px;}
.axis line,.axis path{stroke:var(--border);}
.grid-line{stroke:var(--border-2); stroke-dasharray:2 3;}
