/* Redwell Panel v3 · Studio-Grade Obsidian & Glass Executive Analytics
   Linear / Stripe / Raycast precision: #09090b canvas, #111115 panels, #15151c cards, crisp tabular numbers */

:root {
  --bg: #09090b;
  --bg-2: #0d0d11;
  --panel: #111115;
  --card: #15151c;
  --hover: #1b1b24;
  --active: #232331;
  --input: #0c0c10;
  --line: rgba(255, 255, 255, 0.075);
  --line-2: rgba(255, 255, 255, 0.11);
  --line-3: rgba(255, 255, 255, 0.16);

  --text: #f2f4f8;
  --text-2: #b9bfd0;
  --text-3: #83899d;
  --text-4: #5a6073;

  --accent: #5b53ff;
  --accent-2: #736cff;
  --accent-3: #a29cff;
  --accent-soft: rgba(91, 83, 255, 0.14);
  --accent-line: rgba(115, 108, 255, 0.45);

  --green: #10b981;
  --green-2: #34d399;
  --green-soft: rgba(16, 185, 129, 0.13);
  --amber: #f59e0b;
  --amber-2: #fbbf24;
  --amber-soft: rgba(245, 158, 11, 0.13);
  --red: #ef4444;
  --red-2: #f87171;
  --red-soft: rgba(239, 68, 68, 0.13);

  --r-sm: 7px;
  --r: 10px;
  --r-lg: 13px;
  --r-xl: 16px;

  --sans: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --topbar-h: 52px;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(ellipse 80% 40% at 50% -10%, rgba(91, 83, 255, 0.07), transparent 65%), var(--bg);
  color: var(--text);
  font: 400 13.5px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4, p { margin: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; border-radius: 6px; }

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); }
.c-green { color: var(--green-2); }
.c-amber { color: var(--amber-2); }
.c-red { color: var(--red-2); }
.c-accent { color: var(--accent-3); }

* { scrollbar-width: thin; scrollbar-color: #292d3d transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #292d3d; border-radius: 99px; }

.ico { width: 15px; height: 15px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.ico-xs { width: 13px; height: 13px; }

/* Buttons & Inputs */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: var(--r-sm);
  background: var(--card); border: 1px solid var(--line-2); color: var(--text);
  font-size: 12.5px; font-weight: 500; white-space: nowrap; transition: background 0.14s, border-color 0.14s, color 0.14s;
}
.btn:hover:not(:disabled) { background: var(--hover); border-color: var(--line-3); }
.btn-primary { background: var(--accent); border-color: transparent; color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-2); }
.btn-verify { background: rgba(16, 185, 129, 0.11); border-color: rgba(16, 185, 129, 0.3); color: #6ee7b7; }
.btn-verify:hover:not(:disabled) { background: rgba(16, 185, 129, 0.2); border-color: rgba(16, 185, 129, 0.5); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-3); }
.btn-ghost:hover:not(:disabled) { background: rgba(255, 255, 255, 0.06); color: var(--text); }
.btn-xs { height: 28px; padding: 0 9px; font-size: 12px; }

input:where(:not([type="checkbox"])), select, textarea {
  width: 100%; background: var(--input); border: 1px solid var(--line-2);
  border-radius: var(--r-sm); color: var(--text); font-size: 12.5px; padding: 0 10px; height: 32px;
}
textarea { height: auto; padding: 8px 10px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent-line); }
input[type="date"] { font-family: var(--mono); font-size: 11.5px; width: 124px; padding: 0 7px; height: 26px; border-color: transparent; }

.fld { display: grid; gap: 4px; }
.fld label { font-size: 11.5px; font-weight: 500; color: var(--text-3); }

