/* Otus Energy — Ops Console */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --bg-0: #0A0D10;
  --bg-1: #10141A;
  --bg-2: #171C24;
  --bg-3: #1E242E;
  --bg-4: #242C38;

  --line: #252C37;
  --line-strong: #323A47;

  --text-0: #E6E9EE;
  --text-1: #9AA3B0;
  --text-2: #5F6773;
  --text-3: #434A55;

  --ok: #22C55E;
  --ok-dim: #15803D;
  --ok-bg: rgba(34, 197, 94, 0.10);
  --warn: #F5A524;
  --warn-dim: #B45309;
  --warn-bg: rgba(245, 165, 36, 0.10);
  --alarm: #EF4444;
  --alarm-dim: #B91C1C;
  --alarm-bg: rgba(239, 68, 68, 0.10);
  --off: #5F6773;
  --off-bg: rgba(95, 103, 115, 0.12);

  --accent: #E87A3E;           /* Otus rust/orange primary */
  --accent-2: #F4A261;          /* lighter rust */
  --accent-dim: #7A3E1E;
  --accent-bg: rgba(232, 122, 62, 0.10);
  --accent-cyan: #7AD3FF;       /* secondary cool accent for info sparks */
  --accent-cyan-dim: #2B6A86;

  --mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  --sans: 'Inter', -apple-system, system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { background: var(--bg-0); color: var(--text-0); font-family: var(--sans); font-size: 13px; line-height: 1.4; -webkit-font-smoothing: antialiased; }
body { overflow: hidden; height: 100vh; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
a { color: inherit; text-decoration: none; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* ---------- App shell ---------- */
/* grid-template-rows: minmax(0, 1fr) clamps .main to the viewport so .content's
   overflow: auto actually triggers — without this the grid row auto-grows to
   fit content and the whole dashboard overflows the body (which is hidden),
   producing a page that looks tall but cannot be scrolled. */
.app { display: grid; grid-template-columns: 232px 1fr; grid-template-rows: minmax(0, 1fr); height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar { background: var(--bg-1); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.brand { padding: 18px 18px 16px; display: flex; flex-direction: column; align-items: stretch; gap: 10px; border-bottom: 1px solid var(--line); }
.brand-logo { width: 100%; max-width: 200px; height: auto; display: block; }
.brand-sub { font-family: var(--mono); font-size: 10px; color: var(--text-2); letter-spacing: 0.16em; text-transform: uppercase; padding-left: 2px; }

.sidenav { padding: 12px 10px; display: flex; flex-direction: column; gap: 1px; flex: 1; overflow: auto; }
.sidenav .group-label { font-family: var(--mono); font-size: 10px; color: var(--text-3); letter-spacing: 0.12em; text-transform: uppercase; padding: 16px 10px 6px; }
.sidenav .group-label:first-child { padding-top: 6px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 3px; color: var(--text-1); font-size: 12.5px; position: relative; }
.nav-item:hover { background: var(--bg-2); color: var(--text-0); }
.nav-item.active { background: var(--bg-3); color: var(--text-0); }
.nav-item.active::before { content: ''; position: absolute; left: -10px; top: 6px; bottom: 6px; width: 2px; background: var(--accent); border-radius: 0 2px 2px 0; }
.nav-item .ico { width: 14px; height: 14px; opacity: 0.8; }
.nav-item .count { margin-left: auto; font-family: var(--mono); font-size: 10.5px; color: var(--text-2); background: var(--bg-2); border: 1px solid var(--line); padding: 1px 6px; border-radius: 10px; }
.nav-item.active .count { color: var(--text-0); }
.nav-item .count.alarm { color: var(--alarm); border-color: rgba(239, 68, 68, 0.35); background: var(--alarm-bg); }

.sidefoot { border-top: 1px solid var(--line); padding: 10px 14px; }
.site-picker { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 4px; cursor: pointer; }
.site-picker .label { font-size: 11px; color: var(--text-2); font-family: var(--mono); letter-spacing: 0.08em; text-transform: uppercase; }
.site-picker .val { font-size: 12px; color: var(--text-0); font-weight: 600; }
.site-picker .caret { margin-left: auto; opacity: 0.5; }

/* ---------- Main ---------- */
.main { display: flex; flex-direction: column; min-width: 0; }

/* Top bar */
.topbar { height: 48px; display: flex; align-items: center; padding: 0 18px; border-bottom: 1px solid var(--line); background: var(--bg-0); gap: 18px; flex-shrink: 0; }
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-1); }
.crumbs .sep { color: var(--text-3); }
.crumbs .cur { color: var(--text-0); font-weight: 500; }

.topbar .spacer { flex: 1; }
.topbar .chip { display: flex; align-items: center; gap: 6px; padding: 4px 9px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 3px; font-size: 11.5px; color: var(--text-1); font-family: var(--mono); }
.topbar .chip .live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-bg); animation: pulse 1.8s infinite; }
.topbar .chip.customer { color: var(--text-0); }
.topbar .chip .k { color: var(--text-3); }
.topbar .iconbtn { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 3px; color: var(--text-1); }
.topbar .iconbtn:hover { background: var(--bg-2); color: var(--text-0); }
.topbar .user { display: flex; align-items: center; gap: 8px; padding: 3px 8px 3px 3px; border-radius: 3px; }
.topbar .user:hover { background: var(--bg-2); }
.topbar .avatar { width: 22px; height: 22px; border-radius: 50%; background: linear-gradient(135deg, #4B6479, #2E3D4B); display: grid; place-items: center; font-size: 10.5px; font-weight: 600; color: var(--text-0); }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }

/* Content area */
.content { flex: 1; overflow: auto; display: flex; flex-direction: column; }

/* Page title row */
.pagehead { padding: 18px 22px 14px; display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; }
.pagehead h1 { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; color: var(--text-0); display: flex; align-items: center; gap: 10px; }
.pagehead .subtle { font-size: 12px; color: var(--text-2); font-family: var(--mono); }
.pagehead .right { display: flex; align-items: center; gap: 8px; }
.toolbtn { padding: 5px 10px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 3px; font-size: 11.5px; color: var(--text-1); display: flex; align-items: center; gap: 6px; }
.toolbtn:hover { color: var(--text-0); background: var(--bg-3); border-color: var(--line-strong); }
.toolbtn.active { color: var(--accent); border-color: var(--accent-dim); background: var(--accent-bg); }
.seg { display: inline-flex; background: var(--bg-2); border: 1px solid var(--line); border-radius: 3px; padding: 2px; }
.seg button { padding: 3px 9px; font-size: 11px; border-radius: 2px; color: var(--text-2); font-family: var(--mono); letter-spacing: 0.03em; }
.seg button.on { background: var(--bg-4); color: var(--text-0); }
.seg button:hover:not(.on) { color: var(--text-0); }

/* ---------- KPI bar ---------- */
.kpibar { display: grid; grid-template-columns: repeat(5, 1fr); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--bg-1); margin: 0 0 0; }
.kpi { padding: 14px 18px; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; position: relative; overflow: hidden; }
.kpi:last-child { border-right: none; }
.kpi .label { font-size: 10.5px; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.1em; font-family: var(--mono); display: flex; align-items: center; gap: 6px; }
.kpi .val { font-family: var(--mono); font-size: 26px; font-weight: 500; color: var(--text-0); letter-spacing: -0.02em; display: flex; align-items: baseline; gap: 6px; }
.kpi .val .unit { font-size: 12px; color: var(--text-2); font-weight: 400; }
.kpi .val .sub { font-size: 15px; color: var(--text-2); font-weight: 400; }
.kpi .delta { font-family: var(--mono); font-size: 10.5px; color: var(--text-2); display: flex; align-items: center; gap: 4px; }
.kpi .delta.up { color: var(--ok); }
.kpi .delta.down { color: var(--alarm); }
.kpi .spark { position: absolute; right: 10px; bottom: 10px; opacity: 0.6; }
.kpi.warn .val { color: var(--warn); }
.kpi.alarm .val { color: var(--alarm); }
.kpi .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }
.kpi.warn .dot { background: var(--warn); }
.kpi.alarm .dot { background: var(--alarm); }

