/* ==========================================================================
   Bangladesh Sports Intelligence (BSI) — Eye-Soothing Dark-First Theme
   Calm muted forest-slate palette with soft light fallback. Zero harsh glare.
   ========================================================================== */
:root,
[data-theme="dark"] {
  --bg: #111715;
  --bg-elev: #151d1a;
  --card: #1a2320;
  --card-hover: #1f2a26;
  --ink: #dde8e3;
  --ink-soft: #b5c5be;
  --mut: #889890;
  --ln: #27322e;
  --ab: #4d8e76;
  --ab2: #3a7a66;
  --ab-soft: rgba(77, 142, 118, 0.16);
  --g: #7fc29f;
  --g-soft: rgba(127, 194, 159, 0.14);
  --a: #d6a85f;
  --a-soft: rgba(214, 168, 95, 0.14);
  --r: #e2938a;
  --r-soft: rgba(226, 147, 138, 0.15);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  --radius: 14px;
  --radius-sm: 10px;
}

[data-theme="light"] {
  --bg: #f1f4ef;
  --bg-elev: #e8ede6;
  --card: #fcfdfb;
  --card-hover: #f5f8f3;
  --ink: #24322d;
  --ink-soft: #3d4f48;
  --mut: #67776e;
  --ln: #dce3d9;
  --ab: #3b7d65;
  --ab2: #2e6753;
  --ab-soft: rgba(59, 125, 101, 0.12);
  --g: #357a57;
  --g-soft: rgba(53, 122, 87, 0.12);
  --a: #a87724;
  --a-soft: rgba(168, 119, 36, 0.12);
  --r: #b65348;
  --r-soft: rgba(182, 83, 72, 0.12);
  --shadow: 0 6px 20px rgba(24, 38, 32, 0.07);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}

a { color: var(--g); text-decoration: none; }
a:hover { text-decoration: underline; }

.hidden { display: none !important; }
body.no-scroll { overflow: hidden; }

/* Utility spacing classes (CSP-safe replacement for inline styles) */
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-18 { margin-top: 18px; }
.mt-22 { margin-top: 22px; }
.mb-6 { margin-bottom: 6px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-14 { margin-bottom: 14px; }
.desk-queue-wrap { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--ln); }
.desk-queue-row { justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--ln); }

/* Auth Gate */
.auth-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--card);
  border: 1px solid var(--ln);
  border-radius: 20px;
  padding: 28px;
  box-shadow: var(--shadow);
}
.auth-title { margin: 0; font-size: 1.2rem; font-weight: 700; }
.auth-sub { margin: 2px 0 0; font-size: 0.85rem; color: var(--mut); }
.auth-foot {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--ln);
  font-size: 0.76rem;
  color: var(--mut);
  text-align: center;
}

/* Layout Shell */
.app-shell {
  display: grid;
  grid-template-columns: 256px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--bg-elev);
  border-right: 1px solid var(--ln);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  padding-bottom: max(18px, env(safe-area-inset-bottom));
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  z-index: 50;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px 16px;
  border-bottom: 1px solid var(--ln);
}

.brand-row { display: flex; align-items: center; gap: 11px; }
.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--ab);
  color: #f4faf7;
  font-weight: 800;
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.brand-name { font-weight: 700; font-size: 0.98rem; line-height: 1.2; }
.brand-tag { font-size: 0.74rem; color: var(--mut); }

.sidebar-search {
  margin-top: 12px;
}
.sidebar-search input {
  width: 100%;
  padding: 8px 11px;
  font-size: 0.84rem;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid var(--ln);
  color: var(--ink);
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
  flex: 1;
  overflow-y: auto;
}

