/* ── Dashboard CSS
   Color palette:
     --primary       #0f766e   teal
     --primary-hover #0d6860
     --bg            #f9fafb
     --text          #0f172a
     --muted         #64748b
     --border        #e2e8f0
     --sidebar-bg    #1e293b
   ─────────────────────────────────────────────────────────────────────────── */

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

/* Reset styles.css body rules that lock height to viewport (designed for chatbot, not dashboard) */
html, body {
  height: auto;
  overflow: visible;
  display: block;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f9fafb;
  color: #0f172a;
  min-height: 100vh;
}

/* ── Admin key overlay ────────────────────────────────────────────────────── */
#key-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: #1e293b;
  display: flex; align-items: center; justify-content: center;
}
.key-card {
  background: #fff;
  border-radius: 16px;
  padding: 40px 48px;
  width: 100%; max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  text-align: center;
}
.key-card img { width: 48px; margin-bottom: 20px; }
.key-card h2 { font-size: 1.25rem; font-weight: 700; color: #0f172a; margin-bottom: 6px; }
.key-card p  { color: #64748b; font-size: 0.875rem; margin-bottom: 24px; }
.key-input {
  width: 100%; padding: 10px 14px;
  border: 1.5px solid #e2e8f0; border-radius: 8px;
  font-size: 0.9rem; outline: none; transition: border-color .15s;
  margin-bottom: 12px;
}
.key-input:focus { border-color: #0f766e; }
.key-btn {
  width: 100%; padding: 11px;
  background: #0f766e; color: #fff;
  border: none; border-radius: 8px;
  font-size: 0.95rem; font-weight: 600;
  cursor: pointer; transition: background .15s;
}
.key-btn:hover { background: #0d6860; }
.key-error { color: #dc2626; font-size: 0.82rem; margin-top: 10px; min-height: 20px; }
@keyframes shake {
  0%,100%{transform:translateX(0)} 20%{transform:translateX(-8px)} 60%{transform:translateX(8px)}
}
.key-card.shaking { animation: shake .35s ease; }

/* ── Settings panel ───────────────────────────────────────────────────────── */
#settings-overlay {
  display: none; position: fixed; inset: 0; z-index: 299;
  background: rgba(15,23,42,.25);
}
#settings-overlay.open { display: block; }

#settings-panel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 300;
  width: 320px; max-width: 90vw;
  background: #fff;
  box-shadow: -4px 0 40px rgba(0,0,0,.18);
  transform: translateX(100%);
  transition: transform .25s cubic-bezier(.4,0,.2,1);
  display: flex; flex-direction: column;
}
#settings-panel.open { transform: translateX(0); }

.sp-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
}
.sp-title { font-size: 1rem; font-weight: 700; color: #0f172a; }
.sp-close {
  background: transparent; border: none;
  color: #94a3b8; font-size: 1.2rem;
  cursor: pointer; transition: color .15s; padding: 2px 6px;
}
.sp-close:hover { color: #0f172a; }

.sp-body { flex: 1; overflow-y: auto; padding: 8px 0 24px; }

.sp-section {
  padding: 16px 24px;
  border-bottom: 1px solid #f1f5f9;
}
.sp-section-label {
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: #94a3b8; margin-bottom: 10px;
}
.sp-action-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 8px;
  background: #f8fafc; border: 1.5px solid #e2e8f0;
  color: #0f172a; font-size: 0.875rem; cursor: pointer;
  transition: all .15s; width: 100%;
}
.sp-action-btn:hover { border-color: #0f766e; color: #0f766e; background: #f0fdf4; }

.sp-change-key-form { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.sp-key-input {
  padding: 8px 12px; border: 1.5px solid #e2e8f0; border-radius: 8px;
  font-size: 0.875rem; outline: none; transition: border-color .15s;
}
.sp-key-input:focus { border-color: #0f766e; }
.sp-change-key-actions { display: flex; gap: 8px; }
.sp-save-btn {
  flex: 1; padding: 7px; background: #0f766e; color: #fff;
  border: none; border-radius: 8px; font-size: 0.875rem;
  font-weight: 600; cursor: pointer; transition: background .15s;
}
.sp-save-btn:hover { background: #0d6860; }
.sp-cancel-btn {
  flex: 1; padding: 7px; background: #f1f5f9; color: #64748b;
  border: 1.5px solid #e2e8f0; border-radius: 8px; font-size: 0.875rem;
  cursor: pointer; transition: all .15s;
}
.sp-cancel-btn:hover { border-color: #dc2626; color: #dc2626; }
.sp-key-msg { font-size: 0.8rem; min-height: 18px; }
.sp-key-msg.success { color: #15803d; }
.sp-key-msg.error   { color: #dc2626; }

.sp-options { display: flex; gap: 8px; }
.sp-opt-btn {
  flex: 1; padding: 7px; border-radius: 8px;
  border: 1.5px solid #e2e8f0; background: #fff;
  font-size: 0.875rem; cursor: pointer; transition: all .15s;
  font-weight: 500; color: #64748b;
}
.sp-opt-btn:hover { border-color: #0f766e; color: #0f766e; }
.sp-opt-btn.sp-opt-active {
  background: #0f766e; border-color: #0f766e; color: #fff;
}

.sp-options-col { flex-direction: column; gap: 10px; }
.sp-toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 0.875rem; color: #0f172a; cursor: pointer;
}
.sp-toggle-row input[type="checkbox"] { cursor: pointer; accent-color: #0f766e; width: 16px; height: 16px; }

.sp-version { background: #f8fafc; }
.sp-version-text { font-size: 0.78rem; color: #94a3b8; line-height: 1.6; }

/* ── App shell ────────────────────────────────────────────────────────────── */
#app { display: none; flex-direction: column; min-height: 100vh; }

/* ── Topbar ───────────────────────────────────────────────────────────────── */
#topbar {
  position: sticky; top: 0; z-index: 100;
  background: #0f1a1a;
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px; height: 52px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.35);
  border-bottom: 1px solid #1e3a30;
}
.topbar-brand {
  display: flex; align-items: center; gap: 9px;
  text-decoration: none; color: #e2e8f0; flex-shrink: 0;
  height: 100%;
  padding: 0 20px 0 0;
  border-right: 1px solid #1e3a30;
}
.topbar-brand img { width: 26px; height: 26px; border-radius: 6px; }
.topbar-brand span { font-weight: 700; font-size: 14px; }
.topbar-brand-sub { font-weight: 400; color: #7aaa9a; }
.topbar-divider { width: 1px; height: 24px; background: #1e3a30; flex-shrink: 0; }
.topbar-title { color: #94a3b8; font-size: 0.9rem; flex-shrink: 0; }
.topbar-spacer { flex: 1; }

.year-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.year-pill {
  padding: 5px 14px; border-radius: 20px;
  border: 1.5px solid #475569; background: transparent;
  color: #94a3b8; font-size: 0.8rem; font-weight: 500;
  cursor: pointer; transition: all .15s; white-space: nowrap;
}
.year-pill:hover { border-color: #0f766e; color: #5eead4; }
.year-pill.active { background: #0f766e; border-color: #0f766e; color: #fff; font-weight: 600; }

.settings-btn {
  background: transparent; border: none;
  color: #64748b; cursor: pointer; padding: 6px; border-radius: 6px;
  display: flex; align-items: center; transition: color .15s; flex-shrink: 0;
}
.settings-btn:hover { color: #e2e8f0; }

.topbar-compass-btn {
  display: flex; align-items: center; gap: 5px; flex-shrink: 0;
  padding: 5px 14px;
  background: rgba(255,255,255,0.1); color: #e2e8f0;
  border: 1px solid rgba(255,255,255,0.2); border-radius: 7px;
  font-size: 0.88rem; font-weight: 600; text-decoration: none;
  transition: background .15s, color .15s, border-color .15s;
  white-space: nowrap; cursor: pointer;
  letter-spacing: 0.01em;
}
.topbar-compass-btn:hover { background: rgba(255,255,255,0.18); color: #fff; text-decoration: underline; border-color: rgba(255,255,255,0.35); }
body.dark .topbar-compass-btn { border-color: rgba(255,255,255,0.1); }

/* "Ask" shortcut — links to chat assistant */
.topbar-ask-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: 20px;
  background: #0f766e; color: #fff;
  font-size: 0.82rem; font-weight: 600;
  text-decoration: none; flex-shrink: 0;
  transition: background .15s;
}
.topbar-ask-btn:hover { background: #0d6860; }

/* Shared style for info and settings buttons */
.info-btn {
  background: transparent; border: none;
  color: #94a3b8; cursor: pointer; padding: 6px; border-radius: 6px;
  display: flex; align-items: center; transition: color .15s; flex-shrink: 0;
  font-size: 1.15rem; line-height: 1;
}
.info-btn:hover { color: #5eead4; }

/* ── Info panel (slide-in from right, same pattern as settings) ──────────── */
#info-panel {
  position: fixed; top: 0; right: -380px; width: 360px; height: 100vh;
  background: #fff; border-left: 1px solid #e2e8f0;
  box-shadow: -4px 0 24px rgba(0,0,0,.1);
  z-index: 300; transition: right .25s ease;
  display: flex; flex-direction: column;
  overflow: hidden;
}
#info-panel.open { right: 0; }

.ip-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 14px; border-bottom: 1px solid #e2e8f0; flex-shrink: 0;
}
.ip-title { font-weight: 700; font-size: 0.95rem; color: #0f172a; }
.ip-close {
  background: transparent; border: none; cursor: pointer;
  color: #94a3b8; font-size: 1.1rem; padding: 2px 6px; border-radius: 4px;
  transition: color .15s;
}
.ip-close:hover { color: #0f172a; }

.ip-body { overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 20px; }

.ip-section { display: flex; flex-direction: column; gap: 8px; }
.ip-section-label {
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: #0f766e;
}
.ip-section p {
  margin: 0; font-size: 0.86rem; line-height: 1.65; color: #334155;
}
.ip-section--highlight {
  background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 10px; padding: 14px;
}

/* ── Dashboard coverage notice ───────────────────────────────────────────── */
#dashboard-notice {
  display: flex; align-items: flex-start; gap: 10px;
  background: #f0fdf4; border: 1px solid #6ee7b7; border-radius: 8px;
  padding: 10px 14px; margin-bottom: 16px; font-size: 0.84rem; color: #065f46;
}
.notice-icon { flex-shrink: 0; margin-top: 1px; color: #0f766e; }
.notice-text { flex: 1; line-height: 1.5; }
.notice-dismiss {
  background: transparent; border: none; cursor: pointer;
  color: #6ee7b7; font-size: 1rem; padding: 0 2px; flex-shrink: 0;
  transition: color .15s; line-height: 1;
}
.notice-dismiss:hover { color: #0f766e; }

/* ── Filter bar ───────────────────────────────────────────────────────────── */
#filter-bar {
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  padding: 10px 24px 8px;
  display: flex; flex-direction: column; gap: 8px;
}

/* Search + actions row — always visible */
#search-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  justify-content: center;
}
.search-wrap {
  position: relative; display: flex; align-items: center;
  flex: 0 1 400px; min-width: 160px;
}
.search-icon {
  position: absolute; left: 12px; color: #0f766e; pointer-events: none; flex-shrink: 0;
}
.search-input {
  width: 100%;
  padding: 9px 72px 9px 40px;
  border: 2px solid #0f766e;
  border-radius: 10px;
  font-size: 0.9rem; color: #0f172a;
  outline: none;
  box-shadow: 0 0 0 3px rgba(15,118,110,.08);
  transition: box-shadow .2s, border-color .2s;
  background: #fff;
}
.search-input:focus {
  box-shadow: 0 0 0 4px rgba(15,118,110,.16);
  border-color: #0d6860;
}
.search-input::placeholder { color: #94a3b8; }
.search-clear-x {
  position: absolute; right: 40px;
  background: transparent; border: none; color: #94a3b8;
  font-size: 1rem; cursor: pointer; padding: 4px 6px;
  transition: color .15s; line-height: 1;
}
.search-clear-x:hover { color: #0f172a; }

/* Send button inside search-wrap */
.search-send-btn {
  position: absolute; right: 6px;
  width: 28px; height: 28px;
  background: #0f766e; color: #fff;
  border: none; border-radius: 7px;
  cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.search-send-btn:hover { background: #0d6860; }
.search-send-btn svg { display: block; }

/* Filters toggle button */
.filter-toggle-btn {
  display: flex; align-items: center; gap: 6px; flex-shrink: 0;
  padding: 8px 14px; border-radius: 8px;
  border: 1.5px solid #e2e8f0; background: #fff;
  color: #475569; font-size: 0.85rem; font-weight: 500;
  cursor: pointer; transition: all .15s; white-space: nowrap;
}
.filter-toggle-btn:hover { border-color: #0f766e; color: #0f766e; }
.filter-toggle-btn.active { border-color: #0f766e; background: #f0fdf4; color: #0f766e; }

.filter-toggle-badge {
  background: #0f766e; color: #fff;
  border-radius: 10px; font-size: 0.69rem; font-weight: 700;
  padding: 1px 6px; line-height: 1.4;
}

/* Action buttons */
.apply-btn {
  display: flex; align-items: center; gap: 6px; flex-shrink: 0;
  padding: 8px 18px;
  background: #0f766e; color: #fff;
  border: none; border-radius: 8px;
  font-size: 0.85rem; font-weight: 600;
  cursor: pointer; transition: background .15s; white-space: nowrap;
}
.apply-btn:hover { background: #0d6860; }
.clear-btn {
  padding: 8px 14px; flex-shrink: 0;
  border: 1.5px solid #e2e8f0; border-radius: 8px;
  background: #fff; color: #64748b;
  font-size: 0.82rem; cursor: pointer;
  transition: all .15s; white-space: nowrap;
}
.clear-btn:hover { border-color: #dc2626; color: #dc2626; }

/* Filter dropdowns row — always visible, centered */
#filter-row {
  display: flex; justify-content: center;
  align-items: center; gap: 8px; flex-wrap: wrap;
  padding-top: 4px; padding-bottom: 2px;
  /* No overflow constraint — lets absolute dropdown panels escape freely */
}

/* Chips row — hidden until at least one filter is active */
#chips-row {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: center;
  padding-top: 4px;
}
#chips-row[hidden] { display: none; }

/* Active filter chips */
#filter-chips {
  display: flex; flex-wrap: wrap; gap: 6px; justify-content: center;
}
.filter-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 20px;
  background: #e0f2f1; color: #0f766e;
  font-size: 0.78rem; font-weight: 500;
}
.filter-chip-x {
  background: transparent; border: none; color: #0f766e;
  cursor: pointer; font-size: 0.85rem; padding: 0 1px; line-height: 1;
  transition: color .1s;
}
.filter-chip-x:hover { color: #dc2626; }

/* ── Multi-select dropdown ────────────────────────────────────────────────── */
.multiselect { position: relative; flex-shrink: 0; }

.ms-trigger {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: 8px;
  border: 1.5px solid #e2e8f0; background: #fff;
  font-size: 0.85rem; color: #0f172a;
  cursor: pointer; transition: all .15s; white-space: nowrap;
  user-select: none;
}
.ms-trigger:hover { border-color: #0f766e; }
.ms-trigger.ms-active { border-color: #0f766e; background: #f0fdf4; }

.ms-label { font-weight: 500; }
.ms-badge {
  background: #0f766e; color: #fff;
  border-radius: 10px; font-size: 0.7rem; font-weight: 700;
  padding: 1px 6px; line-height: 1.4;
}
.ms-arrow { color: #94a3b8; transition: transform .15s; flex-shrink: 0; }
.ms-trigger.ms-open .ms-arrow { transform: rotate(180deg); }

.ms-panel {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 200;
  background: #fff; border: 1.5px solid #e2e8f0; border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,.12);
  min-width: 200px; max-height: 320px;
  display: flex; flex-direction: column;
  overflow: hidden;
}
/* Ensure hidden attribute actually hides panels — .ms-panel {display:flex}
   has the same specificity as UA [hidden]{display:none} so we need higher. */
.ms-panel[hidden] { display: none; }
.ms-panel-wide { min-width: 260px; }

.ms-search-wrap { padding: 10px 12px 6px; border-bottom: 1px solid #f1f5f9; }
.ms-search {
  width: 100%; padding: 6px 10px; border: 1.5px solid #e2e8f0;
  border-radius: 6px; font-size: 0.82rem; outline: none;
  transition: border-color .15s;
}
.ms-search:focus { border-color: #0f766e; }

.ms-list { flex: 1; overflow-y: auto; padding: 6px 0; }
.ms-option {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 14px; cursor: pointer; transition: background .1s;
  font-size: 0.84rem; color: #0f172a; user-select: none;
}
.ms-option:hover { background: #f8fafc; }
.ms-option input[type="checkbox"] { cursor: pointer; accent-color: #0f766e; width: 14px; height: 14px; flex-shrink: 0; }
.ms-empty { padding: 12px 14px; color: #94a3b8; font-size: 0.82rem; }

.ms-footer {
  display: flex; align-items: center; gap: 10px; border-top: 1px solid #f1f5f9;
  padding: 7px 12px;
}
/* All / Clear — text links, smaller, left-aligned */
.ms-text-link {
  font-size: 0.74rem; font-weight: 500; cursor: pointer;
  text-decoration: underline; text-underline-offset: 2px;
  user-select: none; transition: color .15s;
}
.ms-all-btn.ms-text-link  { color: #0f766e; }
.ms-all-btn.ms-text-link:hover  { color: #0d5c56; }
.ms-clear-btn.ms-text-link { color: #64748b; }
.ms-clear-btn.ms-text-link:hover { color: #dc2626; }
/* Ok button — pushes to the right */
.ms-ok-btn {
  margin-left: auto;
  padding: 4px 14px; border-radius: 6px; font-size: 0.8rem; font-weight: 600;
  cursor: pointer; transition: all .15s;
  background: #0f766e; color: #fff; border: none;
}
.ms-ok-btn:hover { background: #0d5c56; }

/* ── Main content area ────────────────────────────────────────────────────── */
#content { padding: 20px 24px 32px; max-width: 1600px; margin: 0 auto; width: 100%; }

/* ── KPI cards (clickable) ────────────────────────────────────────────────── */
#kpi-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px; margin-bottom: 20px;
}
.kpi-card {
  background: #fff;
  border: 1px solid #e2e8f0; border-radius: 12px;
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 4px;
  transition: box-shadow .15s;
}
.kpi-card.kpi-clickable {
  cursor: pointer;
  border-left: 3px solid #e2e8f0;
  transition: all .15s;
}
.kpi-card.kpi-clickable:hover {
  box-shadow: 0 4px 20px rgba(15,118,110,.15);
  border-left-color: #0f766e;
  transform: translateY(-1px);
}
.kpi-card.kpi-clickable.kpi-active {
  border-left-color: #0f766e;
  background: #f0fdf4;
  box-shadow: 0 2px 12px rgba(15,118,110,.12);
}
.kpi-card.kpi-amber.kpi-clickable:hover { border-left-color: #d97706; box-shadow: 0 4px 20px rgba(217,119,6,.15); }
.kpi-card.kpi-amber.kpi-clickable.kpi-active { border-left-color: #d97706; background: #fffbeb; }

.kpi-label { font-size: 0.75rem; font-weight: 600; color: #64748b; text-transform: uppercase; letter-spacing: .05em; }
.kpi-value { font-size: 2rem; font-weight: 700; color: #0f172a; line-height: 1; }
.kpi-sub   { font-size: 0.75rem; color: #94a3b8; }
.kpi-filter-hint { color: #0f766e; font-weight: 500; }
.kpi-card.kpi-primary .kpi-value { color: #0f766e; }
.kpi-card.kpi-amber   .kpi-value { color: #d97706; }
.kpi-card.kpi-slate   .kpi-value { color: #475569; }
.kpi-card.kpi-indigo  .kpi-value { color: #4f46e5; }
.kpi-card.kpi-indigo.kpi-clickable:hover { border-left-color: #4f46e5; box-shadow: 0 4px 20px rgba(79,70,229,.15); }
.kpi-card.kpi-indigo.kpi-clickable.kpi-active { border-left-color: #4f46e5; background: #eef2ff; }

.kpi-value.loading {
  background: #e2e8f0; border-radius: 6px; color: transparent;
  animation: pulse 1.2s infinite; min-width: 80px; height: 2rem;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }

/* ── Main panel: side-by-side layout ─────────────────────────────────────── */
#main-panel {
  display: grid;
  grid-template-columns: 400px 1fr;
  gap: 16px; margin-bottom: 16px;
  align-items: start;
}

#charts-col {
  display: flex; flex-direction: column; gap: 16px;
  position: sticky; top: 68px; /* stick below topbar while table scrolls */
}

#features-col { min-width: 0; }

/* ── Chart cards ──────────────────────────────────────────────────────────── */
.chart-card {
  background: #fff;
  border: 1px solid #e2e8f0; border-radius: 12px;
  padding: 18px 22px;
}
.chart-title {
  font-size: 0.85rem; font-weight: 600;
  color: #0f172a; margin-bottom: 14px;
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.chart-title span { color: #64748b; font-weight: 400; font-size: 0.78rem; }
.chart-hint { color: #0f766e; font-size: 0.72rem; font-weight: 400; font-style: italic; margin-left: auto; }
.chart-canvas-wrap { position: relative; }
#areaChartWrap  { height: 280px; }
#effortChartWrap{ height: 240px; display: flex; align-items: center; justify-content: center; }

/* ── Trend chart (full-width, collapsible) ────────────────────────────────── */
#trend-card {
  margin-bottom: 0;
}
.trend-title {
  display: flex; align-items: center;
}
.chart-subtitle-text { flex: 1; }
.trend-toggle-btn {
  background: transparent; border: none; cursor: pointer;
  color: #94a3b8; font-size: 0.75rem; padding: 2px 6px;
  transition: color .15s; margin-left: auto;
}
.trend-toggle-btn:hover { color: #0f172a; }
#trendChartBody { overflow: hidden; transition: max-height .3s ease; }
#trendChartBody.collapsed { max-height: 0 !important; }
#trendChartWrap { height: 200px; }

/* ── Table section ────────────────────────────────────────────────────────── */
#table-section {
  background: #fff;
  border: 1px solid #e2e8f0; border-radius: 12px;
  overflow: hidden;
}
#table-toolbar {
  padding: 12px 18px;
  display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid #e2e8f0;
}
.table-count { flex: 1; font-size: 0.85rem; color: #64748b; font-weight: 500; }
.export-btn {
  padding: 6px 14px;
  background: #fff; border: 1.5px solid #e2e8f0; border-radius: 8px;
  color: #0f766e; font-size: 0.82rem; font-weight: 500;
  cursor: pointer; transition: all .15s;
  display: inline-flex; align-items: center; gap: 6px;
  flex-shrink: 0; width: auto;
}
.export-btn:hover { border-color: #0f766e; background: #f0fdf4; }

#feature-table { width: 100%; border-collapse: collapse; font-size: 0.83rem; }
#feature-table thead th {
  background: #f8fafc; padding: 9px 14px;
  text-align: left; font-weight: 600; font-size: 0.75rem;
  color: #64748b; text-transform: uppercase; letter-spacing: .04em;
  border-bottom: 1px solid #e2e8f0; white-space: nowrap;
}
#feature-table tbody tr {
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer; transition: background .1s;
}
#feature-table tbody tr:hover { background: #f8fafc; }
#feature-table tbody tr:last-child { border-bottom: none; }
#feature-table td { padding: 10px 14px; vertical-align: top; }
.td-title {
  font-weight: 500; color: #0f172a; max-width: 280px;
  display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
}
.td-link { color: #64748b; text-decoration: none; }
.td-link:hover { color: #0f766e; }

/* Badges */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 0.71rem; font-weight: 500; white-space: nowrap;
}
.badge-release { background: #e0f2f1; color: #0f766e; }
.badge-auto    { background: #dcfce7; color: #15803d; }
.badge-setup   { background: #fef3c7; color: #b45309; }
.badge-retired { background: #fee2e2; color: #dc2626; }
.badge-muted   { background: #f1f5f9; color: #64748b; }

/* Area tags */
.area-tags { display: flex; flex-wrap: wrap; gap: 3px; }
.area-tag {
  display: inline-block; padding: 2px 6px;
  background: #f0fdf4; color: #15803d;
  border-radius: 6px; font-size: 0.69rem; font-weight: 500;
}
.area-tag-more { background: #f1f5f9; color: #64748b; }

/* Pagination */
#pagination {
  padding: 10px 18px;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  border-top: 1px solid #e2e8f0; font-size: 0.84rem; color: #64748b;
}
.page-btn {
  padding: 5px 12px;
  border: 1.5px solid #e2e8f0; border-radius: 8px;
  background: #fff; color: #0f172a;
  font-size: 0.82rem; cursor: pointer; transition: all .15s;
}
.page-btn:hover:not(:disabled) { border-color: #0f766e; color: #0f766e; }
.page-btn:disabled { opacity: .35; cursor: not-allowed; }

.table-empty { padding: 40px; text-align: center; color: #94a3b8; font-size: 0.9rem; }

/* ── Detail modal ─────────────────────────────────────────────────────────── */
#detail-modal {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(15,23,42,.5);
  display: none; align-items: center; justify-content: center;
  padding: 40px 16px;
}
#detail-modal.open { display: flex; }

.modal-card {
  background: #fff; border-radius: 16px;
  width: 100%; max-width: 820px;
  box-shadow: 0 24px 80px rgba(0,0,0,.22);
  overflow: hidden; margin: auto;
  display: flex; flex-direction: column;
  max-height: calc(100vh - 80px);
}
.modal-header {
  padding: 22px 28px 14px;
  border-bottom: 1px solid #e2e8f0;
  display: flex; align-items: flex-start; gap: 12px;
  background: #f8fafc;
  position: sticky; top: 0; z-index: 1;
  border-radius: 16px 16px 0 0; flex-shrink: 0;
}
.modal-title-wrap { flex: 1; }
.modal-title { font-size: 1.05rem; font-weight: 700; color: #0f172a; line-height: 1.4; margin-bottom: 8px; }
.modal-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.modal-close {
  background: transparent; border: none;
  color: #94a3b8; cursor: pointer; font-size: 1.4rem; line-height: 1;
  padding: 0 4px; flex-shrink: 0; transition: color .15s;
  position: sticky; top: 14px;
}
.modal-close:hover { color: #0f172a; }

.modal-body { padding: 0; display: flex; flex-direction: column; overflow-y: auto; flex: 1; }

/* AI Analysis section */
.modal-ai-section {
  padding: 20px 28px;
  background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
  border-bottom: 1px solid #bbf7d0;
}
.modal-ai-loading {
  padding: 20px 28px;
  display: flex; align-items: center; gap: 10px;
  color: #64748b; font-size: 0.875rem;
  border-bottom: 1px solid #e2e8f0;
}
.ai-spinner {
  width: 18px; height: 18px; border: 2px solid #e2e8f0;
  border-top-color: #0f766e; border-radius: 50%;
  animation: spin .7s linear infinite; flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.modal-ai-header {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 12px;
}
.modal-ai-icon {
  width: 24px; height: 24px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  overflow: hidden;
}
.modal-ai-icon img { width: 24px; height: 24px; display: block; }

/* ── Tekglen word-loop loader ─────────────────────────────────────────── */
.tg-loader {
  display: inline-block; overflow: hidden;
  height: 1.15em; vertical-align: -0.15em;
  font-weight: 600; color: #0f766e; font-style: italic;
}
.tg-loader-words {
  display: flex; flex-direction: column;
  animation: tgWordCycle 2.8s steps(1, end) infinite;
}
.tg-loader-words span { display: block; line-height: 1.15em; white-space: nowrap; }
@keyframes tgWordCycle {
  0%  { transform: translateY(0); }
  25% { transform: translateY(-1.15em); }
  50% { transform: translateY(-2.3em); }
  75% { transform: translateY(-3.45em); }
}
.modal-ai-title { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: #0f766e; }
.modal-ai-subtitle { font-size: 0.72rem; color: #64748b; margin-left: auto; }

.modal-ai-summary {
  font-size: 0.92rem; color: #0f172a; line-height: 1.7; font-weight: 400;
  margin-bottom: 14px;
}

.modal-ai-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
.modal-ai-block { background: #fff; border-radius: 8px; padding: 12px 14px; border: 1px solid #bbf7d0; }
.modal-ai-block-label {
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: #0f766e; margin-bottom: 6px;
}
.modal-ai-block-content { font-size: 0.82rem; color: #0f172a; line-height: 1.55; }

.modal-ai-actions { margin-top: 12px; }
.modal-ai-actions-label {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: #0f766e; margin-bottom: 6px;
}
.modal-ai-actions ul {
  list-style: none; display: flex; flex-direction: column; gap: 5px;
}
.modal-ai-actions ul li {
  display: flex; align-items: flex-start; gap: 7px;
  font-size: 0.83rem; color: #0f172a; line-height: 1.5;
}
.modal-ai-actions ul li::before {
  content: "→"; color: #0f766e; font-weight: 700; flex-shrink: 0; margin-top: 1px;
}

.modal-ai-tip {
  margin-top: 12px; padding: 10px 14px;
  background: #fff; border-left: 3px solid #0f766e; border-radius: 0 8px 8px 0;
  font-size: 0.82rem; color: #0f172a; line-height: 1.55;
}
.modal-ai-tip-label { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: #0f766e; margin-bottom: 4px; }

/* Security KB cross-link section */
.modal-kb-section {
  margin-top: 14px; padding: 12px 14px;
  background: linear-gradient(135deg, #f0fdf4 0%, #eff6ff 100%);
  border: 1px solid #bbf7d0; border-radius: 10px;
}
.modal-kb-label {
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: #15803d; margin-bottom: 8px;
}
.modal-kb-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.modal-kb-chip {
  display: inline-block; padding: 5px 12px;
  background: #fff; border: 1px solid #86efac; border-radius: 20px;
  font-size: 0.78rem; color: #15803d; text-decoration: none;
  font-weight: 500; transition: background .15s, border-color .15s;
}
.modal-kb-chip:hover { background: #dcfce7; border-color: #4ade80; color: #166534; }

/* Fix 5: separator + source label */
.modal-raw-divider {
  border: none;
  border-top: 1px solid #e5e7eb;
  margin: 20px 28px 0;
}
.modal-raw-source-label {
  display: block;
  font-size: 11px;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 8px 28px 0;
}

/* Fix 7: AI unavailable state */
.modal-ai-unavailable {
  display: block;
  background: #f9fafb;
  border-left: 3px solid #e5e7eb;
  color: #9ca3af;
  font-size: 13px;
  font-style: italic;
  padding: 10px 14px;
  border-radius: 4px;
  margin: 12px 28px;
}

/* Raw data sections */
.modal-sections { padding: 12px 28px 20px; display: flex; flex-direction: column; gap: 18px; }
.modal-section-label {
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: #94a3b8; margin-bottom: 5px;
}
.modal-desc { font-size: 0.88rem; color: #0f172a; line-height: 1.75; white-space: pre-wrap; }

/* Fix 6+9: raw Workday content container */
.modal-raw-content {
  background: #f9fafb;
  border-radius: 6px;
  padding: 14px 16px;
  margin-top: 4px;
  font-size: 15px;
  line-height: 1.65;
  color: #374151;
}

/* Fix 2: subheadings in raw content */
.wn-subheading {
  display: block;
  font-weight: 600;
  font-size: 14px;
  color: #111827;
  margin-top: 16px;
  margin-bottom: 4px;
}
.wn-subheading:first-child { margin-top: 0; }

/* Fix 2: Note: lines */
.wn-note {
  display: block;
  color: #6b7280;
  font-weight: 400;
  font-style: italic;
  font-size: 14px;
  margin-top: 8px;
  margin-bottom: 4px;
}

/* Fix 3: leading-space sub-item bullets */
.wn-sub-list {
  list-style-type: disc;
  margin: 4px 0 8px 24px;
  padding: 0;
}
.wn-sub-item {
  margin-bottom: 5px;
  font-size: 15px;
  line-height: 1.6;
  color: #374151;
}

/* Fix 4: field name lists */
.wn-field-list {
  list-style-type: disc;
  margin: 4px 0 8px 24px;
  padding: 0;
}
.wn-field-item {
  font-size: 14px;
  color: #374151;
  line-height: 1.7;
  margin-bottom: 2px;
}

/* Fix 1: paragraph lines */
.wn-para {
  margin: 0 0 10px;
  font-size: 15px;
  line-height: 1.65;
  color: #374151;
}
.wn-para:last-child { margin-bottom: 0; }

/* Fix 1: empty-line spacer */
.wn-spacer { height: 8px; }
.modal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px,1fr)); gap: 12px; }
.modal-field label { display: block; font-size: 0.7rem; color: #94a3b8; margin-bottom: 3px; }
.modal-field span  { font-size: 0.85rem; color: #0f172a; font-weight: 500; }
.modal-tag-list { display: flex; flex-wrap: wrap; gap: 6px; }

.modal-footer {
  padding: 14px 28px; border-top: 1px solid #e2e8f0;
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap;
}
.modal-link-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 16px;
  background: #f0fdf4; color: #0f766e;
  border: 1.5px solid #0f766e; border-radius: 8px;
  font-size: 0.83rem; font-weight: 500;
  text-decoration: none; transition: background .15s;
}
.modal-link-btn:hover { background: #dcfce7; }
.modal-footer-btn {
  padding: 7px 20px;
  background: #f1f5f9; border: 1.5px solid #e2e8f0; border-radius: 8px;
  font-size: 0.85rem; cursor: pointer; transition: background .15s; margin-left: auto;
}
.modal-footer-btn:hover { background: #e2e8f0; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  #main-panel { grid-template-columns: 340px 1fr; }
  #charts-col { position: static; }
}

@media (max-width: 900px) {
  #kpi-row { grid-template-columns: repeat(3, 1fr); }
  #main-panel { grid-template-columns: 1fr; }
  #charts-col { position: static; }
  #areaChartWrap { height: 240px; }
  .modal-ai-grid { grid-template-columns: 1fr; }
}

/* ── Tablet / mobile: multiselects wrap below search row ──────────────────── */
@media (max-width: 768px) {
  .search-wrap { flex: 1 1 100%; min-width: 0; }
}

/* ── Tablet / mobile header: year pills move to their own scrollable row ──── */
@media (max-width: 768px) {
  #topbar {
    flex-wrap: wrap;
    height: auto;
    min-height: 52px;
    padding: 0 16px;
    column-gap: 12px; row-gap: 0;
  }
  /* Year pills become a full-width horizontal scroll strip below the brand row */
  .year-pills {
    order: 10;
    flex: 0 0 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 6px 0 10px;
    gap: 6px;
    scrollbar-width: none;          /* Firefox */
    -webkit-overflow-scrolling: touch;
  }
  .year-pills::-webkit-scrollbar { display: none; }
  /* Prevent individual pills from shrinking inside the scroll container */
  .year-pill { flex-shrink: 0; }
}

@media (max-width: 600px) {
  /* Tighten horizontal padding on smallest screens; keep top padding for brand row */
  #topbar { padding: 8px 12px 0; gap: 10px; }
  /* Hide subtitle — brand + settings is enough on a phone */
  .topbar-divider, .topbar-title { display: none; }
  #content { padding: 12px; }
  #kpi-row { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi-value { font-size: 1.5rem; }
  .year-pill { padding: 4px 10px; font-size: 0.75rem; }
  #filter-bar { padding: 10px 12px; }
  #search-row { justify-content: flex-start; gap: 6px; }
  .search-wrap { flex: 0 0 100%; min-width: 0; }
  #feature-table thead th:nth-child(n+4) { display: none; }
  #feature-table tbody td:nth-child(n+4) { display: none; }
  .modal-ai-grid { grid-template-columns: 1fr; }
  #settings-panel { width: 100%; }
}

/* ══════════════════════════════════════════════════════════════════════════
   DARK THEME  (body.dark)
   ══════════════════════════════════════════════════════════════════════════ */

body.dark { background: #0f172a; color: #e2e8f0; }

/* Topbar */
body.dark #topbar { background: #0a1212; }
body.dark .topbar-brand { color: #e2e8f0; }
body.dark .topbar-title { color: #64748b; }
body.dark .topbar-divider { background: #1e293b; }
body.dark .year-pill { border-color: #334155; color: #64748b; }
body.dark .year-pill:hover { border-color: #14b8a6; color: #5eead4; }
body.dark .year-pill.active { background: #0f766e; border-color: #0f766e; color: #fff; }
body.dark .settings-btn { color: #475569; }
body.dark .settings-btn:hover { color: #e2e8f0; }
body.dark .topbar-ask-btn { background: #0f766e; }
body.dark .topbar-ask-btn:hover { background: #14b8a6; }
body.dark .info-btn { color: #475569; }
body.dark .info-btn:hover { color: #14b8a6; }
body.dark #info-panel { background: #1e293b; border-color: #334155; }
body.dark .ip-header { border-color: #334155; }
body.dark .ip-title { color: #e2e8f0; }
body.dark .ip-close { color: #475569; }
body.dark .ip-close:hover { color: #e2e8f0; }
body.dark .ip-section p { color: #94a3b8; }
body.dark .ip-section--highlight { background: rgba(15,118,110,.12); border-color: #0f766e; }
body.dark #dashboard-notice { background: rgba(15,118,110,.12); border-color: #0f766e; color: #6ee7b7; }
body.dark .notice-dismiss { color: #0f766e; }
body.dark .notice-dismiss:hover { color: #14b8a6; }

/* Filter bar */
body.dark #filter-bar { background: #1e293b; border-color: #334155; }
body.dark .search-input {
  background: #0f172a; border-color: #334155; color: #e2e8f0;
  box-shadow: 0 0 0 3px rgba(20,184,166,.06);
}
body.dark .search-input:focus { border-color: #14b8a6; box-shadow: 0 0 0 4px rgba(20,184,166,.14); }
body.dark .search-input::placeholder { color: #475569; }
body.dark .search-icon { color: #14b8a6; }
body.dark .search-clear-x { color: #475569; }
body.dark .search-clear-x:hover { color: #e2e8f0; }
body.dark .search-send-btn { background: #0f766e; }
body.dark .search-send-btn:hover { background: #14b8a6; }
body.dark .filter-toggle-btn { background: #0f172a; border-color: #334155; color: #64748b; }
body.dark .filter-toggle-btn:hover { border-color: #14b8a6; color: #14b8a6; }
body.dark .filter-toggle-btn.active { border-color: #14b8a6; background: rgba(20,184,166,.08); color: #14b8a6; }
body.dark .filter-toggle-badge { background: #14b8a6; }
body.dark .clear-btn { background: #0f172a; border-color: #334155; color: #64748b; }
body.dark .clear-btn:hover { border-color: #dc2626; color: #dc2626; }

/* Filter chips */
body.dark .filter-chip { background: rgba(20,184,166,.15); color: #14b8a6; }
body.dark .filter-chip-x { color: #14b8a6; }
body.dark .filter-chip-x:hover { color: #dc2626; }

/* Multiselect dropdowns */
body.dark .ms-trigger { background: #0f172a; border-color: #334155; color: #e2e8f0; }
body.dark .ms-trigger:hover { border-color: #14b8a6; }
body.dark .ms-trigger.ms-active { border-color: #14b8a6; background: rgba(20,184,166,.08); }
body.dark .ms-badge { background: #14b8a6; }
body.dark .ms-arrow { color: #475569; }
body.dark .ms-panel { background: #1e293b; border-color: #334155; box-shadow: 0 8px 32px rgba(0,0,0,.5); }
body.dark .ms-search-wrap { border-color: #334155; }
body.dark .ms-search { background: #0f172a; border-color: #334155; color: #e2e8f0; }
body.dark .ms-search:focus { border-color: #14b8a6; }
body.dark .ms-option { color: #cbd5e1; }
body.dark .ms-option:hover { background: #263347; }
body.dark .ms-empty { color: #475569; }
body.dark .ms-footer { border-color: #334155; }
body.dark .ms-all-btn.ms-text-link  { color: #14b8a6; }
body.dark .ms-all-btn.ms-text-link:hover  { color: #5eead4; }
body.dark .ms-clear-btn.ms-text-link { color: #475569; }
body.dark .ms-clear-btn.ms-text-link:hover { color: #dc2626; }
body.dark .ms-ok-btn { background: #14b8a6; color: #0f172a; }
body.dark .ms-ok-btn:hover { background: #0d9488; color: #fff; }

/* KPI cards */
body.dark .kpi-card { background: #1e293b; border-color: #334155; }
body.dark .kpi-label { color: #64748b; }
body.dark .kpi-value { color: #e2e8f0; }
body.dark .kpi-sub { color: #475569; }
body.dark .kpi-card.kpi-primary .kpi-value { color: #14b8a6; }
body.dark .kpi-card.kpi-amber .kpi-value { color: #f59e0b; }
body.dark .kpi-card.kpi-slate .kpi-value { color: #94a3b8; }
body.dark .kpi-value.loading { background: #334155; }
body.dark .kpi-card.kpi-clickable:hover { box-shadow: 0 4px 20px rgba(20,184,166,.18); border-left-color: #14b8a6; }
body.dark .kpi-card.kpi-clickable.kpi-active { background: rgba(20,184,166,.1); border-left-color: #14b8a6; }
body.dark .kpi-card.kpi-amber.kpi-clickable:hover { box-shadow: 0 4px 20px rgba(245,158,11,.15); border-left-color: #f59e0b; }
body.dark .kpi-card.kpi-amber.kpi-clickable.kpi-active { background: rgba(245,158,11,.08); border-left-color: #f59e0b; }
body.dark .kpi-card.kpi-indigo .kpi-value { color: #818cf8; }
body.dark .kpi-card.kpi-indigo.kpi-clickable:hover { box-shadow: 0 4px 20px rgba(129,140,248,.15); border-left-color: #818cf8; }
body.dark .kpi-card.kpi-indigo.kpi-clickable.kpi-active { background: rgba(79,70,229,.12); border-left-color: #818cf8; }

/* Chart cards */
body.dark .chart-card { background: #1e293b; border-color: #334155; }
body.dark .chart-title { color: #e2e8f0; }
body.dark .chart-title span { color: #64748b; }
body.dark .chart-hint { color: #14b8a6; }
body.dark .trend-toggle-btn { color: #475569; }
body.dark .trend-toggle-btn:hover { color: #e2e8f0; }

/* Feature table */
body.dark #table-section { background: #1e293b; border-color: #334155; }
body.dark #table-toolbar { border-color: #334155; }
body.dark .table-count { color: #64748b; }
body.dark .export-btn { background: #1e293b; border-color: #334155; color: #14b8a6; }
body.dark .export-btn:hover { background: rgba(20,184,166,.1); border-color: #14b8a6; }
body.dark #feature-table thead th { background: #263347; color: #64748b; border-color: #334155; }
body.dark #feature-table tbody tr { border-color: #263347; }
body.dark #feature-table tbody tr:hover { background: #263347; }
body.dark #feature-table td { color: #cbd5e1; }
body.dark .td-title { color: #e2e8f0; }
body.dark .td-link { color: #475569; }
body.dark .td-link:hover { color: #14b8a6; }
body.dark .table-empty { color: #475569; }
body.dark #pagination { border-color: #334155; color: #64748b; }
body.dark .page-btn { background: #1e293b; border-color: #334155; color: #cbd5e1; }
body.dark .page-btn:hover:not(:disabled) { border-color: #14b8a6; color: #14b8a6; }

/* Badges */
body.dark .badge-release { background: rgba(20,184,166,.15); color: #14b8a6; }
body.dark .badge-auto { background: rgba(74,222,128,.12); color: #4ade80; }
body.dark .badge-setup { background: rgba(251,191,36,.12); color: #fbbf24; }
body.dark .badge-retired { background: rgba(248,113,113,.12); color: #f87171; }
body.dark .badge-muted { background: #263347; color: #64748b; }
body.dark .area-tag { background: rgba(74,222,128,.1); color: #4ade80; }
body.dark .area-tag-more { background: #263347; color: #64748b; }

/* Feature detail modal */
body.dark #detail-modal { background: rgba(2,6,23,.75); }
body.dark .modal-card { background: #1e293b; }
body.dark .modal-header { background: #263347; border-color: #334155; position: sticky; top: 0; }
body.dark .modal-title { color: #e2e8f0; }
body.dark .modal-badges { gap: 6px; }
body.dark .modal-close { color: #475569; }
body.dark .modal-close:hover { color: #e2e8f0; }
body.dark .modal-body { background: #1e293b; }
body.dark .modal-ai-section {
  background: linear-gradient(135deg, rgba(15,118,110,.25) 0%, rgba(20,184,166,.12) 100%);
  border-color: #134e4a;
}
body.dark .modal-ai-title { color: #14b8a6; }
body.dark .modal-ai-subtitle { color: #475569; }
body.dark .modal-ai-summary { color: #e2e8f0; }
body.dark .modal-ai-block { background: #1e293b; border-color: #134e4a; }
body.dark .modal-ai-block-label { color: #14b8a6; }
body.dark .modal-ai-block-content { color: #cbd5e1; }
body.dark .modal-ai-actions-label { color: #14b8a6; }
body.dark .modal-ai-actions ul li { color: #cbd5e1; }
body.dark .modal-ai-actions ul li::before { color: #14b8a6; }
body.dark .modal-ai-tip { background: #263347; border-left-color: #14b8a6; color: #cbd5e1; }
body.dark .modal-ai-tip-label { color: #14b8a6; }
body.dark .modal-kb-section { background: linear-gradient(135deg, #132a1f 0%, #131e30 100%); border-color: #166534; }
body.dark .modal-kb-label { color: #4ade80; }
body.dark .modal-kb-chip { background: #1a2e22; border-color: #166534; color: #86efac; }
body.dark .modal-kb-chip:hover { background: #14532d; border-color: #4ade80; color: #bbf7d0; }
body.dark .modal-ai-loading { color: #64748b; border-color: #334155; }
body.dark .modal-sections { background: #1e293b; }
body.dark .modal-section-label { color: #475569; }
body.dark .modal-desc { color: #cbd5e1; }
body.dark .modal-raw-divider { border-top-color: #334155; }
body.dark .modal-raw-source-label { color: #475569; }
body.dark .modal-ai-unavailable { background: #1e293b; border-left-color: #334155; color: #475569; }
body.dark .modal-raw-content { background: #0f172a; color: #cbd5e1; }
body.dark .wn-subheading { color: #f1f5f9; }
body.dark .wn-note { color: #64748b; }
body.dark .wn-sub-item,
body.dark .wn-field-item,
body.dark .wn-para { color: #cbd5e1; }
body.dark .modal-field label { color: #475569; }
body.dark .modal-field span { color: #e2e8f0; }
body.dark .modal-footer { background: #1e293b; border-color: #334155; }
body.dark .modal-footer-btn { background: #263347; border-color: #334155; color: #94a3b8; }
body.dark .modal-footer-btn:hover { background: #334155; }
body.dark .modal-link-btn { background: rgba(20,184,166,.1); border-color: #14b8a6; color: #14b8a6; }
body.dark .modal-link-btn:hover { background: rgba(20,184,166,.2); }

/* Settings panel */
body.dark #settings-overlay { background: rgba(2,6,23,.45); }
body.dark #settings-panel { background: #1e293b; box-shadow: -4px 0 40px rgba(0,0,0,.5); }
body.dark .sp-header { background: #263347; border-color: #334155; }
body.dark .sp-title { color: #e2e8f0; }
body.dark .sp-close { color: #475569; }
body.dark .sp-close:hover { color: #e2e8f0; }
body.dark .sp-section { border-color: #263347; }
body.dark .sp-section-label { color: #475569; }
body.dark .sp-action-btn { background: #263347; border-color: #334155; color: #e2e8f0; }
body.dark .sp-action-btn:hover { border-color: #14b8a6; color: #14b8a6; background: rgba(20,184,166,.08); }
body.dark .sp-key-input { background: #0f172a; border-color: #334155; color: #e2e8f0; }
body.dark .sp-key-input:focus { border-color: #14b8a6; }
body.dark .sp-opt-btn { background: #263347; border-color: #334155; color: #64748b; }
body.dark .sp-opt-btn:hover { border-color: #14b8a6; color: #14b8a6; }
body.dark .sp-opt-btn.sp-opt-active { background: #0f766e; border-color: #0f766e; color: #fff; }
body.dark .sp-toggle-row { color: #e2e8f0; }
body.dark .sp-version { background: #263347; }
body.dark .sp-version-text { color: #475569; }
body.dark .sp-cancel-btn { background: #263347; border-color: #334155; color: #64748b; }

/* Loader & misc */
body.dark .tg-loader { color: #14b8a6; }
body.dark .ai-spinner { border-color: #334155; border-top-color: #14b8a6; }

/* ── Phase 1 & 2 additions ────────────────────────────────────────────────── */

/* Fix 1: settings overlay blocks clicks when open only */
#settings-overlay { pointer-events: none; }
#settings-overlay.open { pointer-events: auto; }
#settingsBtn { position: relative; z-index: 150; }

/* Fix 3 & 7: search input text direction */
#searchInput {
  direction: ltr;
  text-overflow: clip;
}

/* Fix 4: topbar dark mode toggle button */
.tkg-dark-btn {
  background: transparent; border: none;
  color: #94a3b8; cursor: pointer;
  font-size: 1.1rem; padding: 4px 6px; border-radius: 6px;
  transition: color .15s; flex-shrink: 0; line-height: 1;
}
.tkg-dark-btn:hover { color: #e2e8f0; }
body.dark .tkg-dark-btn { color: #94a3b8; }
body.dark .tkg-dark-btn:hover { color: #fbbf24; }

/* Fix 2: search + active filter warning */
#tkg-search-warning {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 16px;
  background: #fffbeb; border-top: 1px solid #fde68a;
  font-size: 0.82rem; color: #92400e;
}
#tkg-search-warning[hidden] { display: none; }
.tkg-search-warning-link {
  color: #0f766e; font-weight: 600; text-decoration: underline; cursor: pointer;
}
body.dark #tkg-search-warning { background: #1c1506; border-color: #78350f; color: #fcd34d; }
body.dark .tkg-search-warning-link { color: #34d399; }

/* Feature 3: Ask AI button — override fixed width from .search-send-btn */
.tkg-ask-ai-btn {
  display: flex; align-items: center; gap: 5px;
  width: auto !important;   /* override width:28px from .search-send-btn */
  height: 30px;
  padding: 0 12px; white-space: nowrap; font-size: 0.8rem; font-weight: 600;
  border-radius: 6px; flex-shrink: 0;
}
/* Widen input right-padding and shift clear-x to make room for the wider button */
.search-wrap .search-input { padding-right: 98px; }
.search-wrap .search-clear-x { right: 86px; }
.tkg-ask-ai-label { font-size: 0.78rem; font-weight: 600; letter-spacing: .01em; }

/* Feature 1: My Modules in settings */
.tkg-modules-hint {
  font-size: 0.78rem; color: #64748b; margin: 4px 0 8px;
}
.tkg-modules-list {
  max-height: 180px; overflow-y: auto; border: 1px solid #e2e8f0;
  border-radius: 6px; padding: 4px 0; margin-bottom: 8px;
}
.tkg-modules-loading { padding: 8px 12px; font-size: 0.8rem; color: #94a3b8; }
.tkg-module-option {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 12px; cursor: pointer; font-size: 0.82rem;
  color: #0f172a; transition: background .1s;
}
.tkg-module-option:hover { background: #f1f5f9; }
.tkg-module-option input[type="checkbox"] { accent-color: #0f766e; flex-shrink: 0; }
.tkg-modules-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.tkg-modules-saved-indicator {
  font-size: 0.72rem; color: #0f766e; font-weight: 600; margin-left: 6px;
}
.tkg-my-modules-badge {
  display: inline-flex; align-items: center;
  background: #0f766e; color: #fff; font-size: 0.68rem; font-weight: 700;
  padding: 1px 6px; border-radius: 10px; margin-left: 4px; vertical-align: middle;
}
body.dark .tkg-modules-hint { color: #475569; }
body.dark .tkg-modules-list { border-color: #334155; background: #0f172a; }
body.dark .tkg-module-option { color: #e2e8f0; }
body.dark .tkg-module-option:hover { background: #1e293b; }
body.dark .tkg-modules-saved-indicator { color: #34d399; }

/* Feature 2: Release ticker (scrolling marquee) */
#tkg-countdown-banner {
  overflow: hidden;
  white-space: nowrap;
  height: 34px;
  display: flex; align-items: center;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}
#tkg-countdown-banner[hidden] { display: none; }
#tkg-countdown-banner.tkg-banner-live { background: #d1fae5; color: #065f46; }
#tkg-countdown-banner.tkg-banner-warn { background: #fef3c7; color: #92400e; }
#tkg-countdown-banner.tkg-banner-future { background: #f0f9ff; color: #0369a1; }

.ticker-track {
  display: inline-flex; align-items: center;
  animation: ticker-scroll 60s linear infinite;
  will-change: transform;
}
.ticker-track:hover { animation-play-state: paused; }

@keyframes ticker-scroll {
  0%   { transform: translateX(-50%); }
  100% { transform: translateX(0); }
}

.ticker-item {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.82rem; font-weight: 500;
  padding: 0 32px;
}
.ticker-dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  flex-shrink: 0;
}
.tkg-banner-live .ticker-dot  { background: #059669; }
.tkg-banner-warn .ticker-dot  { background: #d97706; }
.tkg-banner-future .ticker-dot { background: #0284c7; }
.ticker-sep {
  opacity: .35; font-size: 0.75rem; padding: 0 4px;
}
.ticker-link {
  color: inherit; font-weight: 700; text-decoration: underline;
  cursor: pointer; white-space: nowrap;
}
body.dark #tkg-countdown-banner.tkg-banner-live   { background: #064e3b; color: #a7f3d0; }
body.dark #tkg-countdown-banner.tkg-banner-warn   { background: #451a03; color: #fcd34d; }
body.dark #tkg-countdown-banner.tkg-banner-future { background: #0c2340; color: #7dd3fc; }

/* Feature 4: Email digest CTA */
#tkg-digest-cta {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 16px; margin-bottom: 16px;
  background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 8px;
  font-size: 0.85rem; color: #1e40af;
}
#tkg-digest-cta[hidden] { display: none; }
.tkg-digest-icon { font-size: 1rem; flex-shrink: 0; }
.tkg-digest-text { flex: 1; min-width: 180px; }
.tkg-digest-submit {
  padding: 6px 14px; background: #0f766e; color: #fff;
  border: none; border-radius: 6px; font-size: 0.82rem; font-weight: 600;
  cursor: pointer; flex-shrink: 0; transition: background .15s;
}
.tkg-digest-submit:hover { background: #0d6860; }
.tkg-digest-dismiss {
  background: transparent; border: none; font-size: 1.1rem;
  cursor: pointer; color: #64748b; padding: 0 4px; flex-shrink: 0;
}
.tkg-digest-dismiss:hover { color: #0f172a; }
.tkg-digest-success {
  padding: 10px 16px; margin-bottom: 16px;
  background: #dcfce7; border: 1px solid #bbf7d0; border-radius: 8px;
  font-size: 0.85rem; color: #166534; font-weight: 500;
}
body.dark #tkg-digest-cta { background: #172554; border-color: #1e3a5f; color: #93c5fd; }
body.dark .tkg-digest-dismiss { color: #475569; }
body.dark .tkg-digest-success { background: #14532d; border-color: #166534; color: #a7f3d0; }

/* Feature 5: Back to top button */
.tkg-back-top {
  position: fixed; bottom: 24px; right: 24px; z-index: 999;
  width: 40px; height: 40px; border-radius: 50%;
  background: #0f766e; color: #fff; border: none;
  font-size: 1.2rem; cursor: pointer; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 12px rgba(15,118,110,0.4);
  opacity: 0; transition: opacity .2s, transform .2s;
  pointer-events: none;
}
.tkg-back-top.visible {
  opacity: 1; pointer-events: auto;
}
.tkg-back-top:hover { background: #0d6860; transform: translateY(-2px); }
@media (max-width: 600px) {
  .tkg-back-top { bottom: 80px; right: 16px; }
}
body.dark .tkg-back-top { background: #0f766e; box-shadow: 0 2px 12px rgba(0,0,0,.5); }

/* ── Sign-in card (replaces admin key overlay) ───────────────────────────── */
.signin-card {
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,.22);
  padding: 40px 36px 32px;
  width: 380px;
  max-width: calc(100vw - 32px);
  text-align: center;
}
.signin-logo { width: 52px; margin-bottom: 18px; }
.signin-title { font-size: 1.3rem; font-weight: 700; color: #0f172a; margin-bottom: 6px; }
.signin-sub { color: #64748b; font-size: 0.875rem; line-height: 1.5; margin-bottom: 20px; }

.signin-props {
  text-align: left; margin-bottom: 24px;
  display: flex; flex-direction: column; gap: 8px;
}
.signin-prop {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: 0.82rem; color: #334155; line-height: 1.4;
}
.signin-prop svg { flex-shrink: 0; margin-top: 1px; }

/* SSO row: Google + Microsoft half/half */
.signin-sso-row {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}
/* Google wrapper — overlay pattern so GIS SDK captures the real click */
.signin-google-wrap {
  flex: 1;
  position: relative;
  min-width: 0;
}
.signin-google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid #dadce0;
  border-radius: 8px;
  background: #fff;
  font-size: 0.875rem;
  font-weight: 500;
  color: #3c4043;
  cursor: pointer;
  white-space: nowrap;
  pointer-events: none; /* GIS div captures the click */
}
#signinGoogleDiv {
  position: absolute;
  inset: 0;
  opacity: 0;
  overflow: hidden;
}
/* Microsoft button */
.signin-ms-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1.5px solid #dadce0;
  border-radius: 8px;
  background: #fff;
  font-size: 0.875rem;
  font-weight: 500;
  color: #3c4043;
  cursor: pointer;
  white-space: nowrap;
  min-width: 0;
  overflow: hidden;
  transition: background 0.15s, box-shadow 0.15s;
}
.signin-ms-btn:hover {
  background: #f8f9fa;
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
}

.signin-divider {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 16px;
}
.signin-divider::before,
.signin-divider::after {
  content: ''; flex: 1; height: 1px; background: #e2e8f0;
}
.signin-divider span { font-size: 0.78rem; color: #94a3b8; white-space: nowrap; }

.signin-form { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.signin-input {
  width: 100%; padding: 10px 14px;
  border: 1.5px solid #e2e8f0; border-radius: 8px;
  font-size: 0.875rem; outline: none;
  transition: border-color .15s; box-sizing: border-box;
}
.signin-input:focus { border-color: #0f766e; }
.signin-btn {
  width: 100%; padding: 11px;
  background: #0f766e; color: #fff;
  border: none; border-radius: 8px;
  font-size: 0.9rem; font-weight: 600;
  cursor: pointer; transition: background .15s;
}
.signin-btn:hover { background: #0d6860; }
.signin-btn:disabled { opacity: .6; cursor: not-allowed; }
.signin-error { color: #dc2626; font-size: 0.82rem; min-height: 18px; }
.signin-compass-note {
  font-size: 0.78rem; color: #94a3b8;
  display: flex; align-items: center; justify-content: center; gap: 5px;
  margin-top: 4px;
}
.signin-compass-note a { color: #0f766e; text-decoration: underline; }

/* Dark mode — sign-in card */
body.dark .signin-card { background: #1e293b; }
body.dark .signin-title { color: #f1f5f9; }
body.dark .signin-sub { color: #94a3b8; }
body.dark .signin-prop { color: #94a3b8; }
body.dark .signin-divider::before,
body.dark .signin-divider::after { background: #334155; }
body.dark .signin-input { background: #0f172a; border-color: #334155; color: #e2e8f0; }
body.dark .signin-input:focus { border-color: #14b8a6; }

/* ── Topbar user chip ─────────────────────────────────────────────────────── */
.topbar-user-chip {
  display: flex; align-items: center; gap: 7px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 20px; padding: 3px 10px 3px 4px;
  margin-left: 4px; flex-shrink: 0;
}
.topbar-user-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: #0f766e; color: #fff;
  font-size: 0.75rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; text-transform: uppercase;
}
.topbar-user-name {
  font-size: 0.8rem; color: #e2e8f0; font-weight: 500;
  max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar-signout-btn {
  background: transparent; border: none; cursor: pointer;
  color: #94a3b8; padding: 2px; display: flex; align-items: center;
  border-radius: 4px; transition: color .15s;
}
.topbar-signout-btn:hover { color: #f87171; }
body.dark .topbar-user-chip { background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.1); }
