/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #07090f;
  --bg2:       #0d1117;
  --bg3:       #111827;
  --border:    #1a2030;
  --border2:   #232f44;
  --text:      #e2e8f0;
  --muted:     #64748b;
  --muted2:    #3d4f6a;
  --orange:    #FF8C42;
  --gold:      #FFD700;
  --red:       #FF4444;
  --cyan:      #5BF5E0;
  --blue:      #5B9EF5;
  --green:     #5BF5A0;
  --purple:    #E05BF5;
  --yellow:    #F5C85B;
  --pink:      #F55BE0;
  --teal:      #5BF5E0;
  --radius:    10px;
  --radius-sm: 6px;
}

html { background: var(--bg); overflow-x: hidden; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', system-ui, sans-serif;
  font-size: 13px;
  line-height: 1.5;
  overflow-x: hidden;
  min-height: 100vh;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
#header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 18px;
  height: 50px;
  background: rgba(7,9,15,0.95);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}

.logo-text {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: var(--text);
}
.app-version {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .5px;
  color: var(--text-muted);
  opacity: .6;
  margin-left: 5px;
  align-self: flex-end;
  margin-bottom: 1px;
}

.logo-accent {
  background: linear-gradient(135deg, var(--gold), var(--orange), var(--red));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── OL brand logo in header ─────────────────────────────────────────────── */
.nav-ol-brand {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  opacity: 0.55;
  transition: opacity 0.18s;
  text-decoration: none;
}
.nav-ol-brand:hover { opacity: 0.95; }
.nav-ol-logo-app {
  height: 32px;
  width: 32px;
  object-fit: contain;
  display: block;
}
.nav-header-sep {
  width: 1px;
  height: 18px;
  background: rgba(255,255,255,.1);
  flex-shrink: 0;
}

/* ── View tabs ───────────────────────────────────────────────────────────── */
.view-tabs {
  display: flex;
  gap: 2px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
}

.view-tab {
  display: flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}

.view-tab:hover { color: var(--text); background: var(--border); }

.view-tab.active {
  background: linear-gradient(135deg, #1a1f2e, #1e2540);
  color: var(--orange);
  border: 1px solid rgba(255,140,66,0.3);
}

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted2);
  display: inline-block;
  transition: background 0.3s;
}

.live-dot.active { background: var(--green); animation: pulse 2s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

/* ── Header right ─────────────────────────────────────────────────────────── */
.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.periods {
  display: flex;
  gap: 2px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
}

.period-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  padding: 4px 11px;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.period-btn:hover { color: var(--text); background: var(--border); }

.period-btn.active {
  background: linear-gradient(135deg, #1a1f2e, #1e2540);
  color: var(--orange);
  border: 1px solid rgba(255,140,66,0.3);
}

.refresh-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.refresh-btn:hover { color: var(--orange); border-color: rgba(255,140,66,0.4); }
.refresh-btn.spinning svg { animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Update Banner ───────────────────────────────────────────────────────── */
#updateBanner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: linear-gradient(90deg, #1a2a1a, #162816);
  border-bottom: 1px solid #2a5c2a;
  font-size: 13px;
  color: #7dce7d;
}
#updateBanner span { flex: 1; }
#updateBanner a {
  color: #23D9BF;
  font-weight: 600;
  text-decoration: none;
  padding: 3px 10px;
  border: 1px solid #23D9BF44;
  border-radius: 4px;
}
#updateBanner a:hover { background: #23D9BF22; }
#updateBanner button {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  padding: 3px 8px;
}
#updateBanner button:hover { color: var(--text); }

/* ── Loading ─────────────────────────────────────────────────────────────── */
#loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  height: calc(100vh - 50px);
  color: var(--muted);
}

.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid var(--border2);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.hidden { display: none !important; }

/* ── Views ───────────────────────────────────────────────────────────────── */
.view {
  padding: 16px 18px 32px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 1600px;
  margin: 0 auto;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

/* ── Panel ───────────────────────────────────────────────────────────────── */
.panel {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: border-color 0.2s;
}

.panel:hover { border-color: var(--border2); }

.panel-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  margin-bottom: 14px;
  opacity: 0.9;
}

