/* Snoephond OS — design system aligned met Brand Guidelines v1.0 (mei 2026)
   60% wit / 30% bruin / 10% oranje. Lilita One display, Montserrat body, Allura accent.
*/

:root {
  /* Brand kern (60/30/10) */
  --bg: #ffffff;                /* 60% — papier-wit, primaire ademruimte */
  --bg-tint: #faf5ef;            /* heel zachte cream voor sub-secties */
  --accent: #f57035;             /* 10% — Snoephond oranje, primaire CTA */
  --accent-2: #df5e26;           /* hover / pressed */
  --accent-soft: #ffe1cf;        /* accent backgrounds */
  --accent-line: #fbc09c;
  --bone: #2c1207;               /* 30% — Snoephond bruin, primaire tekst/anker */
  --bone-deep: #1d0b04;          /* sidebar achtergrond, donkerste vlak */
  --bone-tint: #efe7e0;          /* light tint on dark */

  /* Tekstkleuren afgeleid van bone */
  --fg: #2c1207;                 /* primaire tekst = bruin */
  --fg-soft: #4d2616;            /* secundaire tekst */
  --muted: #846654;
  --muted-2: #ad9a8c;

  --card: #ffffff;
  --card-2: #faf5ef;
  --border: #ede2d4;
  --border-strong: #ddc9b3;

  /* Functionele kleuren (status), in brand-toon gekalibreerd */
  --error: #b22c1c;
  --error-soft: #fbe1dc;
  --ok: #2e6f43;
  --ok-soft: #d8ead9;
  --warn: #c47a17;
  --warn-soft: #fdebcb;
  --info: #4f7d9e;
  --info-soft: #dde9f3;

  /* Schaduwen op basis van bruin */
  --shadow-sm: 0 2px 6px -2px rgba(44, 18, 7, 0.08);
  --shadow: 0 8px 22px -10px rgba(44, 18, 7, 0.18), 0 2px 4px -2px rgba(44, 18, 7, 0.06);
  --shadow-lg: 0 30px 60px -30px rgba(245, 112, 53, 0.22), 0 4px 8px -2px rgba(44, 18, 7, 0.06);

  --radius: 14px;
  --radius-lg: 20px;
  --radius-pill: 999px;

  /* Typografie — Brand Guidelines */
  --font-display: 'Lilita One', system-ui, -apple-system, sans-serif;
  --font: 'Montserrat', -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-script: 'Allura', cursive;
  --font-tab: "SF Mono", ui-monospace, Menlo, Consolas, monospace;

  --t: cubic-bezier(0.2, 0.7, 0.2, 1);
  --sidebar-w: 244px;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

/* Brand signature surface — subtiele pootjes/botjes/hartjes patroon
   (10-15% bruin op wit, 220px tile, secondair element conform brand) */
body::before {
  content: '';
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-color: transparent;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220' viewBox='0 0 220 220'><g fill='%232c1207' fill-opacity='0.045'><path d='M40 50c0 4.4-3.6 8-8 8s-8-3.6-8-8 3.6-8 8-8 8 3.6 8 8zM58 60c0 3.3-2.7 6-6 6s-6-2.7-6-6 2.7-6 6-6 6 2.7 6 6zM30 76c0 3.3-2.7 6-6 6s-6-2.7-6-6 2.7-6 6-6 6 2.7 6 6zM52 78c0 3.3-2.7 6-6 6s-6-2.7-6-6 2.7-6 6-6 6 2.7 6 6zM38 92c-6 0-11 5-11 12 0 5 4 9 11 9s11-4 11-9c0-7-5-12-11-12z'/><path d='M155 130c-3-3-8-3-11 0-3-3-8-3-11 0-3 3-3 8 0 11l11 11 11-11c3-3 3-8 0-11z'/><path d='M115 165c-4 0-7 2-7 6 0 2 1 4 3 5l4 2 4-2c2-1 3-3 3-5 0-4-3-6-7-6zm-22 4c-2 1-3 3-3 5s1 4 3 4 3-2 3-4-1-4-3-5zm44 0c-2 1-3 3-3 5s1 4 3 4 3-2 3-4-1-4-3-5z'/><path d='M180 175c-1 0-2 1-2 2s1 2 2 2 2-1 2-2-1-2-2-2zm8-2c-1 0-2 1-2 2s1 2 2 2 2-1 2-2-1-2-2-2zM170 180c-1 0-2 1-2 2 0 2 1 3 3 4l-1-3c0-2 0-3 0-3z'/></g></svg>");
  background-size: 220px 220px;
  opacity: 0.85;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* -------------------------------------------------------------------------
   Layout: sidebar + main
------------------------------------------------------------------------- */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.sidebar {
  background: var(--bone);
  color: var(--bone-tint);
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(0, 0, 0, 0.2);
  overflow-y: auto;
  z-index: 10;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.08); border-radius: 4px; }

.sidebar-brand {
  padding: 22px 20px 18px;
  display: flex;
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-brand img {
  width: 38px; height: 38px; border-radius: 10px; background: #fff;
  object-fit: cover;
}

.sidebar-brand .name {
  font-family: var(--font-display);
  font-size: 18px; letter-spacing: 0.02em; color: #fff;
  line-height: 1.0;
  text-transform: uppercase;
}

.sidebar-brand .tag {
  font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--accent); font-weight: 700;
  margin-top: 4px;
}

.sidebar-nav {
  flex: 1;
  padding: 14px 10px 16px;
  display: flex; flex-direction: column; gap: 2px;
}

.sidebar-section {
  font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase;
  color: rgba(246, 233, 216, 0.42); font-weight: 600;
  padding: 14px 10px 6px;
}

.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: 9px;
  color: rgba(246, 233, 216, 0.78);
  font-size: 13px; font-weight: 500;
  transition: background 0.15s var(--t), color 0.15s var(--t);
  position: relative;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}

