/* NorthLine Outreach
   Light theme (default): soft greys and white cards, after the reference image.
   Dark theme: NorthLine near-black with champagne gold.
   Every colour is a token below, so components never hard-code a colour. */
:root,
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #ECECEC;
  --surface: #FFFFFF;
  --surface-2: #F4F4F4;
  --line: #DEDEDE;
  --text: #151515;
  --text-2: #474747;
  --muted: #6B6B6B;
  --accent: #8C6214;          /* gold text and links (readable on white) */
  --accent-hover: #6E4C0E;
  --chart: #B8862F;           /* funnel bars and meters */
  --chart-hover: #8C6214;
  --btn-primary-bg: #151515;
  --btn-primary-text: #FFFFFF;
  --btn-primary-hover: #333333;
  --badge-win-bg: #151515;
  --badge-win-text: #F6DE9C;
  --due: #A35F0A;
  --topbar-bg: rgba(236, 236, 236, .88);
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 8px 24px rgba(0, 0, 0, .04);
  --ok-bg: #EEF6EF;  --ok-line: #CFE3D2;  --ok-text: #2F6B3A;
  --warn-bg: #FBF4E6; --warn-line: #EBD7AE; --warn-text: #7A5512;
  --err-bg: #FBEDEA;  --err-line: #EDC6BE;  --err-text: #9C3524;
  /* Welcome section chevrons */
  --panel-from: #E4E4E4;
  --panel-to: #F7F7F7;
  --panel-shadow: rgba(0, 0, 0, .10);
  --welcome-bg: #EFEFEF;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0A0908;
  --surface: #151311;
  --surface-2: #1E1B18;
  --line: #2C2823;
  --text: #F7F4EE;
  --text-2: #C9C3B8;
  --muted: #8F887D;
  --accent: #E8C05C;
  --accent-hover: #F6DE9C;
  --chart: #E8C05C;
  --chart-hover: #F6DE9C;
  --btn-primary-bg: #E8C05C;
  --btn-primary-text: #17130B;
  --btn-primary-hover: #F6DE9C;
  --badge-win-bg: #E8C05C;
  --badge-win-text: #17130B;
  --due: #E8A65C;
  --topbar-bg: rgba(10, 9, 8, .9);
  --shadow: none;
  --ok-bg: #142017;  --ok-line: #2F4A33;  --ok-text: #7FC08A;
  --warn-bg: #21180C; --warn-line: #5A4220; --warn-text: #F6DE9C;
  --err-bg: #22110E;  --err-line: #5C2A22;  --err-text: #F3A796;
  --panel-from: #13110F;
  --panel-to: #1D1A17;
  --panel-shadow: rgba(0, 0, 0, .55);
  --welcome-bg: #100E0D;
}

:root {
  --radius: 12px;
  --font-head: "Sora", system-ui, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, sans-serif;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--font-body);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