/* ── Panel color accents ─────────────────────────────────────────────────── */
.panel-overview { border-left: 3px solid var(--orange); }
.panel-daily    { border-left: 3px solid var(--blue); }
.panel-project  { border-left: 3px solid var(--green); }
.panel-sessions { border-left: 3px solid #FF6B6B; }
.panel-activity { border-left: 3px solid var(--yellow); }
.panel-model    { border-left: 3px solid var(--purple); }
.panel-tools    { border-left: 3px solid var(--teal); }
.panel-mcp      { border-left: 3px solid var(--pink); }
.panel-bash     { border-left: 3px solid #F5A05B; }

/* ── KPI grid ────────────────────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.kpi {
  padding: 13px 15px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

.kpi:hover { background: var(--bg3); }
.kpi:nth-child(4), .kpi:nth-child(8)  { border-right: none; }
.kpi:nth-child(5), .kpi:nth-child(6), .kpi:nth-child(7), .kpi:nth-child(8) { border-bottom: none; }

.kpi-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--orange);
  letter-spacing: -0.5px;
  line-height: 1.2;
}

.kpi-small  { font-size: 16px; color: var(--text); }
.kpi-label  { font-size: 10px; color: var(--muted); margin-top: 3px; text-transform: uppercase; letter-spacing: 0.5px; }

/* ── Bar chart (Daily) ────────────────────────────────────────────────────── */
.bar-chart-header {
  display: grid;
  grid-template-columns: 72px 1fr 72px 60px;
  gap: 8px;
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.bar-chart { display: flex; flex-direction: column; gap: 4px; }

.bar-row {
  display: grid;
  grid-template-columns: 72px 1fr 72px 60px;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  border-radius: 4px;
  transition: background 0.1s;
}

.bar-row:hover { background: rgba(255,255,255,0.03); }

.bar-date  { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bar-track { height: 15px; background: var(--bg3); border-radius: 3px; overflow: hidden; }
.bar-fill  { height: 100%; border-radius: 3px; transition: width 0.4s cubic-bezier(0.4,0,0.2,1); }
.bar-cost  { font-size: 11px; font-weight: 600; color: var(--gold); text-align: right; font-variant-numeric: tabular-nums; }
.bar-calls { font-size: 11px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }

/* ── Table rows ─────────────────────────────────────────────────────────── */
.table-header {
  display: flex;
  gap: 8px;
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 3px;
}

/* ── Sortable column headers ──────────────────────────────────────────────── */
.table-header span[data-sort],
.bar-chart-header span[data-sort] {
  cursor: pointer;
  user-select: none;
  transition: color 0.15s;
  white-space: nowrap;
}
.table-header span[data-sort]:hover,
.bar-chart-header span[data-sort]:hover { color: var(--text); }
.table-header span[data-sort]::after,
.bar-chart-header span[data-sort]::after { content: ' ⇅'; opacity: 0.3; font-size: 8px; }
.table-header span[data-sort].sort-asc::after,
.bar-chart-header span[data-sort].sort-asc::after  { content: ' ▲'; opacity: 1; color: var(--cyan); }
.table-header span[data-sort].sort-desc::after,
.bar-chart-header span[data-sort].sort-desc::after { content: ' ▼'; opacity: 1; color: var(--cyan); }
.table-header span[data-sort].sort-asc,
.table-header span[data-sort].sort-desc,
.bar-chart-header span[data-sort].sort-asc,
.bar-chart-header span[data-sort].sort-desc { color: var(--text); }

.table-body { display: flex; flex-direction: column; }

.table-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 3px;
  border-bottom: 1px solid rgba(26,32,48,0.5);
  transition: background 0.1s;
}

.table-row:last-child { border-bottom: none; }
.table-row:hover { background: rgba(255,255,255,0.03); border-radius: 4px; }

.col-grow { flex: 1; min-width: 0; font-size: 12px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.col-num  { width: 76px; text-align: right; font-size: 11px; font-variant-numeric: tabular-nums; flex-shrink: 0; }
.col-date { width: 86px; font-size: 11px; color: var(--muted); flex-shrink: 0; }

.row-bar-wrap { display: flex; align-items: center; gap: 7px; }
.row-mini-bar { width: 44px; height: 7px; background: var(--bg3); border-radius: 2px; overflow: hidden; flex-shrink: 0; }
.row-mini-fill { height: 100%; border-radius: 2px; transition: width 0.4s cubic-bezier(0.4,0,0.2,1); }

/* ── Bar list (tools/bash) ───────────────────────────────────────────────── */
.bar-list { display: flex; flex-direction: column; gap: 5px; }

.bar-list-inline {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px 24px;
}

.bl-row { display: flex; align-items: center; gap: 7px; padding: 2px 0; }
.bl-name { width: 96px; font-size: 11px; color: var(--text); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; flex-shrink: 0; }
.bl-track { flex: 1; height: 11px; background: var(--bg3); border-radius: 3px; overflow: hidden; }
.bl-fill  { height: 100%; border-radius: 3px; transition: width 0.4s cubic-bezier(0.4,0,0.2,1); }
.bl-count { width: 38px; text-align: right; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; flex-shrink: 0; }

/* ── Gradient utilities ──────────────────────────────────────────────────── */
.grad-fire { background: linear-gradient(90deg, #5B9EF5 0%, #FFD700 50%, #FF4444 100%); }

/* ── One-shot & cost colors ──────────────────────────────────────────────── */
.oneshot-high { color: #5BF5A0; }
.oneshot-mid  { color: var(--yellow); }
.oneshot-low  { color: #FF6B6B; }
.cost-hi  { color: var(--gold); font-weight: 600; }
.cost-mid { color: var(--orange); }
.cost-low { color: var(--text); }

/* ── Scrollbar ───────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track  { background: var(--bg); }
::-webkit-scrollbar-thumb  { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted2); }

/* ── Empty / tooltip ─────────────────────────────────────────────────────── */
.empty { color: var(--muted); font-size: 12px; padding: 16px 0; text-align: center; }

[data-tip] { position: relative; cursor: default; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #1a2030;
  color: var(--text);
  font-size: 11px;
  white-space: nowrap;
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid var(--border2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 200;
}
[data-tip]:hover::after { opacity: 1; }

/* ════════════════════════════════════════════════════════════════════════════
   LIVE VIEW
═══════════════════════════════════════════════════════════════════════════ */

.live-status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted2);
  flex-shrink: 0;
  transition: background 0.3s;
}

.status-dot.active   { background: var(--green); animation: pulse 2s infinite; }
.status-dot.inactive { background: var(--yellow); }

.live-countdown {
  margin-left: auto;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.panel-live-session { border-left: 3px solid var(--green); }

.live-session-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.live-project-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-top: 2px;
}

.live-cost-big {
  font-size: 36px;
  font-weight: 700;
  color: var(--orange);
  letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
}

.kpi-grid-live {
  grid-template-columns: repeat(4, 1fr);
  margin-top: 0;
}

.kpi-grid-live .kpi:nth-child(n) { border-bottom: none; }
.kpi-grid-live .kpi:nth-child(4) { border-right: none; }

.kpi-grid-2x2 { grid-template-columns: repeat(2, 1fr); }
.kpi-grid-2x2 .kpi:nth-child(n)  { border-bottom: 1px solid var(--border); }
.kpi-grid-2x2 .kpi:nth-child(2)  { border-right: none; }
.kpi-grid-2x2 .kpi:nth-child(3),
.kpi-grid-2x2 .kpi:nth-child(4)  { border-bottom: none; }
.kpi-grid-2x2 .kpi:nth-child(4)  { border-right: none; }

/* ════════════════════════════════════════════════════════════════════════════
   OPTIMIZE VIEW
═══════════════════════════════════════════════════════════════════════════ */

.panel-health { border-left: 3px solid var(--yellow); }

.health-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 14px;
}

.opt-subtitle { font-size: 11px; color: var(--muted); }

.health-score-wrap { text-align: right; }

.health-grade {
  font-size: 52px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -2px;
}

.grade-A { color: #5BF5A0; }
.grade-B { color: var(--blue); }
.grade-C { color: var(--yellow); }
.grade-D { color: var(--orange); }
.grade-F { color: var(--red); }

.health-score-num {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.health-bar-track {
  height: 6px;
  background: var(--bg3);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 10px;
}

.health-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.6s cubic-bezier(0.4,0,0.2,1);
  background: linear-gradient(90deg, var(--red), var(--yellow), var(--green));
  background-size: 100% 100%;
}

.health-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
}

.opt-savings {
  color: var(--green);
  font-weight: 600;
}

/* Findings grid */
.findings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.finding-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  transition: border-color 0.2s;
  border-left: 3px solid var(--muted2);
}

.finding-card:hover { border-color: var(--border2); }
.finding-card.impact-high   { border-left-color: var(--red); }
.finding-card.impact-medium { border-left-color: var(--yellow); }
.finding-card.impact-low    { border-left-color: var(--blue); }

.finding-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
  gap: 8px;
}

.finding-title { font-size: 13px; font-weight: 600; color: var(--text); }

.impact-badge {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 99px;
  flex-shrink: 0;
}

.impact-badge.high   { background: rgba(255,68,68,0.15);  color: var(--red);    border: 1px solid rgba(255,68,68,0.3); }
.impact-badge.medium { background: rgba(245,200,91,0.12); color: var(--yellow); border: 1px solid rgba(245,200,91,0.3); }
.impact-badge.low    { background: rgba(91,158,245,0.12); color: var(--blue);   border: 1px solid rgba(91,158,245,0.3); }

.finding-desc { font-size: 12px; color: var(--muted); line-height: 1.5; margin-bottom: 8px; }

.finding-details { margin-bottom: 10px; }

.finding-detail-item {
  font-size: 11px;
  color: var(--text);
  padding: 2px 0;
  font-variant-numeric: tabular-nums;
  opacity: 0.75;
}

.finding-detail-item::before { content: "·  "; color: var(--muted); }

.finding-savings {
  display: flex;
  gap: 12px;
  padding: 7px 10px;
  background: var(--bg3);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  font-size: 11px;
}

.saving-item { display: flex; flex-direction: column; gap: 1px; }
.saving-value { font-weight: 600; color: var(--green); font-variant-numeric: tabular-nums; }
.saving-label { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: 0.4px; }

.finding-fix {
  font-size: 11px;
  color: var(--cyan);
  line-height: 1.5;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.finding-fix::before { content: "→  "; opacity: 0.6; }

/* Optimize action buttons */
.finding-action {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.opt-action-btn {
  font-size: 11px;
  padding: 5px 12px;
  border-radius: 5px;
  border: 1px solid var(--cyan);
  background: rgba(0,212,255,0.08);
  color: var(--cyan);
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  font-family: inherit;
}
.opt-action-btn:hover   { background: rgba(0,212,255,0.16); }
.opt-action-btn:disabled { opacity: 0.5; cursor: default; }
.opt-apply-btn { border-color: var(--green); color: var(--green); }
.opt-apply-btn:hover { background: rgba(91,245,160,0.12); }
.opt-action-btn.opt-confirming {
  border-color: var(--yellow);
  color: var(--yellow);
  background: rgba(245,200,91,0.1);
}

.opt-action-cancel {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
}
.opt-action-cancel:hover { color: var(--red); border-color: var(--red); }

/* Channel help popup (Email / Telegram setup guide) */
.chp-help-btn {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--bg3); border: 1px solid var(--border2);
  color: var(--muted); font-size: 11px; font-weight: 700;
  cursor: pointer; line-height: 16px; padding: 0;
  transition: color .15s, border-color .15s;
}
.chp-help-btn:hover { color: var(--cyan); border-color: var(--cyan); }

.channel-help-popup {
  position: fixed; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg2); border: 1px solid var(--border2);
  border-radius: 12px; width: 380px; max-width: 90vw;
  z-index: 20000; box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
.chp-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px 12px; border-bottom: 1px solid var(--border);
}
.chp-title { font-size: 14px; font-weight: 700; color: var(--cyan); }
.chp-close {
  background: none; border: none; color: var(--muted);
  font-size: 14px; cursor: pointer; padding: 2px 6px;
  border-radius: 4px;
}
.chp-close:hover { color: var(--text); background: var(--bg3); }
.chp-body {
  padding: 16px 20px 20px; font-size: 12px;
  color: var(--muted); line-height: 1.6; max-height: 60vh; overflow-y: auto;
}
.chp-body p { margin: 0 0 8px; }
.chp-body ol { margin: 4px 0 10px; padding-left: 18px; }
.chp-body li { margin-bottom: 4px; }
.chp-body strong { color: var(--text); }
.chp-body code {
  font-size: 10px; background: var(--bg); padding: 1px 4px;
  border-radius: 3px; color: var(--cyan); font-family: monospace;
  word-break: break-all;
}

/* All clear */
.opt-all-clear {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 60px 20px;
  color: var(--muted);
  text-align: center;
}

.all-clear-icon  { font-size: 40px; color: var(--green); }
.all-clear-title { font-size: 18px; font-weight: 600; color: var(--text); }
.all-clear-sub   { font-size: 13px; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
/* ════════════════════════════════════════════════════════════════════════════
   BUDGET VIEW
═══════════════════════════════════════════════════════════════════════════ */

.panel-budget-strip { border-left: 3px solid var(--gold); }
.panel-plans        { border-left: 3px solid var(--gold); }
.panel-ctx          { border-left: 3px solid var(--blue); }
.panel-memfiles     { border-left: 3px solid var(--teal); }

.kpi-grid-budget { grid-template-columns: repeat(4, 1fr); }
.kpi-grid-budget .kpi:nth-child(n) { border-bottom: none; }
.kpi-grid-budget .kpi:nth-child(4) { border-right: none; }

.plan-subtitle { font-size: 11px; color: var(--muted); margin-bottom: 14px; }
.plan-cards    { display: flex; flex-direction: column; gap: 10px; }

.plan-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  transition: border-color 0.15s;
}

.plan-card.status-over { border-color: rgba(255,68,68,0.4); }
.plan-card.status-warn { border-color: rgba(245,200,91,0.35); }
.plan-card.status-api  { opacity: 0.65; }

.plan-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.plan-name  { font-size: 13px; font-weight: 600; }
.plan-price { font-size: 11px; color: var(--muted); }

.plan-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 5px;
}

.plan-bar-track { flex: 1; height: 7px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.plan-bar-fill  { height: 100%; border-radius: 4px; transition: width 0.5s ease; }
.plan-pct       { font-size: 11px; width: 44px; text-align: right; flex-shrink: 0; font-variant-numeric: tabular-nums; }

.pct-over { color: var(--red);    font-weight: 700; }
.pct-warn { color: var(--yellow); font-weight: 600; }
.pct-ok   { color: var(--green); }

.plan-days         { font-size: 11px; color: var(--muted); }
.plan-days strong  { color: var(--text); }

/* Context budget */
.ctx-header-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}

.ctx-total { font-size: 26px; font-weight: 700; color: var(--blue); letter-spacing: -0.5px; }
.ctx-pct   { font-size: 12px; color: var(--muted); }

.ctx-bar-track {
  height: 7px;
  background: var(--bg3);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 16px;
}

.ctx-bar-fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--blue), var(--purple));
  transition: width 0.5s ease;
}