.nav-link.active {
  background: rgba(243, 121, 32, 0.16);
  color: #fff;
}

.nav-link.active::before {
  content: ''; position: absolute; left: -10px; top: 8px; bottom: 8px;
  width: 3px; background: var(--accent); border-radius: 0 3px 3px 0;
}

.nav-link svg {
  width: 17px; height: 17px; flex-shrink: 0;
  stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
  opacity: 0.85;
}

.sidebar-footer {
  padding: 14px 16px 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex; gap: 10px; align-items: center; justify-content: space-between;
}

.sidebar-footer .who {
  font-size: 11px; color: rgba(246, 233, 216, 0.5);
  letter-spacing: 0.04em;
}

.sidebar-footer a {
  font-size: 11px; color: rgba(246, 233, 216, 0.65);
  padding: 5px 10px; border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: all 0.15s var(--t);
}

.sidebar-footer a:hover {
  color: #fff; border-color: rgba(243, 121, 32, 0.5); background: rgba(243, 121, 32, 0.08);
}

/* Main */

.main {
  min-width: 0;
  padding: 28px 36px 60px;
  max-width: 1480px;
  width: 100%;
}

.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 4px 0 22px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.topbar .crumbs {
  font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--muted-2); font-weight: 600;
}

.topbar h1 {
  font-family: var(--font-display);
  font-size: 32px; letter-spacing: 0.01em; font-weight: 400;
  color: var(--bone); margin-top: 4px;
  text-transform: uppercase;
  line-height: 1.0;
}

.topbar .lead {
  color: var(--muted); font-size: 13.5px; max-width: 700px;
}

.topbar .right {
  margin-left: auto; display: flex; align-items: center; gap: 10px;
}

.timeframe {
  display: inline-flex; gap: 0; padding: 3px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}

.timeframe button {
  background: none; border: 0; padding: 6px 12px; border-radius: 10px;
  font-size: 12px; font-weight: 600; color: var(--muted);
  letter-spacing: 0.02em;
}

.timeframe button.active {
  background: var(--accent-soft); color: var(--bone);
}

.userpill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 8px 6px 6px; background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius-pill);
  font-size: 12px; font-weight: 600; color: var(--fg-soft);
}

.userpill .av {
  width: 24px; height: 24px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #c95a0f); color: #fff;
  display: grid; place-items: center; font-size: 11px; font-weight: 700;
}

/* -------------------------------------------------------------------------
   Cards
------------------------------------------------------------------------- */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 18px;
  box-shadow: var(--shadow-sm);
  position: relative;
}

.card.lift {
  transition: transform 0.2s var(--t), box-shadow 0.2s var(--t);
}
.card.lift:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.card-h {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; margin-bottom: 12px;
}

.card-h h3 {
  font-size: 13px; font-weight: 600; color: var(--muted);
  letter-spacing: 0.04em; text-transform: uppercase;
}