.nav-group {
  border-bottom: 1px solid var(--ln);
  padding-bottom: 6px;
}
.nav-group:last-child { border-bottom: none; }
.nav-group-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: transparent;
  border: none;
  color: var(--ink);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  border-radius: 8px;
}
.nav-group-toggle:hover { background: var(--card); }
.nav-chev {
  color: var(--mut);
  transition: transform 170ms ease;
  font-size: 0.85rem;
}
.nav-group:not(.open) .nav-chev { transform: rotate(-90deg); }
.nav-group-items {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-left: 14px;
  margin-top: 2px;
}
.nav-group:not(.open) .nav-group-items { display: none; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 0.91rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 170ms cubic-bezier(.2,.8,.2,1), color 170ms ease, border-color 170ms ease;
}
.nav-item:hover { background: var(--card); color: var(--ink); }
.nav-item.active {
  background: var(--ab-soft);
  color: var(--ink);
  border-color: rgba(77, 142, 118, 0.35);
  font-weight: 600;
}

.nav-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--mut);
  flex-shrink: 0;
}
.nav-item.active .nav-dot { background: var(--g); }
.live-dot { background: var(--r); }
.intl-dot { background: var(--a); }
.ai-dot { background: var(--g); }

.sidebar-foot {
  margin-top: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--ln);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.user-pill { display: flex; align-items: center; gap: 10px; padding: 4px 6px; }
.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--ab-soft);
  color: var(--g);
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.user-name { font-size: 0.88rem; font-weight: 600; line-height: 1.2; }
.user-role { font-size: 0.74rem; color: var(--mut); text-transform: capitalize; }

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 24px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--ln);
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.view-title { margin: 0; font-size: 1.18rem; font-weight: 700; line-height: 1.25; }
.view-subtitle { font-size: 0.78rem; color: var(--mut); }

.clock-pill {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--ln);
  padding: 6px 12px;
  border-radius: 999px;
  letter-spacing: 0.01em;
}

/* Global ESPNcricinfo-Style Live & Upcoming Ticker Bar (Every Page) */
.global-ticker {
  background: var(--bg-elev);
  border-bottom: 1px solid var(--ln);
  padding: 12px 24px 10px;
}
.global-ticker:empty { display: none; }
.global-ticker .espn-strip {
  margin-bottom: 0;
  max-width: 1380px;
  margin-left: auto;
  margin-right: auto;
}
.espn-live-teams {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.espn-score-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.espn-score-team {
  font-size: 0.92rem;
  font-weight: 650;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.espn-score-team.is-bd { color: var(--g); }
.espn-score-val {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  flex-shrink: 0;
}
.espn-score-meta {
  font-size: 0.74rem;
  color: var(--mut);
  font-weight: 500;
}
.espn-score-num {
  font-size: 0.98rem;
  font-weight: 750;
  color: var(--ink);
}
.espn-status-line {
  font-size: 0.79rem;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.espn-card-clickable { cursor: pointer; }

/* Portal-Style Breaking / Important News Hierarchy */
.card-breaking {
  border-color: rgba(226, 147, 138, 0.55);
  border-left: 3px solid var(--r);
}
.card-breaking .card-title {
  font-size: 1.18rem;
  font-weight: 750;
  color: var(--r);
  line-height: 1.32;
}
.card-regular .card-title {
  font-size: 0.94rem;
  font-weight: 620;
}
.badge-breaking {
  background: var(--r-soft);
  color: var(--r);
  border-color: rgba(226, 147, 138, 0.45);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ESPNcricinfo-Style Match Center / Scorecard Tabs in Drawer */
.mc-header {
  background: var(--bg-elev);
  border: 1px solid var(--ln);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 14px;
}
.mc-score-big {
  font-size: 1.08rem;
  font-weight: 750;
  color: var(--ink);
  margin: 8px 0 6px;
}
.mc-tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--ln);
  padding-bottom: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.mc-tab {
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--ln);
  background: var(--bg-elev);
  color: var(--ink-soft);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}
.mc-tab.active {
  background: var(--ab);
  color: #f4faf7;
  border-color: var(--ab);
}

/* Settings Toggle Row */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--ln);
}