.ctx-breakdown { display: flex; flex-direction: column; gap: 5px; }

.ctx-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 0;
  font-size: 12px;
}

.ctx-label  { flex: 1; color: var(--text); }
.ctx-count  { font-size: 11px; color: var(--muted); width: 55px; text-align: right; }
.ctx-tokens { font-size: 11px; font-weight: 600; color: var(--blue); width: 50px; text-align: right; font-variant-numeric: tabular-nums; }
.ctx-mini-bar  { width: 72px; height: 5px; background: var(--bg3); border-radius: 3px; overflow: hidden; flex-shrink: 0; }
.ctx-mini-fill { height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--blue), var(--purple)); }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 960px) {
  .grid-2, .grid-3, .findings-grid { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi:nth-child(2), .kpi:nth-child(4), .kpi:nth-child(6), .kpi:nth-child(8) { border-right: none; }
  .kpi:nth-child(3), .kpi:nth-child(4) { border-bottom: 1px solid var(--border); }
  .periods { display: none; }
  .compare-pickers { flex-direction: column; gap: 16px; }
  .compare-vs { display: none; }
}

/* ── Project Filter Bar ────────────────────────────────────────────────────── */

.project-filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0 4px;
}

.pf-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: .05em;
  text-transform: uppercase;
}

