/* ============================================================
   Bedroom Air Quality Monitor — Premium Dashboard Stylesheet
   Light / Dark themes via CSS custom properties on <html[data-theme]>
   ============================================================ */

:root {
  --font-en: "Inter", "Noto Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-th: "Noto Sans Thai", "Sarabun", "Tahoma", var(--font-en);

  /* Light theme palette */
  --bg: #eef2f7;
  --bg-soft: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #f2f5f9;
  --navy: #0f1a2e;
  --navy-2: #16243d;
  --navy-3: #1e2f4d;
  --border: #e3e9f1;
  --text: #16233a;
  --text-2: #5b6b82;
  --text-3: #8b98ab;

  --blue: #2f6bff;
  --blue-soft: #e8efff;
  --cyan: #12b5c6;
  --cyan-soft: #e2f8fb;
  --green: #16a34a;
  --green-soft: #e6f7ec;
  --purple: #8b5cf6;
  --purple-soft: #f1ebfe;
  --coral: #ff6b57;
  --coral-soft: #ffebe8;
  --yellow: #eab308;
  --amber: #f59e0b;
  --red: #ef4444;
  --orange: #f97316;
  --lime: #84cc16;

  --aqi1: #22c55e;
  --aqi2: #84cc16;
  --aqi3: #eab308;
  --aqi4: #f97316;
  --aqi5: #ef4444;

  --grad-brand: linear-gradient(135deg, #34d399 0%, #2f6bff 100%);
  --grad-hero: linear-gradient(118deg, #1c3d8f 0%, #2558c9 38%, #2f6bff 66%, #34d399 130%);

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 4px 16px rgba(16, 24, 40, .07);
  --shadow-lg: 0 10px 30px rgba(16, 24, 40, .12);
  --glass: rgba(255, 255, 255, .55);

  --radius: 16px;
  --radius-sm: 12px;
  --radius-xs: 8px;

  --topbar-h: 62px;
}

html[data-theme="dark"] {
  --bg: #0a1018;
  --bg-soft: #0e151f;
  --surface: #111a28;
  --surface-2: #16202f;
  --navy: #070d17;
  --navy-2: #0d1524;
  --navy-3: #1a2942;
  --border: #20304a;
  --text: #e5ecf7;
  --text-2: #9aa9c0;
  --text-3: #68788f;

  --blue: #4f83ff;
  --blue-soft: #1a2744;
  --cyan: #22c8da;
  --cyan-soft: #0f2830;
  --green: #2fbf66;
  --green-soft: #112a1c;
  --purple: #a78bfa;
  --purple-soft: #241d40;
  --coral: #ff7a66;
  --coral-soft: #351d1a;
  --yellow: #e2b80f;
  --amber: #fb9b2c;
  --red: #f2605c;
  --orange: #fb8734;

  --grad-hero: linear-gradient(118deg, #10244f 0%, #163a8f 42%, #1e4fc0 70%, #0e8f64 130%);

  --shadow: 0 4px 18px rgba(0, 0, 0, .35);
  --shadow-lg: 0 12px 36px rgba(0, 0, 0, .45);
  --glass: rgba(255, 255, 255, .04);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-en);
  background:
    radial-gradient(1100px 420px at 85% -10%, color-mix(in srgb, var(--blue) 9%, transparent), transparent 60%),
    radial-gradient(900px 380px at -10% 8%, color-mix(in srgb, var(--green) 7%, transparent), transparent 55%),
    var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

html[lang="th"] body { font-family: var(--font-th); }

a { color: var(--blue); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

.hidden { display: none !important; }

/* ============ Drawer (Navigation) ============ */
.drawer-overlay {
  position: fixed; inset: 0;
  background: rgba(6, 11, 22, .55);
  z-index: 90;
  opacity: 0;
  visibility: hidden;
  transition: opacity .25s ease, visibility .25s ease;
  backdrop-filter: blur(2px);
}
body.drawer-open .drawer-overlay { opacity: 1; visibility: visible; }

.drawer {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: 268px;
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-2) 60%, var(--navy) 100%);
  color: #c7d2e8;
  z-index: 100;
  transform: translateX(-102%);
  transition: transform .28s cubic-bezier(.4, 0, .2, 1);
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
}
body.drawer-open .drawer { transform: translateX(0); }

.drawer-header {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 18px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.drawer-logo {
  width: 44px; height: 44px; flex: 0 0 44px;
  border-radius: 13px;
  background: var(--grad-brand);
  display: grid; place-items: center;
  color: #fff;
  box-shadow: 0 6px 16px rgba(47, 107, 255, .35);
}
.drawer-logo svg { width: 24px; height: 24px; }
.drawer-title { font-size: 16px; font-weight: 700; color: #fff; letter-spacing: .2px; }
.drawer-sub { font-size: 11px; color: #8fa3c2; margin-top: 2px; }
.drawer-card-chip {
  display: inline-flex; align-items: center; gap: 4px;
  margin-top: 6px; padding: 2px 8px;
  background: rgba(255, 255, 255, .08);
  border-radius: 99px; font-size: 10px; color: #9fd6ff; font-weight: 600;
}

.drawer-close {
  margin-left: auto;
  background: rgba(255, 255, 255, .06);
  border: none; color: #cfd9ea;
  width: 32px; height: 32px; border-radius: 9px;
  display: grid; place-items: center;
  transition: background .2s;
}
.drawer-close:hover { background: rgba(255, 255, 255, .14); }
.drawer-close svg { width: 17px; height: 17px; }

.drawer-nav { flex: 1; overflow-y: auto; padding: 14px 12px 20px; }
.drawer-nav::-webkit-scrollbar { width: 6px; }
.drawer-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 4px; }

.nav-group { margin-bottom: 10px; }
.nav-group-label {
  padding: 8px 12px 6px;
  font-size: 10.5px; font-weight: 700; letter-spacing: 1.2px;
  text-transform: uppercase; color: #64789c;
}

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: 11px;
  color: #b9c6de;
  margin-bottom: 3px;
  transition: background .18s, color .18s;
  border-left: 3px solid transparent;
}
.nav-item svg { width: 19px; height: 19px; flex: 0 0 19px; color: #8296b8; transition: color .18s; }
.nav-item .nav-item-label { font-size: 13.6px; font-weight: 500; }
.nav-item .nav-item-sub { font-size: 10.5px; color: #667a9c; display: block; }
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-item:hover svg { color: #a5c8ff; }
.nav-item.active {
  background: linear-gradient(90deg, #2f6bff, #2563eb);
  color: #fff;
  box-shadow: 0 6px 16px rgba(37, 99, 235, .35);
}
.nav-item.active svg { color: #fff; }
.nav-item.active .nav-item-sub { color: #cfdcff; }

.drawer-footer {
  padding: 12px 16px 16px;
  border-top: 1px solid rgba(255, 255, 255, .08);
  font-size: 11px; color: #64789c;
}
.drawer-footer b { color: #9fd6ff; font-weight: 600; }
.drawer-status {
  display: flex; align-items: center; gap: 9px;
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 11px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .08);
}
.drawer-status .ds-dot {
  width: 9px; height: 9px; border-radius: 50%; flex: 0 0 9px;
}
.drawer-status.online .ds-dot { background: #2fbf66; box-shadow: 0 0 0 0 rgba(47,191,102,.6); animation: pulse 2s infinite; }
.drawer-status.offline .ds-dot { background: #f2605c; }
.drawer-status .ds-label { font-size: 11.5px; color: #cfd9ea; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drawer-status.online .ds-label { color: #7ee2a6; }
.drawer-status.offline .ds-label { color: #f5a3a0; }

/* ============ Top Bar ============ */
.topbar {
  position: sticky; top: 0; z-index: 60;
  height: var(--topbar-h);
  background: color-mix(in srgb, var(--surface) 84%, transparent);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 20px;
}
.hamburger {
  width: 40px; height: 40px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 11px;
  display: grid; place-items: center;
  color: var(--text);
  transition: background .2s, transform .15s;
}
.hamburger:hover { background: var(--surface-2); transform: translateY(-1px); }
.hamburger svg { width: 19px; height: 19px; }

.topbar-brand { margin-left: 14px; display: flex; align-items: center; gap: 10px; }
.topbar-brand .tb-logo {
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--grad-brand);
  display: grid; place-items: center; color: #fff;
}
.topbar-brand .tb-logo svg { width: 18px; height: 18px; }
.tb-title { font-size: 15px; font-weight: 700; color: var(--text); }
.tb-sub { font-size: 11px; color: var(--text-3); }

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.live-dot {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 11.5px; font-weight: 700;
  padding: 7px 12px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  white-space: nowrap;
}
.live-dot .ld-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(47, 191, 102, .55);
  animation: pulse 2s infinite;
}
.live-dot .ld-label { font-weight: 700; }
.live-dot.offline .ld-dot { background: var(--red); animation: none; box-shadow: none; }

.live-clock {
  font-variant-numeric: tabular-nums;
  font-size: 12.5px; font-weight: 700;
  color: var(--text-2);
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
  letter-spacing: .3px;
  white-space: nowrap;
}

.icon-btn {
  width: 40px; height: 40px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  border-radius: 11px;
  display: grid; place-items: center;
  transition: background .2s, color .2s, transform .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); transform: translateY(-1px); }
.icon-btn svg { width: 19px; height: 19px; }

.lang-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
  padding: 3px;
}
.lang-toggle button {
  border: none; background: transparent;
  padding: 6px 13px;
  border-radius: 8px;
  font-size: 12.5px; font-weight: 700;
  color: var(--text-3);
  transition: all .2s;
}
.lang-toggle button.active {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 4px 10px rgba(47, 107, 255, .3);
}

/* ============ Main Layout ============ */
.main {
  max-width: 1600px;
  margin: 0 auto;
  padding: 12px 20px 4px;
}

.page-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }
.page-head h1 { font-size: 24px; font-weight: 800; color: var(--text); letter-spacing: -.3px; }
.page-head .page-head-sub { color: var(--text-3); font-size: 13px; margin-top: 3px; }
html[lang="th"] .page-head h1, html[lang="th"] .section-title, html[lang="th"] .hero h1 { letter-spacing: 0; }

/* ============ Hero (compact) ============ */
.hero {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  padding: 11px 26px;
  margin-bottom: 9px;
  background: var(--grad-hero);
  color: #fff;
  box-shadow: 0 14px 34px rgba(31, 74, 190, .35);
  min-height: 84px;
}
.hero::before {
  content: "";
  position: absolute; right: -60px; top: -80px;
  width: 300px; height: 300px;
  background: radial-gradient(circle, rgba(255,255,255,.16), transparent 65%);
  border-radius: 50%;
}
.hero::after {
  content: "";
  position: absolute; right: 90px; bottom: -120px;
  width: 260px; height: 260px;
  background: radial-gradient(circle, rgba(52, 211, 153, .35), transparent 65%);
  border-radius: 50%;
}
.hero-inner { position: relative; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap; }
.hero-left { min-width: 0; }
.hero .hero-chip {
  display: inline-flex; align-items: center; gap: 7px;
  background: rgba(255, 255, 255, .16);
  border: 1px solid rgba(255, 255, 255, .25);
  padding: 4px 12px; border-radius: 99px;
  font-size: 11px; font-weight: 600; letter-spacing: .4px;
  margin-bottom: 7px;
  white-space: nowrap;
}
.hero-chip .pulse-dot { width: 8px; height: 8px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 0 0 rgba(74,222,128,.7); animation: pulse 2s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(74, 222, 128, .6); }
  70% { box-shadow: 0 0 0 9px rgba(74, 222, 128, 0); }
  100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); }
}
.hero h1 { font-size: 19px; font-weight: 800; letter-spacing: -.3px; line-height: 1.22; }
.hero p { margin-top: 3px; font-size: 12px; color: rgba(255, 255, 255, .82); max-width: 620px; }
.hero-meta { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-top: 7px; }
.hero-meta .meta-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255, 255, 255, .13);
  padding: 4px 12px; border-radius: 10px;
  font-size: 11.5px; font-weight: 600;
  white-space: nowrap;
}
.hero-stats {
  position: relative; z-index: 2;
  display: flex; align-items: center; gap: 18px;
  padding: 7px 16px;
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: var(--radius-sm);
  backdrop-filter: blur(6px);
}
.hero-stat { text-align: center; }
.hero-stat .hs-value { font-size: 19px; font-weight: 800; letter-spacing: -.4px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.hero-stat .hs-value small { font-size: 13px; font-weight: 700; opacity: .85; margin-left: 2px; }
.hero-stat .hs-label { font-size: 10px; opacity: .85; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; margin-top: 2px; }

/* ============ Cards / Grid ============ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-pad { padding: 16px; }

.grid { display: grid; gap: 18px; }

.chart-grid-2 {
  display: grid;
  grid-template-columns: 1.9fr 1fr;
  gap: 18px;
  align-items: stretch;
}
.chart-grid-2:not(:last-child) { margin-bottom: 12px; }
.chart-grid-2.chart-equal { grid-template-columns: 1fr 1fr; }

.bottom-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-top: 12px;
}
.bottom-grid > .card:nth-child(n+5) { display: none; }
@media (max-width: 1280px) {
  .bottom-grid { grid-template-columns: repeat(2, 1fr); }
  .chart-grid-2 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 768px) {
  .chart-grid-2 { grid-template-columns: 1fr; }
  .bottom-grid { grid-template-columns: 1fr; }
}

/* System status row */
.status-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}
.status-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  display: flex; align-items: center; gap: 10px;
  box-shadow: var(--shadow-sm);
  min-width: 0;
  transition: transform .15s, box-shadow .15s;
}
.status-item:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.status-item .st-ico {
  width: 36px; height: 36px; flex: 0 0 36px;
  border-radius: 11px;
  display: grid; place-items: center;
  background: var(--blue-soft); color: var(--blue);
}
.status-item .st-ico svg { width: 18px; height: 18px; }
.status-item .st-ico.green { background: var(--green-soft); color: var(--green); }
.status-item .st-ico.red { background: var(--coral-soft); color: var(--red); }
.status-item .st-ico.cyan { background: var(--cyan-soft); color: var(--cyan); }
.status-item .st-ico.purple { background: var(--purple-soft); color: var(--purple); }
.status-item .st-min { min-width: 0; }
.status-item .st-label {
  font-size: 10px; color: var(--text-3); font-weight: 600;
  letter-spacing: .3px; text-transform: uppercase;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.status-item .st-value {
  font-size: 12.5px; font-weight: 700; color: var(--text);
  margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.status-item .st-value .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; vertical-align: middle; }

/* KPI cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  margin-bottom: 12px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 14px 10px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: transform .2s, box-shadow .2s;
  min-height: 120px;
  display: flex; flex-direction: column;
}
.kpi-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.kpi-card::before {
  content: "";
  position: absolute; top: -34px; right: -34px;
  width: 100px; height: 100px; border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--kpi-accent, var(--blue)) 22%, transparent), transparent 70%);
}
.kpi-card::after {
  content: "";
  position: absolute; left: 0; right: 0; top: 0; height: 3px;
  background: linear-gradient(90deg, var(--kpi-accent, var(--blue)), color-mix(in srgb, var(--kpi-accent, var(--blue)) 40%, transparent));
}
.kpi-card .kpi-top { display: flex; align-items: flex-start; justify-content: space-between; position: relative; }
.kpi-card .kpi-ico {
  width: 38px; height: 38px; border-radius: 11px;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--kpi-accent, var(--blue)) 13%, transparent);
  color: var(--kpi-accent, var(--blue));
}
.kpi-card .kpi-ico svg { width: 20px; height: 20px; }
.kpi-card .kpi-trend {
  font-size: 10.5px; font-weight: 700;
  padding: 2px 8px; border-radius: 99px;
  background: var(--surface-2); color: var(--text-2);
  display: inline-flex; align-items: center; gap: 3px;
  white-space: nowrap;
}
.kpi-card .kpi-trend.up { background: var(--coral-soft); color: var(--coral); }
.kpi-card .kpi-trend.down { background: var(--green-soft); color: var(--green); }
.kpi-card .kpi-title { margin-top: 9px; font-size: 11.5px; font-weight: 700; color: var(--text-2); }
.kpi-card .kpi-sub { font-size: 9.5px; color: var(--text-3); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-card .kpi-value { margin-top: 3px; font-size: 22px; font-weight: 800; color: var(--text); letter-spacing: -.5px; line-height: 1.15; }
.kpi-card .kpi-value small { font-size: 11.5px; font-weight: 700; color: var(--text-3); margin-left: 3px; }
.kpi-card .kpi-aqi-label { margin-top: 2px; font-size: 11px; font-weight: 700; }
.kpi-card .kpi-spark { margin-top: auto; padding-top: 5px; height: 28px; }
.kpi-card .kpi-spark svg.spark { display: block; width: 100%; height: 100%; }
.kpi-card .kpi-spark .spark-empty { font-size: 10px; color: var(--text-3); text-align: center; line-height: 34px; }

/* Charts */
.charts-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 6px; }
.charts-head h2 { font-size: 14px; font-weight: 800; color: var(--text); }

.range-control {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 3px;
  gap: 2px;
  flex-wrap: wrap;
}
.range-btn {
  border: none; background: transparent;
  padding: 7px 15px; border-radius: 8px;
  font-size: 12.5px; font-weight: 700;
  color: var(--text-2);
  transition: all .18s;
}
.range-btn:hover { color: var(--blue); }
.range-btn.active { background: var(--blue); color: #fff; box-shadow: 0 4px 10px rgba(47,107,255,.3); }

.chart-box {
  position: relative;
  height: 158px;
}
.chart-box.tall { height: 210px; }
.chart-empty {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  color: var(--text-3); text-align: center;
  font-size: 13px;
}
.chart-empty svg { width: 44px; height: 44px; margin-bottom: 8px; color: var(--text-3); opacity: .6; display: block; margin-inline: auto; }

.chart-hint {
  font-size: 10px; color: var(--text-3); margin-top: 5px;
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.chart-hint svg { width: 14px; height: 14px; }

/* Chart controls */
.chart-controls {
  display: flex; align-items: center; flex-wrap: wrap; gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px dashed var(--border);
}
.chart-controls .cc-group {
  display: flex; align-items: center; gap: 8px;
}
.cc-label { font-size: 11px; color: var(--text-3); font-weight: 700; text-transform: uppercase; letter-spacing: .4px; margin-right: 2px; }
.chart-toolbar {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 11px; padding: 3px;
  margin-left: auto;
  flex-wrap: wrap;
}
.tool-btn, .chart-toolbar > button {
  border: none; background: transparent;
  width: 32px; height: 32px; border-radius: 8px;
  display: grid; place-items: center;
  color: var(--text-2);
  transition: all .18s;
  position: relative;
}
.tool-btn svg, .chart-toolbar > button svg { width: 16px; height: 16px; }
.tool-btn:hover, .chart-toolbar > button:hover { background: var(--surface); color: var(--blue); }
.tool-btn.active, .chart-toolbar > button.active { background: var(--blue); color: #fff; box-shadow: 0 4px 10px rgba(47,107,255,.3); }
.tool-btn.big { width: auto; padding: 0 11px; gap: 6px; display: inline-flex; font-size: 12px; font-weight: 700; }
.tool-btn.big svg { width: 14px; height: 14px; }
.tool-btn[title]::after {
  content: attr(title);
  position: absolute; top: 38px; left: 50%; transform: translateX(-50%);
  background: var(--navy); color: #fff; font-size: 10.5px; font-weight: 600;
  padding: 4px 8px; border-radius: 6px;
  white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .15s; z-index: 20;
}
.tool-btn:hover::after { opacity: 1; }
.tool-sep { width: 1px; height: 18px; background: var(--border); margin: 0 2px; }

/* Custom range popover */
.cr-wrap { position: relative; }
.cr-pop {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 40;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 16px;
  width: 280px;
}
.cr-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.cr-row label { font-size: 11.5px; color: var(--text-3); font-weight: 700; width: 40px; flex: 0 0 40px; }
.cr-row input { flex: 1; min-width: 0; }
.cr-actions { display: flex; gap: 8px; justify-content: flex-end; }
.cr-error { font-size: 11.5px; color: var(--red); margin-bottom: 8px; }
/* Analytics: keep the custom panel in-flow below the range buttons so it is
   not clipped by the filter card's overflow:hidden */
#analyticsPage .cr-pop {
  position: static;
  width: 320px;
  max-width: 100%;
  margin-top: 12px;
  box-shadow: none;
}

/* Air Quality Status + gauge card */
.aq-card {
  position: relative; overflow: hidden;
  border-radius: var(--radius);
  padding: 11px 14px;
  color: #fff;
  display: flex; flex-direction: column;
  height: 176px;
  background: linear-gradient(150deg, #16a34a, #15803d);
  box-shadow: var(--shadow);
  transition: background .4s;
}
.aq-card::before {
  content: ""; position: absolute; right: -50px; top: -60px;
  width: 200px; height: 200px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.2), transparent 65%);
}
.aq-card .aq-top { display: flex; align-items: center; justify-content: space-between; position: relative; z-index: 2; }
.aq-card .aq-title { font-size: 13px; font-weight: 700; opacity: .95; }
.aq-card .aq-ico { width: 40px; height: 40px; border-radius: 12px; background: rgba(255,255,255,.2); display: grid; place-items: center; }
.aq-card .aq-ico svg { width: 21px; height: 21px; }
.aq-card .aq-gauge { position: relative; z-index: 2; margin: 2px auto 0; flex: 1; display: grid; place-items: center; min-height: 74px; }
.aq-card .aq-gauge svg { width: 100%; max-width: 195px; display: block; }
.aq-card .aq-gauge-center { position: absolute; left: 50%; bottom: 4%; transform: translateX(-50%); text-align: center; width: 80%; pointer-events: none; }
.aq-card .aq-big { font-size: 19px; font-weight: 800; letter-spacing: -.4px; line-height: 1.1; }
.aq-card .aq-desc { font-size: 11.5px; opacity: .9; margin-top: 1px; }
.aq-card .aq-scale {
  position: relative; z-index: 2;
  padding-top: 3px;
}
.aq-card .aq-scale .bar { display: flex; gap: 3px; margin-bottom: 4px; }
.aq-card .aq-scale .bar span { flex: 1; height: 7px; border-radius: 4px; background: rgba(255,255,255,.28); transition: all .25s; }
.aq-card .aq-scale .bar span.active { background: #fff; box-shadow: 0 0 10px rgba(255,255,255,.7); }
.aq-card .aq-scale .nums { display: flex; justify-content: space-between; font-size: 11px; font-weight: 700; opacity: .95; margin-bottom: 2px; }
.aq-card .aq-scale .labels { display: flex; justify-content: space-between; font-size: 9px; opacity: .8; text-transform: uppercase; letter-spacing: .3px; }
.aq-card .aq-scale .labels span { white-space: nowrap; }
.aq-card .aq-ts { position: relative; z-index: 2; font-size: 10px; opacity: .8; text-align: right; margin-top: 6px; }

/* Global status card */
.global-card {
  display: grid; grid-template-columns: auto 1fr; gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.gc-ico {
  width: 46px; height: 46px; border-radius: 13px;
  display: grid; place-items: center;
  background: var(--grad-brand); color: #fff;
}
.gc-ico svg { width: 22px; height: 22px; }
.gc-body { min-width: 0; }
.gc-title { font-size: 13px; font-weight: 800; color: var(--text); }
.gc-text { font-size: 12px; color: var(--text-2); margin-top: 1px; line-height: 1.5; }
.gc-foot { font-size: 10.5px; color: var(--text-3); margin-top: 6px; }
.gc-val { font-size: 15px; font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; }

/* ============ Summary chart / cards ============ */
.section-title {
  font-size: 16px; font-weight: 800; color: var(--text);
  display: flex; align-items: center; gap: 9px;
}
.section-title svg { width: 18px; height: 18px; color: var(--blue); }

.trend-legend { display: flex; gap: 16px; font-size: 12px; color: var(--text-2); margin-left: auto; }
.trend-legend .lg { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.trend-legend .lg .bar { width: 18px; height: 4px; border-radius: 3px; }

.summary-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stat-mini {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: var(--surface-2);
}
.stat-mini .sm-label { font-size: 10.5px; color: var(--text-3); text-transform: uppercase; letter-spacing: .4px; font-weight: 700; white-space: nowrap; }
.stat-mini .sm-value { font-size: 20px; font-weight: 800; color: var(--text); margin-top: 4px; letter-spacing: -.4px; }
.stat-mini .sm-value small { font-size: 11.5px; color: var(--text-3); font-weight: 700; }
.stat-mini .sm-ext { font-size: 11px; color: var(--text-2); margin-top: 2px; }
.stat-mini .mini-time { font-size: 12px; font-weight: 700; color: var(--blue); margin-top: 4px; }

/* ============ Alerts ============ */
.alert-list { display: flex; flex-direction: column; }
.alert-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 7px 4px;
  border-bottom: 1px solid var(--border);
}
.alert-item:last-child { border-bottom: none; }
.alert-item .al-badge {
  flex: 0 0 auto;
  width: 32px; height: 32px; border-radius: 10px;
  display: grid; place-items: center;
  font-size: 16px;
}
.alert-item.critical .al-badge { background: var(--coral-soft); color: var(--coral); }
.alert-item.warning .al-badge { background: var(--yellow); color: var(--surface); opacity: .9; }
.alert-item.info .al-badge { background: var(--blue-soft); color: var(--blue); }
.alert-item .al-ico { width: 19px; height: 19px; }
.alert-item .al-body { min-width: 0; flex: 1; }
.alert-item .al-title { font-size: 12px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.alert-item .al-msg { font-size: 11px; color: var(--text-2); margin-top: 1px; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.alert-item .al-time { font-size: 9.5px; color: var(--text-3); margin-top: 2px; display: inline-flex; align-items: center; gap: 5px; }

.alert-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 800;
  padding: 5px 12px; border-radius: 99px;
  border: 1px solid var(--border);
  white-space: nowrap;
}
.alert-pill svg { width: 13px; height: 13px; }
.alert-pill.critical { background: var(--coral-soft); color: var(--coral); border-color: color-mix(in srgb, var(--coral) 30%, transparent); }
.alert-pill.warning { background: #fef6e0; color: #b7791f; border-color: #f3ddab; }
.alert-pill.info { background: var(--blue-soft); color: var(--blue); border-color: color-mix(in srgb, var(--blue) 30%, transparent); }
html[data-theme="dark"] .alert-pill.warning { background: rgba(234,179,8,.15); color: var(--yellow); border-color: rgba(234,179,8,.3); }

/* ============ Generic controls ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px; font-weight: 700;
  padding: 9px 16px;
  border-radius: 11px;
  transition: all .18s;
  white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { background: var(--surface-2); transform: translateY(-1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary {
  background: linear-gradient(135deg, #2f6bff, #2563eb);
  color: #fff; border-color: transparent;
  box-shadow: 0 6px 14px rgba(37, 99, 235, .28);
}
.btn-primary:hover { background: linear-gradient(135deg, #3a76ff, #2f6bff); color: #fff; filter: brightness(1.05); }
.btn.primary,
.btn-primary {
  background: linear-gradient(135deg, #2f6bff, #2563eb);
  color: #fff; border-color: transparent;
  box-shadow: 0 6px 14px rgba(37, 99, 235, .28);
}
.btn.primary:hover,
.btn-primary:hover { background: linear-gradient(135deg, #3a76ff, #2f6bff); color: #fff; filter: brightness(1.05); }
.btn-green {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #fff; border-color: transparent;
  box-shadow: 0 6px 14px rgba(22, 163, 74, .28);
}
.btn-green:hover { background: linear-gradient(135deg, #2fd76d, #1ab856); color: #fff; }
.btn-danger {
  background: var(--coral-soft); color: var(--coral);
  border-color: color-mix(in srgb, var(--coral) 30%, transparent);
}
.btn-danger:hover { background: color-mix(in srgb, var(--coral) 16%, transparent); }
.btn-sm { padding: 7px 12px; font-size: 12px; border-radius: 9px; }
.btn-block { width: 100%; }

.input, textarea.input, select.input {
  width: 100%;
  padding: 9px 12px;
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: border .18s, box-shadow .18s;
  outline: none;
}
.input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 18%, transparent); }
.input[type="datetime-local"] { color-scheme: light; }
html[data-theme="dark"] .input[type="datetime-local"] { color-scheme: dark; }
.select-wrap { position: relative; display: inline-flex; align-items: center; }
.select-wrap::after {
  content: ""; position: absolute; right: 12px; top: 50%;
  width: 7px; height: 7px;
  border-right: 2px solid var(--text-3);
  border-bottom: 2px solid var(--text-3);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}
.select-wrap select.input { appearance: none; padding-right: 30px; cursor: pointer; }

.toggle-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 13px 0;
  border-bottom: 1px solid var(--border);
}
.toggle-row:last-child { border-bottom: none; }
.toggle-row .tr-title { font-size: 13.5px; font-weight: 700; color: var(--text); }
.toggle-row .tr-sub { font-size: 12px; color: var(--text-3); margin-top: 1px; }
.switch { position: relative; width: 46px; height: 26px; flex: 0 0 46px; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch .track {
  position: absolute; inset: 0;
  background: var(--border);
  border-radius: 99px;
  transition: background .2s;
  cursor: pointer;
}
.switch .track::before {
  content: "";
  position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgba(0,0,0,.25);
  transition: transform .2s;
}
.switch input:checked + .track { background: var(--blue); }
.switch input:checked + .track::before { transform: translateX(20px); }

.chip-toggle {
  display: inline-flex; align-items: center; gap: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 12.5px; font-weight: 700; color: var(--text-2);
  transition: all .18s; cursor: pointer;
  user-select: none;
}
.chip-toggle .cb-sq {
  width: 17px; height: 17px; border-radius: 5px;
  border: 2px solid var(--border);
  display: grid; place-items: center;
  transition: all .15s; flex: 0 0 17px;
}
.chip-toggle .cb-sq svg { width: 11px; height: 11px; color: #fff; opacity: 0; transition: opacity .15s; }
.chip-toggle.active { border-color: var(--blue); color: var(--blue); background: var(--blue-soft); }
.chip-toggle.active .cb-sq { background: var(--blue); border-color: var(--blue); }
.chip-toggle.active .cb-sq svg { opacity: 1; }

/* ============ Tables ============ */
.table-wrap { overflow-x: auto; }
.table-scroll { max-height: 460px; overflow-y: auto; border-radius: 6px; }
.table-scroll::-webkit-scrollbar { width: 8px; height: 8px; }
.table-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 5px; }
.table-scroll::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

table.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
table.tbl thead th {
  position: sticky; top: 0; z-index: 5;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 10.5px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .4px;
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.tbl th.sortable { cursor: pointer; user-select: none; }
table.tbl th.sortable:hover { color: var(--blue); }
table.tbl th .sort-arrow { font-size: 9px; margin-left: 3px; }
table.tbl td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
  white-space: nowrap;
}
table.tbl tbody tr { transition: background .12s; }
table.tbl tbody tr:hover { background: color-mix(in srgb, var(--blue) 5%, transparent); }
table.tbl tbody tr:last-child td { border-bottom: none; }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 700;
  padding: 3px 10px; border-radius: 99px;
  white-space: nowrap;
}
.pill.good { background: var(--green-soft); color: var(--green); }
.pill.moderate { background: var(--yellow); color: var(--surface); opacity: .92; }
.pill.unhealthy { background: #fde5bd; color: #b45309; }
.pill.hazardous { background: var(--coral-soft); color: var(--coral); }
html[data-theme="dark"] .pill.moderate { color: var(--navy); }
html[data-theme="dark"] .pill.unhealthy { background: rgba(249,115,22,.18); color: var(--orange); }

.risk-cir {
  width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 800; color: #fff;
  flex: 0 0 38px;
  box-shadow: 0 4px 10px rgba(0,0,0,.18);
}

/* ============ Timeline ============ */
.timeline { position: relative; padding-top: 6px; }
.timeline::before {
  content: "";
  position: absolute; left: 17px; top: 6px; bottom: 6px;
  width: 3px; border-radius: 3px;
  background: linear-gradient(180deg, var(--green), var(--yellow), var(--coral));
  opacity: .35;
}
.tl-item { position: relative; padding: 0 0 18px 52px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-dot {
  position: absolute; left: 8px; top: 4px;
  width: 21px; height: 21px; border-radius: 50%;
  background: var(--surface);
  border: 4px solid var(--green);
  box-shadow: 0 0 0 4px var(--green-soft);
}
.tl-item.warning .tl-dot { border-color: var(--yellow); box-shadow: 0 0 0 4px #fef6e0; }
.tl-item.critical .tl-dot { border-color: var(--coral); box-shadow: 0 0 0 4px var(--coral-soft); }
.tl-title { font-size: 13px; font-weight: 800; color: var(--text); }
.tl-msg { font-size: 12.5px; color: var(--text-2); margin-top: 2px; line-height: 1.5; }
.tl-time { font-size: 11px; color: var(--text-3); margin-top: 4px; display: inline-flex; align-items: center; gap: 5px; }

/* ============ Device / Snapshot ============ */
.device-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px;
}
.device-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.device-card .dc-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, color-mix(in srgb, var(--blue) 6%, transparent), transparent);
}
.device-card .dc-ico {
  width: 46px; height: 46px; border-radius: 13px;
  background: var(--grad-brand); color: #fff;
  display: grid; place-items: center; flex: 0 0 46px;
  box-shadow: 0 6px 14px rgba(47,107,255,.3);
}
.device-card .dc-ico svg { width: 22px; height: 22px; }
.device-card .dc-name { font-size: 15px; font-weight: 800; color: var(--text); }
.device-card .dc-chip { font-size: 10.5px; color: var(--text-3); margin-top: 2px; }
.device-card .dc-body { padding: 16px 18px; }

.snap-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.snap-item {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 10px 12px;
  background: var(--surface-2);
  min-width: 0;
}
.snap-item .sn-ico { color: var(--text-3); flex: 0 0 auto; display: grid; place-items: center; }
.snap-item .sn-ico svg { width: 18px; height: 18px; }
.snap-item .sn-body { min-width: 0; }
.snap-item .sn-label { font-size: 10.5px; color: var(--text-3); font-weight: 700; text-transform: uppercase; letter-spacing: .3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.snap-item .sn-value { font-size: 13px; font-weight: 800; color: var(--text); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.snap-item .sn-value small { font-size: 10.5px; color: var(--text-3); font-weight: 600; margin-left: 2px; }

.health-row {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
  margin-top: 12px;
}
.health-pill {
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  background: var(--surface-2);
}
.health-pill .hp-dot { width: 11px; height: 11px; border-radius: 50%; margin: 0 auto 6px; background: var(--green); }
.health-pill.nok .hp-dot { background: var(--red); }
.health-pill .hp-label { font-size: 10.5px; color: var(--text-3); font-weight: 700; }
.health-pill .hp-text { font-size: 12.5px; font-weight: 800; color: var(--text); margin-top: 2px; }

.pw-meter { margin-top: 12px; }
.pw-meter .pm-head { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-3); font-weight: 700; margin-bottom: 5px; }
.pw-bar { height: 8px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.pw-bar i { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--yellow), var(--green)); transition: width .5s; }

/* ============ Telegram ============ */
.telegram-send {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  margin-bottom: 14px;
}
.telegram-send .ts-ico { width: 42px; height: 42px; flex: 0 0 42px; border-radius: 12px; background: linear-gradient(135deg, #2aabee, #229ed9); display: grid; place-items: center; color: #fff; }
.telegram-send .ts-ico svg { width: 21px; height: 21px; }
.telegram-send .ts-label { font-size: 13px; font-weight: 800; color: var(--text); }
.telegram-send .ts-sub { font-size: 11px; color: var(--text-3); margin-top: 1px; }

.test-console {
  background: var(--navy);
  color: #c9d6ec;
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-family: "SFMono-Regular", Consolas, "Cascadia Code", monospace;
  font-size: 12px;
  line-height: 1.6;
  max-height: 220px;
  overflow-y: auto;
  margin-top: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}
.test-console::-webkit-scrollbar { width: 7px; }
.test-console::-webkit-scrollbar-thumb { background: rgba(255,255,255,.18); border-radius: 4px; }
.test-console .tc-line { color: #9aa9c0; }
.test-console .tc-line.ok { color: #7ee2a6; }
.test-console .tc-line.err { color: #f5a3a0; }
.test-console .tc-line.sent { color: #9fd6ff; }
.test-console .tc-caret { animation: blink 1s step-end infinite; color: #4ade80; }
@keyframes blink { 50% { opacity: 0; } }

.toast-wrap {
  position: fixed; top: 72px; right: 18px; z-index: 150;
  display: flex; flex-direction: column; gap: 10px;
}
.toast {
  display: flex; align-items: flex-start; gap: 11px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--blue);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 13px 16px;
  min-width: 280px; max-width: 380px;
  animation: slideIn .25s ease;
}
.toast.success { border-left-color: var(--green); }
.toast.error { border-left-color: var(--red); }
.toast.warning { border-left-color: var(--amber); }
.toast.out { animation: slideOut .25s ease forwards; }
.toast .ts-ico { color: var(--blue); margin-top: 1px; display: grid; place-items: center; }
.toast.success .ts-ico { color: var(--green); }
.toast.error .ts-ico { color: var(--red); }
.toast.warning .ts-ico { color: var(--amber); }
.toast .ts-ico svg { width: 18px; height: 18px; }
.toast .ts-msg { font-size: 13px; font-weight: 600; color: var(--text); }
.toast .ts-close { margin-left: auto; background: none; border: none; color: var(--text-3); width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; }
.toast .ts-close:hover { background: var(--surface-2); color: var(--text); }
.toast .ts-close svg { width: 14px; height: 14px; }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes slideOut { to { transform: translateX(30px); opacity: 0; } }

/* ============ Fullscreen modal ============ */
.fs-mask {
  position: fixed; inset: 0; z-index: 160;
  background: var(--bg);
  display: flex; flex-direction: column;
  opacity: 0; visibility: hidden;
  transition: opacity .2s ease, visibility .2s ease;
}
.fs-mask.open { opacity: 1; visibility: visible; }
.fs-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.fs-bar .fs-title { font-size: 14px; font-weight: 800; color: var(--text); }
.fs-body { flex: 1; min-height: 0; padding: 14px 18px; position: relative; }
.fs-body .chart-box { height: 100%; }

/* ============ Skeleton / Empty / Error ============ */
.skeleton { position: relative; overflow: hidden; background: var(--surface-2); border-radius: 12px; }
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--text) 6%, transparent), transparent);
  animation: shimmer 1.3s infinite;
}
@keyframes shimmer { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }

.empty-state {
  display: grid; place-items: center;
  text-align: center;
  color: var(--text-3);
  padding: 40px 20px;
}
.empty-state svg { width: 46px; height: 46px; margin-bottom: 10px; opacity: .55; display: block; margin-inline: auto; }
.empty-state .es-title { font-size: 14px; font-weight: 800; color: var(--text-2); }
.empty-state .es-sub { font-size: 12px; margin-top: 3px; max-width: 340px; }

.error-banner {
  display: flex; align-items: center; gap: 12px;
  background: var(--coral-soft);
  color: var(--coral);
  border: 1px solid color-mix(in srgb, var(--coral) 30%, transparent);
  border-radius: var(--radius-sm);
  padding: 13px 16px;
  font-size: 13px; font-weight: 600;
  margin-bottom: 14px;
}
.error-banner svg { width: 20px; height: 20px; flex: 0 0 20px; }

/* ============ Pagination ============ */
.pagination {
  display: flex; align-items: center; gap: 6px;
  justify-content: flex-end;
  padding: 12px 14px;
}
.pagination button {
  min-width: 32px; height: 32px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  border-radius: 9px;
  font-size: 12.5px; font-weight: 700;
  transition: all .18s;
}
.pagination button:hover:not(:disabled) { border-color: var(--blue); color: var(--blue); }
.pagination button.active { background: var(--blue); color: #fff; border-color: var(--blue); }
.pagination button:disabled { opacity: .4; cursor: not-allowed; }

/* ============ Code / API docs ============ */
.code-block {
  background: var(--navy);
  color: #cdd9ef;
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  font-family: "SFMono-Regular", Consolas, "Cascadia Code", monospace;
  font-size: 12px;
  line-height: 1.65;
  overflow-x: auto;
  overflow-y: auto;
  max-height: 420px;
  margin-top: 8px;
  white-space: pre;
}
.code-block::-webkit-scrollbar { width: 7px; height: 7px; }
.code-block::-webkit-scrollbar-thumb { background: rgba(255,255,255,.18); border-radius: 4px; }
.code-block .c-key { color: #7dd3fc; }
.code-block .c-str { color: #86efac; }
.code-block .c-num { color: #fcd34d; }
.code-block .c-com { color: #64748b; }
.code-block .c-meth { color: #f0abfc; font-weight: 700; }
.api-method {
  display: inline-block; font-size: 10.5px; font-weight: 800;
  padding: 3px 9px; border-radius: 6px;
  letter-spacing: .4px;
}
.api-method.get { background: var(--green-soft); color: var(--green); }
.api-method.post { background: var(--blue-soft); color: var(--blue); }
.endpoint-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.endpoint-row:last-child { border-bottom: none; }
.endpoint-row .ep-url { font-family: "SFMono-Regular", Consolas, monospace; font-size: 12.5px; color: var(--text); font-weight: 600; flex: 1; min-width: 200px; word-break: break-all; }
.endpoint-row .ep-desc { width: 100%; font-size: 12px; color: var(--text-2); }

.tabs {
  display: inline-flex; align-items: center; gap: 3px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 3px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.tab-btn {
  border: none; background: transparent;
  padding: 8px 16px; border-radius: 8px;
  font-size: 12.5px; font-weight: 700;
  color: var(--text-2);
  transition: all .18s;
}
.tab-btn:hover { color: var(--blue); }
.tab-btn.active { background: var(--surface); color: var(--blue); box-shadow: var(--shadow-sm); border: 1px solid var(--border); }

.note-box {
  display: flex; gap: 11px;
  border: 1px solid color-mix(in srgb, var(--blue) 30%, transparent);
  background: var(--blue-soft);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 12px 15px;
  font-size: 12.5px;
  margin: 10px 0;
}
.note-box svg { width: 18px; height: 18px; color: var(--blue); flex: 0 0 18px; margin-top: 1px; }

.card-list { display: flex; flex-direction: column; gap: 12px; }
.list-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 15px;
  background: var(--surface-2);
  flex-wrap: wrap;
}
.list-row .lr-left { display: flex; align-items: center; gap: 11px; min-width: 0; }
.list-row .lr-ico { width: 36px; height: 36px; flex: 0 0 36px; border-radius: 10px; background: var(--blue-soft); color: var(--blue); display: grid; place-items: center; }
.list-row .lr-ico svg { width: 18px; height: 18px; }
.list-row .lr-title { font-size: 13px; font-weight: 800; color: var(--text); }
.list-row .lr-sub { font-size: 11px; color: var(--text-3); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 420px; }

/* about feature tiles */
.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.feature-tile {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  background: var(--surface-2);
  transition: transform .18s, box-shadow .18s;
}
.feature-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.feature-tile .ft-ico { width: 40px; height: 40px; border-radius: 11px; background: var(--blue-soft); color: var(--blue); display: grid; place-items: center; margin-bottom: 11px; }
.feature-tile .ft-ico svg { width: 20px; height: 20px; }
.feature-tile .ft-title { font-size: 13.5px; font-weight: 800; color: var(--text); }
.feature-tile .ft-text { font-size: 12px; color: var(--text-2); margin-top: 4px; line-height: 1.55; }

/* back to top */
.back-to-top {
  position: fixed; right: 18px; bottom: 18px; z-index: 70;
  width: 42px; height: 42px; border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  box-shadow: var(--shadow);
  display: grid; place-items: center;
  opacity: 0; visibility: hidden;
  transition: all .2s;
}
.back-to-top.show { opacity: 1; visibility: visible; }
.back-to-top:hover { color: var(--blue); transform: translateY(-2px); }
.back-to-top svg { width: 19px; height: 19px; }

.footer {
  max-width: 1600px; margin: 0 auto;
  padding: 18px 20px 30px;
  text-align: center;
  font-size: 11.5px; color: var(--text-3);
}
.footer b { color: var(--text-2); }

/* ============ Responsive ============ */
@media (max-width: 1280px) {
  .status-grid { grid-template-columns: repeat(3, 1fr); }
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .summary-stats { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 1024px) {
  .hero { padding: 20px 22px; }
  .hero-stats { padding: 10px 16px; gap: 18px; }
  .feature-grid { grid-template-columns: repeat(2, 1fr); }
  .device-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  body { font-size: 13px; }
  .topbar { padding: 0 12px; }
  .tb-sub, .live-clock { display: none; }
  .status-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .summary-stats { grid-template-columns: 1fr; }
  .hero { padding: 18px; }
  .hero-stats { width: 100%; justify-content: space-around; }
  .main { padding: 14px 12px 30px; }
  .trend-legend { display: none; }
  .chart-toolbar { margin-left: 0; }
  .snap-grid { grid-template-columns: 1fr; }
  .health-row { grid-template-columns: 1fr; }
  .toast-wrap { left: 12px; right: 12px; min-width: 0; }
  .toast { min-width: 0; max-width: none; width: 100%; }
  .cr-pop { right: 50%; transform: translateX(50%); width: 260px; }
}
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .status-grid { grid-template-columns: 1fr 1fr; }
  .status-item { padding: 10px 11px; }
  .page-head h1 { font-size: 20px; }
  .lang-toggle button { padding: 5px 10px; }
  .hero h1 { font-size: 18px; }
  .hero-stat .hs-value { font-size: 19px; }
}

/* ============ Scrollbars ============ */
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; border: 3px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ============ Print ============ */
@media print {
  .topbar, .drawer, .drawer-overlay, .back-to-top, .footer, .chart-controls, .chart-hint, .chart-toolbar, .live-dot, .lang-toggle, .no-print { display: none !important; }
  body { background: #fff; }
  .main { padding: 0; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}
/* ============================================================
   Legacy/compatibility helpers used by page-level scripts
   ============================================================ */
.muted { color: var(--text-3); }
.small { font-size: 11.5px; }
.num { font-variant-numeric: tabular-nums; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 10.5px; font-weight: 800;
  padding: 3px 10px; border-radius: 99px;
  letter-spacing: .3px; white-space: nowrap;
}
.badge.alert-solid { background: var(--coral-soft); color: var(--coral); }
.badge.normal-solid { background: var(--green-soft); color: var(--green); }
.badge.normal { background: var(--border); color: var(--text-2); }

.info-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
}
.info-row:last-child { border-bottom: none; }
.info-row .ir-label { color: var(--text-3); font-weight: 600; font-size: 12px; }
.info-row .ir-value { color: var(--text); font-weight: 700; text-align: right; }

.loading-slot { padding: 14px 0; color: var(--text-3); font-size: 12.5px; display: flex; align-items: center; gap: 8px; }
.spinner {
  display: inline-block; width: 15px; height: 15px;
  border: 2px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.section-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 9px;
}
.section-link { font-size: 12px; font-weight: 700; color: var(--blue); }

.filters { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 14px; padding: 16px 18px; }
.select-label {
  font-size: 10.5px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .5px; color: var(--text-3);
  margin-bottom: 5px;
}
.flex { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }

.seg {
  display: inline-flex; gap: 3px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
}
.seg button {
  border: none; background: transparent;
  padding: 7px 14px; border-radius: 7px;
  font-size: 12px; font-weight: 700; color: var(--text-2);
  transition: all .18s;
}
.seg button:hover { color: var(--blue); }
.seg button.active { background: var(--blue); color: #fff; box-shadow: 0 4px 10px rgba(47,107,255,.3); }

.search-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.search-bar input { flex: 1; min-width: 220px; }

.form-control {
  padding: 9px 12px; font-size: 13px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  transition: border .18s, box-shadow .18s;
}
.form-control:focus { border-color: var(--blue); box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 18%, transparent); }
select.form-control { cursor: pointer; }

.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table thead th {
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .4px;
  text-align: left; padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
.data-table tbody tr:hover { background: color-mix(in srgb, var(--blue) 5%, transparent); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tr.row-alert td { background: color-mix(in srgb, var(--coral) 6%, transparent); }
th.sortable .arr { font-size: 9px; margin-left: 3px; color: var(--blue); }

.page-btn {
  min-width: 32px; height: 32px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  border-radius: 9px;
  font-size: 12.5px; font-weight: 700;
  transition: all .18s;
}
.page-btn:hover:not(:disabled) { border-color: var(--blue); color: var(--blue); }
.page-btn.active { background: var(--blue); color: #fff; border-color: var(--blue); }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }
.page-info { margin-left: 8px; font-size: 12px; color: var(--text-3); }

.settings-list { display: flex; flex-direction: column; }
.settings-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.settings-row:last-child { border-bottom: none; }
.settings-row .sr-label { font-size: 13px; font-weight: 700; color: var(--text); }
.settings-row .sr-hint { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.settings-row .sr-value { font-size: 13px; font-weight: 700; color: var(--text-2); text-align: right; }

.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.stat-cell {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 11px;
  background: var(--surface-2);
}
.stat-cell .sv { font-size: 15px; font-weight: 800; color: var(--text); letter-spacing: -.3px; }
.stat-cell .sv small { font-size: 10px; color: var(--text-3); font-weight: 700; }
.stat-cell .sl { font-size: 9px; color: var(--text-3); font-weight: 700; text-transform: uppercase; letter-spacing: .3px; margin-top: 2px; }
.stat-cell.worst-aqi { transition: background .3s; }
.stat-cell { transition: transform .15s; }
.stat-cell:hover { transform: translateY(-1px); }

.stats-cards { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 18px; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 15px 16px;
  box-shadow: var(--shadow-sm);
}
.stat-card .sc-label { font-size: 10.5px; color: var(--text-3); font-weight: 800; text-transform: uppercase; letter-spacing: .5px; }
.stat-card .sc-value { font-size: 23px; font-weight: 800; color: var(--text); letter-spacing: -.4px; margin-top: 6px; display: block; }
.stat-card .sc-value small { font-size: 12px; color: var(--text-3); font-weight: 700; }
.stat-card .sc-trend { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 800; margin-top: 6px; }
.stat-card .sc-trend.up { color: var(--green); }
.stat-card .sc-trend.down { color: var(--coral); }
@media (max-width: 1280px) { .stats-cards { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 768px) { .stats-cards { grid-template-columns: repeat(2, 1fr); } }

.about-hero {
  display: flex; align-items: center; gap: 16px;
  background: var(--grad-hero);
  color: #fff;
  border-radius: var(--radius);
  padding: 24px 28px;
  box-shadow: 0 12px 30px rgba(31,74,190,.3);
}
.about-hero h1 { font-size: 21px; font-weight: 800; }
.about-hero p { margin-top: 4px; opacity: .85; font-size: 13px; }
.about-hero .ah-ico {
  width: 56px; height: 56px; flex: 0 0 56px;
  border-radius: 16px;
  background: rgba(255,255,255,.18);
  display: grid; place-items: center;
}
.about-hero .ah-ico svg { width: 30px; height: 30px; }

.info-ico-row { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.info-ico-row .di-ico {
  width: 48px; height: 48px; flex: 0 0 48px; border-radius: 14px;
  background: var(--grad-brand); color: #fff;
  display: grid; place-items: center;
  box-shadow: 0 6px 14px rgba(47,107,255,.3);
}
.info-ico-row .di-ico svg { width: 24px; height: 24px; }
.info-ico-row .di-name { font-size: 15px; font-weight: 800; color: var(--text); }
.info-ico-row .di-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }

.endpoint-card { margin-bottom: 16px; }
.ep-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ep-method {
  display: inline-block; font-size: 11px; font-weight: 800;
  padding: 4px 11px; border-radius: 7px; letter-spacing: .5px;
}
.ep-method.post { background: var(--blue-soft); color: var(--blue); }
.ep-method.get { background: var(--green-soft); color: var(--green); }
.ep-url { font-family: "SFMono-Regular", Consolas, monospace; font-size: 13.5px; font-weight: 700; color: var(--text); }
.ep-desc { font-size: 12.5px; color: var(--text-2); margin-top: 8px; }

.copy-float {
  position: relative; float: right;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.15);
  color: #c9d6ec;
  border-radius: 7px;
  padding: 4px 9px;
  font-size: 10.5px; font-weight: 700;
  display: inline-flex; align-items: center; gap: 5px;
  cursor: pointer;
}
.copy-float:hover { background: rgba(255,255,255,.16); }
.copy-float svg { width: 12px; height: 12px; }
.btn.ghost { background: transparent; }

.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }

.dsc-en, .dsc-th { margin-right: 4px; }

.code-block code { display: block; color: #cdd9ef; }
.tok-k { color: #7dd3fc; }
.tok-s { color: #86efac; }
.tok-n { color: #fcd34d; }
.tok-b { color: #f0abfc; }

/* ============ Sticky table headers ============ */
.table-scroll table.data-table thead th {
  position: sticky; top: 0; z-index: 5;
  background: var(--surface-2);
}

/* ============ Stale / offline status ============ */
.status-item.stale {
  border-color: color-mix(in srgb, var(--orange) 55%, var(--border));
  background: color-mix(in srgb, var(--orange) 6%, var(--surface));
}
.stale-note {
  display: inline-block; margin-left: 6px;
  font-size: 10px; font-weight: 800;
  color: var(--orange);
  padding: 1px 7px; border-radius: 99px;
  background: color-mix(in srgb, var(--orange) 16%, transparent);
  vertical-align: 1px;
}

/* ============ Card grid (about/settings/device/telegram) ============ */
.card-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
@media (max-width: 1100px) { .card-grid { grid-template-columns: 1fr; } }

/* wrap safe: long values + badges in info rows */
.info-row .ir-value { min-width: 0; overflow-wrap: anywhere; }
.info-row .ir-value .badge { flex-shrink: 0; }

/* ============ Air Quality Guide ============ */
.g-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.g-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  min-width: 0;
}
.g-card .g-pad { padding: 16px 18px; }
.g-head { display: flex; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.g-head .g-name { font-size: 14px; font-weight: 800; color: var(--text); }
.g-head .g-live { margin-left: auto; text-align: right; }
.g-head .g-live .g-value { font-size: 20px; font-weight: 800; color: var(--text); line-height: 1; letter-spacing: -.4px; }
.g-head .g-live .g-live-label { font-size: 9.5px; color: var(--text-3); font-weight: 700; text-transform: uppercase; letter-spacing: .4px; margin-top: 3px; }
.g-scale { position: relative; margin-top: 14px; }
.g-bands { position: relative; height: 10px; border-radius: 999px; overflow: hidden; display: flex; }
.g-band { flex: 0 0 auto; height: 100%; min-width: 0; }
.g-marker {
  position: absolute; left: 2%;
  top: -8px;
  font-size: 13px; line-height: 1;
  color: var(--text);
  z-index: 3;
  display: none;
  transform: translateX(-50%);
  text-shadow: 0 0 0 3px var(--surface);
  transition: left .4s ease;
}
.g-legend { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.g-lrow { display: flex; align-items: center; gap: 9px; font-size: 12px; color: var(--text-2); }
.g-lrow .g-swatch { width: 12px; height: 12px; border-radius: 4px; flex: 0 0 12px; }
.g-lrow .g-lmin { margin-left: auto; font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.g-note { margin-top: 12px; font-size: 11.5px; color: var(--text-3); line-height: 1.5; }
.g-expl {
  margin-top: 10px;
  display: flex; align-items: flex-start; gap: 8px;
  font-size: 12px; font-weight: 600; line-height: 1.5;
  color: var(--text-2);
  background: color-mix(in srgb, var(--text-2) 5%, var(--surface));
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
}
.g-expl-badge { flex: 0 0 8px; width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; }
.g-meta { margin-top: 12px; border-top: 1px dashed var(--border); padding-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.g-mrow { display: flex; align-items: flex-start; gap: 8px; font-size: 11.5px; color: var(--text-2); line-height: 1.45; }
.g-mrow svg { flex: 0 0 15px; width: 15px; height: 15px; margin-top: 1px; }
.g-chip { display: inline-flex; align-items: center; gap: 5px; flex: 0 0 auto; font-size: 10px; font-weight: 800; letter-spacing: .3px; text-transform: uppercase; color: var(--blue); background: color-mix(in srgb, var(--blue) 10%, var(--surface-2)); border: 1px solid color-mix(in srgb, var(--blue) 30%, var(--border)); border-radius: 999px; padding: 2px 8px; }
.g-note-card {
  grid-column: 1 / -1;
  background: color-mix(in srgb, var(--blue) 5%, var(--surface));
  border: 1px dashed color-mix(in srgb, var(--blue) 35%, var(--border));
}
@media (max-width: 700px) { .g-grid { grid-template-columns: 1fr; } }

/* ============ Simulator ============ */
.sim-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 10.5px; font-weight: 800; letter-spacing: .6px;
  color: var(--orange);
  background: color-mix(in srgb, var(--orange) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--orange) 45%, transparent);
  padding: 4px 11px; border-radius: 99px;
}
.sim-badge .sim-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--orange);
  animation: blink 1.4s step-end infinite;
}
.sim-note { font-size: 12px; color: var(--text-3); line-height: 1.5; }
.sim-form { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 12px; }
.sim-form .select-label { grid-column: 1 / -1; }
.sim-check { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-2); cursor: pointer; grid-column: 1 / -1; }
.sim-check input { accent-color: var(--blue); width: 15px; height: 15px; }
.sim-result { margin-top: 12px; }
.sim-result .sim-ok { color: var(--green); }
.sim-result .sim-fail { color: var(--red); }
@media (max-width: 520px) { .sim-form { grid-template-columns: 1fr; } }

/* ============ History custom range ============ */
.history-custom { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding-top: 10px; }
.history-custom input[type="datetime-local"] {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  font-size: 12.5px;
  padding: 7px 10px;
  font-family: inherit;
}
.history-custom input[type="datetime-local"]:focus { outline: none; border-color: var(--blue); }

/* ============ API tester ============ */
.tester-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1100px) { .tester-grid { grid-template-columns: 1fr; } }
.tester-params { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.tester-param { display: grid; grid-template-columns: 110px 1fr; align-items: center; gap: 8px; }
.tester-param .select-label { font-size: 11.5px; margin: 0; }
.tester-form { grid-template-columns: repeat(2, 1fr); gap: 8px 10px; align-items: center; }
.tester-form .select-label { font-size: 11.5px; margin: 0; }
.tester-meta { margin-left: 10px; font-variant-numeric: tabular-nums; }
.test-out { max-height: 300px; overflow: auto; }
.test-out code { display: block; white-space: pre-wrap; word-break: break-word; font-size: 12px; }
.test-out.ok { border: 1px solid color-mix(in srgb, var(--green) 40%, transparent); }
.test-out.err { border: 1px solid color-mix(in srgb, var(--coral) 55%, transparent); }
