/* Omura Sales Dashboard — v1 */

:root {
  --teal:    #00B8B0;
  --blue:    #1A3C6E;
  --light:   #F4F7FB;
  --white:   #FFFFFF;
  --grey:    #8A9BAD;
  --border:  #DDE3EB;
  --red:     #E05555;
  --green:   #27AE60;
  --text:    #1A1F2C;
  --text-sm: #5A6478;
  --radius:  8px;
  --shadow:  0 1px 4px rgba(0,0,0,.08);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--light);
  line-height: 1.5;
}

/* ── Header ────────────────────────────────────────────────────────────── */

header {
  background: var(--blue);
  color: var(--white);
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.header-left {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.header-logo {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  opacity: .7;
}

header h1 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -.01em;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.range-badge {
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 20px;
  padding: 3px 12px;
  font-size: 12px;
  font-weight: 500;
}

.timestamp {
  font-size: 11px;
  opacity: .6;
}

/* ── Main layout ────────────────────────────────────────────────────────── */

main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 24px 40px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

/* ── Section ────────────────────────────────────────────────────────────── */

.section {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.section-header {
  padding: 14px 20px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}

.section-header h2 {
  font-size: 16px;
  font-weight: 600;
  color: var(--blue);
  letter-spacing: -.005em;
}

.section-sub {
  font-size: 11.5px;
  color: var(--text-sm);
  font-weight: 400;
}

/* ── Region grid (3 columns for KPI / donut sections) ───────────────────── */

.region-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border);
}

/* Modifier — stack regions vertically (full-width per region).  Used by
   Stock Watch where the per-region table has 6 columns and the default
   3-up grid leaves each card too narrow to render cleanly (header text
   wraps to 3 lines, SKU codes wrap, "Order Now" wraps, etc.). */
.region-grid--stacked {
  grid-template-columns: 1fr;
  gap: 0;
}
.region-grid--stacked .region-card {
  border-bottom: 1px solid var(--border);
}
.region-grid--stacked .region-card:last-child {
  border-bottom: none;
}

.region-card {
  background: var(--white);
  padding: 14px 18px 16px;
}

.region-card h3 {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-sm);
  letter-spacing: .04em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.donut-grid .region-card {
  padding: 16px 12px;
}

/* ── KPI table ──────────────────────────────────────────────────────────── */

.kpi-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.kpi-table th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-sm);
  padding: 5px 6px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.kpi-table td {
  padding: 7px 6px;
  border-bottom: 1px solid var(--light);
}

.kpi-table tr:last-child td {
  border-bottom: none;
}

.kpi-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Sub-section divider inside a KPI table — used by the Unit Economics
 * subscriber-split block to separate subscriber rows from the main
 * lifetime / CAC rows.  Italic label, muted background, no top border. */
.kpi-table .kpi-subhead td {
  background: var(--light);
  color: var(--text-sm);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 5px 6px;
  border-bottom: 1px solid var(--border);
}

/* In-table secondary value (e.g., "(45% of base)" tucked next to the n) */
.kpi-table .muted {
  color: var(--text-sm);
  font-size: 11px;
  font-weight: 400;
}

.delta-up   { color: var(--green); font-weight: 500; }
.delta-down { color: var(--red);   font-weight: 500; }
.delta-neutral { color: var(--grey); }

/* Combined Period Comparison: 4 columns, slightly tighter for fit */
.kpi-table-combined th,
.kpi-table-combined td {
  padding-left: 5px;
  padding-right: 5px;
}

.kpi-table-combined th {
  font-size: 10px;
}

/* ── Chart stack (full-width sections with 3 stacked charts) ────────────── */

.chart-stack {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.chart-block {
  padding: 8px 12px 12px;
  border-bottom: 1px solid var(--border);
}

.chart-block:last-child {
  border-bottom: none;
}

/* Make Plotly charts fill their container */
.chart-block .plotly-graph-div {
  width: 100% !important;
}

/* ── Product table ──────────────────────────────────────────────────────── */

.product-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.product-table th {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-sm);
  padding: 5px 6px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.product-table td {
  padding: 6px;
  border-bottom: 1px solid var(--light);
  vertical-align: middle;
}

.product-table tr:last-child td {
  border-bottom: none;
}

.product-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ── Funnel-band dividers (Acquisition / Conversion / Retention) ────────── */

.funnel-band {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-sm);
  text-align: center;
  margin: 8px 0 -4px;
  padding: 6px 0;
  user-select: none;
}

/* ── Marketing & Acquisition — headline tiles ───────────────────────────── */

.marketing-tiles {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border);
  border-bottom: 1px solid var(--border);
}