.card-h .h-tail {
  font-size: 11px; color: var(--muted-2);
}

.card-title {
  font-family: var(--font-display);
  font-size: 17px; font-weight: 400; color: var(--bone);
  letter-spacing: 0.01em;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.card-sub {
  font-size: 12.5px; color: var(--muted); margin-bottom: 12px;
}

.section {
  margin-bottom: 24px;
}

.section-title {
  display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px;
}

.section-title h2 {
  font-family: var(--font-display);
  font-size: 20px; font-weight: 400; letter-spacing: 0.01em;
  color: var(--bone); text-transform: uppercase;
  line-height: 1.05;
}

.section-title .meta {
  font-size: 12px; color: var(--muted);
}

/* -------------------------------------------------------------------------
   KPI cards
------------------------------------------------------------------------- */

.kpis {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-bottom: 22px;
}

.kpi {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 16px 14px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s var(--t), box-shadow 0.18s var(--t);
}

.kpi:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.kpi.hero {
  background: linear-gradient(140deg, #fff 0%, #fff 60%, var(--accent-soft) 140%);
  border-color: var(--accent-line);
}

.kpi .label {
  font-size: 11px; font-weight: 600; color: var(--muted);
  letter-spacing: 0.10em; text-transform: uppercase;
  display: flex; align-items: center; gap: 6px;
}

.kpi .label svg { width: 13px; height: 13px; opacity: 0.7; stroke: currentColor; fill: none; stroke-width: 2; }

.kpi .v {
  font-family: var(--font-display);
  font-size: 32px; font-weight: 400; color: var(--bone);
  letter-spacing: 0.005em; line-height: 1.0;
  margin-top: 8px;
  font-variant-numeric: tabular-nums;
}

.kpi .v small {
  font-family: var(--font);
  font-size: 13px; font-weight: 600; color: var(--muted);
  margin-left: 4px;
  letter-spacing: 0;
}

.kpi .delta {
  display: inline-flex; align-items: center; gap: 4px;
  margin-top: 6px;
  font-size: 11.5px; font-weight: 600;
  padding: 2px 8px; border-radius: var(--radius-pill);
}

.kpi .delta.up { background: var(--ok-soft); color: var(--ok); }
.kpi .delta.down { background: var(--error-soft); color: var(--error); }
.kpi .delta.flat { background: var(--bone-tint); color: var(--bone); }
.kpi .delta.warn { background: var(--warn-soft); color: var(--warn); }

.kpi .sub {
  display: block;
  margin-top: 6px;
  font-size: 11.5px; color: var(--muted-2);
}

.kpi .spark {
  margin-top: 10px;
  height: 32px;
  width: 100%;
}

/* -------------------------------------------------------------------------
   Grids
------------------------------------------------------------------------- */

.grid {
  display: grid;
  gap: 18px;
}

.grid.cols-2 { grid-template-columns: 1fr 1fr; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2-1 { grid-template-columns: 2fr 1fr; }
.grid.cols-1-2 { grid-template-columns: 1fr 2fr; }

@media (max-width: 1100px) {
  .grid.cols-2, .grid.cols-3, .grid.cols-2-1, .grid.cols-1-2 { grid-template-columns: 1fr; }
}

/* -------------------------------------------------------------------------
   Pills, badges, statuses
------------------------------------------------------------------------- */

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.04em;
  background: var(--bone-tint);
  color: var(--bone);
  border: 1px solid transparent;
  white-space: nowrap;
}

.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.danger { background: var(--error-soft); color: var(--error); }
.pill.warm { background: var(--accent-soft); color: var(--bone); border-color: var(--accent-line); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.muted { background: #f3eee6; color: var(--muted); }
.pill.dark { background: var(--bone); color: #fff; }

.pill .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; opacity: 0.85;
}

.tag {
  display: inline-flex; align-items: center;
  padding: 3px 8px; border-radius: 7px;
  font-size: 11px; font-weight: 600;
  background: var(--bg-tint); color: var(--fg-soft);
  border: 1px solid var(--border);
  letter-spacing: 0.02em;
}

.tag.orange { background: var(--accent-soft); color: var(--bone); border-color: var(--accent-line); }
.tag.brown { background: var(--bone-tint); color: var(--bone); border-color: var(--border-strong); }

/* -------------------------------------------------------------------------
   Tables
------------------------------------------------------------------------- */

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

.tbl th {
  font-size: 10.5px; font-weight: 600; color: var(--muted);
  letter-spacing: 0.10em; text-transform: uppercase;
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-tint);
}

.tbl th.num, .tbl td.num { text-align: right; font-variant-numeric: tabular-nums; }

.tbl td {
  padding: 12px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--fg-soft);
  vertical-align: middle;
}

.tbl tr:last-child td { border-bottom: 0; }

.tbl tr:hover td { background: var(--card-2); }

.tbl td .pname {
  font-weight: 600; color: var(--fg);
}

.tbl td .psub {
  font-size: 11.5px; color: var(--muted-2); margin-top: 2px;
}

/* -------------------------------------------------------------------------
   Bars (mini horizontal bar charts)
------------------------------------------------------------------------- */

.bar-row {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 0;
}

.bar-row + .bar-row { border-top: 1px solid var(--border); }

.bar-row .bn {
  flex: 1; min-width: 0;
}

.bar-row .bn .name {
  font-size: 13px; font-weight: 600; color: var(--fg-soft);
  display: flex; justify-content: space-between; gap: 12px;
  margin-bottom: 5px;
}

.bar-row .bn .name b {
  font-variant-numeric: tabular-nums; color: var(--fg); font-weight: 700;
}

.bar-row .bar {
  height: 7px; background: var(--bg-tint); border-radius: var(--radius-pill);
  overflow: hidden; position: relative;
}

.bar-row .bar > span {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--accent), #ffaa5e);
  border-radius: var(--radius-pill);
  animation: barGrow 0.7s var(--t) forwards;
  transform-origin: left;
}

@keyframes barGrow {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

/* -------------------------------------------------------------------------
   Funnel
------------------------------------------------------------------------- */

.funnel {
  display: grid; gap: 8px;
  grid-template-columns: repeat(7, 1fr);
}

.funnel.compact { grid-template-columns: repeat(7, 1fr); }

.funnel.b2b { grid-template-columns: repeat(7, 1fr); }

.funnel-step {
  background: var(--bg-tint);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex; flex-direction: column; gap: 4px;
  position: relative;
  transition: border-color 0.15s var(--t), transform 0.15s var(--t);
}

.funnel-step:hover { border-color: var(--accent-line); transform: translateY(-1px); }

.funnel-step .stage {
  font-size: 10.5px; letter-spacing: 0.10em; text-transform: uppercase;
  color: var(--muted-2); font-weight: 600;
}

.funnel-step .count {
  font-size: 18px; font-weight: 700; color: var(--fg); letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

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

/* -------------------------------------------------------------------------
   Calendar grid
------------------------------------------------------------------------- */

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.cal-cell {
  aspect-ratio: 1 / 0.75;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 8px;
  display: flex; flex-direction: column;
  gap: 3px;
  font-size: 11px;
  position: relative;
  overflow: hidden;
}

.cal-cell.today {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(243, 121, 32, 0.12);
}

.cal-cell .d {
  font-weight: 700; font-size: 11px; color: var(--muted-2);
  letter-spacing: 0.05em;
}

.cal-cell .ev {
  background: var(--accent-soft); color: var(--bone);
  font-size: 10px; font-weight: 600;
  padding: 2px 5px; border-radius: 5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  border: 1px solid var(--accent-line);
}

.cal-cell .ev.live { background: var(--ok-soft); color: var(--ok); border-color: rgba(44, 122, 75, 0.3); }
.cal-cell .ev.late { background: var(--error-soft); color: var(--error); border-color: rgba(192, 57, 43, 0.3); }

/* -------------------------------------------------------------------------
   Lists
------------------------------------------------------------------------- */

.list {
  display: flex; flex-direction: column;
}

.list-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: flex-start; gap: 12px;
}

.list-item:last-child { border-bottom: 0; }

.list-item .icon-wrap {
  width: 32px; height: 32px; flex-shrink: 0;
  border-radius: 9px; background: var(--bg-tint);
  display: grid; place-items: center; color: var(--bone);
}

.list-item .icon-wrap.warm { background: var(--accent-soft); color: var(--bone); }
.list-item .icon-wrap.danger { background: var(--error-soft); color: var(--error); }
.list-item .icon-wrap.ok { background: var(--ok-soft); color: var(--ok); }
.list-item .icon-wrap.info { background: var(--info-soft); color: var(--info); }

.list-item .body { flex: 1; min-width: 0; }
.list-item .body .title { font-weight: 600; font-size: 13px; color: var(--fg); }
.list-item .body .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.list-item .meta { font-size: 11px; color: var(--muted-2); flex-shrink: 0; }

/* -------------------------------------------------------------------------
   Charts (Chart.js wrappers)
------------------------------------------------------------------------- */

.chart-wrap {
  position: relative;
  width: 100%;
  height: 240px;
}

.chart-wrap.tall { height: 320px; }
.chart-wrap.short { height: 160px; }

/* -------------------------------------------------------------------------
   Animations
------------------------------------------------------------------------- */

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.main > * { animation: fadeUp 0.4s var(--t) backwards; }
.main > *:nth-child(1) { animation-delay: 0.0s; }
.main > *:nth-child(2) { animation-delay: 0.04s; }
.main > *:nth-child(3) { animation-delay: 0.08s; }
.main > *:nth-child(4) { animation-delay: 0.12s; }
.main > *:nth-child(5) { animation-delay: 0.16s; }
.main > *:nth-child(6) { animation-delay: 0.20s; }
.main > *:nth-child(7) { animation-delay: 0.24s; }
.main > *:nth-child(8) { animation-delay: 0.28s; }

@media (prefers-reduced-motion: reduce) {
  .main > * { animation: none; }
  .bar-row .bar > span { animation: none; }
}

/* -------------------------------------------------------------------------
   Helpers
------------------------------------------------------------------------- */

.row { display: flex; align-items: center; gap: 8px; }
.row.between { justify-content: space-between; }
.row.tight { gap: 4px; }
.col { display: flex; flex-direction: column; gap: 8px; }

.muted { color: var(--muted); }
.muted-2 { color: var(--muted-2); }
.fg-strong { color: var(--fg); font-weight: 700; }

.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-tab); font-size: 12px; }

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

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border-radius: 10px;
  background: var(--accent); color: #fff; border: 0;
  font-size: 12.5px; font-weight: 600;
  letter-spacing: 0.01em;
  transition: background 0.15s var(--t), transform 0.1s var(--t);
}

