/* Hirsch portal design language: Montserrat, zinc neutrals, accent #92D400, rounded-2xl cards. */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700&display=swap');

:root {
  color-scheme: light;
  --accent: #92d400;
  --accent-hover: #7ab800;
  --accent-subtle: rgba(146, 212, 0, 0.1);
  --bg: #fafafa;
  --bg-secondary: #f4f4f5;
  --surface: #ffffff;
  --hover: #f4f4f5;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --text: #18181b;
  --text-2: #52525b;
  --text-3: #71717a;
  --muted: #a1a1aa;
  /* chart roles (dataviz reference palette, light steps) */
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --good: #0ca30c; --warning: #fab219; --serious: #ec835a; --critical: #d03b3b;
  --grid: rgba(24, 24, 27, 0.07);
  --idle: #d4d4d8;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --accent-hover: #a6e600;
  --accent-subtle: rgba(146, 212, 0, 0.15);
  --bg: #09090b;
  --bg-secondary: #18181b;
  --surface: #18181b;
  --hover: #27272a;
  --border: #27272a;
  --border-strong: #3f3f46;
  --text: #ffffff;
  --text-2: #d4d4d8;
  --text-3: #a1a1aa;
  --muted: #71717a;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --grid: rgba(255, 255, 255, 0.06);
  --idle: #3f3f46;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --accent-hover: #a6e600;
    --accent-subtle: rgba(146, 212, 0, 0.15);
    --bg: #09090b; --bg-secondary: #18181b; --surface: #18181b; --hover: #27272a;
    --border: #27272a; --border-strong: #3f3f46;
    --text: #ffffff; --text-2: #d4d4d8; --text-3: #a1a1aa; --muted: #71717a;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --grid: rgba(255, 255, 255, 0.06); --idle: #3f3f46;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Montserrat', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- login ---------- */
.auth {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px;
}
.auth-card {
  width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 32px; box-shadow: 0 1px 2px rgba(0,0,0,.05);
}
.auth-card img { height: 48px; display: block; margin-bottom: 24px; }
.auth-card h1 { font-size: 20px; font-weight: 600; margin: 0 0 4px; }
.auth-card p { color: var(--text-3); margin: 0 0 24px; font-size: 13px; }
.field label { display: block; font-size: 12px; font-weight: 500; color: var(--text-2); margin-bottom: 6px; }
.field input {
  width: 100%; padding: 11px 14px; border-radius: 12px; border: 1px solid var(--border-strong);
  background: var(--bg); color: var(--text); font: inherit; outline: none;
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-subtle); }
.btn-primary {
  width: 100%; margin-top: 16px; padding: 11px 14px; border: 0; border-radius: 12px; cursor: pointer;
  background: var(--accent); color: #0b0b0b; font-weight: 600;
}
.btn-primary:hover { background: var(--accent-hover); }
.error { margin-top: 12px; font-size: 13px; color: var(--critical); }

/* ---------- shell ---------- */
.top {
  position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(16px); border-bottom: 1px solid var(--border);
}
.top-inner {
  max-width: 1440px; margin: 0 auto; padding: 12px 24px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand img { height: 32px; }
.brand h1 { font-size: 15px; font-weight: 600; margin: 0; white-space: nowrap; }
.brand .sub { font-size: 11px; color: var(--text-3); white-space: nowrap; }
.spacer { flex: 1; }
.seg { display: inline-flex; background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 12px; padding: 3px; }
.seg button {
  border: 0; background: transparent; padding: 6px 12px; border-radius: 9px; cursor: pointer; font-size: 12px; font-weight: 500;
  color: var(--text-3);
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.icon-btn {
  border: 1px solid var(--border); background: var(--surface); border-radius: 12px; padding: 7px 10px; cursor: pointer;
  font-size: 12px; color: var(--text-2); text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
.icon-btn:hover { background: var(--hover); }
.pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600; padding: 4px 10px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--surface); white-space: nowrap;
}
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }

main { max-width: 1440px; margin: 0 auto; padding: 20px 24px 64px; }
.section-title {
  font-size: 10px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
  margin: 28px 0 10px;
}
.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); }
.charts { grid-template-columns: repeat(auto-fill, minmax(min(100%, 560px), 1fr)); }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 18px 20px;
  box-shadow: 0 1px 2px rgba(0,0,0,.04); min-width: 0;
}
.kpi { position: relative; overflow: hidden; }
.kpi::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--kpi-bar, transparent); }
.kpi .label { font-size: 11px; font-weight: 500; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-size: 26px; font-weight: 600; margin-top: 6px; }
.kpi .value small { font-size: 14px; font-weight: 500; color: var(--text-3); }
.kpi .hint { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.kpi .flag { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600; margin-top: 8px; }

.chart-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 4px; flex-wrap: wrap; }
.chart-head h3 { font-size: 13px; font-weight: 600; margin: 0; }
.chart-head .desc { font-size: 12px; color: var(--text-3); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11px; color: var(--text-2); margin: 6px 0 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 3px; border-radius: 2px; display: inline-block; }
.legend i.box { height: 10px; border-radius: 3px; }
.chart-box { position: relative; height: 210px; }