h1, h2 { font-family: var(--font-head); font-weight: 600; letter-spacing: -0.01em; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.05rem; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: .85em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.block { display: block; }
.gold { color: var(--accent); }
.error-text { color: var(--err-text); }
.due { color: var(--due); font-weight: 600; }
.inline { display: inline; margin: 0; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .75rem 1.5rem; border-bottom: 1px solid var(--line);
  background: var(--topbar-bg); position: sticky; top: 0; z-index: 10;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.brand { font-family: var(--font-head); font-weight: 700; letter-spacing: .08em; color: var(--text); font-size: .95rem; white-space: nowrap; }
.brand span { color: var(--accent); }
.brand:hover { color: var(--text); text-decoration: none; }
.brand.big { font-size: 1.4rem; text-align: center; margin-bottom: 1.5rem; }
.nav { display: flex; align-items: center; gap: .25rem; overflow-x: auto; }
.nav a, .nav .link { color: var(--text-2); padding: .4rem .7rem; border-radius: 6px; white-space: nowrap; font-size: .9rem; }
.nav a:hover, .nav .link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a[aria-current="page"] { color: var(--text); background: var(--surface); box-shadow: var(--shadow); }
button.link { background: none; border: 0; font: inherit; cursor: pointer; }
.theme-toggle { display: inline-flex; align-items: center; gap: .35rem; }
.theme-toggle svg { width: 15px; height: 15px; }

.container { max-width: 1180px; margin: 0 auto; padding: 1.75rem 1.5rem 4rem; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-head h1 { margin: .15rem 0 .35rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.stack { display: flex; flex-direction: column; gap: 1rem; }

/* ---------- Cards, buttons, forms ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.15rem 1.3rem; box-shadow: var(--shadow); }
.card + .card { margin-top: 1rem; }
.stack > .card + .card { margin-top: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; }
.empty { color: var(--muted); }
.placeholder { border-style: dashed; box-shadow: none; }

.btn {
  display: inline-block; padding: .55rem 1rem; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font: 500 .9rem var(--font-body); cursor: pointer; white-space: nowrap;
  transition: border-color .2s, background-color .2s;
}
.btn:hover { border-color: var(--muted); color: var(--text); text-decoration: none; }
.btn.primary { background: var(--btn-primary-bg); border-color: var(--btn-primary-bg); color: var(--btn-primary-text); }
.btn.primary:hover { background: var(--btn-primary-hover); border-color: var(--btn-primary-hover); }

label { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; color: var(--text-2); }
input, select, textarea {
  width: 100%; padding: .55rem .7rem; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font: 15px/1.4 var(--font-body);
}
input:focus, select:focus, textarea:focus, .btn:focus-visible, .welcome-cta:focus-visible, button:focus-visible {
  outline: 2px solid var(--chart); outline-offset: 2px;
}
input[type="file"] { padding: .45rem; }
label.check { flex-direction: row; align-items: center; gap: .6rem; color: var(--text); }
label.check input { width: auto; accent-color: var(--chart); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .85rem 1rem; }
.span-2 { grid-column: span 2; }
.row-form { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .75rem; }
.row-form input, .row-form select { flex: 1 1 160px; width: auto; }

.flash { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid; }
.flash-ok { border-color: var(--ok-line); background: var(--ok-bg); color: var(--ok-text); }
.flash-warn { border-color: var(--warn-line); background: var(--warn-bg); color: var(--warn-text); }
.flash-error { border-color: var(--err-line); background: var(--err-bg); color: var(--err-text); }

/* ---------- Welcome section (top of the dashboard) ---------- */
.welcome {
  position: relative; overflow: hidden; isolation: isolate;
  min-height: 300px; margin-bottom: 2.25rem;
  border: 1px solid var(--line); border-radius: 16px;
  background: var(--welcome-bg);
  display: grid; grid-template-columns: minmax(0, 44%) minmax(0, 1fr); align-items: center;
}
/* Layered chevron panels, as in the reference image. Decorative only. */
.welcome-art { position: relative; height: 100%; min-height: 300px; }
.welcome-art .panel {
  position: absolute; inset: 0 auto 0 0;
  filter: drop-shadow(10px 0 18px var(--panel-shadow));  /* shadow survives the clip below */
}
.welcome-art .panel::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, var(--panel-from), var(--panel-to));
  clip-path: polygon(0 0, calc(100% - 64px) 0, 100% 26%, 100% 74%, calc(100% - 64px) 100%, 0 100%);
}
.welcome-art .panel:nth-child(1) { width: 100%; z-index: 1; }
.welcome-art .panel:nth-child(2) { width: 74%;  z-index: 2; }
.welcome-art .panel:nth-child(3) { width: 50%;  z-index: 3; }
.welcome-art .panel:nth-child(4) { width: 27%;  z-index: 4; }

.welcome-body { padding: 2.75rem 3rem 2.75rem 3.25rem; }
.welcome-date {
  margin: 0 0 1rem; color: var(--muted);
  font-size: .78rem; font-weight: 500; letter-spacing: .14em; text-transform: uppercase;
}
.welcome-greeting {
  margin: 0; font-family: var(--font-head); font-weight: 300;
  font-size: clamp(2rem, 1.2rem + 2.6vw, 3.1rem); line-height: 1.08; letter-spacing: -0.025em;
  color: var(--text); text-wrap: balance;
}
.welcome-name { white-space: nowrap; }
.welcome-summary { margin: .9rem 0 0; color: var(--text-2); font-size: 1rem; }
.welcome-summary strong { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

.welcome-cta {
  display: inline-flex; align-items: center; gap: .85rem; margin-top: 2rem;
  padding: .85rem 1.15rem .85rem 1.4rem; border-radius: 999px;
  background: var(--btn-primary-bg); color: var(--btn-primary-text);
  font: 500 .92rem var(--font-body); letter-spacing: .02em;
  transition: background-color .25s var(--ease), transform .25s var(--ease), box-shadow .25s var(--ease);
}
.welcome-cta svg { width: 18px; height: 18px; transition: transform .3s var(--ease); }
.welcome-cta:hover { color: var(--btn-primary-text); text-decoration: none; background: var(--btn-primary-hover);
  transform: translateY(-1px); box-shadow: 0 8px 22px rgba(0, 0, 0, .14); }
.welcome-cta:hover svg { transform: translateX(4px); }
.welcome-cta:active { transform: translateY(0) scale(.98); box-shadow: none; transition-duration: .08s; }

/* Entrance: text fades up, panels slide in one after another. */
@media (prefers-reduced-motion: no-preference) {
  .welcome-body > * { opacity: 0; animation: rise .8s var(--ease) forwards; }
  .welcome-body > :nth-child(2) { animation-delay: .08s; }
  .welcome-body > :nth-child(3) { animation-delay: .18s; }
  .welcome-body > :nth-child(4) { animation-delay: .28s; }
  .welcome-art .panel { opacity: 0; animation: slide 1s var(--ease) forwards; }
  .welcome-art .panel:nth-child(2) { animation-delay: .06s; }
  .welcome-art .panel:nth-child(3) { animation-delay: .12s; }
  .welcome-art .panel:nth-child(4) { animation-delay: .18s; }
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes slide { from { opacity: 0; transform: translateX(-24px); } to { opacity: 1; transform: none; } }

.section-title { font-size: 1.6rem; margin: 0; }
#overview { scroll-margin-top: 80px; }
#overview:focus { outline: none; }

/* ---------- Overview ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.05rem 1.1rem; display: flex; flex-direction: column; gap: .25rem; box-shadow: var(--shadow); }
.tile-label { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 500; }
.tile-value { font: 600 1.8rem/1.15 var(--font-head); font-variant-numeric: tabular-nums; }
.tile-value small { font-size: .95rem; color: var(--muted); font-weight: 500; }
.tile-sub { color: var(--muted); font-size: .8rem; }
.meter { display: block; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; margin-top: .35rem; }
.meter span { display: block; height: 100%; background: var(--chart); border-radius: 3px; }

/* Funnel: one series, so one hue; labels and counts are text. */
.funnel { list-style: none; margin: .75rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.funnel a { display: grid; grid-template-columns: 9.5rem 1fr 3rem; align-items: center; gap: .75rem; padding: .35rem .4rem; border-radius: 6px; color: var(--text-2); }
.funnel a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.funnel-track { height: 14px; }
.funnel-bar { display: block; height: 100%; background: var(--chart); border-radius: 0 4px 4px 0; }
.funnel a:hover .funnel-bar { background: var(--chart-hover); }
.funnel-count { text-align: right; font-variant-numeric: tabular-nums; color: var(--text); font-weight: 600; }
.funnel-exits { display: flex; gap: 1.5rem; margin: .75rem 0 0; padding-top: .75rem; border-top: 1px solid var(--line); font-size: .9rem; }
.funnel-exits a { color: var(--muted); }

/* ---------- Lead table ---------- */
.filters { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .75rem; }
.filters input { flex: 3 1 240px; width: auto; }
.filters select { flex: 1 1 150px; width: auto; }
.result-count { margin: 0 0 .5rem; font-size: .85rem; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .7rem .9rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 500; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
.row-link { color: var(--text); font-weight: 600; }

.badge { display: inline-block; padding: .15rem .6rem; border-radius: 999px; font-size: .75rem; font-weight: 500; border: 1px solid var(--line); color: var(--text-2); background: var(--surface); white-space: nowrap; }
.stage-draft_ready, .stage-approved { color: var(--accent); border-color: var(--chart); }
.stage-contacted, .stage-replied, .stage-call_booked, .stage-offer_sent { color: var(--text); border-color: var(--text-2); }
.stage-signed, .stage-paid { color: var(--badge-win-text); background: var(--badge-win-bg); border-color: var(--badge-win-bg); }
.stage-needs_listing_info { color: var(--due); border-color: var(--warn-line); }
.stage-lost, .stage-unsubscribed { color: var(--muted); }
.flag { display: inline-block; font-size: .72rem; padding: .1rem .45rem; border-radius: 4px; background: var(--surface-2); color: var(--muted); margin: 0 .25rem .25rem 0; }
.flag.warn { color: var(--due); }

/* ---------- Lead detail ---------- */
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: .6rem 0 .6rem .9rem; border-left: 2px solid var(--line); position: relative; }
.timeline li::before { content: ""; position: absolute; left: -5px; top: .95rem; width: 8px; height: 8px; border-radius: 50%; background: var(--chart); }
.timeline-kind { font-weight: 600; margin-right: .4rem; }
.timeline p { margin: .2rem 0 0; color: var(--text-2); white-space: pre-wrap; }

/* ---------- Today / import / login ---------- */
.today-grid, .import-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.today-grid .card + .card, .import-grid .card + .card { margin-top: 0; }
.count { display: inline-block; min-width: 1.6rem; text-align: center; padding: 0 .4rem; border-radius: 999px; background: var(--surface-2); color: var(--accent); font-size: .8rem; margin-left: .3rem; }
.today-list { list-style: none; margin: 0; padding: 0; }
.today-list li { display: flex; flex-wrap: wrap; gap: .4rem .6rem; align-items: center; padding: .55rem 0; border-bottom: 1px solid var(--line); }
.today-list li:last-child { border-bottom: 0; }
.today-list li a { font-weight: 600; color: var(--text); }
.today-list li .small { flex-basis: 100%; }
.report { margin-bottom: 1rem; }
.login { max-width: 360px; margin: 12vh auto 0; }

/* ---------- Tablet ---------- */
@media (max-width: 1000px) {
  .welcome { grid-template-columns: minmax(0, 34%) minmax(0, 1fr); }
  .welcome-body { padding: 2.25rem 2rem 2.25rem 2.25rem; }
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ---------- Phones ---------- */
@media (max-width: 760px) {
  .topbar { flex-direction: column; align-items: stretch; gap: .4rem; padding: .6rem 1rem; }
  .nav { flex-wrap: wrap; overflow: visible; }
  .nav a, .nav .link { padding: .35rem .55rem; }
  .container { padding: 1rem 1rem 3rem; }
  .detail-grid, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .hide-sm { display: none; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .funnel a { grid-template-columns: 7.5rem 1fr 2.2rem; gap: .5rem; }
  h1 { font-size: 1.35rem; }

  /* Chevrons become a short band above the greeting so text keeps full width. */
  .welcome { grid-template-columns: 1fr; min-height: 0; margin-bottom: 1.75rem; }
  .welcome-art { min-height: 0; height: 84px; }
  .welcome-art .panel::before { clip-path: polygon(0 0, calc(100% - 36px) 0, 100% 50%, calc(100% - 36px) 100%, 0 100%); }
  .welcome-body { padding: 1.5rem 1.4rem 1.75rem; }
  .welcome-greeting { font-size: 2rem; }
  .welcome-cta { margin-top: 1.5rem; }
}

/* ---------------- Stage 2: best bit (photos + hook) and drafts ---------------- */
.btn.small { padding: .3rem .7rem; font-size: .82rem; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; font-size: .8rem; color: var(--accent); cursor: pointer; }
.link-btn:hover { color: var(--accent-hover); text-decoration: underline; }
.link-btn.danger { color: var(--muted); }
.link-btn.danger:hover { color: var(--err-text); }
.hint { margin: .35rem 0 1rem; }

.photo-grid { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .75rem; }
.photo { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface-2); }
.photo img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.photo.is-best { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.photo-bar { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .4rem .55rem; }
.photo-bar form { margin: 0; }
.photo-best { font-size: .8rem; font-weight: 600; color: var(--accent); }

.upload-row { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; padding: .75rem; margin-bottom: 1.1rem; border: 1px dashed var(--line); border-radius: 10px; background: var(--surface-2); }
.upload-pick { flex: 1 1 200px; min-width: 0; }
.upload-pick input { width: 100%; min-width: 0; border: 0; padding: 0; background: none; }
.field-hint { display: block; margin-top: .25rem; }

.draft { border-top: 1px solid var(--line); padding-top: 1rem; margin-top: 1rem; }
.draft:first-of-type { border-top: 0; padding-top: 0; }
.card-head + .draft, .card-head + .row-flash + .draft { margin-top: .75rem; }
.draft-head { display: flex; justify-content: space-between; align-items: baseline; gap: .75rem; flex-wrap: wrap; margin-bottom: .5rem; }
.draft-head h3 { margin: 0; font-size: .95rem; }
.draft-subject { margin: 0 0 .5rem; display: flex; gap: .5rem; align-items: baseline; flex-wrap: wrap; font-weight: 600; }
.draft-body { white-space: pre-wrap; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: .85rem 1rem; line-height: 1.55; }
.draft-actions { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-top: .6rem; }
.draft-history { margin-top: .75rem; }
.draft-history summary { cursor: pointer; color: var(--accent); font-size: .85rem; }
.draft-old { margin-top: .6rem; }
.draft-old .draft-body { margin-top: .3rem; opacity: .85; }
.row-flash { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; }
.row-flash form { margin: 0; }
[data-copied] { border-color: var(--ok-line) !important; color: var(--ok-text) !important; }

.today-actions { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin: 0 0 1rem; }
.today-actions form { margin: 0; }

@media (max-width: 760px) {
  .photo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hook-form { grid-template-columns: 1fr; }
  .hook-form .span-2 { grid-column: auto; }
}

/* Draft editing and the personalisation groups */
.form-group { margin: .5rem 0 0; font-size: .72rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.hook-form + .form-group { margin: 1.4rem 0 .6rem; }
.words-off { color: var(--due); font-weight: 600; }
.draft-edit { margin-top: .6rem; }
.draft-edit summary { cursor: pointer; color: var(--accent); font-size: .85rem; }
.stack-form { display: flex; flex-direction: column; gap: .7rem; margin-top: .6rem; }
.stack-form textarea { line-height: 1.5; }

/* ======================================================================
   Tracker: one calendar with two displays (Outreach Activity / Revenue).
   It uses the same clean white palette as the Daily Outreach Challenge, so
   both read as one interface: pastel emerald = on target / money in, amber =
   some outreach, soft red = costs only, grey = nothing.
   The tokens live on .tk-scope so the slide-out day panel shares them.
   ====================================================================== */
.tk-scope {
  --tk-bg: var(--surface);
  --tk-surface: var(--surface-2);
  --tk-surface-2: #EDEDEF;
  --tk-cell: #F7F7F8;
  --tk-line: #E4E4E7;
  --tk-line-2: #D6D6DB;
  --tk-text: var(--text);
  --tk-text-2: var(--text-2);
  --tk-muted: var(--muted);
  --tk-pos: #3A8659;   --tk-pos-bg: #E6F2EB;  --tk-pos-line: #BCDCC8;
  --tk-neg: #B4474F;   --tk-neg-bg: #FBEDEE;  --tk-neg-line: #EFC9CC;
  --tk-amber: #B26F16; --tk-amber-bg: #FBF2E4; --tk-amber-line: #F0DDBF;
  --tk-accent: #151515;  /* the selected day */
  --tk-today: #9A9AA2;
  --tk-radius: 9px;
  --tk-num: inherit;
}
:root[data-theme="dark"] .tk-scope {
  --tk-surface-2: #24211D;
  --tk-cell: #1A1815;
  --tk-line: #2C2823;
  --tk-line-2: #3A352E;
  --tk-pos: #6CC593;   --tk-pos-bg: rgba(74, 170, 118, .14);  --tk-pos-line: rgba(74, 170, 118, .38);
  --tk-neg: #E08A90;   --tk-neg-bg: rgba(200, 80, 90, .14);   --tk-neg-line: rgba(224, 138, 144, .35);
  --tk-amber: #E8B45C; --tk-amber-bg: rgba(232, 180, 92, .10); --tk-amber-line: rgba(232, 180, 92, .30);
  --tk-accent: var(--accent);
  --tk-today: #8F887D;
}
.tk {
  background: var(--tk-bg);
  color: var(--tk-text);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.5rem 1.6rem;
  box-shadow: var(--shadow);
  font-size: .9rem;
  position: relative;
}
.tk a { color: inherit; text-decoration: none; }
.tk input, .tk select, .tk-panel input, .tk-panel select { background: var(--surface); color: var(--tk-text); border: 1px solid var(--tk-line-2); border-radius: 8px; }
.tk input:focus-visible, .tk select:focus-visible, .tk a:focus-visible, .tk button:focus-visible { outline: 2px solid var(--tk-accent); outline-offset: 1px; }
.tk-num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.tk-compact { display: none; }
.tk .pos, .tk-num.pos, .tk-panel .pos { color: var(--tk-pos); }
.tk .neg, .tk-num.neg, .tk-panel .neg { color: var(--tk-neg); }
.tk-num.flat { color: var(--tk-muted); }
.tk small, .tk-panel small { color: var(--tk-muted); font-size: .78em; font-family: inherit; }
.tk-unit { font-weight: 400; }
.tk-muted, .tk-meta, .tk-empty { color: var(--tk-muted); }
.tk-meta { font-size: .74rem; }
.tk-empty { font-size: .82rem; margin: .25rem 0; }
.tk-eyebrow { margin: 0; font-size: .68rem; letter-spacing: .14em; text-transform: uppercase; color: var(--tk-muted); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------------- Display settings (upper right) ---------------- */
.tk-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.tk-page-title { margin: 0; font-size: 1.5rem; font-weight: 600; letter-spacing: -.01em; }
.tk-settings { position: relative; }
.tk-settings-btn { list-style: none; display: inline-flex; align-items: center; gap: .45rem; height: 38px; padding: 0 .85rem; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--text-2); font-size: .88rem; cursor: pointer; transition: border-color .15s, color .15s; box-shadow: var(--shadow); }
.tk-settings-btn::-webkit-details-marker { display: none; }
.tk-settings-btn svg { width: 18px; height: 18px; }
.tk-settings-btn:hover, .tk-settings[open] .tk-settings-btn { border-color: var(--muted); color: var(--text); }
.tk-menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; width: 260px; padding: .4rem; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 32px rgba(0, 0, 0, .10); animation: tk-menu-in .14s ease-out both; }
@keyframes tk-menu-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.tk-menu-label { margin: .2rem .55rem .35rem; font-size: .68rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.tk-menu-item { display: flex; gap: .55rem; align-items: flex-start; padding: .55rem; border-radius: 8px; color: var(--text); text-decoration: none; transition: background-color .12s; }
.tk-menu-item:hover { background: var(--surface-2); text-decoration: none; }
.tk-menu-item.is-on { background: var(--surface-2); }
.tk-menu-item strong { font-weight: 600; font-size: .9rem; }
.tk-menu-item em { font-style: normal; font-size: .7rem; color: var(--muted); margin-left: .3rem; }
.tk-menu-item small { display: block; color: var(--muted); font-size: .76rem; }
.tk-menu-check { flex: none; width: 18px; height: 18px; margin-top: 1px; color: var(--dmc-green, #3A8659); }
.tk-menu-check svg { width: 18px; height: 18px; }
.tk-switch { animation: tk-in .22s ease-out both; }

/* Loading bar and error message (shown by app.js during HTMX requests) */
.tk-root { position: relative; }
.tk-loading { position: absolute; top: 0; left: 14px; right: 14px; height: 2px; overflow: hidden; opacity: 0; transition: opacity .15s; }
.tk-loading::after { content: ""; position: absolute; inset: 0; width: 30%; background: var(--tk-pos); animation: tk-slide 1s ease-in-out infinite; }
.tk-root.is-loading .tk-loading { opacity: 1; }
.tk-root.is-loading .tk-view, .tk-root.is-loading .tk-summary { opacity: .55; transition: opacity .2s; }
@keyframes tk-slide { from { transform: translateX(-100%); } to { transform: translateX(400%); } }
.tk-error { margin-bottom: 1rem; padding: .6rem .8rem; border: 1px solid var(--tk-neg-line); background: var(--tk-neg-bg); color: var(--tk-neg); border-radius: var(--tk-radius); font-size: .85rem; }

/* ---------------- Header ---------------- */
.tk-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1.25rem 2rem; flex-wrap: wrap; padding-bottom: 1.1rem; margin-bottom: 1.1rem; border-bottom: 1px solid var(--tk-line); }
.tk-title { margin: .15rem 0 .7rem; font-weight: 600; font-size: 1.35rem; letter-spacing: -.01em; color: var(--tk-text); }
.tk-controls { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.tk-stepper { display: inline-flex; border: 1px solid var(--tk-line); border-radius: 8px; overflow: hidden; }
.tk-stepper .tk-icon-btn { border: 0; border-radius: 0; }
.tk-stepper .tk-icon-btn + .tk-icon-btn { border-left: 1px solid var(--tk-line); }
.tk-icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; background: var(--surface); border: 1px solid var(--tk-line); border-radius: 8px; color: var(--tk-text-2); cursor: pointer; transition: background .15s, color .15s; }
.tk-icon-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tk-icon-btn:hover { background: var(--tk-surface-2); color: var(--tk-text); }
.tk-btn { display: inline-flex; align-items: center; height: 34px; padding: 0 .85rem; background: var(--surface); border: 1px solid var(--tk-line); border-radius: 8px; color: var(--tk-text-2); font-size: .84rem; cursor: pointer; transition: background .15s, color .15s; }
.tk-btn:hover { background: var(--tk-surface-2); color: var(--tk-text); }
.tk-year { margin: 0; }
.tk-year select { height: 34px; padding: 0 1.8rem 0 .6rem; font-size: .84rem; width: auto; }
.tk-seg { display: inline-flex; padding: 3px; background: var(--tk-surface); border: 1px solid var(--tk-line); border-radius: 10px; }
.tk-seg a { padding: .32rem .85rem; border-radius: 7px; font-size: .82rem; color: var(--tk-text-2); transition: background .15s, color .15s, box-shadow .15s; }
.tk-seg a:hover { color: var(--tk-text); }
.tk-seg a[aria-current] { background: var(--surface); color: var(--tk-text); box-shadow: 0 1px 2px rgba(0, 0, 0, .08), inset 0 0 0 1px var(--tk-line); }

.tk-stats { display: flex; margin: 0; border: 0; border-radius: 12px; background: var(--tk-surface); }
.tk-stats > div { padding: .55rem 1rem; min-width: 92px; }
.tk-stats > div + div { border-left: 1px solid var(--tk-surface-2); }
.tk-stats dt { font-size: .66rem; letter-spacing: .08em; text-transform: uppercase; color: var(--tk-muted); }
.tk-stats dd { margin: .2rem 0 0; font-size: 1.1rem; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------------- Shared cell look and colour system ---------------- */
.tk-day, .tk-wk, .tk-daycard, .tk-monthcard {
  position: relative; display: flex; flex-direction: column; background: var(--tk-cell);
  border: 1px solid var(--tk-line); border-radius: var(--tk-radius);
  transition: border-color .15s, background-color .15s, transform .15s;
}
a.tk-day:hover, a.tk-daycard:hover, a.tk-monthcard:hover { border-color: var(--tk-line-2); background-color: var(--tk-surface); }
.tone-pos { background-color: var(--tk-pos-bg) !important; border-color: var(--tk-pos-line); }
.tone-neg { background-color: var(--tk-neg-bg) !important; border-color: var(--tk-neg-line); }
.is-today { box-shadow: inset 0 0 0 1px var(--tk-today); }
.tone-amber { background-color: var(--tk-amber-bg) !important; border-color: var(--tk-amber-line); }
.is-selected { box-shadow: inset 0 0 0 1.5px var(--tk-accent) !important; }
.is-outside { background: transparent; border-color: transparent; color: var(--tk-muted); opacity: .45; }
.is-future .tk-date, .is-future .tk-daycard-date { color: var(--tk-muted); }
.tk-pnl { font-variant-numeric: tabular-nums; font-size: 1rem; font-weight: 600; }

/* ---------------- Monthly grid ---------------- */
.tk-month { display: grid; gap: 4px; }
.tk-month-head, .tk-month-row { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)) minmax(0, 1.15fr); gap: 4px; }
.tk-month-head span { padding: 0 .4rem .3rem; font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; color: var(--tk-muted); }
.tk-day { min-height: 92px; padding: .45rem .55rem; align-items: center; justify-content: center; text-align: center; }
.tk-day .tk-date { position: absolute; top: .4rem; left: .5rem; font-size: .74rem; color: var(--tk-text-2); font-variant-numeric: tabular-nums; }
.tk-day.is-today .tk-date { color: var(--tk-text); font-weight: 600; }
.tk-day .tk-pnl { margin-top: .5rem; }
.tk-day .tk-meta { margin-top: .15rem; }
.tk-wk { min-height: 92px; padding: .5rem .7rem; justify-content: center; background: var(--tk-surface); border-color: transparent; }
.tk-wk-label { font-size: .66rem; letter-spacing: .08em; text-transform: uppercase; color: var(--tk-muted); margin-bottom: .2rem; }

/* ---------------- Weekly cards ---------------- */
.tk-week { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.tk-daycard { padding: .75rem .85rem; gap: .45rem; min-height: 140px; }
.tk-daycard-date { font-size: .8rem; color: var(--tk-text-2); }
.tk-daycard-date strong { color: var(--tk-text); font-weight: 600; margin-right: .2rem; }
.tk-daycard .tk-pnl { font-size: 1.2rem; }
.tk-weeksum { background: var(--tk-surface); }
.tk-mini { display: grid; grid-template-columns: 1fr 1fr; gap: .3rem .8rem; margin: 0; }
.tk-mini dt { font-size: .64rem; letter-spacing: .06em; text-transform: uppercase; color: var(--tk-muted); }
.tk-mini dd { margin: 0; font-variant-numeric: tabular-nums; font-size: .84rem; font-weight: 500; }

/* ---------------- Yearly cards ---------------- */
.tk-year-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.tk-monthcard { padding: .75rem .85rem; gap: .5rem; min-height: 150px; }
.tk-monthcard-head { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; font-size: .85rem; }
.tk-monthcard-head strong { font-weight: 600; }
.tk-spark { display: block; width: 100%; height: 44px; }
.tk-spark-empty { height: 44px; }
.tk-bestworst { display: flex; justify-content: space-between; gap: .5rem; font-size: .7rem; color: var(--tk-muted); }
.tk-bestworst b { font-weight: 600; }

/* ---------------- Charts ---------------- */
.tk-zero { stroke: var(--tk-line-2); stroke-width: 1; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
.tk-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.tk-line.pos { stroke: var(--tk-pos); } .tk-line.neg { stroke: var(--tk-neg); } .tk-line.flat { stroke: var(--tk-muted); }
.tk-area { stroke: none; opacity: .14; } .tk-area.pos { fill: var(--tk-pos); } .tk-area.neg { fill: var(--tk-neg); }
.tk-chart { position: relative; margin: 0; }
.tk-chart svg { display: block; width: 100%; height: 160px; }
.tk-chart-axis { display: flex; justify-content: space-between; font-size: .68rem; color: var(--tk-muted); margin-top: .3rem; font-variant-numeric: tabular-nums; }
.tk-tip { position: absolute; transform: translate(-50%, calc(-100% - 10px)); padding: .3rem .5rem; background: var(--tk-surface-2); border: 1px solid var(--tk-line-2); border-radius: var(--tk-radius); font-size: .72rem; white-space: nowrap; pointer-events: none; color: var(--tk-text); }
.tk-tip b { font-weight: 600; margin-left: .35rem; }
.tk-tip::after { content: ""; position: absolute; left: 50%; bottom: -14px; width: 1px; height: 10px; background: var(--tk-line-2); }
.tk-dot { position: absolute; width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 50%; background: var(--tk-text); box-shadow: 0 0 0 2px var(--tk-bg); pointer-events: none; }

.tk-hours { display: grid; grid-template-columns: repeat(24, 1fr); gap: 2px; height: 56px; align-items: end; }
.tk-hour { height: 100%; display: flex; align-items: flex-end; }
.tk-hour span { display: block; width: 100%; background: var(--tk-pos); opacity: .75; border-radius: 3px 3px 0 0; min-height: 0; }

/* ---------------- Performance summary ---------------- */
.tk-summary { margin-top: 1.5rem; padding-top: 1.1rem; border-top: 1px solid var(--tk-line); }
.tk-section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; margin-bottom: .8rem; }
.tk-section-head h2 { margin: 0; font-size: 1rem; font-weight: 600; color: var(--tk-text); }
.tk-section-head span { font-size: .78rem; }
.tk-summary-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 1rem; }
.tk-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 0; border: 1px solid var(--tk-line); border-radius: 12px; background: var(--surface); overflow: hidden; }
.tk-metrics > div { padding: .65rem .8rem; border-bottom: 1px solid var(--tk-line); border-right: 1px solid var(--tk-line); }
.tk-metrics > div:nth-child(3n) { border-right: 0; }
.tk-metrics > div:nth-last-child(-n+3) { border-bottom: 0; }
.tk-metrics dt { font-size: .66rem; letter-spacing: .06em; text-transform: uppercase; color: var(--tk-muted); }
.tk-metrics dd { margin: .25rem 0 0; font-size: 1rem; font-weight: 600; }
.tk-chart-card { border: 1px solid var(--tk-line); border-radius: 12px; background: var(--surface); padding: .75rem .9rem; }
.tk-chart-card h3 { margin: 0 0 .5rem; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--tk-muted); font-weight: 500; }
.tk-empty-state { margin-bottom: .9rem; padding: .8rem 1rem; border: 1px dashed var(--tk-line-2); border-radius: var(--tk-radius); color: var(--tk-text-2); font-size: .85rem; }
.tk-empty-state p { margin: 0; } .tk-empty-state p + p { margin-top: .25rem; color: var(--tk-muted); }

/* ---------------- Record money ---------------- */
.tk-record { margin-top: 1.1rem; }
.tk-record > summary { cursor: pointer; font-size: .82rem; color: var(--accent); }
.tk-money-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: .6rem; align-items: end; margin-top: .7rem; }
.tk-money-form label { display: flex; flex-direction: column; gap: .25rem; font-size: .72rem; color: var(--tk-muted); }
.tk-money-form input, .tk-money-form select { height: 34px; padding: 0 .55rem; font-size: .85rem; width: 100%; }
.tk-money-form .tk-money-desc { grid-column: span 2; }
.tk-money-form .btn { height: 34px; }

/* ---------------- Day panel ---------------- */
.tk-scrim { position: fixed; inset: 0; background: rgba(20, 20, 24, .16); z-index: 40; opacity: 0; transition: opacity .2s; }
.tk-scrim.show { opacity: 1; }
.tk-panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 100vw); z-index: 41;
  background: var(--surface); border-left: 1px solid var(--tk-line); color: var(--tk-text);
  transform: translateX(100%); visibility: hidden; overflow-y: auto;
  transition: transform .28s cubic-bezier(.2, .7, .2, 1), visibility 0s linear .28s;
  box-shadow: -16px 0 40px rgba(0, 0, 0, .08);
}
.tk-panel.open { transform: none; visibility: visible; transition: transform .28s cubic-bezier(.2, .7, .2, 1), visibility 0s; }
.tk-panel-inner { padding: 1.2rem 1.3rem 2rem; }
.tk-panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.tk-panel-head h2 { margin: .15rem 0 0; font-size: 1.15rem; font-weight: 600; color: var(--tk-text); }
.tk-panel-hero { margin: 1.1rem 0 .9rem; padding: .9rem 1rem; background: var(--tk-surface); border-radius: 12px; display: flex; justify-content: space-between; align-items: baseline; }
.tk-label { font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; color: var(--tk-muted); }
.tk-hero-num { font-size: 1.6rem; font-weight: 700; }
.tk-panel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin: 0; background: var(--tk-line); border: 1px solid var(--tk-line); border-radius: 12px; overflow: hidden; }
.tk-panel-grid > div { background: var(--surface); padding: .6rem .75rem; }
.tk-panel-grid dt { font-size: .64rem; letter-spacing: .06em; text-transform: uppercase; color: var(--tk-muted); }
.tk-panel-grid dd { margin: .2rem 0 0; font-size: .92rem; }
.tk-panel-section { margin-top: 1.25rem; }
.tk-panel-section h3 { margin: 0 0 .55rem; font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: var(--tk-muted); font-weight: 500; }
.tk-ledger, .tk-notes, .tk-history { list-style: none; margin: 0; padding: 0; }
.tk-ledger li { display: grid; grid-template-columns: 1fr auto auto; gap: .75rem; align-items: center; padding: .5rem 0; border-bottom: 1px solid var(--tk-line); font-size: .84rem; }
.tk-ledger-main { display: flex; flex-direction: column; } .tk-ledger-main a { color: var(--tk-text-2); font-size: .76rem; }
.tk-ledger-amt { display: flex; flex-direction: column; align-items: flex-end; }
.tk-ledger form { margin: 0; }
.tk-record-inline .tk-money-form { grid-template-columns: 1fr 1fr; }
.tk-notes li, .tk-history li { padding: .45rem 0; border-bottom: 1px solid var(--tk-line); font-size: .82rem; }
.tk-notes p, .tk-history p { margin: .15rem 0 0; color: var(--tk-text-2); }
.tk-notes time, .tk-history time { color: var(--tk-muted); font-variant-numeric: tabular-nums; font-size: .74rem; }
.tk-kind { color: var(--tk-text-2); margin: 0 .3rem; }
.tk-history a, .tk-notes a { color: var(--accent); }

/* Smooth switch between periods and views */
.tk-view, .tk-summary { animation: tk-in .22s ease-out both; }
@keyframes tk-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .tk-view, .tk-summary { animation: none; }
  .tk-panel, .tk-scrim { transition: none; }
  .tk-loading::after { animation: none; }
}

/* Pay list on lead pages */
.pay-list { list-style: none; margin: .5rem 0 0; padding: 0; }
.pay-list li { display: grid; grid-template-columns: 1fr auto auto; gap: .6rem; align-items: center; padding: .45rem 0; border-bottom: 1px solid var(--line); font-size: .88rem; }
.pay-list form { margin: 0; }
.pay-amt { font-variant-numeric: tabular-nums; font-weight: 600; }
.pay-add { margin-top: .75rem; }
.pay-add summary { cursor: pointer; color: var(--accent); font-size: .85rem; }
.pay-add .tk-money-form label { color: var(--muted); }
.nav-icon { display: inline-flex; align-items: center; gap: .35rem; }
.nav-icon svg { width: 15px; height: 15px; }

/* ---------------- Tracker: tablet and phone ---------------- */
@media (max-width: 1000px) {
  .tk-head { align-items: flex-start; }
  .tk-stats { width: 100%; }
  .tk-stats > div { flex: 1; min-width: 0; }
  .tk-summary-grid { grid-template-columns: minmax(0, 1fr); }
  .tk-year-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tk-week { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .tk { padding: 1.1rem 1rem; }
  .tk-page-title { font-size: 1.25rem; }
  .tk-settings-btn span { display: none; }
  .tk-settings-btn { width: 38px; padding: 0; justify-content: center; }
  .tk-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tk-stats > div { padding: .5rem .6rem; border-left: 0 !important; }
  .tk-stats > div:nth-child(n+4) { border-top: 1px solid var(--tk-line); }
  .tk-stats dd { font-size: .92rem; }
  /* Month: keep 7 columns, drop the week column to its own row under each week */
  .tk-month-head { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .tk-month-head .tk-wk-col { display: none; }
  .tk-month-row { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
  .tk-wk { grid-column: 1 / -1; min-height: 0; flex-direction: row; align-items: baseline; gap: .6rem; padding: .35rem .6rem; }
  .tk-wk-label { margin: 0; }
  .tk-day { min-height: 58px; padding: .3rem .2rem; }
  .tk-day .tk-date { top: .25rem; left: .3rem; font-size: .66rem; }
  .tk-day .tk-pnl { font-size: .66rem; margin-top: .7rem; }
  .tk-day .tk-full { display: none; }
  .tk-day .tk-compact { display: inline; }
  .tk-day .tk-meta { display: none; }
  .tk-year-grid, .tk-week { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tk-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tk-metrics > div:nth-child(3n) { border-right: 1px solid var(--tk-line); }
  .tk-metrics > div:nth-child(2n) { border-right: 0; }
  .tk-metrics > div:nth-last-child(-n+3) { border-bottom: 1px solid var(--tk-line); }
  .tk-metrics > div:nth-last-child(-n+2) { border-bottom: 0; }
  .tk-money-form .tk-money-desc { grid-column: 1 / -1; }
}
.form-group .small { text-transform: none; letter-spacing: 0; font-weight: 400; }

/* ======================================================================
   Daily Outreach Challenge (top of the Tracker). Follows the app's own
   light design (and dark mode); emerald = done, amber = achievements.
   ====================================================================== */
.dm-challenge {
  --dmc-done-bg: #E6F2EB; --dmc-done-line: #BCDCC8; --dmc-done-ink: #3A8659;
  --dmc-todo-bg: #F6F6F7; --dmc-todo-line: #E4E4E7; --dmc-todo-ink: #A1A1AA;
  --dmc-amber: #B26F16; --dmc-amber-bg: #FBF2E4; --dmc-amber-line: #F0DDBF;
  --dmc-green: #3A8659;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 1.5rem 1.6rem; margin-bottom: 1.25rem; box-shadow: var(--shadow);
}
:root[data-theme="dark"] .dm-challenge {
  --dmc-done-bg: rgba(74, 170, 118, .14); --dmc-done-line: rgba(74, 170, 118, .38); --dmc-done-ink: #6CC593;
  --dmc-todo-bg: #1A1815; --dmc-todo-line: #2C2823; --dmc-todo-ink: #6E675D;
  --dmc-amber: #E8B45C; --dmc-amber-bg: rgba(232, 180, 92, .10); --dmc-amber-line: rgba(232, 180, 92, .30);
  --dmc-green: #6CC593;
}
.dmc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.dmc-head h2 { margin: 0; font-size: 1.35rem; font-weight: 600; letter-spacing: -.01em; }
.dmc-head p { margin: .3rem 0 0; }
.dmc-streak { display: inline-flex; align-items: center; gap: .4rem; padding: .45rem .8rem; border-radius: 10px; background: var(--dmc-amber-bg); color: var(--dmc-amber); font-weight: 500; white-space: nowrap; }
.dmc-streak svg { width: 18px; height: 18px; }

.dmc-count { display: flex; justify-content: space-between; align-items: baseline; margin: 1.1rem 0 .9rem; }
.dmc-count p { margin: 0; display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap; }
.dmc-num { font-size: 3.4rem; font-weight: 700; line-height: 1; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.dmc-of { font-size: 1.25rem; color: var(--text-2); font-weight: 500; }
.dmc-over { font-size: .8rem; color: var(--dmc-green); background: var(--dmc-done-bg); border-radius: 999px; padding: .15rem .55rem; }
.dmc-pct { font-size: 1.6rem; font-weight: 600; color: var(--dmc-green); font-variant-numeric: tabular-nums; }

.dmc-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: .55rem; }
.tally {
  position: relative; aspect-ratio: 1; display: grid; place-items: center; border-radius: 9px;
  background: var(--dmc-todo-bg); border: 1px solid var(--dmc-todo-line); color: var(--dmc-todo-ink);
  font-size: .85rem; font-variant-numeric: tabular-nums;
  transition: background-color .35s ease, border-color .35s ease, color .35s ease, transform .2s ease;
}
.tally svg { position: absolute; width: 38%; height: 38%; stroke-width: 2; stroke-dasharray: 24; stroke-dashoffset: 24; opacity: 0; transition: stroke-dashoffset .4s ease .05s, opacity .1s; }
.tally.done { background: var(--dmc-done-bg); border-color: var(--dmc-done-line); color: var(--dmc-done-ink); }
.tally.done .tally-n { opacity: 0; }
.tally.done svg { stroke-dashoffset: 0; opacity: 1; }
.tally-n { transition: opacity .2s; }
.tally.just-done { animation: tally-pop .5s cubic-bezier(.2, .8, .3, 1.2) both; }
.tally.just-done::after { content: ""; position: absolute; inset: -1px; border-radius: inherit; box-shadow: 0 0 0 0 rgba(58, 134, 89, .35); animation: tally-pulse .7s ease-out .1s both; }
.tally.milestone.just-done::after { box-shadow: 0 0 0 0 rgba(178, 111, 22, .4); animation-name: tally-pulse-amber; }
.tally.just-undone { animation: tally-unpop .35s ease both; }
@keyframes tally-pop { 0% { transform: scale(.9); } 55% { transform: scale(1.06); } 100% { transform: scale(1); } }
@keyframes tally-unpop { 0% { transform: scale(1); } 50% { transform: scale(.94); } 100% { transform: scale(1); } }
@keyframes tally-pulse { from { box-shadow: 0 0 0 0 rgba(58, 134, 89, .35); } to { box-shadow: 0 0 0 9px rgba(58, 134, 89, 0); } }
@keyframes tally-pulse-amber { from { box-shadow: 0 0 0 0 rgba(178, 111, 22, .4); } to { box-shadow: 0 0 0 12px rgba(178, 111, 22, 0); } }

.dmc-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin-top: 1.1rem; }
.dmc-actions form { margin: 0; }
.dmc-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem; width: 100%;
  height: 50px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font: inherit; font-size: 1rem; font-weight: 500; cursor: pointer;
  transition: background-color .15s, border-color .15s, transform .1s;
}
.dmc-btn svg { width: 18px; height: 18px; }
.dmc-btn:hover:not(:disabled) { border-color: var(--muted); }
.dmc-btn:active:not(:disabled) { transform: scale(.98); }
.dmc-btn:disabled { opacity: .45; cursor: default; }
.dmc-btn.primary { background: var(--btn-primary-bg); border-color: var(--btn-primary-bg); color: var(--btn-primary-text); }
.dmc-btn.primary:hover:not(:disabled) { background: var(--btn-primary-hover); }
.dmc-btn.small { height: 34px; width: auto; padding: 0 .9rem; font-size: .85rem; }
.dmc-btn.htmx-request { opacity: .7; }

.dmc-status { margin: 1rem 0 0; color: var(--text-2); }
.dmc-done { display: inline-flex; align-items: center; gap: .5rem; color: var(--dmc-green); }
.dmc-done svg { width: 22px; height: 22px; color: var(--dmc-amber); }
.dm-challenge.celebrate .dmc-done { animation: dmc-rise .6s ease-out both; }
.dm-challenge.celebrate .dmc-done svg { animation: dmc-trophy 1.2s ease-out both; }
@keyframes dmc-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes dmc-trophy { 0% { transform: scale(.6) rotate(-8deg); opacity: 0; } 40% { transform: scale(1.15) rotate(4deg); opacity: 1; } 100% { transform: none; } }
.dmc-note { margin: .4rem 0 0; font-size: .82rem; color: var(--muted); }

.dmc-milestone { display: inline-block; margin-left: .6rem; padding: .15rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 500; color: var(--dmc-amber); background: var(--dmc-amber-bg); border: 1px solid var(--dmc-amber-line); animation: dmc-chip 2.6s ease both; vertical-align: middle; }
@keyframes dmc-chip { 0% { opacity: 0; transform: translateY(4px); } 12%, 80% { opacity: 1; transform: none; } 100% { opacity: 0; } }

.dmc-compare { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .6rem; margin: 1.3rem 0 0; padding-top: 1.2rem; border-top: 1px solid var(--line); }
.dmc-compare > div { background: var(--surface-2); border-radius: 12px; padding: .8rem .95rem; }
.dmc-compare dt { color: var(--text-2); font-size: .85rem; }
.dmc-compare dd { margin: .35rem 0 0; font-size: 1.25rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.dmc-compare dd.up { color: var(--dmc-green); }
.dmc-feedback { list-style: none; margin: .9rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .35rem; }
.dmc-feedback li { display: flex; align-items: center; gap: .55rem; color: var(--text-2); }
.dmc-feedback svg { width: 20px; height: 20px; color: var(--dmc-green); flex: none; }

.dmc-ach-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; margin-top: 1.4rem; }
.dmc-ach-head h3 { margin: 0; font-size: .95rem; font-weight: 600; }
.dmc-achievements { list-style: none; margin: .7rem 0 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .6rem; }
.ach { display: flex; gap: .7rem; align-items: flex-start; padding: .75rem .85rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); transition: border-color .3s, background-color .3s; }
.ach-icon { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--surface-2); color: var(--muted); }
.ach-icon svg { width: 18px; height: 18px; }
.ach-text { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.ach-text strong { font-size: .88rem; font-weight: 600; color: var(--text-2); }
.ach-text span { font-size: .78rem; color: var(--muted); }
.ach-text small { font-size: .74rem; color: var(--muted); }
.ach.unlocked .ach-icon { color: var(--dmc-amber); background: var(--dmc-amber-bg); }
.ach.unlocked strong { color: var(--text); }
.ach.earned { border-color: var(--dmc-amber-line); background: var(--dmc-amber-bg); }
.ach.earned .ach-icon { color: var(--dmc-amber); background: var(--surface); }
.ach.earned strong { color: var(--text); }
.ach.earned small { color: var(--dmc-amber); font-weight: 500; }
.ach.just-earned { animation: dmc-rise .5s ease-out both; }

.dmc-schedule { margin-top: 1.1rem; }
.dmc-schedule summary { cursor: pointer; color: var(--accent); font-size: .85rem; }
.dmc-weekdays, .dmc-rest { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .9rem; margin-top: .7rem; }
.dmc-weekdays label { display: inline-flex; align-items: center; gap: .3rem; font-size: .88rem; }
.dmc-weekdays input { width: auto; }

@media (prefers-reduced-motion: reduce) {
  .tally, .tally svg { transition: none; }
  .tally.just-done, .tally.just-done::after, .tally.just-undone, .dm-challenge.celebrate .dmc-done,
  .dm-challenge.celebrate .dmc-done svg, .dmc-milestone, .ach.just-earned { animation: none; }
}
@media (max-width: 1000px) {
  .dmc-compare { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dmc-achievements { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .dm-challenge { padding: 1.1rem 1rem; }
  .dmc-head h2 { font-size: 1.15rem; }
  .dmc-streak { font-size: .82rem; padding: .35rem .6rem; }
  .dmc-num { font-size: 2.6rem; }
  .dmc-grid { gap: .3rem; }
  .tally { border-radius: 6px; font-size: .68rem; }
  .dmc-btn { height: 46px; font-size: .95rem; }
  .dmc-compare { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dmc-compare > div:last-child { grid-column: 1 / -1; }
  .dmc-achievements { grid-template-columns: minmax(0, 1fr); }
}

/* ======================================================================
   Approval queue (stage 3)
   ====================================================================== */
.nav-count { display: inline-grid; place-items: center; min-width: 1.25rem; height: 1.25rem; padding: 0 .3rem; margin-left: .2rem; border-radius: 999px; background: var(--btn-primary-bg); color: var(--btn-primary-text); font-size: .7rem; font-weight: 600; vertical-align: 1px; }
.q-section { margin-top: 1.25rem; }
.q-section-head { display: flex; justify-content: space-between; align-items: center; gap: .75rem 1rem; flex-wrap: wrap; margin-bottom: .75rem; }
.q-section-head h2 { margin: 0; font-size: 1.05rem; }
.q-bulk { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin: 0; }
.q-bulk .check { display: inline-flex; align-items: center; gap: .35rem; font-size: .88rem; margin-right: .35rem; }
.q-bulk .check input, .q-pick input { width: auto; }
.q-card { margin-bottom: .9rem; transition: box-shadow .3s; }
.q-card + .q-card { margin-top: 0; }
.q-focus { box-shadow: 0 0 0 2px var(--ok-line), var(--shadow); }
.q-card-head { display: flex; align-items: flex-start; gap: .75rem; flex-wrap: wrap; }
.q-pick { padding-top: .2rem; }
.q-who { flex: 1 1 260px; min-width: 0; }
.q-who h2 { margin: 0; font-size: 1.05rem; }
.q-who h2 a { color: var(--text); }
.q-who p { margin: .2rem 0 0; }
.q-card-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.q-card-actions form, .q-actions form { margin: 0; }
.q-drafts { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 1rem; margin-top: .9rem; }
.q-draft { border: 1px solid var(--line); border-radius: 12px; padding: .85rem .95rem; background: var(--surface); transition: border-color .25s, background-color .25s; }
.q-draft.is-approved { border-color: #BCDCC8; background: #F4FAF6; }
:root[data-theme="dark"] .q-draft.is-approved { border-color: rgba(74, 170, 118, .38); background: rgba(74, 170, 118, .08); }
.q-draft-head { display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap; margin-bottom: .5rem; }
.q-draft-head h3 { margin: 0; font-size: .92rem; }
.q-subject { margin: 0 0 .45rem; font-weight: 600; }
.q-badge { display: inline-flex; align-items: center; padding: .1rem .55rem; border-radius: 999px; background: #E6F2EB; color: #3A8659; font-size: .75rem; font-weight: 600; }
:root[data-theme="dark"] .q-badge { background: rgba(74, 170, 118, .16); color: #6CC593; }
.q-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-top: .65rem; }
.q-checks { list-style: none; margin: .55rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .25rem; }
.q-check { font-size: .8rem; padding: .3rem .55rem; border-radius: 8px; }
.q-block { background: var(--err-bg); color: var(--err-text); }
.q-warn { background: var(--warn-bg); color: var(--warn-text); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
@media (max-width: 1000px) { .q-drafts { grid-template-columns: minmax(0, 1fr); } }

/* ======================================================================
   Funnel (stage 4)
   ====================================================================== */
.fn-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .6rem; align-items: flex-start; }
.fn-step > summary { list-style: none; }
.fn-step > summary::-webkit-details-marker { display: none; }
.fn-step[open] > summary { box-shadow: 0 0 0 2px var(--line); }
.fn-exit > summary { color: var(--muted); }
.fn-form { display: flex; flex-wrap: wrap; gap: .5rem .7rem; align-items: flex-end; margin-top: .55rem; padding: .7rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); min-width: min(320px, 80vw); }
.fn-form label { display: flex; flex-direction: column; gap: .2rem; font-size: .78rem; color: var(--muted); }
.fn-form .fn-note { flex: 1 1 220px; }
.fn-hint { flex-basis: 100%; margin: 0; }
.fn-step[open] { flex-basis: 100%; }
.fn-correct { margin-top: .9rem; }
.fn-correct summary { cursor: pointer; color: var(--muted); font-size: .82rem; }
.fn-correct .row-form { margin: .5rem 0 0; }

.fn-page .card + .card { margin-top: 1rem; }
.fn-periods { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.fn-periods a { padding: .3rem .8rem; border-radius: 7px; font-size: .84rem; color: var(--text-2); }
.fn-periods a[aria-current] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); text-decoration: none; }
.fn-headline { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .6rem; margin: 0 0 1rem; }
.fn-headline > div { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: .8rem .95rem; }
.fn-headline dt { font-size: .8rem; color: var(--text-2); }
.fn-headline dd { margin: .3rem 0 0; font-size: 1.4rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.fn-steps { list-style: none; margin: .5rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .55rem; }
.fn-row { display: grid; grid-template-columns: 110px minmax(0, 1fr) 54px 150px; gap: .8rem; align-items: center; font-size: .9rem; }
.fn-row-label { font-weight: 500; }
.fn-track { height: 10px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.fn-bar { display: block; height: 100%; background: var(--chart); border-radius: 0 4px 4px 0; min-width: 2px; transition: width .4s ease; }
.fn-count { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.fn-rate { color: var(--text-2); font-size: .8rem; font-variant-numeric: tabular-nums; }
.fn-two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; }
.fn-list { list-style: none; margin: .4rem 0 0; padding: 0; }
.fn-list li { display: flex; justify-content: space-between; gap: 1rem; padding: .45rem 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.fn-list li:last-child { border-bottom: 0; }
.fn-list .fn-days { color: var(--due); font-variant-numeric: tabular-nums; white-space: nowrap; }
.export-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
.export-grid .card + .card { margin-top: 0; }
.export-card p { margin: .3rem 0 .8rem; }
.sheets-steps { margin: .4rem 0 0; padding-left: 1.2rem; font-size: .88rem; color: var(--text-2); }
.sheets-steps li + li { margin-top: .3rem; }
.sheets-status { display: inline-flex; align-items: center; gap: .4rem; font-size: .85rem; }
.sheets-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.sheets-dot.on { background: #3A8659; }
@media (max-width: 760px) {
  .fn-headline { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fn-row { grid-template-columns: 84px minmax(0, 1fr) 40px; }
  .fn-rate { grid-column: 1 / -1; margin-top: -.3rem; }
  .fn-two { grid-template-columns: minmax(0, 1fr); }
}

/* ======================================================================
   Sending (stage 5)
   ====================================================================== */
.send-setup { border-color: var(--warn-line); background: var(--warn-bg); margin-bottom: 1rem; }
.send-setup h2 { margin-top: 0; }
.send-setup ol { margin: .4rem 0 .6rem; padding-left: 1.2rem; color: var(--warn-text); }
.send-setup li + li { margin-top: .3rem; }
.send-settings { display: flex; flex-direction: column; gap: .85rem; }
.send-settings .check { display: flex; gap: .6rem; align-items: flex-start; }
.send-settings .check input { width: auto; margin-top: .25rem; }
.send-settings .btn { align-self: flex-start; }
.send-window { font-size: 1.05rem !important; }
.table-wrap { overflow-x: auto; }
.nowrap { white-space: nowrap; }
.unsub-card { max-width: 460px; margin: 12vh auto 0; text-align: center; padding: 2rem 1.75rem; }
.unsub-card .brand { margin: 0 0 1rem; display: inline-block; }
.unsub-card h1 { margin: 0 0 .5rem; font-size: 1.4rem; }
.unsub-card form { margin-top: 1.2rem; }
.email-list { list-style: none; margin: .5rem 0 0; padding: 0; }
.email-list li { padding: .45rem 0; border-bottom: 1px solid var(--line); font-size: .88rem; }
.email-list li:last-child { border-bottom: 0; }

/* Our own light/dark modes, declared so browsers never force their own. */
:root[data-theme="light"] { color-scheme: only light; }
:root[data-theme="dark"] { color-scheme: only dark; }
html { background: var(--bg); }