.btn:hover { background: var(--accent-2); }
.btn:active { transform: translateY(1px); }

.btn.ghost {
  background: transparent; color: var(--fg-soft);
  border: 1px solid var(--border);
}

.btn.ghost:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--bone); }

.btn svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; }

/* Auto-grid for dynamic columns */
.auto-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.auto-grid.tight { gap: 10px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }

/* Channel colour swatch */
.swatch { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; display: inline-block; }

/* SVG icon helpers */
.icon-sm { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; }
.icon { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Decision log card */
.decision {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  position: relative;
  display: grid; gap: 12px;
}

.decision::before {
  content: ''; position: absolute; left: 0; top: 18px; bottom: 18px;
  width: 3px; border-radius: 0 3px 3px 0;
  background: var(--cat-color, var(--accent));
}

.decision .meta-row {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  font-size: 11.5px;
}

.decision h4 {
  font-family: var(--font-display);
  font-size: 18px; font-weight: 400; letter-spacing: 0.01em;
  color: var(--bone); text-transform: uppercase; line-height: 1.05;
}

.decision dl {
  display: grid; grid-template-columns: 130px 1fr; gap: 6px 16px;
  font-size: 12.5px;
}

.decision dt {
  font-size: 11px; letter-spacing: 0.10em; text-transform: uppercase;
  color: var(--muted); font-weight: 600; padding-top: 1px;
}

.decision dd { color: var(--fg-soft); }

/* Hero scorecard */
.hero-scorecard {
  background: linear-gradient(140deg, #fff 0%, var(--accent-soft) 240%);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-lg);
  padding: 24px 24px;
  position: relative; overflow: hidden;
}

.hero-scorecard::after {
  content: ''; position: absolute; right: -80px; top: -80px; width: 280px; height: 280px;
  background: radial-gradient(circle, rgba(243, 121, 32, 0.16), transparent 70%);
  pointer-events: none;
}

.hero-scorecard .heading {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 18px; flex-wrap: wrap;
  margin-bottom: 18px;
}

.hero-scorecard h2 {
  font-family: var(--font-display);
  font-size: 28px; font-weight: 400; letter-spacing: 0.01em;
  color: var(--bone); text-transform: uppercase; line-height: 1.0;
}

.hero-scorecard .h-status {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; background: var(--ok); color: #fff;
  border-radius: var(--radius-pill); font-size: 12px; font-weight: 700;
  letter-spacing: 0.04em;
}

.hero-scorecard .scorecard-group {
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.hero-scorecard .scorecard-group h4 {
  font-size: 11px; letter-spacing: 0.10em; text-transform: uppercase;
  color: var(--muted); font-weight: 600; margin-bottom: 10px;
}

.hero-scorecard .scorecard-group dl {
  display: grid; grid-template-columns: 1fr auto;
  gap: 6px 12px; font-size: 13px;
}

.hero-scorecard .scorecard-group dt { color: var(--muted); }
.hero-scorecard .scorecard-group dd { font-weight: 700; color: var(--fg); font-variant-numeric: tabular-nums; }

.hero-scorecard .scorecard-group dd small { font-weight: 500; color: var(--muted-2); margin-left: 4px; font-size: 11.5px; }

.hero-progress {
  display: flex; flex-direction: column; gap: 6px;
}

.hero-progress .label { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.hero-progress .label b { color: var(--fg); font-variant-numeric: tabular-nums; }

.hero-progress .bar {
  height: 8px; background: var(--bg-tint); border-radius: var(--radius-pill);
  overflow: hidden;
}

.hero-progress .bar > span {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--accent), #ffaa5e);
  border-radius: var(--radius-pill);
}

/* Channel mini card */
.ch-mini {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px;
  display: flex; flex-direction: column; gap: 4px;
  min-width: 0;
}
.ch-mini .row { gap: 8px; }
.ch-mini .nm { font-size: 12px; font-weight: 600; color: var(--fg-soft); flex: 1; min-width: 0; }
.ch-mini .nm b { color: var(--fg); }
.ch-mini .v { font-size: 16px; font-weight: 700; color: var(--fg); font-variant-numeric: tabular-nums; }
.ch-mini .sub { font-size: 11px; color: var(--muted-2); }

/* Insight card */
.insight {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  position: relative;
}

.insight + .insight { margin-top: 16px; }

.insight .head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; margin-bottom: 14px;
}

.insight h3 {
  font-family: var(--font-display);
  font-size: 20px; font-weight: 400; letter-spacing: 0.01em;
  color: var(--bone); text-transform: uppercase; line-height: 1.05;
}

.insight .head .week {
  font-size: 11px; letter-spacing: 0.10em; text-transform: uppercase;
  color: var(--muted); font-weight: 600; margin-bottom: 4px;
}

.insight ul {
  list-style: none; display: grid; gap: 6px;
}

.insight ul li {
  padding-left: 16px; position: relative; font-size: 13px; color: var(--fg-soft);
  line-height: 1.5;
}

.insight ul li::before {
  content: ''; position: absolute; left: 0; top: 9px;
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent);
}

.insight .blocks {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px;
  margin-top: 14px;
}

.insight .blocks .blk {
  background: var(--bg-tint);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
}

.insight .blocks .blk h5 {
  font-size: 11px; letter-spacing: 0.10em; text-transform: uppercase;
  color: var(--muted); font-weight: 600; margin-bottom: 8px;
  display: flex; align-items: center; gap: 6px;
}

.insight .blocks .blk h5 .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.insight .blocks .blk h5.wins .dot { background: var(--ok); }
.insight .blocks .blk h5.issues .dot { background: var(--warn); }
.insight .blocks .blk h5.actions .dot { background: var(--info); }

@media (max-width: 900px) {
  .insight .blocks { grid-template-columns: 1fr; }
}

/* Tabs */
.tabs {
  display: flex; gap: 2px;
  background: var(--card-2); padding: 3px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  align-self: flex-start;
  margin-bottom: 16px;
}

.tabs .tab {
  background: none; border: 0; padding: 7px 14px;
  border-radius: 10px; font-size: 12.5px; font-weight: 600;
  color: var(--muted); letter-spacing: 0.02em;
  cursor: pointer;
  transition: all 0.15s var(--t);
}

.tabs .tab.active {
  background: var(--card); color: var(--fg);
  box-shadow: var(--shadow-sm);
}

.tab-pane { display: none; }
.tab-pane.active { display: block; animation: fadeUp 0.3s var(--t) backwards; }

/* Search */
.search {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--border);
  width: 320px; max-width: 100%;
}