/* Mobile Floating Pill Bottom Nav (Parts Stock Style) */
.mobile-bottom-nav {
  display: none;
}
@media (max-width: 860px) {
  .global-ticker { padding: 10px 12px 8px; }
  .view-container { padding-bottom: 92px; }
  .mobile-bottom-nav {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    align-items: center;
    gap: 4px;
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: max(10px, env(safe-area-inset-bottom));
    z-index: 42;
    background: color-mix(in srgb, var(--card) 94%, transparent);
    backdrop-filter: blur(14px);
    border: 1px solid var(--ln);
    border-radius: 22px;
    padding: 6px 8px;
    box-shadow: var(--shadow);
  }
  .mbn-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 6px 2px;
    border: none;
    border-radius: 14px;
    background: transparent;
    color: var(--mut);
    font: inherit;
    cursor: pointer;
    transition: background 160ms ease, color 160ms ease, transform 120ms ease;
  }
  .mbn-item:active { transform: scale(0.95); }
  .mbn-item.active { color: var(--g); background: var(--ab-soft); }
  .mbn-ico { font-size: 1rem; line-height: 1; }
  .mbn-lbl { font-size: 0.68rem; font-weight: 650; letter-spacing: 0.01em; }
  .mbn-center {
    background: var(--ab);
    color: #f4faf7 !important;
    border-radius: 16px;
    padding: 8px 4px;
    box-shadow: 0 4px 12px rgba(77, 142, 118, 0.35);
  }
  .mbn-center.active { background: var(--ab2); }
}

.view-container {
  padding: 22px 24px 48px;
  max-width: 1380px;
  width: 100%;
  margin: 0 auto;
}

/* Cards, Grids & Controls */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.kpi-card {
  background: var(--card);
  border: 1px solid var(--ln);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.kpi-label { font-size: 0.78rem; color: var(--mut); text-transform: uppercase; letter-spacing: 0.04em; }
.kpi-value { font-size: 1.65rem; font-weight: 700; margin-top: 4px; color: var(--ink); }
.kpi-sub { font-size: 0.76rem; color: var(--mut); margin-top: 2px; }

/* ESPN-style 5-Card Upcoming Bangladesh Strip (Dashboard Top) */
.espn-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.espn-card {
  background: var(--card);
  border: 1px solid var(--ln);
  border-radius: 14px;
  padding: 13px 14px 11px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 220px;
  transition: border-color 170ms ease, background 170ms ease;
}
.espn-card:hover {
  border-color: rgba(77, 142, 118, 0.55);
  background: var(--card-hover);
}
.espn-card-bd {
  border-top: 2px solid var(--ab);
}
.espn-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.7rem;
  letter-spacing: 0.04em;
}
.espn-status {
  font-weight: 700;
  color: var(--g);
  text-transform: uppercase;
}
.espn-status.is-live { color: var(--r); }
.espn-meta-right {
  color: var(--mut);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 65%;
  text-align: right;
}
.espn-body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.espn-teams {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  flex: 1;
}
.espn-team-row {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.9rem;
  font-weight: 650;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.espn-team-row.is-bd { color: var(--g); }
.espn-flag { font-size: 1rem; line-height: 1; flex-shrink: 0; }
.espn-time-col {
  text-align: right;
  flex-shrink: 0;
}
.espn-day {
  font-size: 0.74rem;
  color: var(--mut);
  font-weight: 500;
}
.espn-clock {
  font-size: 1.02rem;
  font-weight: 750;
  color: var(--ink);
  line-height: 1.2;
}
.espn-countdown {
  font-size: 0.77rem;
  color: var(--ink-soft);
}
.espn-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--ln);
  font-size: 0.76rem;
}
.espn-link-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--ink-soft);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.espn-link-btn:hover { color: var(--g); text-decoration: underline; }

/* Upcoming Events 2-Column Split (Left: World Events, Right: Bangladesh Pinned) */
.upcoming-split {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 1fr);
  gap: 18px;
  align-items: start;
}
.upcoming-bd-col {
  position: sticky;
  top: 78px;
}