.pf-select {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 12px;
  padding: 5px 10px;
  cursor: pointer;
  outline: none;
  max-width: 320px;
}
.pf-select:focus { border-color: var(--orange); }

.pf-clear {
  background: none;
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 11px;
  padding: 4px 10px;
  cursor: pointer;
}
.pf-clear:hover { color: var(--text); border-color: var(--border2); }

.table-row.dimmed { opacity: .25; }
.table-row.highlight { background: rgba(255,140,66,.05); border-left: 2px solid var(--orange); }

/* ── Compare View ──────────────────────────────────────────────────────────── */

.panel-compare-header { padding: 16px 20px; }

.compare-pickers {
  display: flex;
  align-items: flex-start;
  gap: 24px;
}

.compare-picker { flex: 1; }

.compare-picker-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.compare-vs {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: .1em;
  padding-top: 30px;
}

/* KPI comparison table */
.compare-kpi-grid {
  display: grid;
  grid-template-columns: 2fr 1.4fr 1.4fr 1.2fr;
  gap: 0;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
  margin-bottom: 6px;
}

.ck-header {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 4px 8px;
}
.ck-a   { color: var(--blue);   }
.ck-b   { color: var(--orange); }
.ck-delta { text-align: right;  }

.compare-kpi-rows { display: flex; flex-direction: column; gap: 0; }

