/* Daylight ledger — bright, direct, blueprint-precise.
   Type: Geist (display/body) + Geist Mono (labels, metadata, controls).
   Structure: hairline + dashed rules, fused 1px grids, square corners. */

:root {
  --paper: #fafaf7;
  --surface: #ffffff;
  --ink: #16181a;
  --muted: #66706a;
  --line: #e4e6e1;
  --dash: #c9cec8;
  --green: #0e8155;        /* text-safe accent on white */
  --green-bright: #14a86a; /* fills, bars, dots */
  --mint: #ecf6ef;
  --blue: #2563eb;         /* revenue series (chart) */
  --red: #bf3f1d;
  --gold: #d8a842;
  --sans: Geist, "Geist Fallback", Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  --nav-width: 218px;
}

* { box-sizing: border-box; }

html { color-scheme: light; scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--sans);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }

button, a { -webkit-tap-highlight-color: transparent; }

/* Mono utility voice: labels, tags, controls, metadata. */
.eyebrow,
.kpi-top,
.kpi-context,
.delta,
.view-control,
.view-switch button,
.range-switch button,
.side-nav-list a,
.logout-link,
.kit-status,
.kit-metric span,
.kit-card-head > div > span,
.daily-stat span,
.lifetime-item span,
.month-label,
.conversion-label span,
.chart-legend,
.chart-summary,
.loading-card,
.login-form label,
.login-note {
  font-family: var(--mono);
}

.page-shell {
  width: min(1440px, calc(100% - 48px));
  margin: 0 auto;
  padding-left: var(--nav-width);
}

/* ---------- side navigation ---------- */

.side-nav {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 5;
  width: var(--nav-width);
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 30px 18px 24px;
  border-right: 1px solid var(--line);
  background: var(--paper);
}

.side-nav-list {
  flex: 1 1 auto;
  display: grid;
  align-content: start;
  gap: 1px;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-y: auto;
}

.side-nav-list a {
  display: flex;
  gap: 8px;
  padding: 9px 10px;
  color: var(--muted);
  text-decoration: none;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: color .14s ease, background-color .14s ease;
}

.side-nav-list a:hover { color: var(--ink); background: rgba(22, 24, 26, 0.04); }

.side-nav-list a.active {
  color: var(--green);
  background: var(--mint);
  font-weight: 600;
}

.logout-link {
  flex: 0 0 auto;
  padding: 9px 10px;
  color: var(--muted);
  font-size: 11px;
  text-decoration: none;
}

.logout-link:hover { color: var(--ink); }

.logout-link::before { content: "← "; color: var(--dash); }

/* ---------- shared type ---------- */

.eyebrow {
  margin: 0 0 12px;
  color: var(--green);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }

h1, h2 {
  font-weight: 500;
  letter-spacing: -0.02em;
}

.page-title {
  margin: 0;
  font-size: clamp(30px, 3.4vw, 44px);
  line-height: 1.04;
}

main > section,
.content-grid > .panel { scroll-margin-top: 26px; }

/* ---------- hero ---------- */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(440px, 0.86fr);
  gap: clamp(24px, 4vw, 60px);
  align-items: center;
  padding: 44px 0 30px;
}

.hero .eyebrow { margin-bottom: 0; }

.hero-context {
  display: grid;
  justify-items: start;
  gap: 14px;
}

