:root { --bg:#edf2f7; --card:#fff; --ink:#102a43; --muted:#486581; --line:#d9e2ec; --accent:#0b4f6c; --accent2:#243b53; --soft:#f8fbfd; --ok:#1f7a4f; --okbg:#dcfce7; --minor:#854d0e; --minorbg:#fef9c3; --major:#c2410c; --majorbg:#ffedd5; --critical:#b42318; --criticalbg:#fee2e2; --inactivebg:#4b5563; --inactivefg:#d1d5db; --balbg:#1d4ed8; --balfg:#fde047; --protbg:#b91c1c; --protfg:#fde047; }
* { box-sizing:border-box; }
body { margin:0; font-family:Arial,sans-serif; background:var(--bg); color:var(--ink); }
a { color:var(--accent); }
.shell { max-width:1380px; margin:0 auto; padding:24px; }
.panel { background:var(--card); border-radius:14px; box-shadow:0 10px 28px rgba(16,42,67,.08); padding:20px; margin-bottom:18px; }
.topbar,.stackbar,.statusbar,.actions,.toolbar,.file-toolbar,.row-actions,.device-actions,.state-pills,.chart-legend { display:flex; gap:12px; flex-wrap:wrap; }
.topbar,.stackbar { justify-content:space-between; align-items:flex-start; }
.stackbar,.statusbar,.chart-legend { align-items:center; }
h1,h2,h3 { margin:0; }
p { margin:8px 0 0 0; color:var(--muted); }
.button,button { appearance:none; border:none; border-radius:10px; padding:11px 14px; cursor:pointer; background:var(--accent); color:#fff; font-size:14px; font-weight:bold; text-decoration:none; display:inline-flex; align-items:center; }
.button.secondary,button.secondary { background:var(--accent2); }
button:disabled { opacity:.55; cursor:wait; }
.badge,.conn-pill,.alert-pill,.mini-pill { display:inline-flex; align-items:center; justify-content:center; gap:8px; border-radius:999px; padding:7px 12px; font-size:12px; font-weight:bold; }
.badge { background:#f0f4f8; color:var(--muted); font-size:13px; }
.dot { width:9px; height:9px; border-radius:50%; background:#94a3b8; }
.dot.live { background:#22c55e; }
.dot.offline { background:#ef4444; }
.summary-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(170px,1fr)); gap:14px; margin-top:18px; }
.summary-card { border:1px solid var(--line); border-radius:12px; padding:14px; background:linear-gradient(180deg,#fff,var(--soft)); min-height:82px; }
.summary-card .label,.section-title,.cell-table th { color:var(--muted); font-size:12px; text-transform:uppercase; letter-spacing:.04em; }
.summary-card .label { display:block; margin-bottom:8px; }
.summary-card .value { display:block; font-size:28px; font-weight:bold; line-height:1.1; }
.toolbar input,.toolbar select,.file-toolbar input,.file-toolbar select,.actions select { padding:10px 12px; border:1px solid #bcccdc; border-radius:10px; font-size:14px; background:#fff; color:var(--ink); }
.device-list { display:grid; gap:12px; margin-top:16px; }
.device-row { display:grid; grid-template-columns:minmax(180px,1.4fr) minmax(120px,.8fr) minmax(140px,.8fr) minmax(170px,1fr) minmax(220px,1fr) auto; gap:12px; align-items:center; border:1px solid var(--line); border-radius:12px; padding:14px; background:linear-gradient(180deg,#fff,var(--soft)); }
.device-name { font-weight:bold; font-size:18px; }
.device-meta,.subtext { color:var(--muted); }
.device-meta { font-size:12px; margin-top:4px; }
.subtext { font-size:13px; }
.conn-pill.online,.alert-pill.ok { background:var(--okbg); color:var(--ok); }
.conn-pill.offline,.alert-pill.critical { background:var(--criticalbg); color:var(--critical); }
.alert-pill.minor { background:var(--minorbg); color:var(--minor); }
.alert-pill.major { background:var(--majorbg); color:var(--major); }
.kv { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:10px 14px; margin-bottom:14px; }
.metric { border:1px solid var(--line); border-radius:10px; padding:10px; background:#fff; min-height:76px; }
.metric .label { display:block; color:var(--muted); font-size:12px; margin-bottom:4px; }
.metric .value { font-size:21px; font-weight:bold; }
.meta { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px 14px; margin:12px 0 14px 0; font-size:13px; }
.meta div { color:var(--muted); }
.meta strong { color:var(--ink); }
.messages { display:grid; gap:10px; margin-bottom:14px; }
.message { border-left:4px solid var(--accent); background:#d9eff7; border-radius:8px; padding:10px 12px; }
.message.warning { border-left-color:#d97706; background:#fff7ed; }
.message.alert { border-left-color:#dc2626; background:#fef2f2; }
.file-table-wrap { width:100%; overflow-x:auto; overflow-y:hidden; }
.file-table,.cell-table { width:100%; }
.file-table { border-collapse:collapse; font-size:14px; min-width:860px; }
.file-table th,.file-table td { padding:9px 10px; border-bottom:1px solid var(--line); text-align:left; vertical-align:top; }
.cell-table { border-collapse:separate; border-spacing:0; border:1px solid var(--line); border-radius:12px; overflow:hidden; }
.cell-table th,.cell-table td { padding:9px 10px; border-bottom:1px solid var(--line); background:#fff; }
.cell-table tr:last-child td { border-bottom:none; }
.mono { font-family:Consolas,'Courier New',monospace; }
.mini-pill { background:var(--inactivebg); color:var(--inactivefg); min-width:48px; }
.mini-pill.bal-on { background:var(--balbg); color:var(--balfg); }
.mini-pill.prot-on { background:var(--protbg); color:var(--protfg); }
.history-layout { display:grid; grid-template-columns:minmax(420px,1.1fr) minmax(420px,1fr); gap:18px; align-items:start; }
.history-panel { border:1px solid var(--line); border-radius:12px; background:#fff; padding:16px; min-width:0; }
.history-panel pre { margin:0; overflow:auto; background:#0f172a; color:#e2e8f0; border-radius:10px; padding:14px; font-size:12px; line-height:1.45; }
.history-resizable { height:clamp(220px,33vh,520px); min-height:220px; resize:vertical; overflow:hidden; }
.history-panel-body { height:calc(100% - 58px); min-height:120px; }
.history-scroll { height:100%; overflow:auto; }
.history-table-wrap { min-width:860px; }
.history-table { min-width:860px; }
.history-table td:nth-child(1),.history-table th:nth-child(1),.history-table td:nth-child(2),.history-table th:nth-child(2),.history-table td:nth-child(3),.history-table th:nth-child(3),.history-table td:nth-child(4),.history-table th:nth-child(4),.history-table td:nth-child(5),.history-table th:nth-child(5) { white-space:nowrap; }
.history-table td:nth-child(1),.history-table th:nth-child(1) { width:180px; }
.history-table td:nth-child(2),.history-table th:nth-child(2) { width:130px; }
.history-table td:nth-child(3),.history-table th:nth-child(3) { width:190px; }
.history-table td:nth-child(4),.history-table th:nth-child(4) { width:90px; }
.history-table td:nth-child(5),.history-table th:nth-child(5) { width:auto; }
.chart-wrap { border:1px solid var(--line); border-radius:12px; background:#fff; padding:12px; }
.chart-wrap.chart-resizable { height:360px; min-height:360px; max-height:1440px; resize:vertical; overflow:auto; display:flex; flex-direction:column; gap:10px; box-sizing:border-box; }
.chart-svg { width:100%; height:360px; display:block; background:linear-gradient(180deg,#fff,#f8fbfd); border-radius:10px; }
.chart-wrap.chart-resizable .chart-svg { flex:1 1 auto; height:auto; min-height:230px; }
.chart-title-row,.chart-source-row { display:flex; align-items:center; gap:12px; flex-wrap:wrap; }
.chart-source-row { justify-content:space-between; margin-bottom:10px; }
.info-popup { position:relative; display:inline-block; }
.info-popup summary { list-style:none; width:20px; height:20px; border:1px solid #829ab1; border-radius:50%; color:var(--accent); cursor:pointer; display:grid; place-items:center; font-size:13px; font-weight:bold; }
.info-popup summary::-webkit-details-marker { display:none; }
.info-popup-content { position:absolute; z-index:5; top:26px; left:0; width:min(360px,75vw); padding:10px 12px; border:1px solid var(--line); border-radius:8px; background:#fff; box-shadow:0 8px 22px rgba(16,42,67,.16); color:var(--muted); font-size:13px; font-weight:normal; line-height:1.4; }
.battery-chart-legend { display:grid; gap:6px; }
.battery-chart-legend-row { display:flex; align-items:center; gap:8px 18px; flex-wrap:wrap; min-width:0; }
.battery-chart-legend-title { width:68px; color:var(--ink); font-size:12px; font-weight:bold; }
.battery-chart-legend .legend-pill { display:grid; grid-template-columns:18px max-content minmax(10ch,10ch); gap:8px; min-width:0; padding-left:10px; border-left:1px solid var(--line); }
.legend-label { white-space:nowrap; }
.legend-value { min-width:10ch; text-align:right; white-space:nowrap; font-family:Consolas,'Courier New',monospace; font-variant-numeric:tabular-nums; }
.legend-pill { display:inline-flex; align-items:center; gap:8px; font-size:12px; color:var(--muted); }
.legend-line { width:18px; height:3px; border-radius:999px; display:inline-block; }
.legend-b1-voltage { background:#0b4f6c; }
.legend-b1-current { background:#c2410c; }
.legend-b1-soc { background:#2f855a; }
.legend-b2-voltage { background:#3b82f6; }
.legend-b2-current { background:#f97316; }
.legend-b2-soc { background:#10b981; }
.empty-state { color:var(--muted); padding:10px 0; }
.chart-controls { display:flex; gap:12px; flex-wrap:wrap; align-items:center; }
.chart-controls select { min-width:140px; max-width:100%; }
.chart-controls label { display:inline-flex; gap:6px; align-items:center; color:var(--muted); font-size:13px; }
.chart-controls input[type="date"] { min-width:150px; }
.chart-toggles { display:flex; gap:14px; flex-wrap:wrap; align-items:center; font-size:13px; color:var(--muted); }
.chart-toggles label { display:inline-flex; gap:6px; align-items:center; }
.experimental-soc-controls { display:flex; flex:1 1 100%; gap:10px 14px; flex-wrap:wrap; align-items:center; padding:10px; border:1px solid #c4b5fd; border-radius:10px; background:#faf5ff; }
.experimental-soc-controls[hidden] { display:none; }
.experimental-soc-controls-title { color:#5b21b6; font-size:13px; font-weight:bold; }
.experimental-soc-controls input[type="number"] { width:5.5em; }
.experimental-soc-controls .subtext { flex:1 1 100%; }
.device-subsection { margin-top:18px; padding-top:18px; border-top:1px solid var(--line); }
.device-subsection:first-of-type { margin-top:16px; }
.prominent-section-title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: .01em;
  text-transform: none;
  color: var(--text);
  padding: 8px 12px;
  margin: 2px 0 12px;
  background: #eef6ff;
  border-left: 4px solid #2563eb;
  border-radius: 8px;
}
.hidden { display:none !important; }
code.inline { background:#eef2f7; padding:2px 6px; border-radius:6px; }
body.login-page { min-height:100vh; display:flex; align-items:center; justify-content:center; background:linear-gradient(135deg,#0b1f33,#173b5f); color:#122230; }
.login-card { width:min(420px,92vw); background:#fff; padding:28px; border-radius:14px; box-shadow:0 18px 50px rgba(0,0,0,0.28); }
.login-card h1 { margin:0 0 8px 0; font-size:28px; color:#102a43; }
.login-card p { color:#486581; margin:0 0 18px 0; }
.login-card label { display:block; font-size:14px; font-weight:bold; margin:12px 0 6px 0; color:#243b53; }
.login-card input { width:100%; box-sizing:border-box; padding:10px 12px; border:1px solid #bcccdc; border-radius:8px; font-size:15px; }
.login-card button { margin-top:18px; width:100%; padding:12px; border:none; border-radius:8px; background:#0b4f6c; color:#fff; font-size:16px; font-weight:bold; cursor:pointer; }
.login-error { margin-bottom:14px; padding:10px 12px; background:#fde8e8; color:#9b1c1c; border-radius:8px; }
.login-hint { margin-top:12px; font-size:13px; color:#627d98; }
@media (max-width:1100px) { .device-row,.history-layout { grid-template-columns:1fr; } .row-actions { justify-content:flex-start; } .kv { grid-template-columns:repeat(2,minmax(0,1fr)); } }
@media (max-width:720px) { .shell { padding:14px; } .meta,.kv { grid-template-columns:1fr; } }
