:root {
  color-scheme: light;
  --ink: #12211d;
  --muted: #66746d;
  --line: #dce5df;
  --paper: #ffffff;
  --soft: #f1f5f1;
  --accent: #087f73;
  --accent-dark: #075c55;
  --amber: #c47c16;
  --red: #b64743;
  --shadow: 0 18px 50px rgba(32, 61, 50, .09);
  font-family: "Aptos", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: #e9efea; color: var(--ink); }
button, input, select { font: inherit; }
button { border: 0; cursor: pointer; }
#app { min-height: 100vh; }
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 28px; background: radial-gradient(circle at 10% 10%, #d6eee3 0, transparent 38%), linear-gradient(135deg, #e9f2ed, #dce8e0); }
.login-card { width: min(430px, 100%); padding: 34px; border: 1px solid rgba(255,255,255,.7); border-radius: 24px; background: rgba(255,255,255,.9); box-shadow: var(--shadow); }
.eyebrow { color: var(--accent); font-size: 12px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.login-card h1 { margin: 10px 0 8px; font-size: 30px; letter-spacing: -.04em; }
.login-card p { color: var(--muted); line-height: 1.6; }
.field { display: grid; gap: 7px; margin: 16px 0; }
.field span { color: var(--muted); font-size: 12px; font-weight: 750; }
input, select { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; outline: none; background: #fff; color: var(--ink); }
select[multiple] { min-height: 132px; }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(8,127,115,.12); }
.primary, .danger, .ghost { padding: 11px 15px; border-radius: 10px; font-weight: 750; }
.primary { color: #fff; background: var(--accent); }
.primary:hover { background: var(--accent-dark); }
.ghost { color: var(--accent-dark); background: #e2f0eb; }
.danger { color: #fff; background: var(--red); }
button:disabled { cursor: wait; opacity: .55; }
.error { min-height: 20px; color: var(--red); font-size: 13px; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 260px minmax(0, 1fr); }
.sidebar { display: flex; flex-direction: column; padding: 25px 18px; color: #e9f4ee; background: #102a25; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 10px 24px; }
.brand-mark { display: grid; width: 36px; height: 36px; place-items: center; border-radius: 12px; color: #0d322b; background: #aee6d2; font-weight: 900; }
.brand strong { display: block; font-size: 16px; }
.brand small { color: #9dbbb0; }
.nav { display: grid; gap: 7px; }
.nav button { padding: 12px 13px; border-radius: 11px; color: #b7d0c6; background: transparent; text-align: left; font-weight: 700; }
.nav button:hover, .nav button.active { color: #fff; background: #1b5a4e; }
.sidebar-foot { margin-top: auto; display: grid; gap: 12px; padding: 18px 10px 0; border-top: 1px solid rgba(255,255,255,.12); color: #9dbbb0; font-size: 12px; }
.user-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.content { min-width: 0; padding: 24px; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 20px; }
.topbar h1 { margin: 0; font-size: clamp(25px, 3vw, 38px); letter-spacing: -.05em; }
.topbar p { margin: 7px 0 0; color: var(--muted); }
.live-pill { display: flex; align-items: center; gap: 7px; padding: 9px 12px; border-radius: 999px; color: var(--accent-dark); background: #dff2e9; font-size: 12px; font-weight: 800; white-space: nowrap; }
.live-pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #27a37b; box-shadow: 0 0 0 4px rgba(39,163,123,.14); }
.view { display: none; }
.view.active { display: block; }
.toolbar { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; padding: 15px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.86); box-shadow: 0 8px 24px rgba(40,70,55,.04); }
.toolbar .field { min-width: 150px; flex: 1; margin: 0; }
@media (min-width: 641px) { #view-export .field:has(input[type="datetime-local"]) { min-width: 220px; } }
.channel-picker-field { min-width: 220px !important; }
.multi-select { position: relative; min-width: 220px; }
.multi-select-toggle { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: #fff; text-align: left; }
.multi-select-toggle::after { content: "▾"; float: right; color: var(--muted); }
.multi-select-menu { position: absolute; top: calc(100% + 7px); left: 0; right: 0; z-index: 10; display: grid; gap: 2px; max-height: 260px; overflow: auto; padding: 7px; border: 1px solid var(--line); border-radius: 12px; background: #fff; box-shadow: var(--shadow); }
.multi-select-menu label { display: flex; align-items: center; gap: 8px; padding: 8px 7px; border-radius: 8px; color: var(--ink); font-size: 13px; cursor: pointer; }
.multi-select-menu label:hover { background: var(--soft); }
.multi-select-menu input { width: auto; margin: 0; accent-color: var(--accent); }
.toolbar .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.history-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 16px; margin-top: 16px; align-items: start; }
.history-channels { position: sticky; top: 18px; padding: 15px; border: 1px solid var(--line); border-radius: 18px; background: var(--paper); box-shadow: 0 8px 24px rgba(40,70,55,.04); }
.history-channels-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.history-channels-head strong, .history-channels-head small { display: block; }
.history-channels-head small { margin-top: 4px; color: var(--muted); font-size: 11px; }
.channel-actions { display: flex; gap: 4px; }
.channel-actions .ghost { padding: 5px 7px; font-size: 11px; }
.channel-list { display: grid; gap: 2px; max-height: 520px; overflow: auto; padding-top: 8px; }
.channel-list label { display: flex; align-items: center; gap: 9px; padding: 9px 7px; border-radius: 9px; color: var(--ink); font-size: 13px; cursor: pointer; }
.channel-list label:hover { background: var(--soft); }
.channel-list input { width: auto; margin: 0; accent-color: var(--accent); }
.history-main { min-width: 0; }
.panel { margin-top: 16px; padding: 18px; border: 1px solid var(--line); border-radius: 18px; background: var(--paper); box-shadow: 0 8px 24px rgba(40,70,55,.04); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.panel-head h2 { margin: 0; font-size: 17px; }
.panel-head p { margin: 0; color: var(--muted); font-size: 12px; }
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat { min-height: 114px; padding: 16px; border: 1px solid var(--line); border-radius: 15px; background: linear-gradient(145deg, #fff, #f5faf6); }
.stat span { color: var(--muted); font-size: 12px; font-weight: 700; }
.stat strong { display: block; margin-top: 13px; font-size: 26px; letter-spacing: -.04em; }
.stat small { color: var(--muted); }
.site-block { margin-top: 18px; }
.site-title { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.site-title h3 { margin: 0; font-size: 16px; }
.site-title span { color: var(--muted); font-size: 12px; }
.channel-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 11px; }
.channel-card { width: 100%; padding: 14px; border: 1px solid var(--line); border-left: 4px solid #9aa9a1; border-radius: 14px; background: #fff; text-align: left; color: var(--ink); }
.channel-card.online { border-left-color: #1d9d75; }
.channel-card.stale { border-left-color: var(--amber); background: #fffaf1; }
.channel-card:hover { border-color: #8ac9b2; box-shadow: 0 8px 20px rgba(8,127,115,.08); }
.channel-top, .channel-bottom { display: flex; justify-content: space-between; gap: 10px; }
.channel-top strong { font-size: 15px; }
.channel-top span, .channel-bottom { color: var(--muted); font-size: 12px; }
.channel-values { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 18px 0 13px; }
.channel-values span { color: var(--muted); font-size: 11px; }
.channel-values strong { display: block; margin-top: 3px; font-size: 17px; }
.metric-tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.metric-tabs button { padding: 7px 11px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: #fff; font-size: 12px; font-weight: 750; }
.metric-tabs button.active { border-color: var(--accent); color: #fff; background: var(--accent); }
.chart-wrap { min-height: 330px; overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: #fbfdfb; }
.chart-wrap svg { width: 100%; height: 330px; display: block; }
.export-help { display: flex; gap: 12px; align-items: center; padding: 18px; color: var(--muted); }
.chart-grid-line { stroke: #dde7e1; stroke-width: 1; }
.chart-axis-text { fill: #73837b; font-size: 11px; }
.chart-line { fill: none; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; min-width: 680px; border-collapse: collapse; font-size: 13px; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: var(--muted); background: var(--soft); font-size: 11px; text-transform: uppercase; }
.config-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 16px; }
.config-nav { display: grid; align-content: start; gap: 8px; }
.config-nav button { padding: 12px; border: 1px solid var(--line); border-radius: 11px; background: #fff; text-align: left; color: var(--ink); }
.config-nav button.active { border-color: var(--accent); color: var(--accent-dark); background: #e4f3ed; }
.setting-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.setting-card { display: grid; gap: 7px; padding: 14px; border: 1px solid var(--line); border-radius: 13px; background: #fbfdfb; }
.setting-card label { color: var(--muted); font-size: 12px; font-weight: 750; }
.setting-card .setting-actions { display: flex; justify-content: flex-end; gap: 8px; }
.setting-card small { color: var(--muted); line-height: 1.5; }
.empty { display: grid; min-height: 160px; place-items: center; color: var(--muted); text-align: center; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 20; max-width: min(420px, calc(100vw - 48px)); padding: 13px 16px; border-radius: 12px; color: #fff; background: #173d35; box-shadow: var(--shadow); }
.toast.error { background: #8e322e; }
@media (max-width: 980px) { .app-shell { grid-template-columns: 1fr; } .sidebar { padding: 14px; } .brand { padding-bottom: 12px; } .nav { grid-template-columns: repeat(4, 1fr); } .nav button { text-align: center; } .sidebar-foot { display: none; } .stat-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .content { padding: 14px; } .topbar { align-items: flex-start; flex-direction: column; } .nav { grid-template-columns: repeat(2, 1fr); } .stat-grid, .setting-grid, .config-layout { grid-template-columns: 1fr; } .toolbar .field { min-width: 100%; } .panel { padding: 13px; } }
@media (max-width: 820px) { .history-layout { grid-template-columns: 1fr; } .history-channels { position: static; } .channel-list { max-height: 210px; grid-template-columns: repeat(2, minmax(0, 1fr)); } }