.search input {
  border: 0; outline: 0; background: none; flex: 1; min-width: 0;
  font-family: inherit; font-size: 13px; color: var(--fg);
}

.search svg { width: 14px; height: 14px; stroke: var(--muted); fill: none; stroke-width: 2; }

/* Empty state */
.empty {
  text-align: center; padding: 28px 16px;
  color: var(--muted); font-size: 13px;
}

/* Avatar (creator/customer) */
.av-circle {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--bone-tint); color: var(--bone);
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700;
  flex-shrink: 0;
}

.av-circle.tt { background: #2a1812; color: #fff; }
.av-circle.ig { background: linear-gradient(135deg, #ff7a59, #f7396d); color: #fff; }

/* ----------------------------- Login ------------------------------------- */

.login-bg {
  display: grid; place-items: center; padding: 2rem; min-height: 100vh;
}

.login-card {
  width: 100%; max-width: 380px; background: var(--card);
  border: 1px solid var(--border); border-radius: 20px;
  padding: 2.25rem; box-shadow: var(--shadow-lg);
}

.login-card .logo {
  display: block; width: 96px; height: 96px;
  margin: 0 auto 1.25rem; border-radius: 18px;
  animation: bob 3.6s ease-in-out infinite;
}

@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-1.2deg); }
  50% { transform: translateY(-5px) rotate(1.2deg); }
}

