/* Tick-and-Tie Working Paper: shared design system for landing, dashboard, and auth.
   Ground is columnar analysis-pad green; ink is graphite; red pencil is reserved for leaks. */

@font-face { font-family: "Barlow Condensed"; font-style: normal; font-weight: 500; font-display: swap; src: url("/static/fonts/BarlowCondensed-500.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Barlow Condensed"; font-style: normal; font-weight: 600; font-display: swap; src: url("/static/fonts/BarlowCondensed-600.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Barlow Condensed"; font-style: normal; font-weight: 700; font-display: swap; src: url("/static/fonts/BarlowCondensed-700.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Libre Franklin"; font-style: normal; font-weight: 400 700; font-display: swap; src: url("/static/fonts/LibreFranklin-400-700.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --paper: #cfe3cb;
  --paper-deep: #c1d8bd;
  --sheet: #eef4e8;
  --ink: #23272b;
  --ink-2: #434b52;
  --rule: #a9c2a5;
  --rule-strong: #86a483;
  --red: #9e231b;
  --display: "Barlow Condensed", "Arial Narrow", "Helvetica Neue", sans-serif;
  --ui: "Libre Franklin", system-ui, -apple-system, "Segoe UI", sans-serif;
  --line: 24px; /* spacing unit: body leading, inputs, buttons and table rows are multiples of it. The page ruling is texture, not a strict baseline grid. */
}

*, *::before, *::after { box-sizing: border-box; }

html {
  background: var(--paper);
  color: var(--ink);
  font: 400 1rem/24px var(--ui);
  -webkit-text-size-adjust: 100%;
  scrollbar-color: var(--rule-strong) var(--paper);
}

body {
  margin: 0;
  min-height: 100vh;
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--line) - 1px), rgba(86, 128, 84, 0.11) calc(var(--line) - 1px), rgba(86, 128, 84, 0.11) var(--line));
}

::selection { background: var(--ink); color: var(--sheet); }
input, textarea, select { caret-color: var(--red); }

a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 3px; }