.view-control {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.view-switch {
  display: inline-flex;
  border: 1px solid var(--ink);
  background: var(--surface);
}

.view-switch button {
  padding: 8px 12px;
  border: 0;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.view-switch button + button { border-left: 1px solid var(--line); }

.view-switch button.active {
  color: var(--surface);
  background: var(--ink);
}

.view-switch button:disabled { opacity: .4; cursor: not-allowed; }

.view-switch button:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

.view-disclosure {
  max-width: 460px;
  margin: 0;
  padding: 10px 12px;
  border: 1px dashed var(--dash);
  border-left: 3px solid var(--gold);
  color: var(--muted);
  background: var(--surface);
  font-size: 11.5px;
  line-height: 1.55;
}

/* ---------- daily check-in: the single dark anchor ---------- */

.daily-checkin {
  position: relative;
  padding: 26px 28px;
  color: var(--paper);
  background: var(--ink);
}

.daily-checkin .eyebrow { color: var(--green-bright); }
.daily-checkin h2 { margin-bottom: 24px; font-size: 26px; }

.daily-checkin-grid {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.daily-stat { flex: 1; min-width: 0; }

.daily-stat span {
  display: block;
  color: rgba(250, 250, 247, .55);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.daily-stat strong {
  display: block;
  margin-top: 8px;
  font-size: 21px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.daily-op {
  flex: 0 0 auto;
  align-self: flex-end;
  padding-bottom: 2px;
  color: rgba(250, 250, 247, .4);
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 400;
  line-height: 1;
}

/* ---------- KPI grid: fused hairline cells ---------- */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1px;
  margin-bottom: 40px;
  border: 1px solid var(--line);
  background: var(--line);
}

.kpi-card {
  min-height: 168px;
  padding: 22px;
  background: var(--surface);
}

.kpi-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  min-height: 30px; /* two label lines, so values baseline-align across cards */
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

/* bracketed metadata, wriks-style */
.kpi-top span:last-child::before { content: "["; color: var(--dash); }
.kpi-top span:last-child::after { content: "]"; color: var(--dash); }

.kpi-value {
  display: block;
  margin: 22px 0 14px;
  font-size: clamp(26px, 2.6vw, 37px);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}

.delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--green);
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.delta.down { color: var(--red); }
.delta.neutral { color: var(--muted); }
/* Meta spend is an input cost, not a win/loss — keep its change neutral ink. */
.delta.flat { color: var(--ink); }

.kpi-context {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

/* ---------- panels ---------- */

.content-grid {
  display: grid;
  grid-template-columns: minmax(320px, .7fr) minmax(0, 1.7fr);
  gap: 40px;
}

.panel {
  padding: 26px 0 0;
  border-top: 1px solid var(--ink);
  background: transparent;
}

.panel-header,
.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
}

.panel-header h2,
.section-heading h2 {
  margin-bottom: 0;
  font-size: 24px;
}

.range-switch {
  display: inline-flex;
  border: 1px solid var(--line);
  background: var(--surface);
}

.range-switch button {
  padding: 7px 11px;
  border: 0;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.range-switch button + button { border-left: 1px solid var(--line); }

.range-switch button.active {
  color: var(--surface);
  background: var(--ink);
}

/* ---------- chart ---------- */

.chart-legend {
  display: flex;
  gap: 20px;
  margin-top: 26px;
  color: var(--muted);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.chart-legend span { display: inline-flex; align-items: center; gap: 7px; }
.chart-legend i { width: 18px; height: 2px; }
.legend-revenue {
  background: repeating-linear-gradient(90deg, var(--blue) 0 4px, transparent 4px 7px);
}
.legend-profit { background: var(--green-bright); }

.chart-wrap {
  position: relative;
  width: 100%;
  height: 330px;
  margin-top: 16px;
}

#trend-chart { width: 100%; height: 100%; }

.chart-tooltip {
  position: absolute;
  z-index: 2;
  min-width: 150px;
  padding: 10px 12px;
  transform: translate(-50%, calc(-100% - 15px));
  border: 1px solid var(--ink);
  color: var(--ink);
  background: var(--surface);
  box-shadow: 4px 4px 0 rgba(22, 24, 26, 0.08);
  pointer-events: none;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.55;
  font-variant-numeric: tabular-nums;
}

.chart-tooltip strong { display: block; margin-bottom: 3px; }
.chart-summary { margin: 10px 0 0; color: var(--muted); font-size: 10.5px; }

/* ---------- monthly result ---------- */

.monthly-list { margin-top: 20px; }

.month-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px dotted var(--dash);
}

.month-row:last-child { border-bottom: 0; }

.month-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.month-value {
  text-align: right;
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.month-value.negative { color: var(--red); }

/* ---------- licensing kit ---------- */

.kit-section {
  position: relative;
  margin: 64px 0;
  padding: 40px 0 0;
  border-top: 1px solid var(--ink);
}

.kit-section::before {
  content: "+";
  position: absolute;
  top: -8px;
  right: 0;
  color: var(--green-bright);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1;
  pointer-events: none;
}

.section-heading > p {
  max-width: 470px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.kit-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
  margin-top: 28px;
}

.kit-card {
  padding: 26px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.kit-card.recent { border-style: dashed; border-color: var(--dash); }

.kit-card.current {
  grid-column: 1 / -1;
  border: 1px solid var(--green);
  background: var(--mint);
}

.kit-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.kit-card h3 {
  margin-bottom: 6px;
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.015em;
}

.kit-card-head > div > span {
  color: var(--muted);
  font-size: 10.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.kit-status {
  padding: 5px 8px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--surface);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.kit-card.current .kit-status {
  border-color: var(--green);
  color: var(--surface);
  background: var(--green);
}

.kit-card.recent .kit-status { border-style: dashed; border-color: var(--gold); color: #8a6210; }

.kit-narrative {margin: 20px 0;color: var(--muted);font-size: 14px;line-height: 1.7;}

.kit-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px 12px;
  padding-top: 20px;
  border-top: 1px dotted var(--dash);
}

.kit-card.current .kit-metrics {
  grid-template-columns: repeat(6, 1fr);
  border-top-color: rgba(14, 129, 85, 0.35);
}

.kit-metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.kit-metric strong {
  display: block;
  margin-top: 7px;
  font-size: 17px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.kit-metric.has-tip { position: relative; cursor: help; }

.kit-metric.has-tip strong {
  text-decoration: underline dotted var(--ink);
  text-underline-offset: 3px;
}

.kit-tip {
  position: absolute;
  left: 0;
  bottom: calc(100% + 10px);
  z-index: 4;
  width: max-content;
  max-width: 250px;
  padding: 11px 13px;
  border: 1px solid var(--ink);
  color: var(--ink);
  background: var(--surface);
  box-shadow: 4px 4px 0 rgba(22, 24, 26, 0.08);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.6;
  white-space: normal;
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  transition: opacity .16s ease, transform .16s ease, visibility .16s ease;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}

.kit-tip em {
  display: block;
  margin-bottom: 6px;
  color: var(--green);
  font-style: normal;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.kit-metric.has-tip:hover .kit-tip,
.kit-metric.has-tip:focus .kit-tip,
.kit-metric.has-tip:focus-within .kit-tip {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  font-size: 12px;
}

/* ---------- conversion ---------- */

.lower-grid { grid-template-columns: 1fr; margin-bottom: 70px; }

.conversion-list { margin-top: 20px; }

.conversion-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) 2fr 66px;
  gap: 16px;
  align-items: center;
  padding: 13px 0;
  border-bottom: 1px dotted var(--dash);
}

.conversion-row:last-child { border-bottom: 0; }
.conversion-label strong { display: block; font-size: 13px; font-weight: 600; }
.conversion-label span { color: var(--muted); font-size: 10px; }
.conversion-track { height: 6px; background: #eef0ec; }
.conversion-fill { height: 100%; min-width: 3px; background: var(--green-bright); }

.conversion-rate {
  text-align: right;
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ---------- loading ---------- */

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  background: rgba(250, 250, 247, .95);
  transition: opacity .22s ease, visibility .22s ease;
}

.loading-overlay.hidden { opacity: 0; visibility: hidden; }

.loading-card {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.loading-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--line);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- login ---------- */

.brand-mark {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  color: var(--paper);
  background: var(--ink);
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 600;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(440px, 100%);
  padding: 44px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.login-card .brand-mark { margin-bottom: 32px; }
.login-card h1 { margin-bottom: 15px; font-size: 36px; }
.login-intro { color: var(--muted); font-size: 13px; line-height: 1.6; }

.login-error {
  padding: 11px 13px;
  border: 1px solid var(--red);
  color: var(--red);
  background: #fdf1ed;
  font-size: 12px;
}

.login-form { display: grid; gap: 9px; margin-top: 28px; }

.login-form label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.login-form input {
  width: 100%;
  padding: 12px 13px;
  border: 1px solid var(--line);
  background: var(--surface);
  outline: none;
}

.login-form input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(14, 129, 85, .14); }

.login-form button {
  margin-top: 5px;
  padding: 13px 16px;
  border: 0;
  color: var(--surface);
  background: var(--ink);
  cursor: pointer;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.login-form button:hover { background: var(--green); }

.login-note { margin: 18px 0 0; color: var(--muted); font-size: 10px; text-align: center; }

/* ---------- responsive ---------- */

@media (max-width: 1050px) {
  .page-shell { padding-left: 0; }

  .side-nav {
    position: sticky;
    top: 0;
    bottom: auto;
    width: 100%;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 8px 14px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .side-nav-list {
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    gap: 2px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
  }

  .side-nav-list::-webkit-scrollbar { display: none; }
  .side-nav-list a { white-space: nowrap; padding: 8px 10px; }
  main > section, .content-grid > .panel { scroll-margin-top: 64px; }

  .hero { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .content-grid { grid-template-columns: 1fr; }
  .monthly-list { display: grid; grid-template-columns: 1fr 1fr; column-gap: 32px; }
  .kit-card.current .kit-metrics { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 700px) {
  .page-shell { width: min(100% - 28px, 1440px); }
  .hero { gap: 20px; padding: 26px 0 22px; }
  .view-control { align-items: flex-start; flex-direction: column; }
  .daily-checkin { padding: 22px; }
  .daily-checkin-grid { gap: 10px; }
  .daily-stat strong { font-size: 17px; }
  .kpi-grid { grid-template-columns: 1fr; margin-bottom: 32px; }
  .kpi-card { min-height: 0; padding: 18px 20px; }
  .kpi-value { margin: 14px 0 10px; }
  .content-grid { gap: 32px; }
  .panel-header h2, .section-heading h2 { font-size: 21px; }
  .trend-panel .panel-header { align-items: flex-end; }
  .chart-wrap { height: 280px; }
  .monthly-list { display: block; }
  .kit-section { margin: 44px 0; padding-top: 32px; }
  .section-heading { display: block; }
  .section-heading > p { margin-top: 16px; }
  .kit-grid { grid-template-columns: 1fr; gap: 16px; }
  .kit-card { padding: 22px; }
  .kit-metrics { grid-template-columns: 1fr 1fr; }
  .kit-card.current .kit-metrics { grid-template-columns: 1fr 1fr; }
  .lower-grid { margin-bottom: 45px; }
}

@media (max-width: 430px) {
  .daily-checkin-grid { flex-direction: column; align-items: stretch; }
  .daily-op { display: none; }
  .daily-stat {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 8px 0;
    border-bottom: 1px dotted rgba(250, 250, 247, .3);
  }
  .daily-stat:last-child { border-bottom: 0; }
  .daily-stat strong { margin-top: 0; }
  .panel-header { gap: 12px; }
  .conversion-row { grid-template-columns: 1fr 58px; }
  .conversion-track { grid-column: 1 / -1; grid-row: 2; }
  .login-card { padding: 34px 26px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
