
:root{
  --bg:#FAF7EF;
  --bg-alt:#F1EAD9;
  --card:#FFFFFF;
  --ink:#17140D;
  --ink-soft:#6B6252;
  --ink-faint:#9C9280;
  --gold:#E3A62F;
  --gold-deep:#B9791C;
  --gold-soft:#F6E4BC;
  --charcoal:#211E17;
  --charcoal-soft:#332F24;
  --line:#E6DEC9;
  --good:#5C7A45;
  --good-bg:#E8EEDF;
  --retention:#2E7C8A;
  --best:#B9791C;
  --best-bg:#FBEAC9;
  --real-bg:#EDE9DD;
  --danger:#B84334;
  --shadow: 0 1px 2px rgba(23,20,13,0.04), 0 8px 24px -12px rgba(23,20,13,0.12);
  --radius: 14px;
}
[data-theme="dark"]{
  --bg:#131109;
  --bg-alt:#1B180F;
  --card:#1E1B12;
  --ink:#F3EEDF;
  --ink-soft:#B6AC94;
  --ink-faint:#7C755F;
  --gold:#F0B93E;
  --gold-deep:#D99B2B;
  --gold-soft:#3A2F16;
  --charcoal:#0E0C08;
  --charcoal-soft:#221E14;
  --line:#332E1E;
  --good:#8FB56F;
  --good-bg:#20281A;
  --retention:#4FA8B8;
  --best:#F0B93E;
  --best-bg:#2E2410;
  --real-bg:#211E14;
  --danger:#E37059;
  --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 8px 24px -12px rgba(0,0,0,0.5);
}
*{box-sizing:border-box;}
html,body{margin:0;padding:0;}
body{
  background:var(--bg);
  color:var(--ink);
  font-family:'Inter',sans-serif;
  font-size:14px;
  line-height:1.5;
  -webkit-font-smoothing:antialiased;
  transition:background .2s ease, color .2s ease;
}
h1,h2,h3,h4,.display{ font-family:'Space Grotesk',sans-serif; letter-spacing:-0.01em; }
.mono{ font-family:'IBM Plex Mono',monospace; font-variant-numeric: tabular-nums; }
a{color:inherit;}
button{font-family:inherit;cursor:pointer;}
input,select,textarea{font-family:inherit;}

/* Layout */
#shell{display:flex; min-height:100vh;}
#sidebar{
  width:250px; flex-shrink:0; background:var(--charcoal); color:#EDE6D3;
  display:flex; flex-direction:column; position:sticky; top:0; height:100vh;
}
#sidebar .brand-mark{ display:flex; align-items:center; gap:10px; padding:22px 20px 18px; border-bottom:1px solid rgba(255,255,255,0.08);}
#sidebar .brand-mark img{ width:34px; height:34px; object-fit:contain; }
#sidebar .brand-mark .name{ font-family:'Space Grotesk',sans-serif; font-weight:600; font-size:15px; line-height:1.15; color:#F7F1DE;}
#sidebar .brand-mark .sub{ font-size:10px; letter-spacing:.08em; text-transform:uppercase; color:#B9AE8C;}