.login-card h1 {
  font-size: 1.5rem; font-weight: 700; letter-spacing: -0.015em;
  text-align: center; margin-bottom: 0.35rem;
}

.login-card .sub {
  color: var(--muted); font-size: 0.92rem;
  text-align: center; margin-bottom: 1.6rem;
}

.login-card label {
  display: block; font-size: 0.76rem; font-weight: 600;
  letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 0.4rem;
}

.login-card input {
  width: 100%; padding: 0.78rem 0.95rem;
  border: 1px solid var(--border); border-radius: 11px;
  font-size: 1rem; background: #fffdfa;
  color: var(--fg); margin-bottom: 1rem;
  font-family: inherit;
  transition: border-color 0.15s var(--t), box-shadow 0.15s var(--t);
}

.login-card input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(243, 121, 32, 0.16);
}

.login-card input[name="code"] {
  letter-spacing: 0.4em; text-align: center;
  font-size: 1.2rem; font-variant-numeric: tabular-nums;
}

.login-card button {
  width: 100%; padding: 0.9rem;
  background: var(--accent); color: #fff; border: 0;
  border-radius: 11px; font-size: 1rem; font-weight: 600;
  letter-spacing: 0.01em;
  box-shadow: 0 8px 20px -8px rgba(243, 121, 32, 0.55);
  transition: transform 0.1s var(--t), background 0.15s var(--t);
}