.cmp-row {
  display: grid;
  grid-template-columns: 2fr 1.4fr 1.4fr 1.2fr;
  align-items: center;
  padding: 8px 8px;
  border-bottom: 1px solid var(--border);
  transition: background .15s;
}
.cmp-row:hover { background: rgba(255,255,255,.03); }
.cmp-row:last-child { border-bottom: none; }

.cmp-metric {
  font-size: 12px;
  color: var(--text);
  font-weight: 500;
}
.cmp-val-a { font-size: 14px; font-weight: 600; color: var(--blue);   padding: 0 8px; }
.cmp-val-b { font-size: 14px; font-weight: 600; color: var(--orange); padding: 0 8px; }
.cmp-delta {
  font-size: 11px;
  font-weight: 600;
  text-align: right;
  padding: 0 8px;
}
.delta-up   { color: var(--red);   }
.delta-down { color: var(--green); }
.delta-neutral { color: var(--muted); }

/* ── Modals (shared) ────────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-overlay.hidden { display: none; }

.modal-box {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 14px;
  width: 100%; max-width: 520px;
  max-height: 88vh; overflow-y: auto;
  box-shadow: 0 24px 80px rgba(0,0,0,.6);
}
.modal-box-wide { max-width: 680px; }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--bg2); z-index: 1;
  border-radius: 14px 14px 0 0;
}
.modal-title { font-size: 16px; font-weight: 700; letter-spacing: .04em; }
.modal-close  {
  background: none; border: none;
  color: var(--muted); font-size: 16px;
  cursor: pointer; padding: 4px 8px; border-radius: 6px;
  transition: color .15s, background .15s;
}
.modal-close:hover { color: var(--text); background: var(--bg3); }

/* Language selector in modal header */
.modal-lang-select {
  flex: 1; max-width: 120px; margin: 0 12px;
  background: var(--bg3); border: 1px solid var(--border2);
  color: var(--text); border-radius: 6px;
  font-size: 12px; padding: 4px 8px; cursor: pointer;
  font-family: inherit;
}
.modal-lang-select:focus { outline: none; border-color: var(--cyan); }