/* ---------- Filter/Toolbar row ---------- */
.filterbar { display: flex; align-items: center; gap: 10px; padding: 12px 22px; border-bottom: 1px solid var(--line); background: var(--bg-0); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; row-gap: 8px; }
.search { display: flex; align-items: center; gap: 8px; padding: 5px 10px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 3px; min-width: 260px; }
.search input { background: none; border: none; outline: none; color: var(--text-0); font-family: var(--mono); font-size: 12px; width: 100%; }
.search input::placeholder { color: var(--text-3); }
.search .kbd { font-family: var(--mono); font-size: 10px; color: var(--text-3); background: var(--bg-3); border: 1px solid var(--line); padding: 1px 5px; border-radius: 2px; }

.filterchips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip-btn { display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 3px; font-size: 11.5px; color: var(--text-1); font-family: var(--mono); letter-spacing: 0.02em; }
.chip-btn:hover { color: var(--text-0); border-color: var(--line-strong); }
.chip-btn.on { background: var(--bg-3); color: var(--text-0); border-color: var(--line-strong); }
.chip-btn .sdot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.chip-btn .sdot.ok { background: var(--ok); }
.chip-btn .sdot.warn { background: var(--warn); }
.chip-btn .sdot.alarm { background: var(--alarm); }
.chip-btn .sdot.off { background: var(--off); }
.chip-btn .sdot.all { background: var(--accent); }
.chip-btn .n { color: var(--text-2); }
.chip-btn.on .n { color: var(--text-0); }

/* ---------- Site group ---------- */
.site-group { padding: 18px 22px 6px; }
.site-group .site-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px dashed var(--line); }
.site-group .site-head .name { font-size: 13px; font-weight: 600; color: var(--text-0); letter-spacing: 0.01em; }
.site-group .site-head .meta { font-family: var(--mono); font-size: 11px; color: var(--text-2); display: flex; align-items: center; gap: 10px; }
.site-group .site-head .bar { flex: 1; height: 1px; }
.site-group .site-head .rollup { display: flex; align-items: center; gap: 14px; font-family: var(--mono); font-size: 11px; color: var(--text-1); }
.site-group .site-head .rollup .k { color: var(--text-3); margin-right: 4px; }
.site-group .site-head .rollup .v { color: var(--text-0); }
.site-head .caret { color: var(--text-2); transition: transform 0.15s; }
.site-head:hover .name { color: var(--accent); }

.cardgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; margin-bottom: 8px; }

/* ---------- Genset card ---------- */
.gcard { background: var(--bg-1); border: 1px solid var(--line); border-radius: 4px; padding: 0; position: relative; cursor: pointer; transition: border-color 0.12s, background 0.12s; overflow: hidden; }
.gcard:hover { border-color: var(--line-strong); background: var(--bg-2); }
.gcard::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; background: var(--off); }
.gcard.running::before { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.gcard.warn::before { background: var(--warn); }
.gcard.alarm::before { background: var(--alarm); }
.gcard.offline::before { background: var(--off); opacity: 0.6; }

.gcard .row1 { display: flex; align-items: center; gap: 8px; padding: 10px 12px 8px; border-bottom: 1px solid var(--line); }
.gcard .sdot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; position: relative; }
.gcard.running .sdot { background: var(--ok); }
.gcard.running .sdot::after { content: ''; position: absolute; inset: -3px; border-radius: 50%; border: 1px solid var(--ok); opacity: 0.4; animation: ring 2s infinite; }
.gcard.warn .sdot { background: var(--warn); }
.gcard.alarm .sdot { background: var(--alarm); }
.gcard.alarm .sdot::after { content: ''; position: absolute; inset: -3px; border-radius: 50%; border: 1px solid var(--alarm); opacity: 0.6; animation: ring 1s infinite; }
.gcard.offline .sdot { background: var(--off); }

@keyframes ring { 0% { transform: scale(0.8); opacity: 0.7; } 100% { transform: scale(1.6); opacity: 0; } }

.gcard .tag { font-family: var(--mono); font-size: 12.5px; font-weight: 600; color: var(--text-0); letter-spacing: 0.02em; }
.gcard .state-label { margin-left: auto; font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.12em; padding: 2px 6px; border-radius: 2px; }
.gcard.running .state-label { color: var(--ok); background: var(--ok-bg); }
.gcard.warn .state-label { color: var(--warn); background: var(--warn-bg); }
.gcard.alarm .state-label { color: var(--alarm); background: var(--alarm-bg); }
.gcard.offline .state-label { color: var(--off); background: var(--off-bg); }

.gcard .row2 { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px 4px; font-family: var(--mono); font-size: 11px; color: var(--text-2); }
.gcard .row2 .model { color: var(--text-1); }

.gcard .bars { padding: 6px 12px 8px; display: flex; flex-direction: column; gap: 8px; }
.gcard .metric { display: flex; flex-direction: column; gap: 3px; }
.gcard .metric .mhd { display: flex; align-items: center; justify-content: space-between; font-family: var(--mono); font-size: 10.5px; }
.gcard .metric .mhd .lbl { color: var(--text-2); letter-spacing: 0.06em; text-transform: uppercase; }
.gcard .metric .mhd .v { color: var(--text-0); font-weight: 500; }
.gcard .metric .mhd .v .u { color: var(--text-2); margin-left: 2px; }
.gcard .bar { height: 4px; background: var(--bg-3); border-radius: 1px; overflow: hidden; position: relative; }
.gcard .bar .fill { height: 100%; background: var(--accent); transition: width 0.3s; }
.gcard .bar .fill.ok { background: var(--ok); }
.gcard .bar .fill.warn { background: var(--warn); }
.gcard .bar .fill.alarm { background: var(--alarm); }
.gcard .bar .tick { position: absolute; top: -1px; bottom: -1px; width: 1px; background: var(--line-strong); }

.gcard .row-foot { display: flex; align-items: center; gap: 10px; padding: 6px 12px 10px; border-top: 1px solid var(--line); font-family: var(--mono); font-size: 10.5px; color: var(--text-2); margin-top: 2px; }
.gcard .row-foot .hrs { color: var(--text-1); }
.gcard .row-foot .alarms { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.gcard .row-foot .alarms.has { color: var(--alarm); }
.gcard .row-foot .alarms.has .dotmini { background: var(--alarm); }
.gcard .row-foot .dotmini { width: 5px; height: 5px; border-radius: 50%; background: var(--text-3); }

/* sparkline inside card */
.gcard .spark-row { padding: 0 12px 10px; }
.gcard .spark-row svg { width: 100%; height: 22px; display: block; }

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--line); background: var(--bg-1); padding: 8px 22px; display: flex; align-items: center; gap: 16px; font-family: var(--mono); font-size: 10.5px; color: var(--text-3); letter-spacing: 0.05em; flex-shrink: 0; }
.footer .sep { color: var(--text-3); }
.footer .right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.footer .ok { color: var(--ok); }

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-0); }
::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 5px; border: 2px solid var(--bg-0); }
::-webkit-scrollbar-thumb:hover { background: var(--bg-4); }