.login-card button:hover { background: var(--accent-2); }
.login-card button:active { transform: translateY(1px); }

.login-card .err {
  background: var(--error-soft); color: var(--error);
  border: 1px solid #f5c6c0; padding: 0.6rem 0.85rem;
  border-radius: 10px; font-size: 0.85rem; margin-bottom: 1rem;
}

/* Mobile */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; left: 0; right: 0; bottom: auto; height: auto;
    flex-direction: row; align-items: center; padding: 8px 12px;
    border-right: 0; border-bottom: 1px solid rgba(0,0,0,0.2);
    overflow-x: auto; overflow-y: hidden;
  }
  .sidebar-brand { padding: 8px 10px 8px; border-bottom: 0; flex-shrink: 0; }
  .sidebar-section { display: none; }
  .sidebar-nav { flex-direction: row; flex: 1; padding: 4px; gap: 4px; }
  .sidebar-nav { overflow-x: auto; }
  .nav-link { white-space: nowrap; padding: 8px 10px; }
  .nav-link.active::before { display: none; }
  .sidebar-footer { display: none; }
  .main { padding: 84px 16px 60px; }
  .topbar h1 { font-size: 22px; }
  .funnel { grid-template-columns: repeat(2, 1fr); }
}

/* Empty state for sections without real data yet */
.empty-state-card { padding: 40px 28px; text-align: center; }
.empty-state-card h3 { margin: 0 0 6px; font-size: 18px; color: var(--fg); font-weight: 600; }
.empty-state-card p { margin: 0; font-size: 13.5px; line-height: 1.55; }
.empty-state { padding: 18px 14px; text-align: center; font-size: 13px; color: var(--muted); background: rgba(255, 255, 255, 0.4); border-radius: 10px; }