.mode-switch{ display:flex; gap:4px; margin:14px 12px 4px; padding:3px; background:rgba(255,255,255,0.06); border-radius:10px; }
.mode-btn{
  flex:1; border:none; background:transparent; color:#B9AE8C; font-size:11.5px; font-weight:600;
  padding:8px 6px; border-radius:8px; cursor:pointer; transition: background .15s ease, color .15s ease; line-height:1.2;
}
.mode-btn:hover{ color:#F7F1DE; }
.mode-btn.active{ background:var(--gold); color:#1C1707; }
[data-mode].mode-hidden{ display:none !important; }

.nav-section{ padding: 14px 12px; }
.nav-label{ font-size:10px; text-transform:uppercase; letter-spacing:.1em; color:#8A806A; padding:8px 10px 6px; }
.nav-item{
  display:flex; align-items:center; gap:10px; padding:9px 10px; border-radius:9px; color:#D9D0BA;
  font-size:13.5px; font-weight:500; margin-bottom:2px; transition: background .15s ease, color .15s ease;
}
.nav-item:hover{ background:rgba(255,255,255,0.06); color:#fff; }
.nav-item.active{ background:var(--gold); color:#1C1707; font-weight:600;}
.nav-item svg{ width:16px; height:16px; flex-shrink:0; }

#brand-list{ flex:1; overflow-y:auto; padding: 4px 12px 12px;}
.brand-chip{
  display:flex; align-items:center; justify-content:space-between; gap:8px;
  padding:8px 10px; border-radius:9px; color:#D9D0BA; font-size:13px; margin-bottom:2px;
}
.brand-chip:hover{ background:rgba(255,255,255,0.06); }
.brand-chip.active{ background:rgba(227,166,47,0.18); color:#F6E4BC; }
.brand-chip .dot{ width:6px;height:6px;border-radius:50%; background:var(--gold); flex-shrink:0; }
.brand-chip .bname{ flex:1; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; cursor:pointer; }

#sidebar-footer{ padding:14px 20px 18px; border-top:1px solid rgba(255,255,255,0.08); font-size:11px; color:#8A806A;}

#main{ flex:1; min-width:0; }
#topbar{
  position:sticky; top:0; z-index:20; background:var(--bg); border-bottom:1px solid var(--line);
  display:flex; align-items:center; justify-content:space-between; padding:16px 28px; backdrop-filter:blur(6px);
}
#content{ padding:26px 28px 60px; max-width:1400px; }

.btn{
  display:inline-flex; align-items:center; gap:7px; padding:9px 14px; border-radius:9px; border:1px solid var(--line);
  background:var(--card); color:var(--ink); font-size:13px; font-weight:600; transition:all .15s ease;
}
.btn:hover{ border-color:var(--gold-deep); transform:translateY(-1px); box-shadow:var(--shadow); }
.btn-primary{ background:var(--charcoal); color:#F6E4BC; border-color:var(--charcoal); }
.btn-primary:hover{ background:var(--gold); color:#1C1707; border-color:var(--gold); }
.btn-gold{ background:var(--gold); color:#1C1707; border-color:var(--gold); }
.btn-ghost{ background:transparent; border-color:transparent; }
.btn-ghost:hover{ background:var(--bg-alt); border-color:var(--line); transform:none; box-shadow:none;}
.btn-danger{ color:var(--danger); }
.btn-sm{ padding:6px 10px; font-size:12px; }
.btn svg{ width:14px; height:14px; }

.card{ background:var(--card); border:1px solid var(--line); border-radius:var(--radius); box-shadow:var(--shadow); }
.pad{ padding:20px; }

.grid{ display:grid; gap:16px; }
.grid-4{ grid-template-columns:repeat(4,1fr); }
.grid-3{ grid-template-columns:repeat(3,1fr); }
.grid-2{ grid-template-columns:repeat(2,1fr); }
@media(max-width:1100px){ .grid-4{grid-template-columns:repeat(2,1fr);} .grid-3{grid-template-columns:repeat(2,1fr);} }
@media(max-width:720px){ .grid-4,.grid-3,.grid-2{grid-template-columns:1fr;} #sidebar{position:fixed; left:-260px; z-index:50; transition:left .2s ease;} #sidebar.open{left:0;} }

.stat-card{ padding:18px 20px; }
.stat-label{ font-size:11px; text-transform:uppercase; letter-spacing:.08em; color:var(--ink-faint); font-weight:600; margin-bottom:8px;}
.stat-value{ font-family:'Space Grotesk',sans-serif; font-size:26px; font-weight:700; }
.stat-sub{ font-size:12px; color:var(--ink-soft); margin-top:4px; }

label{ display:block; font-size:12px; font-weight:600; color:var(--ink-soft); margin-bottom:6px; }
input[type=text],input[type=number],input[type=date],textarea,select{
  width:100%; padding:9px 11px; border-radius:9px; border:1px solid var(--line); background:var(--bg);
  color:var(--ink); font-size:13.5px; outline:none; transition:border-color .15s ease;
}
input:focus,textarea:focus,select:focus{ border-color:var(--gold-deep); }
.field{ margin-bottom:14px; }
.row{ display:flex; gap:12px; }
.row > *{ flex:1; }

table{ width:100%; border-collapse:collapse; font-size:13px; }
th{ text-align:left; font-size:10.5px; text-transform:uppercase; letter-spacing:.06em; color:var(--ink-faint); font-weight:700; padding:10px 12px; border-bottom:1px solid var(--line); white-space:nowrap;}
td{ padding:11px 12px; border-bottom:1px solid var(--line); white-space:nowrap; }
tr:last-child td{ border-bottom:none; }
.scenario-badge{ display:inline-flex; align-items:center; gap:7px; font-weight:600; font-size:12.5px;}
.arch{ width:14px; height:14px; border-radius:14px 14px 0 0; display:inline-block; }
.arch.real{ background:var(--ink-faint); }
.arch.good{ background:var(--good); }
.arch.best{ background:var(--gold); }
.row-real td:first-child{ border-left:3px solid var(--ink-faint); }
.row-good td:first-child{ border-left:3px solid var(--good); }
.row-best td:first-child{ border-left:3px solid var(--gold); }

.tag{ display:inline-block; padding:3px 9px; border-radius:100px; font-size:11px; font-weight:600; }
.tag-good{ background:var(--good-bg); color:var(--good); }
.tag-best{ background:var(--best-bg); color:var(--best); }

.section-title{ display:flex; align-items:center; justify-content:space-between; margin-bottom:14px; }
.section-title h2{ font-size:18px; margin:0; }
.section-title .hint{ font-size:12px; color:var(--ink-faint); }

.chart-box{ height:260px; position:relative; }

.stage-row{ display:flex; align-items:center; gap:10px; margin-bottom:8px; }
.stage-row input[type=text]{ flex:1.4; }
.stage-row input[type=number]{ flex:0.8; }
.stage-bar-track{ height:8px; border-radius:5px; background:var(--bg-alt); overflow:hidden; display:flex; margin-top:10px; }
.stage-bar-seg{ height:100%; }

.icon-btn{ width:30px; height:30px; display:flex; align-items:center; justify-content:center; border-radius:8px; border:1px solid var(--line); background:var(--card); color:var(--ink-soft); flex-shrink:0;}
.icon-btn:hover{ border-color:var(--danger); color:var(--danger); }

.pill-toggle{ display:inline-flex; background:var(--bg-alt); border-radius:100px; padding:3px; border:1px solid var(--line); }
.pill-toggle button{ border:none; background:transparent; padding:6px 13px; border-radius:100px; font-size:12.5px; font-weight:600; color:var(--ink-soft); }
.pill-toggle button.active{ background:var(--charcoal); color:#F6E4BC; }

.search-box{ position:relative; }
.search-box input{ padding-left:32px; }
.search-box svg{ position:absolute; left:10px; top:50%; transform:translateY(-50%); width:14px; height:14px; color:var(--ink-faint);}

.empty-state{ text-align:center; padding:70px 20px; color:var(--ink-soft); }
.empty-state svg{ width:44px; height:44px; margin-bottom:14px; color:var(--ink-faint); }

.warn-text{ font-size:11px; color:var(--danger); font-weight:600; margin-top:4px; }
.ok-text{ font-size:11px; color:var(--good); font-weight:600; margin-top:4px; }

.divider{ height:1px; background:var(--line); margin:22px 0; }

.top-title{ display:flex; align-items:center; gap:10px; }
.top-title h1{ font-size:19px; margin:0; }
.top-title .path{ font-size:11.5px; color:var(--ink-faint); text-transform:uppercase; letter-spacing:.06em; }

.logo-mini{ width:22px; height:22px; object-fit:contain; }

::-webkit-scrollbar{ width:9px; height:9px; }
::-webkit-scrollbar-thumb{ background:var(--line); border-radius:6px; }
#brand-list::-webkit-scrollbar-thumb{ background:rgba(255,255,255,0.12); }

.fade-in{ animation: fadein .25s ease; }
@keyframes fadein{ from{opacity:0; transform:translateY(4px);} to{opacity:1; transform:translateY(0);} }

.export-menu{ position:relative; display:inline-block; }
.export-dropdown{
  position:absolute; right:0; top:calc(100% + 6px); background:var(--card); border:1px solid var(--line);
  border-radius:11px; box-shadow:var(--shadow); min-width:210px; padding:6px; z-index:30; display:none;
}
.export-dropdown.open{ display:block; }
.export-dropdown button{ width:100%; text-align:left; padding:9px 10px; border-radius:7px; background:none; border:none; font-size:13px; color:var(--ink); display:flex; align-items:center; gap:9px; }
.export-dropdown button:hover{ background:var(--bg-alt); }

.notes-area{ min-height:70px; resize:vertical; }

/* ===== Client Report (PDF export template) ===== */
@keyframes spin{ to{ transform:rotate(360deg); } }
.report-container{ width:900px; background:#FAF7EF; color:#17140D; padding:0; font-family:'Inter',sans-serif; }
.report-container .mono{ font-family:'IBM Plex Mono',monospace; font-variant-numeric: tabular-nums; }
.report-page-pad{ padding:0 50px; }
.report-cover{ position:relative; overflow:hidden; padding:54px 50px 44px; border-bottom:3px solid #E3A62F; margin-bottom:8px; background:linear-gradient(180deg,#FFFFFF 0%,#FAF7EF 100%); }
.report-cover-motif{ position:absolute; top:-90px; right:-90px; width:340px; height:340px; opacity:0.9; }
.report-cover-inner{ position:relative; z-index:1; }
.report-cover img.report-logo{ height:48px; margin-bottom:26px; }
.report-cover .eyebrow{ display:inline-flex; align-items:center; gap:7px; font-size:11px; letter-spacing:.12em; text-transform:uppercase; color:#B9791C; font-weight:700; margin-bottom:14px; background:#FBEAC9; padding:6px 13px; border-radius:100px; }
.report-cover h1{ font-family:'Space Grotesk',sans-serif; font-size:36px; font-weight:700; margin:0 0 10px; letter-spacing:-0.01em; }
.report-cover h1.report-cover-title{ display:flex; align-items:center; gap:15px; font-size:31px; line-height:1.12; flex-wrap:wrap; }
.report-cover h1.report-cover-title img.report-cover-title-logo{ height:46px; width:auto; flex-shrink:0; }
.report-cover h1.report-cover-title .cover-x{ color:#B9791C; font-weight:600; margin:0 3px; }
.report-cover .sub{ font-size:13.5px; color:#6B6252; margin-bottom:22px; }
.report-cover .cover-badges{ display:flex; gap:8px; flex-wrap:wrap; }
.report-cover .cover-badge{ font-size:11px; font-weight:700; padding:5px 12px; border-radius:100px; background:#211E17; color:#F6E4BC; }
.report-header{ display:flex; align-items:center; justify-content:space-between; padding:16px 50px; border-bottom:1px solid #E6DEC9; margin-bottom:20px; }
.report-header img{ height:22px; }
.report-header .rh-name{ font-family:'Space Grotesk',sans-serif; font-weight:700; font-size:13px; }
.report-header .rh-meta{ font-size:10.5px; color:#9C9280; text-align:right; }
.report-intro{ font-size:13.5px; line-height:1.75; color:#4A4433; margin-bottom:24px; }
.report-section-heading{ font-family:'Space Grotesk',sans-serif; font-size:17px; font-weight:700; margin:0 0 4px; display:flex; align-items:center; gap:10px;}
.report-section-sub{ font-size:12px; color:#9C9280; margin-bottom:14px; }
.report-explain{ font-size:12.5px; color:#4A4433; line-height:1.65; margin:12px 0 18px; background:#F1EAD9; padding:14px 16px; border-radius:10px; border-left:3px solid #E3A62F; }
.report-footer{ margin-top:8px; padding:16px 50px 30px; display:flex; justify-content:space-between; align-items:center; font-size:10px; color:#9C9280; }
.report-footer .rf-brand{ display:flex; align-items:center; gap:8px; font-weight:700; color:#59503E; }
.report-footer img{ height:15px; }
.report-stat-grid{ display:grid; grid-template-columns:repeat(4,1fr); gap:14px; margin-bottom:22px; }
.report-stat{ background:#FFFFFF; border:1px solid #E6DEC9; border-left:3px solid #E3A62F; border-radius:12px; padding:16px 17px; box-shadow:0 1px 0 rgba(23,20,13,0.02); }
.report-stat .rs-label{ font-size:10px; text-transform:uppercase; letter-spacing:.07em; color:#9C9280; font-weight:700; margin-bottom:7px; }
.report-stat .rs-value{ font-family:'Space Grotesk',sans-serif; font-size:22px; font-weight:700; }
.report-stat .rs-sub{ font-size:11px; color:#6B6252; margin-top:3px; }
.report-uplift{ display:flex; align-items:center; gap:16px; background:#211E17; color:#F6E4BC; border-radius:14px; padding:20px 24px; margin-bottom:24px; }
.report-uplift .ru-icon{ width:44px; height:44px; border-radius:50%; background:#E3A62F; display:flex; align-items:center; justify-content:center; flex-shrink:0; font-family:'Space Grotesk',sans-serif; font-weight:700; font-size:15px; color:#1C1707; }
.report-uplift .ru-text{ font-size:13px; line-height:1.55; }
.report-uplift .ru-text b{ color:#F0B93E; font-family:'Space Grotesk',sans-serif; font-size:15px; }
.report-section{ margin-bottom:8px; padding:0 50px 26px; }
.report-section.alt{ background:#F4EEDF; padding-top:22px; margin:0 -50px 8px; padding-left:50px; padding-right:50px; }
.report-table{ width:100%; border-collapse:collapse; font-size:12px; margin-top:6px;}
.report-table th{ text-align:left; font-size:9.5px; text-transform:uppercase; letter-spacing:.05em; color:#9C9280; font-weight:700; padding:8px 10px; border-bottom:1px solid #E6DEC9; }
.report-table td{ padding:9px 10px; border-bottom:1px solid #EFE9D9; }
.report-table tr:last-child td{ border-bottom:none; }
.report-table tr.hl td{ background:#FBEAC9; font-weight:700; }
.report-platform-badge{ display:inline-flex; align-items:center; padding:3px 10px; border-radius:100px; font-size:10.5px; font-weight:700; color:#1C1707; }
.report-chart-row{ display:grid; grid-template-columns:1.3fr 1fr; gap:18px; margin-bottom:6px; }
.report-chart-box{ background:#FFFFFF; border:1px solid #E6DEC9; border-radius:12px; padding:14px 16px; height:230px; }
.report-funnel-list{ list-style:none; margin:10px 0 0; padding:0; font-size:12px; }
.report-funnel-list li{ display:flex; align-items:center; gap:9px; padding:6px 0; border-bottom:1px solid #EFE9D9; }
.report-funnel-list .dot{ width:9px; height:9px; border-radius:3px; flex-shrink:0; }
.report-funnel-list .fname{ flex:1; color:#4A4433; }
.report-funnel-list .fpct{ font-family:'IBM Plex Mono',monospace; font-weight:600; }