/* Browse button + input row */
.input-browse-row { display: flex; gap: 6px; flex: 1; }
.input-browse-row .settings-input { flex: 1; }
.browse-btn {
  padding: 4px 10px; background: var(--bg3);
  border: 1px solid var(--border2); border-radius: 6px;
  color: var(--text); cursor: pointer; font-size: 14px;
  transition: background .15s;
  white-space: nowrap;
}
.browse-btn:hover { background: var(--border2); }

/* Configuration hints */
.settings-hint {
  font-size: 11px; color: var(--muted); line-height: 1.5;
  background: rgba(91,159,245,0.06); border: 1px solid rgba(91,159,245,0.15);
  border-radius: 6px; padding: 8px 12px; margin: 6px 0;
}
.settings-hint code {
  font-size: 10px; background: var(--bg); padding: 1px 4px;
  border-radius: 3px; color: var(--cyan); font-family: monospace;
}
.settings-hint strong { color: var(--text); }
/* Voice picker rows */
.voice-row {
  display: flex; align-items: center; padding: 5px 16px; gap: 8px;
  cursor: default; transition: background .12s;
}
.voice-row:hover { background: rgba(255,255,255,0.04); }
.voice-name {
  flex: 1; font-size: 13px; color: var(--text); cursor: pointer;
}
.voice-name:hover { color: var(--cyan); }
.voice-lang { font-size: 10px; color: var(--muted); min-width: 60px; }
.voice-preview-btn {
  background: none; border: 1px solid var(--border2); color: var(--cyan);
  border-radius: 4px; padding: 2px 8px; font-size: 11px; cursor: pointer;
  transition: background .12s;
}
.voice-preview-btn:hover { background: rgba(0,212,255,0.12); }