@media (max-width: 1180px) {
  .espn-strip {
    grid-template-columns: repeat(5, 245px);
  }
}
@media (max-width: 960px) {
  .upcoming-split {
    grid-template-columns: 1fr;
  }
  .upcoming-bd-col {
    position: static;
    order: -1;
  }
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(310px, 100%), 1fr));
  gap: 14px;
}

.panel {
  background: var(--card);
  border: 1px solid var(--ln);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 18px;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.panel-title { margin: 0; font-size: 1rem; font-weight: 700; }
.panel-sub { font-size: 0.8rem; color: var(--mut); margin-top: 2px; }

.card {
  background: var(--card);
  border: 1px solid var(--ln);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 170ms ease, background 170ms ease;
}
.card:hover { border-color: rgba(77, 142, 118, 0.45); background: var(--card-hover); }
.card-title { margin: 0; font-size: 0.96rem; font-weight: 650; line-height: 1.35; }
.card-summary {
  margin: 0;
  font-size: 0.86rem;
  color: var(--ink-soft);
  line-height: 1.48;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  font-size: 0.76rem;
  color: var(--mut);
}
.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid var(--ln);
}

.score-box {
  background: var(--bg-elev);
  border: 1px solid var(--ln);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--ink);
}

.bd-angle-box {
  background: var(--ab-soft);
  border-left: 3px solid var(--ab);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.83rem;
  color: var(--ink);
}
.bd-angle-box strong { color: var(--g); }

/* Badges & Pills */
.badge-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  border: 1px solid var(--ln);
  background: var(--bg-elev);
  color: var(--ink-soft);
}
.badge-live { background: var(--r-soft); color: var(--r); border-color: rgba(226, 147, 138, 0.35); }
.badge-bd { background: var(--g-soft); color: var(--g); border-color: rgba(127, 194, 159, 0.35); }
.badge-confirmed { background: var(--g-soft); color: var(--g); border-color: rgba(127, 194, 159, 0.35); }
.badge-reported { background: var(--ab-soft); color: var(--ink); border-color: rgba(77, 142, 118, 0.35); }
.badge-rumor { background: var(--a-soft); color: var(--a); border-color: rgba(214, 168, 95, 0.4); }

/* Filter Bar & Inputs */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}
.pill-group { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--ln);
  background: var(--card);
  color: var(--ink-soft);
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease;
}
.pill:hover { border-color: var(--ab); color: var(--ink); }
.pill.active { background: var(--ab); color: #f4faf7; border-color: var(--ab); font-weight: 600; }

input[type="text"],
input[type="password"],
input[type="url"],
input[type="datetime-local"],
select,
textarea {
  width: 100%;
  background: var(--bg-elev);
  color: var(--ink);
  border: 1px solid var(--ln);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 160ms ease;
}
input:focus, select:focus, textarea:focus { border-color: var(--ab); }
textarea { resize: vertical; min-height: 110px; line-height: 1.55; }

.search-input { max-width: 280px; }

.form-stack { display: flex; flex-direction: column; gap: 13px; margin-top: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 0.84rem; color: var(--ink-soft); }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, transform 120ms ease;
}
.btn:active { transform: scale(0.985); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--ab); color: #f4faf7; }
.btn-primary:hover:not(:disabled) { background: var(--ab2); }
.btn-secondary { background: var(--card); color: var(--ink); border-color: var(--ln); }
.btn-secondary:hover:not(:disabled) { border-color: var(--ab); }
.btn-ghost { background: transparent; color: var(--ink-soft); border-color: var(--ln); }
.btn-ghost:hover:not(:disabled) { background: var(--card); color: var(--ink); }
.btn-danger { background: var(--r-soft); color: var(--r); border-color: rgba(226, 147, 138, 0.35); }
.btn-sm { padding: 6px 11px; font-size: 0.8rem; }
.btn-full { width: 100%; }

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid var(--ln);
  background: var(--card);
  color: var(--ink);
  font-size: 1.15rem;
  cursor: pointer;
  display: grid;
  place-items: center;
}