/* Segmented Pills */
.seg {
  display: inline-flex; align-items: center; padding: 2px; gap: 2px;
  border-radius: var(--r-sm); background: var(--input); border: 1px solid var(--line);
}
.seg button {
  height: 24px; padding: 0 9px; border-radius: 5px;
  color: var(--text-3); font-size: 11.5px; font-weight: 500; white-space: nowrap; transition: all 0.13s;
}
.seg button:hover { color: var(--text); }
.seg button.is-active { background: var(--active); color: var(--text); font-weight: 600; }

/* Tags */
.tag {
  display: inline-flex; align-items: center; gap: 5px; height: 21px; padding: 0 8px;
  border-radius: 99px; font-size: 11px; font-weight: 600; background: rgba(255, 255, 255, 0.06); color: var(--text-2); white-space: nowrap;
}
.tag-green { background: var(--green-soft); color: var(--green-2); }
.tag-amber { background: var(--amber-soft); color: var(--amber-2); }
.tag-red { background: var(--red-soft); color: var(--red-2); }
.tag-accent { background: var(--accent-soft); color: var(--accent-3); }

.dot { width: 6px; height: 6px; border-radius: 99px; display: inline-block; background: var(--green); }
.dot-sync { background: #3b82f6; animation: pulse 1.1s infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }

/* Topbar (Compact 52px Glass Header) */
.topbar {
  height: var(--topbar-h); padding: 0 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: rgba(9, 9, 11, 0.88); backdrop-filter: blur(20px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; flex: none; }
.brand-mark { width: 19px; height: 19px; border-radius: 5px; background: linear-gradient(145deg, #ef4b51, #b8242a); }
.brand-name { font-size: 14px; font-weight: 700; letter-spacing: -0.02em; white-space: nowrap; }
.brand-name span { color: var(--text-3); font-weight: 500; }

.nav-tabs { display: flex; align-items: center; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.nav-tabs::-webkit-scrollbar { display: none; }
.nav-tab {
  height: 32px; padding: 0 11px; border-radius: var(--r-sm);
  color: var(--text-3); font-size: 12.5px; font-weight: 500; white-space: nowrap; transition: all 0.13s;
}
.nav-tab:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.nav-tab.is-active { color: #fff; background: var(--card); font-weight: 600; box-shadow: inset 0 0 0 1px var(--line-2); }

.topbar-right { display: flex; align-items: center; gap: 7px; flex: none; }
.custom-dates { display: inline-flex; align-items: center; gap: 4px; background: var(--input); padding: 1px 6px; border-radius: var(--r-sm); border: 1px solid var(--line-2); }

/* Layout */
.main { height: calc(100vh - var(--topbar-h)); height: calc(100dvh - var(--topbar-h)); overflow-y: auto; }
.wrap { max-width: 1380px; margin: 0 auto; padding: 20px 24px 64px; display: grid; gap: 14px; }

/* KPI Strip */
.kpi-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 15px 17px; display: grid; gap: 6px; min-inline-size: 0;
  transition: border-color 0.14s;
}
.kpi:hover { border-color: var(--line-2); }
.kpi-lbl { font-size: 11.5px; font-weight: 500; color: var(--text-3); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.kpi-num { font: 700 25px/1.1 var(--mono); letter-spacing: -0.03em; }
.kpi-sub { font-size: 12px; color: var(--text-3); display: flex; gap: 7px; align-items: center; flex-wrap: wrap; }

/* Grids & Cards */
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.grid-12 { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px; }
.col-8 { grid-column: span 8; }
.col-7 { grid-column: span 7; }
.col-6 { grid-column: span 6; }
.col-5 { grid-column: span 5; }
.col-4 { grid-column: span 4; }
.col-12 { grid-column: span 12; }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-xl);
  padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; min-inline-size: 0;
}
.card.clickable { cursor: pointer; transition: border-color 0.15s; }
.card.clickable:hover { border-color: var(--line-3); }

.card-hd { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.card-title { font-size: 14px; font-weight: 600; letter-spacing: -0.015em; color: var(--text); }

/* Horizontal Bars */
.hbar-list { display: grid; gap: 9px; }
.hbar-row { display: grid; grid-template-columns: 160px 1fr 120px; gap: 12px; align-items: center; font-size: 12.5px; min-inline-size: 0; }
.hbar-row.clickable { cursor: pointer; padding: 4px 6px; margin: -4px -6px; border-radius: 7px; }
.hbar-row.clickable:hover { background: rgba(255, 255, 255, 0.045); }
.hbar-lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); font-weight: 500; min-inline-size: 0; }
.hbar-track { height: 10px; border-radius: 99px; background: var(--input); overflow: hidden; display: flex; border: 1px solid rgba(255, 255, 255, 0.04); }
.hbar-fill { height: 100%; border-radius: 99px; transition: width 0.25s ease; }
.hbar-val { text-align: right; font: 600 12px var(--mono); color: var(--text); white-space: nowrap; }

.seg-tof { background: #6366f1; height: 100%; }
.seg-mof { background: #f59e0b; height: 100%; }
.seg-bof { background: #10b981; height: 100%; }

.legend { display: flex; align-items: center; gap: 14px; font-size: 11.5px; color: var(--text-3); flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 8px; height: 8px; border-radius: 3px; display: inline-block; }

/* Donut */
.donut-wrap { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.donut-list { flex: 1; min-inline-size: 185px; display: grid; gap: 8px; }
.donut-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12.5px; }

/* Interactive Floating Chart Tooltip */
.chart-tip {
  position: fixed; z-index: 120; pointer-events: none;
  padding: 9px 12px; border-radius: 9px;
  background: rgba(17, 17, 23, 0.96); backdrop-filter: blur(12px);
  border: 1px solid var(--line-3); box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
  font-size: 12px; line-height: 1.5; color: var(--text); min-width: 170px;
}
.chart-tip-hd { font-family: var(--mono); font-weight: 700; font-size: 11.5px; color: var(--text); margin-bottom: 4px; border-bottom: 1px solid var(--line); padding-bottom: 3px; }
.chart-tip-row { display: flex; justify-content: space-between; gap: 14px; font-size: 11.5px; }
.chart-tip-row span:first-child { color: var(--text-3); }

/* SVG Bar Hover Highlight */
.svg-col-hit { fill: transparent; cursor: crosshair; }
.svg-col-hit:hover { fill: rgba(255, 255, 255, 0.04); }

/* Minimalist A/B Test Card */
.ab-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-xl);
  padding: 20px 22px; display: grid; gap: 15px;
}
.ab-card.is-winner { border-color: rgba(16, 185, 129, 0.3); }
.ab-card.is-live { border-color: rgba(91, 83, 255, 0.32); }
.ab-3rows { display: grid; gap: 7px; }
.ab-line { display: grid; grid-template-columns: 88px 1fr; gap: 10px; align-items: baseline; font-size: 13.5px; }
.ab-key { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-4); }
.ab-bars-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.ab-metric-box { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; display: grid; gap: 8px; }
.ab-metric-hd { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 11.5px; font-weight: 600; color: var(--text-3); }

/* Tables */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--bg-2); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tbl th {
  text-align: left; padding: 9px 12px; font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-4);
  border-bottom: 1px solid var(--line); background: var(--panel); white-space: nowrap;
  position: sticky; top: 0; z-index: 2;
}
.tbl th.r, .tbl td.r { text-align: right; }
.tbl td { padding: 9px 12px; border-bottom: 1px solid rgba(255, 255, 255, 0.04); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr.clickable { cursor: pointer; }
.tbl tbody tr.clickable:hover { background: var(--hover); }

/* Filter Strip */
.flt-strip { display: flex; gap: 7px; flex-wrap: wrap; align-items: center; }
.flt-strip select { width: auto; min-width: 112px; }
.flt-strip input[type="search"] { width: 185px; }

/* White-Space Matrix */
.ws-wrap { overflow-x: auto; }
.ws-tbl { width: 100%; border-collapse: separate; border-spacing: 5px; font-size: 11.5px; }
.ws-tbl th { padding: 6px 8px; color: var(--text-3); font-weight: 500; text-align: center; white-space: nowrap; }
.ws-tbl th.rh { text-align: left; color: var(--text); font-weight: 600; min-width: 165px; }
.ws-c { border-radius: 7px; padding: 8px; text-align: center; cursor: pointer; font-family: var(--mono); font-weight: 600; }
.ws-c.winner { background: rgba(16, 185, 129, 0.2); color: #6ee7b7; border: 1px solid rgba(16, 185, 129, 0.35); }
.ws-c.tested { background: rgba(245, 158, 11, 0.14); color: #fde047; border: 1px solid rgba(245, 158, 11, 0.28); }
.ws-c.produced_untested { background: rgba(255, 255, 255, 0.06); color: var(--text-2); }
.ws-c.whitespace { background: rgba(91, 83, 255, 0.06); color: var(--text-4); border: 1px dashed rgba(115, 108, 255, 0.25); }

/* Native <dialog> Modals & Drawer */
.dlg {
  padding: 0; border: 1px solid var(--line-3); border-radius: var(--r-xl);
  background: var(--panel); color: var(--text);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.72);
  max-width: 94vw; max-height: 88dvh; margin: auto; overflow: hidden;
}
.dlg[open] { display: flex; flex-direction: column; }
.dlg:modal { overscroll-behavior: contain; }
.dlg::backdrop {
  background: rgba(5, 6, 10, 0.72); backdrop-filter: blur(6px);
  overflow: hidden; overscroll-behavior: contain;
}

.dlg-audit { width: 940px; }
.dlg-modal { width: 520px; }
.dlg-drawer {
  width: min(620px, 100vw); height: 100dvh; max-height: 100dvh;
  margin: 0 0 0 auto; border-radius: 0; border-right: 0; border-top: 0; border-bottom: 0;
}

.dlg-hd { padding: 15px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex: none; }
.dlg-hd h1 { font-size: 16px; font-weight: 650; letter-spacing: -0.02em; }
.dlg-bd { padding: 18px 20px; overflow-y: auto; flex: 1; display: grid; gap: 14px; align-content: start; }
.dlg-ft { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 10px; flex: none; }

/* Audit Cards inside Verify Dialog */
.audit-box { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 13px 15px; display: grid; gap: 6px; min-inline-size: 0; }
.audit-box-hd { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-3); display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.audit-box-hd > span { white-space: nowrap; }
.audit-num { font: 700 20px/1.15 var(--mono); }
.audit-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 12px; color: var(--text-2); min-inline-size: 0; }
.audit-row > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-inline-size: 0; }
.audit-row > span:last-child { white-space: nowrap; flex-shrink: 0; }

.check-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.check-pill { display: inline-flex; align-items: center; gap: 5px; padding: 4px 9px; border-radius: 6px; background: var(--input); border: 1px solid var(--line-2); font-size: 11.5px; cursor: pointer; }
.check-pill:has(input:checked) { background: var(--accent-soft); border-color: var(--accent-line); color: #fff; }

.toast {
  position: fixed; bottom: 18px; right: 18px; z-index: 140;
  background: var(--card); border: 1px solid var(--accent-line); padding: 9px 14px;
  border-radius: var(--r-sm); font-size: 12.5px; box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55);
}

@media (max-width: 1120px) {
  .topbar { height: auto; padding: 10px 14px; flex-wrap: wrap; }
  .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2, .grid-3, .ab-bars-grid { grid-template-columns: 1fr; }
  .col-8, .col-7, .col-6, .col-5, .col-4 { grid-column: span 12; }
  .hbar-row { grid-template-columns: 125px 1fr 95px; }
}