.hint-link, .chp-body .hint-link {
  color: var(--cyan); text-decoration: none; font-family: monospace; font-size: 10px;
  border-bottom: 1px solid rgba(0,212,255,0.35); transition: border-color .15s, color .15s;
}
.hint-link:hover { color: #fff; border-bottom-color: var(--cyan); }

/* Toast notification */
#toknora-toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--bg3); border: 1px solid var(--border2);
  color: var(--text); padding: 10px 20px; border-radius: 8px;
  font-size: 13px; z-index: 9999; pointer-events: none;
  opacity: 0; transition: opacity .25s;
}
#toknora-toast.visible { opacity: 1; }
#toknora-toast.err { border-color: var(--red); color: var(--red); }

.modal-footer {
  display: flex; align-items: center; justify-content: flex-end; gap: 12px;
  padding: 16px 24px 20px;
  border-top: 1px solid var(--border);
  position: sticky; bottom: 0; background: var(--bg2);
  border-radius: 0 0 14px 14px;
}
.save-status { flex: 1; font-size: 12px; color: var(--green); }
.btn-primary {
  background: var(--orange); color: #000;
  border: none; border-radius: 8px;
  padding: 8px 20px; font-size: 13px; font-weight: 700;
  cursor: pointer; transition: opacity .15s;
}
.btn-primary:hover { opacity: .85; }

/* ── Export modal ────────────────────────────────────────────────────────────── */

.export-period-row {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 24px 0;
}
.exp-label { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; }

.export-section-title {
  font-size: 10px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted);
  padding: 16px 24px 8px;
  display: flex; align-items: center; gap: 10px;
}

.export-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
  padding: 0 24px;
}
.export-card {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 10px; padding: 14px 10px;
  cursor: pointer; text-align: center;
  transition: border-color .15s, background .15s;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.export-card:hover { border-color: var(--green); background: rgba(91,245,160,.06); }
.export-card.loading { opacity: .5; pointer-events: none; }
.exp-icon { font-size: 22px; }
.exp-name { font-size: 11px; font-weight: 700; color: var(--text); }
.exp-desc { font-size: 9px; color: var(--muted); line-height: 1.3; }

.nlm-card:hover { border-color: var(--purple); background: rgba(224,91,245,.06); }
.nlm-badge {
  font-size: 9px; font-weight: 700; padding: 2px 8px;
  border-radius: 20px; letter-spacing: .05em;
}
.nlm-badge.ok    { background: rgba(91,245,160,.15); color: var(--green); }
.nlm-badge.fail  { background: rgba(255,68,68,.15);  color: var(--red); }
.nlm-badge.check { background: rgba(100,116,139,.15); color: var(--muted); }

.nlm-auth-note {
  margin: 8px 24px; padding: 8px 12px;
  background: rgba(255,68,68,.08); border: 1px solid rgba(255,68,68,.2);
  border-radius: 8px; font-size: 11px; color: var(--muted);
}
.nlm-auth-note code { color: var(--orange); font-size: 11px; }

.export-status {
  margin: 12px 24px 16px; padding: 10px 14px;
  border-radius: 8px; font-size: 12px;
}
.export-status.ok  { background: rgba(91,245,160,.1); color: var(--green); border: 1px solid rgba(91,245,160,.2); }
.export-status.err { background: rgba(255,68,68,.1);  color: var(--red);   border: 1px solid rgba(255,68,68,.2); }

/* ── Settings modal ──────────────────────────────────────────────────────────── */

.stab-row {
  display: flex; gap: 4px;
  padding: 12px 24px 0;
  border-bottom: 1px solid var(--border);
}
.stab {
  background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--muted); font-size: 12px; font-weight: 600;
  padding: 8px 14px; cursor: pointer;
  transition: color .15s, border-color .15s;
  margin-bottom: -1px;
}
.stab:hover { color: var(--text); }
.stab.active { color: var(--orange); border-bottom-color: var(--orange); }

.stab-panel { padding: 16px 24px; }
.stab-panel.hidden { display: none; }

.settings-group {
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.settings-group:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

.sg-title {
  font-size: 10px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted);
  margin-bottom: 10px;
}
.sg-row {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 8px;
}
.sg-row label { font-size: 12px; color: var(--muted); min-width: 140px; }
.settings-input {
  flex: 1; background: var(--bg3); border: 1px solid var(--border2);
  border-radius: 6px; color: var(--text);
  font-size: 12px; padding: 6px 10px; outline: none;
}
.settings-input:focus { border-color: var(--orange); }