.marks-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 11px; color: var(--text-3); margin-top: 8px; }
.marks-legend b { font-weight: 600; color: var(--text-2); }

/* device grid */
.dev-groups { display: grid; gap: 14px; }
.dev-group { display: grid; grid-template-columns: 170px 1fr; gap: 12px; align-items: start; }
.dev-group .gname { font-size: 12px; font-weight: 600; }
.dev-group .ginfo { font-size: 11px; color: var(--text-3); }
.cells { display: flex; flex-wrap: wrap; gap: 3px; }
.cell {
  width: 14px; height: 14px; border-radius: 4px; background: var(--idle); cursor: pointer; border: 0; padding: 0;
  position: relative;
}
.cell.online { background: var(--good); }
.cell.planned_off { background: var(--muted); opacity: .55; }
.cell.backoff, .cell.connecting { background: var(--warning); }
.cell.never, .cell.init, .cell.stopped { background: transparent; box-shadow: inset 0 0 0 1px var(--border-strong); }
.cell.mm { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--critical); }
.cell:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cell-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 11px; color: var(--text-2); margin-bottom: 14px; }
.cell-legend span { display: inline-flex; align-items: center; gap: 6px; }
.cell-legend .cell { cursor: default; }

table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { text-align: left; font-weight: 600; font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; color: var(--text-2); }
tr:last-child td { border-bottom: 0; }
td.n { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }
.tag {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  background: var(--bg-secondary); color: var(--text-2); white-space: nowrap;
}
.tag.good { color: var(--good); background: color-mix(in srgb, var(--good) 12%, transparent); }
.tag.bad { color: var(--critical); background: color-mix(in srgb, var(--critical) 12%, transparent); }
.tag.warn { color: color-mix(in srgb, var(--warning) 70%, var(--text)); background: color-mix(in srgb, var(--warning) 14%, transparent); }

.problems { max-height: 520px; overflow: auto; }
.problem { display: grid; grid-template-columns: 120px 120px 1fr; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 12px; }
.problem:last-child { border-bottom: 0; }
.problem time { color: var(--text-3); font-variant-numeric: tabular-nums; }
.problem code { font-size: 11px; color: var(--text-3); word-break: break-word; }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(460px, 100vw); background: var(--surface);
  border-left: 1px solid var(--border); box-shadow: -8px 0 24px rgba(0,0,0,.2); z-index: 20; padding: 20px; overflow: auto;
  transform: translateX(100%); transition: transform .2s ease-out;
}
.drawer.open { transform: none; }
.drawer h2 { font-size: 16px; margin: 0 0 4px; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; font-size: 12px; margin: 14px 0; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; word-break: break-word; }

.empty { color: var(--text-3); font-size: 12px; padding: 12px 0; }
.two { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); }
.note { font-size: 12px; color: var(--text-3); margin: -4px 0 12px; }

@media (max-width: 720px) {
  .top-inner, main { padding-left: 16px; padding-right: 16px; }
  .dev-group { grid-template-columns: 1fr; }
  .problem { grid-template-columns: 1fr; gap: 2px; }
  .brand .sub { display: none; }
}

/* countdown hero */
.hero { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; margin-top: 4px;
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); background:
  linear-gradient(135deg, var(--accent-subtle), transparent 60%), var(--surface); }
.hero-main { flex: 1 1 320px; min-width: 0; }
.hero .label { font-size: 11px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; }
.countdown { font-size: 40px; font-weight: 700; line-height: 1.15; margin: 4px 0 2px; color: var(--text); }
.countdown small { font-size: 18px; font-weight: 500; color: var(--text-3); margin-left: 1px; }
.hero .hint { font-size: 12px; color: var(--text-3); }
.hero-side { flex: 1 1 280px; min-width: 0; }
.progress { height: 8px; border-radius: 999px; background: var(--bg-secondary); overflow: hidden; margin-bottom: 8px; }
.progress-bar { height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width .4s ease; }
@media (max-width: 720px) { .countdown { font-size: 30px; } }