.marketing-tile {
  background: var(--white);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mt-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-sm);
}

.mt-value {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--blue);
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
}

.mt-sub {
  font-size: 11px;
  color: var(--text-sm);
}

@media (max-width: 1100px) {
  .marketing-tiles { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .marketing-tiles { grid-template-columns: 1fr; }
}

/* ── Stock Watch ────────────────────────────────────────────────────────── */

.stock-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.stock-pill {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .04em;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  white-space: nowrap;
}

.stock-pill-out {
  background: #FBE3E3;
  color: #C53030;
  border: 1px solid #F1B5B5;
}

.stock-pill-critical {
  background: #FFE9D6;
  color: #C75300;
  border: 1px solid #F4C99B;
}

.stock-pill-low {
  background: #FFF3CD;
  color: #856404;
  border: 1px solid #F0DA88;
}

.stock-pill-healthy {
  background: #E0F2EB;
  color: #1F7A4D;
  border: 1px solid #B8DDC9;
}

.stock-pill-overstocked {
  background: #E5EAF3;
  color: #3D5A80;
  border: 1px solid #BFCCDF;
}

.stock-pill-dead {
  background: #ECEEF1;
  color: #5A6478;
  border: 1px solid #C9CDD4;
}

.stock-pill-untracked {
  background: #F4F7FB;
  color: #8A9BAD;
  border: 1px solid #D9E0E9;
}

.stock-watch-table .sku {
  font-family: "SF Mono", "Fira Mono", Consolas, monospace;
  font-size: 10px;
  color: var(--text-sm);
  letter-spacing: .02em;
}

.stock-watch-table small {
  font-size: 10px;
  color: var(--text-sm);
  font-weight: 400;
}

/* ── Methodology note (chart caveats) ───────────────────────────────────── */

.chart-note {
  padding: 10px 20px 14px;
  font-size: 11px;
  line-height: 1.55;
  color: var(--text-sm);
  border-top: 1px solid var(--border);
  background: #FAFBFD;
}

.chart-note strong {
  color: var(--text);
  font-weight: 600;
}

.chart-note em {
  font-style: italic;
}

/* ── No data placeholder ─────────────────────────────────────────────────── */

.no-data {
  font-size: 12px;
  color: var(--grey);
  padding: 16px 0;
  text-align: center;
}

/* ── Footer ─────────────────────────────────────────────────────────────── */

footer {
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px 24px 32px;
  font-size: 11px;
  color: var(--grey);
  text-align: center;
}

footer a {
  color: var(--teal);
  text-decoration: none;
}

/* ── Preset nav ─────────────────────────────────────────────────────────── */

.preset-nav {
  display: flex;
  gap: 2px;
}

.preset-nav a {
  color: rgba(255,255,255,.7);
  text-decoration: none;
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 4px;
  transition: background .15s, color .15s;
  white-space: nowrap;
}

.preset-nav a:hover {
  background: rgba(255,255,255,.12);
  color: var(--white);
}

.preset-nav a.active {
  background: rgba(255,255,255,.2);
  color: var(--white);
}

/* ── Pulse banner — top-of-page "needs attention" surfacing ────────────── */

.pulse-banner {
  background: var(--white);
  border: 1px solid var(--border);
  border-left: 3px solid var(--red);
  border-radius: var(--radius);
  padding: 12px 16px 14px;
  box-shadow: var(--shadow);
}

.pulse-header {
  font-size: 11px;
  font-weight: 700;
  color: var(--red);
  letter-spacing: .08em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.pulse-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pulse-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
}

.pulse-icon {
  flex-shrink: 0;
  width: 18px;
  text-align: center;
  font-size: 14px;
}

.pulse-msg {
  flex: 1;
}

.pulse-high .pulse-icon { color: var(--red); }
.pulse-medium .pulse-icon { color: #C75300; }

/* Legacy class — keep so older builds don't break, but it's unused now. */
.freshness-warning {
  background: #FFF3CD;
  border: 1px solid #FFEAA0;
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13px;
  color: #856404;
  line-height: 1.5;
}

/* ── Narrative card ─────────────────────────────────────────────────────── */

.narrative-section {
  border-left: 3px solid var(--teal);
}

.narrative-section .section-header {
  background: #F8FFFE;
}

.section-sub .narrative-credit,
.narrative-credit {
  font-size: 11px;
  color: var(--text-sm);
  font-style: italic;
}

.narrative-body {
  padding: 16px 20px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
}

/* Board summary — multi-paragraph, slightly more generous typography */
.narrative-section--board {
  border-left-color: var(--blue);  /* differentiate from Sonnet card */
}

.narrative-body--board p {
  margin-bottom: 12px;
}

.narrative-body--board p:last-child {
  margin-bottom: 0;
}

/* Brand-health table headings inside region cards */
.brand-table-h {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-sm);
  margin: 12px 0 6px;
}

.gsc-queries-table {
  font-size: 11px;
}

/* ── Hero scoreboard ────────────────────────────────────────────────────── */

.hero-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border);
}