/* Banners, Empty States, Toast */
.info-banner {
  background: var(--ab-soft);
  border: 1px solid rgba(77, 142, 118, 0.35);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 0.84rem;
  color: var(--ink);
  margin: 12px 0;
}
.warn-banner {
  background: var(--a-soft);
  border: 1px solid rgba(214, 168, 95, 0.35);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 0.84rem;
  color: var(--ink);
  margin: 12px 0;
}
.error-box {
  background: var(--r-soft);
  border: 1px solid rgba(226, 147, 138, 0.4);
  color: var(--r);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.84rem;
}
.empty-state {
  text-align: center;
  padding: 32px 18px;
  color: var(--mut);
  border: 1px dashed var(--ln);
  border-radius: var(--radius);
  font-size: 0.9rem;
}

.toast {
  position: fixed;
  bottom: 20px;
  right: 22px;
  z-index: 80;
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--ab);
  border-radius: 12px;
  padding: 11px 16px;
  box-shadow: var(--shadow);
  font-size: 0.86rem;
  max-width: 380px;
}

/* AI Report Editor & Preview */
.report-layout {
  display: grid;
  grid-template-columns: 390px 1fr;
  gap: 18px;
  align-items: start;
}
.report-preview {
  background: var(--bg-elev);
  border: 1px solid var(--ln);
  border-radius: var(--radius);
  padding: 22px 24px;
  line-height: 1.7;
  font-size: 0.95rem;
}
.report-preview h1 { margin: 0 0 12px; font-size: 1.45rem; line-height: 1.28; color: var(--ink); }
.report-preview h2 { margin: 20px 0 8px; font-size: 1.08rem; color: var(--g); border-bottom: 1px solid var(--ln); padding-bottom: 4px; }
.report-preview h3 { margin: 16px 0 6px; font-size: 0.98rem; }
.report-preview p { margin: 0 0 12px; color: var(--ink); }
.report-preview ul, .report-preview ol { margin: 0 0 12px; padding-left: 22px; }
.report-preview li { margin-bottom: 5px; }
.report-preview blockquote {
  margin: 12px 0;
  padding: 10px 14px;
  border-left: 3px solid var(--a);
  background: var(--a-soft);
  border-radius: 6px;
  font-size: 0.86rem;
}
.report-editor-area {
  min-height: 420px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.86rem;
}

/* Drawer & Backdrops (clean z-index stack: sidebar-backdrop 45 < sidebar 50 < drawer-backdrop 55 < drawer 60) */
.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 45;
}
#drawer-backdrop { z-index: 55; }
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(560px, 100vw);
  height: 100vh;
  height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--card);
  border-left: 1px solid var(--ln);
  z-index: 60;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}
.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--ln);
}
.drawer-head h3 { margin: 0; font-size: 1.05rem; }
.drawer-body { padding: 18px 20px; overflow-y: auto; flex: 1; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
th, td {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid var(--ln);
}
th { color: var(--mut); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; }

.mobile-only { display: none; }

@media (max-width: 1024px) {
  .report-layout { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .mobile-only { display: inline-grid; }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: min(280px, 84vw);
    z-index: 50;
    transform: translateX(-105%);
    transition: transform 200ms cubic-bezier(.2,.8,.2,1);
  }
  .sidebar.open { transform: translateX(0); }
  .topbar {
    padding: 10px 14px;
    flex-wrap: wrap;
    gap: 8px;
  }
  .topbar-right {
    width: 100%;
    justify-content: space-between;
  }
  .view-subtitle { display: none; }
  .view-container { padding: 14px 12px 44px; }
  .field-grid { grid-template-columns: 1fr; }
  .search-input { max-width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