h1, h2, h3, p { margin: 0; }
h1, h2 { font-family: var(--display); font-weight: 700; line-height: 0.98; text-wrap: balance; }
h1 { font-size: clamp(2.9rem, 6.4vw, 5rem); letter-spacing: -0.01em; }
h2 { font-size: clamp(2rem, 3.4vw, 2.75rem); font-weight: 600; }
h3, .h-sub { font: 600 1.875rem/1.05 var(--display); text-wrap: balance; }
p { max-width: 68ch; }
.muted { color: var(--ink-2); }
.small { font-size: 0.875rem; line-height: 24px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- Page frame: red double margin rule on wide screens ---- */
.page { position: relative; max-width: 1180px; margin: 0 auto; padding: 0 20px 96px; }
@media (min-width: 900px) {
  .page { padding-left: 104px; padding-right: 40px; }
  .page::before {
    content: "";
    position: absolute; top: 0; bottom: 0; left: 72px; width: 5px;
    border-left: 1px solid rgba(158, 35, 27, 0.55);
    border-right: 1px solid rgba(158, 35, 27, 0.55);
  }
}

.band { padding-top: calc(var(--line) * 3); }
.band > h2 { margin-bottom: var(--line); }
.lede { font-size: 1.125rem; line-height: 24px; max-width: 48ch; }

/* ---- Header ---- */
.masthead {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 12px 24px; padding: 20px 0; min-height: calc(var(--line) * 3);
}
.wordmark {
  display: inline-flex; align-items: center; gap: 10px; text-decoration: none;
  font: 700 1.625rem/1 var(--display); letter-spacing: 0.01em;
}
.wordmark svg { width: 22px; height: 22px; }
.nav { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 22px; font-size: 0.9375rem; }
.nav a, .nav button.linklike { color: var(--ink); }
.nav a.btn { color: var(--sheet); text-decoration: none; }
.status {
  display: inline-flex; align-items: center; gap: 6px;
  font: 600 0.8125rem/1 var(--display); letter-spacing: 0.08em; text-transform: uppercase;
  padding: 6px 10px; border: 1px solid var(--rule-strong);
}
.status.is-active { background: var(--ink); color: var(--sheet); border-color: var(--ink); }
button.linklike {
  background: none; border: 0; padding: 0; font: inherit; cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; color: inherit;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 24px; border: 2px solid var(--ink); border-radius: 2px;
  background: var(--ink); color: var(--sheet);
  font: 600 1rem/1 var(--ui); text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background-color 120ms ease-out, color 120ms ease-out;
}
.btn:hover { background: #000; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.55; cursor: progress; }
.btn--ghost { background: transparent; color: var(--ink); }
.btn--ghost:hover { background: var(--ink); color: var(--sheet); }
.btn--sm { min-height: 40px; padding: 0 16px; font-size: 0.9375rem; }
.btn--wide { width: 100%; }

/* ---- Forms ---- */
.field { display: block; margin-bottom: var(--line); }
.field > span { display: block; font-size: 0.875rem; font-weight: 600; color: var(--ink-2); }
.input, select.input {
  width: 100%; min-height: 48px; margin-top: 0; padding: 12px 10px;
  background: var(--sheet); color: var(--ink); font: 400 1rem/1.3 var(--ui);
  border: 0; border-bottom: 2px solid var(--ink); border-radius: 0;
}
.input::placeholder { color: var(--ink-2); opacity: 0.8; }
.input:focus-visible { outline: 2px solid var(--red); outline-offset: 0; }
input[type="range"].input { padding: 0; min-height: 32px; background: transparent; border-bottom: 0; accent-color: var(--ink); }
input[type="file"].input { padding: 8px 0; background: transparent; border-bottom: 1px solid var(--rule-strong); font-size: 0.875rem; }
input[type="file"]::file-selector-button {
  margin-right: 12px; padding: 6px 12px; border: 1.5px solid var(--ink); border-radius: 2px;
  background: transparent; color: var(--ink); font: 600 0.8125rem var(--ui); cursor: pointer;
}
input[type="checkbox"] { accent-color: var(--ink); width: 18px; height: 18px; }
.check { display: flex; align-items: center; gap: 10px; font-size: 0.9375rem; margin-bottom: var(--line); }

/* ---- Notes (notice / error) written on the sheet ---- */
.note { margin-bottom: var(--line); padding: 8px 12px; background: var(--sheet); border: 1px solid var(--rule-strong); font-size: 0.9375rem; }
.note--error { border-color: var(--red); color: var(--red); font-weight: 600; }
.note--ok { border-color: var(--ink); }

/* ---- Pencil marks ---- */
.tick { width: 18px; height: 18px; flex: none; vertical-align: -3px; }
.tick path { fill: none; stroke: var(--ink); stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.circled { position: relative; display: inline-block; color: var(--red); font-weight: 700; padding: 0 8px; }
.circled::after {
  content: ""; position: absolute; inset: -9px -10px -7px -10px; pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 44' preserveAspectRatio='none'%3E%3Cpath d='M9 24C5 11 31 4 63 4s53 7 50 19-29 17-62 16C26 38 4 33 9 21c2-6 11-10 20-12' fill='none' stroke='%239e231b' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round' vector-effect='non-scaling-stroke'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
}

/* ---- Ledger tables ---- */
.ledger { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 0.9375rem; }
.ledger caption { text-align: left; padding-bottom: 8px; font-size: 0.875rem; color: var(--ink-2); }
.ledger th {
  padding: 12px 12px 9px; text-align: left; font: 600 0.9375rem/1.1 var(--display);
  letter-spacing: 0.07em; text-transform: uppercase; border-bottom: 3px double var(--ink); white-space: nowrap;
}
.ledger th.num { text-align: right; }
.ledger td { padding: 12px 12px 11px; line-height: 24px; border-left: 1px solid var(--rule-strong); border-bottom: 1px solid var(--rule); vertical-align: middle; }
.ledger td:first-child, .ledger th:first-child { border-left: 0; }
.ledger tbody tr:hover td { background: rgba(35, 39, 43, 0.045); }
.ledger tfoot td { border-top: 3px double var(--ink); border-bottom: 0; font-weight: 600; }
.ledger .mark { width: 36px; text-align: center; padding: 12px 4px 11px; }
.ledger tr.is-leak td { color: var(--ink); }
.ledger tr.is-locked td {
  color: transparent; user-select: none; pointer-events: none;
  background: repeating-linear-gradient(135deg, transparent 0 5px, rgba(35, 39, 43, 0.22) 5px 6px);
}
.table-wrap { overflow-x: auto; background: var(--paper); }
.worksheet .table-wrap, .modal-sheet .table-wrap { background: transparent; }
.ledger td.nowrap, .ledger th.nowrap { white-space: nowrap; }

/* ---- Stamped figures ---- */
.stamp { font: 700 clamp(3.25rem, 8vw, 6rem)/0.9 var(--display); letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.stamp--leak { color: var(--red); }
.figure { font: 700 2rem/1 var(--display); font-variant-numeric: tabular-nums; }

/* ---- Layout helpers ---- */
.split, .cols-2 { display: grid; grid-template-columns: minmax(0, 1fr); }
.split > *, .cols-2 > * { min-width: 0; }
.split { gap: calc(var(--line) * 1.5) 48px; }
@media (min-width: 900px) { .split { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); align-items: start; } }
.cols-2 { gap: var(--line) 48px; }
@media (min-width: 760px) { .cols-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; }
.stack > * + * { margin-top: var(--line); }
.rule { border: 0; border-top: 1px solid var(--rule-strong); margin: var(--line) 0; }

/* ---- The worksheet that leads the landing page ---- */
.worksheet { background: var(--sheet); border: 1px solid var(--rule-strong); padding: 20px 20px 24px; }
.worksheet .ledger th, .worksheet .ledger td { padding-left: 10px; padding-right: 10px; }
.worksheet-foot { margin-top: var(--line); display: grid; gap: 8px 24px; align-items: end; }
@media (min-width: 560px) { .worksheet-foot { grid-template-columns: 1fr auto; } }

/* ---- Toast ---- */
.toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 60; max-width: 360px;
  padding: 12px 16px; background: var(--sheet); border: 2px solid var(--ink); font-size: 0.9375rem;
}
.toast strong { display: block; font: 700 1.125rem/1.2 var(--display); letter-spacing: 0.02em; }

/* ---- Plans dialog (native <dialog>: focus trap, Esc, and inert background come built in) ---- */
dialog.modal {
  width: min(860px, calc(100% - 32px)); max-height: 92vh; margin: 4vh auto; padding: 24px; overflow-y: auto;
  background: var(--sheet); color: var(--ink); border: 2px solid var(--ink);
}
dialog.modal::backdrop { background: rgba(35, 39, 43, 0.55); }
body:has(dialog[open]) { overflow: hidden; }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: var(--line); }

/* ---- Stacked tables on narrow screens: plan, price and button stay together ---- */
@media (max-width: 640px) {
  .ledger--stack thead { display: none; }
  .ledger--stack, .ledger--stack tbody, .ledger--stack tr, .ledger--stack td { display: block; width: 100%; }
  .ledger--stack tr { padding: 12px 0; border-bottom: 1px solid var(--rule-strong); }
  .ledger--stack td { padding: 2px 0; border: 0; text-align: left; }
  .ledger--stack td.num { text-align: left; }
  .ledger--stack td .btn { margin-top: 8px; }
  .ledger--stack td[data-label]::before { content: attr(data-label) ": "; color: var(--ink-2); font-size: 0.875rem; }
  .ledger--stack tfoot td:first-child { font-weight: 600; }
  .ledger--hero .col-ticket, .ledger--hero .small { display: none; }
  .ledger--hero th { padding-left: 3px; padding-right: 3px; font-size: 0.75rem; letter-spacing: 0.03em; }
  .ledger--hero td { padding-left: 4px; padding-right: 4px; }
  .ledger--hero .mark { width: 22px; padding-left: 0; padding-right: 0; }
  .ledger--hero .tie { display: none; }
  .ledger--hero td.num { white-space: nowrap; }
  .worksheet { padding: 12px 12px 16px; }
  .worksheet .ledger { font-size: 0.875rem; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
@media (max-width: 899px) { .masthead { padding-top: 16px; } }

/* ---- The tie: a graphite arc joining hours worked to hours billed on a matched row ---- */
.ledger td.has-tie { position: relative; }
.tie { position: absolute; left: -34px; bottom: 3px; width: 46px; height: 9px; pointer-events: none; }
.tie path { fill: none; stroke: var(--ink); stroke-width: 1.5; stroke-linecap: round; opacity: 0.7; }

/* ---- One authored moment: ticks draw, the leak is circled, the total lands ---- */
@media (prefers-reduced-motion: no-preference) {
  .worksheet .tick path { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 420ms cubic-bezier(0.22, 1, 0.36, 1) forwards; }
  .worksheet tr:nth-child(1) .tick path { animation-delay: 150ms; }
  .worksheet tr:nth-child(2) .tick path { animation-delay: 300ms; }
  .worksheet tr:nth-child(3) .tick path { animation-delay: 450ms; }
  .worksheet .tie path { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 500ms cubic-bezier(0.22, 1, 0.36, 1) 600ms forwards; }
  .worksheet .circled::after { clip-path: inset(0 100% 0 0); animation: reveal 520ms cubic-bezier(0.22, 1, 0.36, 1) 900ms forwards; }
  .worksheet .stamp { opacity: 0; transform: translateY(-8px); animation: land 480ms cubic-bezier(0.22, 1, 0.36, 1) 1300ms forwards; }
}
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes reveal { to { clip-path: inset(0 0 0 0); } }
@keyframes land { to { opacity: 1; transform: none; } }