.settings-toggle {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; margin-bottom: 8px; font-size: 13px; color: var(--text);
}
.settings-toggle input[type=checkbox] {
  width: 16px; height: 16px; accent-color: var(--orange); cursor: pointer;
}

.settings-sub { padding: 10px 0 0 24px; }

.test-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.test-btn {
  background: var(--bg3); border: 1px solid var(--border2);
  border-radius: 6px; color: var(--muted);
  font-size: 11px; padding: 6px 12px; cursor: pointer;
  transition: color .15s, border-color .15s;
}
.test-btn:hover { color: var(--text); border-color: var(--muted2); }
.test-result {
  margin-top: 10px; padding: 8px 12px; border-radius: 6px;
  font-size: 11px;
}
.test-result.ok  { background: rgba(91,245,160,.1); color: var(--green); }
.test-result.err { background: rgba(255,68,68,.1);  color: var(--red); }

/* ── Help modal ──────────────────────────────────────────────────────────────── */

.help-content { padding: 20px 24px 24px; }
.help-section { margin-bottom: 24px; }
.help-h2 {
  font-size: 13px; font-weight: 700; color: var(--blue);
  margin-bottom: 8px; letter-spacing: .02em;
}
.help-content p { font-size: 12px; color: var(--text); line-height: 1.6; margin-bottom: 8px; }
.help-content ul { padding-left: 18px; }
.help-content li { font-size: 12px; color: var(--text); line-height: 1.7; }
.help-content code {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 4px; padding: 1px 5px;
  font-size: 11px; color: var(--orange);
}
.help-table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.help-table td { font-size: 12px; color: var(--text); padding: 5px 8px; border-bottom: 1px solid var(--border); }
.help-table td:first-child { width: 60px; }
kbd {
  display: inline-block;
  background: var(--bg3); border: 1px solid var(--border2);
  border-radius: 4px; padding: 1px 6px;
  font-size: 11px; color: var(--text); font-family: monospace;
}

/* ── LICENSE GATE ─────────────────────────────────────────────────────────── */
.license-gate {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--darker);
  display: flex; align-items: center; justify-content: center;
}
.license-gate.hidden { display: none; }
.license-box {
  background: var(--bg2); border: 1px solid var(--border2);
  border-radius: 16px; padding: 40px 44px;
  width: 440px; max-width: 95vw;
  display: flex; flex-direction: column; align-items: center; gap: 0;
  box-shadow: 0 24px 64px rgba(0,0,0,.6);
}
.license-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.license-logo-text { font-size: 22px; font-weight: 800; letter-spacing: .04em; color: var(--text-bright); }
.license-title { font-size: 17px; font-weight: 700; color: var(--text-bright); margin: 0 0 6px; }
.license-sub   { font-size: 12px; color: var(--text-dim); margin: 0 0 24px; text-align: center; line-height: 1.5; }
.license-fields { width: 100%; display: flex; flex-direction: column; gap: 14px; margin-bottom: 16px; }
.lf-group  { display: flex; flex-direction: column; gap: 5px; }
.lf-label  { font-size: 11px; font-weight: 600; color: var(--text-dim); letter-spacing: .06em; text-transform: uppercase; }
.lf-input  {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px;
  font-size: 13px; color: var(--text-bright); font-family: monospace;
  width: 100%; box-sizing: border-box; outline: none;
  transition: border-color .15s;
}
.lf-input:focus { border-color: var(--orange); }
.lic-error {
  width: 100%; background: rgba(255,68,68,.1); border: 1px solid rgba(255,68,68,.3);
  border-radius: 8px; padding: 9px 12px;
  font-size: 12px; color: #ff6b6b; margin-bottom: 12px;
}
.lic-error.hidden { display: none; }
.lic-btn-primary {
  width: 100%; padding: 12px; background: var(--orange);
  border: none; border-radius: 8px; cursor: pointer;
  font-size: 14px; font-weight: 700; color: #fff; letter-spacing: .02em;
  transition: opacity .15s; margin-bottom: 16px;
}
.lic-btn-primary:hover   { opacity: .85; }
.lic-btn-primary:disabled { opacity: .45; cursor: not-allowed; }
.lic-buy-link {
  font-size: 12px; color: var(--blue); text-decoration: none;
  letter-spacing: .02em;
}
.lic-buy-link:hover { text-decoration: underline; }
