/* ── Theme Tokens ───────────────────────────────────────── */
:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #eef3fb;
  --text: #1f2937;
  --muted: #64748b;
  --border: #d9e2ef;
  --brand: #2563eb;
  --brand-strong: #1d4ed8;
  --navbar-bg: #ffffff;
  --navbar-text: #334155;
  --navbar-hover: #eff6ff;
  --navbar-active: #dbeafe;
  --shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

[data-theme="dark"] {
  --bg: #0b1220;
  --surface: #121b2d;
  --surface-soft: #182338;
  --text: #e5edf7;
  --muted: #9fb0c8;
  --border: #26334d;
  --brand: #60a5fa;
  --brand-strong: #3b82f6;
  --navbar-bg: #101827;
  --navbar-text: #d5deec;
  --navbar-hover: #1f2a40;
  --navbar-active: #25385a;
  --shadow: 0 12px 30px rgba(2, 6, 23, 0.35);
}

html, body {
  background: var(--bg);
  color: var(--text);
}

.box,
.card,
.table {
  background-color: var(--surface);
  color: var(--text);
}

/* ── Dashboard 100vh Layout ────────────────────────────── */
.section-dashboard {
  padding: 0 !important;
}
.section-dashboard > .container {
  max-width: 100%;
  padding: 0.5rem 1rem 0;
}

/* Desktop: lock to viewport, no scroll */
@media screen and (min-width: 1024px) {
  body.page-dashboard {
    overflow: hidden;
  }
  .dashboard-page {
    height: calc(100vh - 3.75rem);
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }
  .dashboard-page > .columns.is-multiline {
    flex: 0 0 auto;
    margin-bottom: 0.25rem;
  }
  .dashboard-page > .columns:not(.is-multiline) {
    flex: 1 1 0;
    min-height: 0;
    margin-bottom: 0.25rem;
  }
  .dashboard-page .column > .box {
    height: 100%;
    display: flex;
    flex-direction: column;
  }
  .dashboard-page .column > .box > .subtitle {
    flex: 0 0 auto;
    margin-bottom: 0.5rem;
  }
  .dashboard-page .chart-container {
    flex: 1 1 0;
    min-height: 0;
  }
}

/* Mobile / Tablet: scrollable with fixed-height charts */
@media screen and (max-width: 1023px) {
  .dashboard-page .chart-container {
    height: 250px;
  }
}

/* ── Navbar ─────────────────────────────────────────────── */
.app-navbar {
  background: var(--navbar-bg);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.app-navbar .navbar-item,
.app-navbar .navbar-link {
  color: var(--navbar-text);
}
.app-navbar .navbar-brand .navbar-item {
  font-weight: 700;
  letter-spacing: 0.2px;
  color: var(--brand-strong);
}
.app-navbar .navbar-end .navbar-item {
  margin: 0.35rem 0.22rem;
  border-radius: 10px;
  padding: 0.45rem 0.9rem;
  transition: background-color 0.2s ease, color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
}
.app-navbar .navbar-end .navbar-item:hover {
  background: var(--navbar-hover) !important;
  color: var(--brand-strong) !important;
  transform: translateY(-1px);
}
.app-navbar .navbar-end .navbar-item.is-active {
  background: var(--navbar-active) !important;
  color: var(--brand-strong) !important;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--brand) 45%, transparent);
}
.app-navbar .navbar-burger {
  color: var(--navbar-text);
}
.app-navbar .navbar-burger:hover {
  background: var(--navbar-hover);
}
.theme-toggle {
  border-radius: 999px !important;
  border: 1px solid var(--border) !important;
  background: var(--surface-soft) !important;
  color: var(--navbar-text) !important;
  font-size: 0.8rem;
}
.theme-toggle:hover {
  background: var(--navbar-hover) !important;
}
@media screen and (max-width: 1023px) {
  .app-navbar .navbar-menu {
    background: var(--navbar-bg);
    border-top: 1px solid var(--border);
    box-shadow: var(--shadow);
  }
  .app-navbar .navbar-end .navbar-item {
    margin: 0.2rem 0;
  }
}

/* ── Stat Cards ────────────────────────────────────────── */
.stat-card {
  border-left: 4px solid hsl(171, 100%, 41%);
}
.stat-card:nth-child(2) { border-left-color: #3b82f6; }
.stat-card:nth-child(3) { border-left-color: #f59e0b; }
.stat-card:nth-child(4) { border-left-color: #8b5cf6; }
.stat-card .stat-label {
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  margin-bottom: .25rem;
}
.stat-card .stat-value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.15;
  color: var(--text);
}

/* ── Chart Panels ──────────────────────────────────────── */
.chart-container {
  position: relative;
}

/* ── Status Badges (custom overrides on Bulma tags) ───── */
.status-badge {
  font-variant-numeric: tabular-nums;
  min-width: 3em;
  justify-content: center;
}

/* ── Filter Panel ──────────────────────────────────────── */
.filter-panel fieldset {
  min-width: 0;
}
.filter-panel .select,
.filter-panel .select select {
  width: 100%;
  max-width: 100%;
}
.filter-panel {
  margin-bottom: 1.5rem;
}
.filter-panel summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 1.05rem;
  list-style: none;
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .75rem 0;
}
.filter-panel summary::-webkit-details-marker { display: none; }
.filter-panel summary::before {
  content: "\25B6";
  font-size: .65em;
  transition: transform .2s;
}
.filter-panel[open] summary::before {
  transform: rotate(90deg);
}

/* ── Log Table ─────────────────────────────────────────── */
.query-page {
  width: min(95vw, 1900px);
  margin: 0 auto;
}
.query-layout {
  width: min(95vw, 1900px);
  margin: 0 auto;
}
.query-page .table-container {
  overflow-x: auto;
  overflow-y: hidden;
}
.log-table {
  font-size: .875rem;
  width: 100%;
}
.log-table th { white-space: nowrap; }
.log-table th a { display: inline-flex; align-items: center; gap: .3em; }
.log-table th a:hover { opacity: .7; }
.log-table td { vertical-align: middle; }
.log-table code {
  font-size: .8rem;
  word-break: break-all;
}
.ua-cell {
  max-width: 360px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Upload Drop Zone ──────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: 6px;
  padding: 3rem 2rem;
  text-align: center;
  transition: border-color .2s, background .2s;
  cursor: pointer;
  background: var(--surface);
}
.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--brand);
  background: color-mix(in srgb, var(--brand) 9%, var(--surface));
}
.drop-zone p {
  margin-top: .75rem;
  color: var(--muted);
  font-size: .95rem;
}
.drop-zone input[type="file"] { display: none; }

/* ── Upload JSON Preview ───────────────────────────────── */
.example-card {
  background: var(--surface-soft);
  border: 1px solid var(--border);
}
.example-card .subtitle {
  color: var(--text);
}
.json-preview {
  margin: 0;
  padding: 1rem 1.1rem;
  border-radius: 10px;
  background: #020617;
  border: 1px solid rgba(148, 163, 184, 0.25);
  overflow-x: auto;
}
.json-preview code {
  color: #e2e8f0;
  line-height: 1.55;
  font-size: 0.9rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}
.json-key { color: #7dd3fc; }
.json-string { color: #86efac; }
.json-comment { color: #94a3b8; font-style: italic; }

/* ── Misc ──────────────────────────────────────────────── */
.method-tag {
  font-family: monospace;
  font-size: .8rem;
  font-weight: 600;
}
.hidden { display: none !important; }

/* Human */
.columns > .column {
  flex: 1 !important;
}
.control > span {
  height: 100% !important;
}