.hero-card {
  background: var(--white);
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hero-card--group {
  background: #F8FFFE;
}

.hero-region {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-sm);
}

.hero-revenue {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -.025em;
  color: var(--blue);
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
}

.hero-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
}

.hero-delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 13px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
  width: fit-content;
}

.hero-delta.delta-up {
  color: var(--green);
  background: #EBF7F0;
}

.hero-delta.delta-down {
  color: var(--red);
  background: #FDF0F0;
}

.hero-sub {
  font-size: 12px;
  color: var(--text-sm);
}

.hero-projection {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-sm);
  background: rgba(0, 184, 176, 0.08);
  border: 1px dashed var(--teal);
  border-radius: 12px;
  padding: 2px 10px;
  width: fit-content;
}

.hero-projection strong {
  color: var(--blue);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.hero-projection small {
  color: var(--text-sm);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  margin-left: 2px;
}

/* ── Empty state ────────────────────────────────────────────────────────── */

.empty-state {
  background: #F8F9FC;
  border: 1px dashed var(--border);
  border-radius: 6px;
  padding: 20px;
  text-align: left;
  font-size: 12px;
  color: var(--text-sm);
}

.empty-state code {
  font-family: "SF Mono", "Fira Mono", Consolas, monospace;
  font-size: 11px;
  background: var(--light);
  padding: 1px 4px;
  border-radius: 3px;
}

/* ── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 1200px) {
  .hero-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 1100px) {
  .region-grid { grid-template-columns: 1fr; gap: 0; }
  .region-card  { border-bottom: 1px solid var(--border); }
}

@media (max-width: 768px) {
  .hero-grid { grid-template-columns: 1fr 1fr; }
  .preset-nav { display: none; }
  .range-badge { display: none; }
  .hero-revenue { font-size: 22px; }
  .section-header { flex-wrap: wrap; }
}

@media (max-width: 480px) {
  .hero-grid { grid-template-columns: 1fr; }
  header h1 { font-size: 15px; }
  main { padding: 12px 12px 32px; gap: 20px; }
}

@media (max-width: 700px) {
  .header-inner { flex-direction: column; align-items: flex-start; gap: 8px; }
  main { padding: 16px; }
}

/* ── Print ──────────────────────────────────────────────────────────────── */

@media print {
  @page { margin: 15mm 12mm; }

  header {
    position: static;
    box-shadow: none;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .preset-nav,
  .timestamp,
  .range-badge { display: none; }

  main { padding: 0; gap: 20px; }

  .section {
    box-shadow: none;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  /* Two-column grid for hero on print */
  .hero-grid { grid-template-columns: repeat(2, 1fr); }
  .region-grid { grid-template-columns: repeat(2, 1fr); }

  /* Prevent orphan chart blocks */
  .chart-block { break-inside: avoid; page-break-inside: avoid; }

  /* Force chart SVGs to render fully */
  .plotly-graph-div { width: 100% !important; }
}

/* ── Roadmap section ────────────────────────────────────────────────────── */

.roadmap-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
  padding: 16px;
}

.roadmap-item {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.roadmap-item h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.roadmap-item p {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-sm);
  margin: 0;
}

.roadmap-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.roadmap-pill {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.pill-up-next {
  background: rgba(0, 184, 176, 0.12);
  color: var(--teal);
}

.pill-backlog {
  background: rgba(26, 60, 110, 0.10);
  color: var(--blue);
}

.pill-future {
  background: rgba(138, 155, 173, 0.15);
  color: var(--text-sm);
}

.pill-shipped {
  background: rgba(39, 174, 96, 0.14);
  color: var(--green);
}

.roadmap-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--grey);
  background: var(--light);
  padding: 2px 6px;
  border-radius: 4px;
}

/* ── Tooltip info-icon — used inside KPI table labels and headline tiles ─── */

.info-icon {
  display: inline-block;
  font-size: 11px;
  color: var(--grey);
  margin-left: 3px;
  cursor: help;
  vertical-align: 1px;
  opacity: 0.55;
  transition: opacity 120ms ease;
}

tr:hover .info-icon,
.marketing-tile:hover .info-icon {
  opacity: 1;
}

/* When a row has a title attribute, give a subtle hint that it's hoverable */
tr[title] {
  cursor: help;
}

.marketing-tile[title] {
  cursor: help;
}
