: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; }
.events-workspace { padding-bottom:14px; }
.events-titlebar { align-items:center; }
.events-controls { margin-top:16px; border-top:1px solid var(--line); padding-top:12px; }
.events-controls > summary { cursor:pointer; color:var(--accent); font-weight:bold; padding:6px 0; }
.events-filter-grid { display:grid; grid-template-columns:repeat(4,minmax(160px,1fr)); gap:10px 12px; margin-top:10px; align-items:end; }
.events-filter-grid label,.events-limit-label { display:grid; gap:5px; color:var(--muted); font-size:12px; font-weight:bold; }
.events-filter-grid input,.events-filter-grid select,.events-limit-label select { padding:9px 10px; border:1px solid #bcccdc; border-radius:8px; background:#fff; color:var(--ink); min-width:0; }
.events-date-presets { display:flex; gap:6px; flex-wrap:wrap; grid-column:span 2; }
.events-date-presets button { padding:9px 10px; }
.events-selection-bar { display:flex; align-items:center; gap:10px; flex-wrap:wrap; margin-top:14px; padding:10px; border-radius:10px; background:var(--soft); border:1px solid var(--line); }
.events-selection-bar #events-hidden-count { color:#92400e; font-weight:bold; }
.events-action-status { min-height:1.4em; margin-top:8px; color:var(--muted); }
.events-action-results { margin-top:8px; padding:8px 10px; border:1px solid var(--line); border-radius:8px; background:#fff; }
.events-action-results summary { cursor:pointer; font-weight:bold; color:var(--accent); }
.events-action-results ul { margin:8px 0 0; padding-left:22px; }
.events-action-results li { margin:4px 0; overflow-wrap:anywhere; }
.events-error { margin-top:10px; padding:9px 11px; border-radius:8px; color:#991b1b; background:#fee2e2; font-weight:bold; }
.events-filter-indicator { display:inline-block; margin-top:5px; padding:5px 9px; border:2px solid #b45309; border-radius:999px; background:#fff7ed; color:#7c2d12; font-size:13px; }
.events-filter-indicator[hidden],.events-overflow-indicator[hidden] { display:none; }
.events-frame { height:340px; min-height:220px; max-height:900px; display:flex; flex-direction:column; overflow:hidden; position:relative; }
#journal-frame { height:500px; }
.events-frame-heading { flex:0 0 auto; align-items:center; margin-bottom:10px; }
.events-frame-heading p { font-size:13px; }
.events-size-button { min-width:42px; justify-content:center; font-size:18px; padding:8px 12px; }
.events-scroll-shell { min-height:100px; flex:1 1 auto; position:relative; overflow:hidden; border:1px solid var(--line); border-radius:10px; background:#fff; }
.events-scroll { width:100%; height:100%; overflow:auto; scroll-behavior:smooth; }
.events-table { min-width:1180px; }
.events-table thead th { position:sticky; top:0; z-index:2; background:#eef2f7; box-shadow:0 1px 0 var(--line); }
.events-table td { max-width:360px; }
.events-table .events-summary { min-width:240px; white-space:normal; }
.events-select-column { width:68px; text-align:center !important; }
.events-select-column input { width:20px; height:20px; cursor:pointer; }
.events-overflow-indicator { position:absolute; z-index:4; left:50%; transform:translateX(-50%); padding:6px 14px; min-height:30px; border:2px solid #64748b; border-radius:999px; background:#fff; color:#334155; box-shadow:0 3px 10px rgba(15,23,42,.25); }
.events-overflow-up { top:6px; }
.events-overflow-down { bottom:6px; }
.events-resize-handle { flex:0 0 12px; margin:7px auto -9px; width:min(180px,40%); cursor:ns-resize; border-top:4px double #64748b; border-bottom:4px double #64748b; border-radius:3px; }
.events-resize-handle:focus { outline:3px solid #2563eb; outline-offset:3px; }
.events-record td { transition:background-color .12s ease,color .12s ease; }
.events-record.is-selected { outline:3px solid #2563eb; outline-offset:-3px; }
.events-record.is-selected td:first-child { box-shadow:inset 6px 0 #2563eb; }
.events-severity { font-weight:800; white-space:nowrap; }
.events-record.event-row td,.events-record.alarm-acknowledged-cleared td { background:#fff; color:var(--ink); }
.events-record.event-row.severity-critical .events-severity,.events-record.alarm-acknowledged-cleared.severity-critical .events-severity { color:#b91c1c; }
.events-record.event-row.severity-error .events-severity,.events-record.alarm-acknowledged-cleared.severity-error .events-severity { color:#c2410c; }
.events-record.event-row.severity-major .events-severity,.events-record.alarm-acknowledged-cleared.severity-major .events-severity { color:#9a3412; }
.events-record.event-row.severity-minor .events-severity,.events-record.alarm-acknowledged-cleared.severity-minor .events-severity { color:#854d0e; }
.events-record.event-row.severity-warning .events-severity,.events-record.alarm-acknowledged-cleared.severity-warning .events-severity { color:#854d0e; }
.events-record.event-row.severity-info .events-severity,.events-record.alarm-acknowledged-cleared.severity-info .events-severity { color:#0369a1; }
.events-record.event-row.severity-routine .events-severity,.events-record.alarm-acknowledged-cleared.severity-routine .events-severity { color:#475569; }
.events-record.event-row.severity-unknown .events-severity,.events-record.alarm-acknowledged-cleared.severity-unknown .events-severity { color:#475569; }
.events-record.alarm-unacknowledged td { background:var(--events-bright-bg,#64748b); color:var(--events-bright-fg,#fff); }
.events-record.alarm-acknowledged-active.severity-critical td { background:#fee2e2; color:#7f1d1d; }
.events-record.alarm-acknowledged-active.severity-error td { background:#ffedd5; color:#7c2d12; }
.events-record.alarm-acknowledged-active.severity-major td { background:#ffedd5; color:#7c2d12; }
.events-record.alarm-acknowledged-active.severity-minor td { background:#fef3c7; color:#713f12; }
.events-record.alarm-acknowledged-active.severity-warning td { background:#fef9c3; color:#713f12; }
.events-record.alarm-acknowledged-active.severity-info td { background:#e0f2fe; color:#075985; }
.events-record.alarm-acknowledged-active.severity-routine td { background:#e2e8f0; color:#334155; }
.events-record.alarm-acknowledged-active.severity-unknown td { background:#e2e8f0; color:#334155; }
.events-dialog { width:min(620px,calc(100vw - 30px)); border:0; border-radius:14px; padding:20px; color:var(--ink); box-shadow:0 24px 70px rgba(15,23,42,.4); }
.events-dialog::backdrop { background:rgba(15,23,42,.55); }
.events-dialog p { margin:10px 0; }
.events-dialog .row-actions { margin-top:16px; }
.events-dialog-options { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px 14px; max-height:45vh; overflow:auto; padding:10px; border:1px solid var(--line); border-radius:8px; }
.events-dialog-options label { display:flex; align-items:center; gap:8px; min-height:36px; }
.events-dialog-options input { width:19px; height:19px; }
.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)); } .events-filter-grid { grid-template-columns:repeat(2,minmax(150px,1fr)); } }
@media (max-width:720px) { .shell { padding:14px; } .meta,.kv,.events-filter-grid { grid-template-columns:1fr; } .events-date-presets { grid-column:auto; } .events-dialog-options { grid-template-columns:1fr; } .events-frame { height:420px; } }
