/* KAEDIX Platform - UX 2.0.

   Tokens from the KAEDIX brand system; the visual language matches the Hub
   (docs/design, direction 1d with the 1b icon set): DM Sans throughout, an
   off-white ground, charcoal chrome, opaque cards with hairline borders, and
   Tiger reserved for the primary action, the required marker and focus.
   Nothing else is orange.

   Mobile-first on purpose. The Streamlit portal met the phone by overriding
   a desktop DOM after the fact, which is how it shipped 13.5px inputs that
   made iOS Safari zoom on every field. Here the phone sizes ARE the base
   rules: 16px inputs, 44px controls, and desktop is the media query. */

:root {
  --kdx-tiger:#FF671F; --kdx-tiger-200:#FFC4A3; --kdx-tiger-600:#E85A15; --kdx-tiger-700:#C94A0E;
  --kdx-navy:#0A294A; --kdx-charcoal:#2D2D2D; --kdx-iron:#454545; --kdx-graphite:#666666;
  --kdx-ink-50:#FAFAF8; --kdx-ink-100:#F2F1EE; --kdx-ink-200:#E5E3DE;
  --kdx-ink-300:#C9C6BF; --kdx-ink-400:#9A978F; --kdx-white:#FFFFFF;

  /* Semantic layer. Only these are redefined for dark mode, so every rule
     below is written once. */
  --bg:var(--kdx-ink-50); --card:var(--kdx-white);
  --border:var(--kdx-ink-200); --border-strong:var(--kdx-ink-300);
  --fg:var(--kdx-charcoal); --fg-2:var(--kdx-graphite); --fg-3:var(--kdx-ink-400);
  --field:var(--kdx-white); --field-locked:var(--kdx-ink-100);
  --chrome:var(--kdx-charcoal); --chrome-fg:var(--kdx-white);
  --chrome-fg-2:rgba(255,255,255,.62); --chrome-line:rgba(255,255,255,.14);
  --success:#0F5933; --error:#C2262E; --warn:#8A5A14;
  --success-bg:rgba(15,89,51,.07); --error-bg:rgba(194,38,46,.06);
  --warn-bg:rgba(222,153,66,.1); --info-bg:var(--kdx-ink-100);

  --font-sans:'DM Sans',-apple-system,BlinkMacSystemFont,'Helvetica Neue',Arial,sans-serif;
  --font-mono:ui-monospace,'SF Mono',Menlo,monospace;
  --radius:4px; --radius-card:8px;
  --ease:cubic-bezier(.2,.6,.2,1);
  --tap:44px;
}

/* The portal follows the device. There is no in-app toggle, by design: the
   Hub does the same and the two should never disagree on a phone. */
@media (prefers-color-scheme: dark) {
  :root {
    --bg:#1A1A1A; --card:#242424;
    --border:#333331; --border-strong:#454545;
    --fg:#FFFFFF; --fg-2:#A8A5A0; --fg-3:#7C7A76;
    --field:#1F1F1F; --field-locked:#2A2A28;
    --chrome:#242424; --chrome-line:rgba(255,255,255,.1);
    --success:#4CAF7D; --error:#F08A8F; --warn:#E0A758;
    --success-bg:rgba(76,175,125,.1); --error-bg:rgba(240,138,143,.09);
    --warn-bg:rgba(224,167,88,.1); --info-bg:#2A2A28;
  }
}

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

body {
  margin:0; background:var(--bg); color:var(--fg);
  font-family:var(--font-sans); font-size:16px; line-height:1.5;
  -webkit-font-smoothing:antialiased; -moz-osx-font-smoothing:grayscale;
}

/* The insets are load-bearing: base.html sets viewport-fit=cover and this
   installs as a standalone PWA, so the ends of the page reach the hardware. */
.wrap {
  max-width:960px; margin:0 auto;
  padding: max(env(safe-area-inset-top), 16px) max(22px, env(safe-area-inset-left))
           calc(28px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-right));
}

a { color:var(--fg); }
a:hover { color:var(--kdx-tiger); }

/* ── Header ─────────────────────────────────────────────
   The same header the Hub draws: a spaced kicker, then a serif title with
   a short Tiger rule. The nav is plain text at the kicker's right. */
.top { display:flex; flex-wrap:wrap; align-items:baseline; justify-content:space-between; gap:4px 16px; margin:24px 0 10px; }
.kicker { margin:0; font-size:10px; letter-spacing:.35em; text-transform:uppercase; color:var(--fg-2); white-space:nowrap; }
.topnav { display:flex; gap:18px; font-size:13px; margin-left:auto; white-space:nowrap; }
.topnav a { color:var(--fg-2); text-decoration:none; min-height:var(--tap); display:inline-flex; align-items:center; }
.topnav a:hover { color:var(--kdx-tiger); }
.topnav a[aria-current="page"] { color:var(--fg); font-weight:700; }
h1.page::after { content:""; display:block; width:32px; height:2px; margin:12px 0 10px; background:var(--kdx-tiger); }

/* ── Tiles (document picker) ─────────────────────────────
   Hub tiles, carrying a description line because a form is not an app. */
.tile-grid { display:grid; grid-template-columns:repeat(2, minmax(0,1fr)); gap:12px; }
.tile {
  position:relative; display:flex; flex-direction:column; justify-content:space-between; gap:14px;
  min-height:150px; padding:18px; background:var(--card); border:1px solid var(--border);
  border-radius:6px; color:var(--fg); text-decoration:none;
  transition:box-shadow 200ms var(--ease), background 120ms var(--ease);
}
.tile:hover { box-shadow:0 12px 32px rgba(45,45,45,.08), 0 4px 10px rgba(45,45,45,.05); color:var(--fg); }
.tile:active { background:var(--info-bg); }
.tile:focus-visible { outline:2px solid var(--kdx-tiger); outline-offset:2px; }
.tile-icon { width:44px; height:44px; flex:none; }
.tile-icon .accent { stroke:var(--kdx-tiger); }
.tile-text { display:flex; flex-direction:column; gap:3px; }
.tile-label { font-weight:700; font-size:14px; line-height:1.3; }
.tile-desc { font-size:12.5px; color:var(--fg-2); line-height:1.4; text-wrap:pretty; }
.tile-soon { cursor:default; }
.tile-soon:hover { box-shadow:none; }
.tile-soon .tile-icon, .tile-soon .tile-label, .tile-soon .tile-desc { opacity:.38; }
.tile-badge {
  position:absolute; top:14px; right:14px; font-size:9px; font-weight:700; letter-spacing:.12em;
  text-transform:uppercase; color:var(--fg-2); border:1px solid var(--border); border-radius:999px; padding:3px 8px;
}
@media (min-width:700px) {
  .top { margin-top:40px; }
  .tile-grid { grid-template-columns:repeat(auto-fill, minmax(200px,1fr)); gap:16px; }
  .tile { min-height:190px; padding:24px; }
  .tile-icon { width:56px; height:56px; }
  .tile-label { font-size:16px; }
  .tile-desc { font-size:13px; }
}

/* ── Type ──────────────────────────────────────────────── */
.eyebrow {
  font-size:10px; font-weight:700; letter-spacing:.18em; text-transform:uppercase;
  color:var(--fg-3); margin:26px 2px 10px;
}
.eyebrow-sub { color:var(--fg-2); letter-spacing:.12em; margin:12px 2px 4px; }
.sub-hint { color:var(--fg-3); font-size:13px; font-style:italic; margin:0 2px 10px; max-width:60ch; text-wrap:pretty; }
h1.page { font-family:'DM Serif Display',Georgia,serif; font-weight:400; font-size:28px; line-height:1.2; letter-spacing:0; margin:0 0 6px; text-wrap:pretty; }
p.lede { color:var(--fg-2); font-size:14px; margin:0; max-width:60ch; text-wrap:pretty; }

/* ── Cards / rows ──────────────────────────────────────── */
.card {
  background:var(--card); border:1px solid var(--border);
  border-radius:var(--radius-card); padding:18px; margin-bottom:14px;
}

.doc-card {
  display:flex; align-items:center; gap:14px; min-height:var(--tap);
  background:var(--card); border:1px solid var(--border);
  border-radius:var(--radius-card); padding:14px 16px; margin-bottom:8px;
  color:inherit; text-decoration:none;
  transition:border-color 200ms var(--ease), background 120ms var(--ease);
}
.doc-card:hover { border-color:var(--border-strong); color:inherit; }
.doc-card:active { background:var(--info-bg); }
.doc-card:focus-visible { outline:2px solid var(--kdx-tiger); outline-offset:2px; }
.doc-card[aria-disabled="true"] { background:transparent; pointer-events:none; }
.doc-mark {
  width:36px; height:36px; flex:none; border-radius:var(--radius);
  background:var(--info-bg); color:var(--fg-2);
  font-size:14px; font-weight:700; letter-spacing:.02em;
  display:flex; align-items:center; justify-content:center;
}
.doc-card[aria-disabled="true"] .doc-mark { color:var(--fg-3); }
/* These are spans inside a span, so they need to be told to stack; left
   inline they read as one run-on sentence. */
.doc-name { display:block; font-weight:600; font-size:15px; line-height:1.35; letter-spacing:-.01em; }
.doc-desc { display:block; font-size:13px; color:var(--fg-2); margin-top:3px; text-wrap:pretty; }
.doc-card > span:not([class]) { min-width:0; flex:1 1 auto; }
.doc-chev { margin-left:auto; color:var(--fg-3); font-size:20px; line-height:1; }
/* An unavailable type says so in a chip rather than by looking broken. */
.doc-pill {
  margin-left:auto; flex:none; font-size:9.5px; font-weight:700;
  letter-spacing:.12em; text-transform:uppercase; color:var(--fg-3);
  border:1px solid var(--border-strong); border-radius:999px;
  padding:4px 9px; white-space:nowrap;
}

/* ── Form sections ─────────────────────────────────────── */
/* Numbered groups: a change order runs to seven sections, and an operator
   scrolling one on a phone needs to know where they are in it. */
.group {
  background:var(--card); border:1px solid var(--border);
  border-radius:var(--radius-card); margin-bottom:12px;
}
.group-head {
  display:flex; align-items:baseline; gap:10px;
  padding:14px 18px; border-bottom:1px solid var(--border);
}
.group-n { font-size:11px; font-weight:700; color:var(--fg-3); font-variant-numeric:tabular-nums; }
.group-t { font-size:13px; font-weight:700; letter-spacing:.02em; }
.group-body { padding:16px 18px 4px; }

/* ── Fields ────────────────────────────────────────────── */
.field { margin-bottom:16px; }
.field label.lbl {
  display:block; font-size:11px; font-weight:700; letter-spacing:.07em;
  text-transform:uppercase; color:var(--fg-2); margin-bottom:6px;
}
.field .help { font-size:12.5px; color:var(--fg-2); margin-top:6px; text-wrap:pretty; }
.req { color:var(--kdx-tiger); margin-left:3px; }

input[type=text],input[type=email],input[type=tel],input[type=date],
input[type=number],select,textarea {
  width:100%; min-height:var(--tap);
  border:1px solid var(--border-strong); border-radius:var(--radius);
  background:var(--field); color:var(--fg);
  font-family:var(--font-sans); font-size:16px; padding:10px 12px;
}
textarea { min-height:92px; resize:vertical; line-height:1.5; }
input:focus,select:focus,textarea:focus {
  outline:none; border-color:var(--kdx-tiger);
  box-shadow:0 0 0 2px rgba(255,103,31,.16);
}
input[readonly] { background:var(--field-locked); color:var(--fg-2); }
input::placeholder,textarea::placeholder { color:var(--fg-3); }
input[type=file] {
  border:1px dashed var(--border-strong); border-radius:var(--radius);
  background:transparent; color:var(--fg); font-size:14px; padding:12px;
}
.money-wrap { position:relative; }
.money-wrap span { position:absolute; left:12px; top:50%; transform:translateY(-50%); color:var(--fg-3); }
.money-wrap input { padding-left:26px; font-variant-numeric:tabular-nums; }

/* The server is still what rejects a bad form; this only puts the reason
   next to the field it belongs to instead of only at the top. */
.field.bad input, .field.bad select, .field.bad textarea {
  border-color:var(--error); background:var(--error-bg);
}
.field-err { font-size:12.5px; font-weight:600; color:var(--error); margin-top:6px; }

.check {
  display:flex; align-items:center; gap:11px; min-height:var(--tap);
  font-size:15px; cursor:pointer;
}
.check input { width:21px; height:21px; accent-color:var(--kdx-tiger); flex:none; margin:0; }

/* ── Buttons ───────────────────────────────────────────── */
/* Send and Download live in one bar. Download was a corner link before,
   which hid the only way to get a document out without sending it. */
.actions {
  display:flex; flex-direction:column; gap:10px; margin-top:18px; padding:16px;
  background:var(--card); border:1px solid var(--border); border-radius:var(--radius-card);
}
.actions-hint { font-size:12.5px; color:var(--fg-2); order:3; text-align:center; }

.btn-primary, .btn-quiet {
  display:inline-flex; align-items:center; justify-content:center; gap:8px;
  border-radius:var(--radius); font-family:var(--font-sans);
  letter-spacing:.01em; text-decoration:none; cursor:pointer;
  border:1px solid transparent;
  transition:background 120ms var(--ease), border-color 120ms var(--ease);
}
.btn-primary {
  width:100%; min-height:50px; padding:0 20px;
  background:var(--kdx-tiger); color:var(--kdx-white);
  font-size:15px; font-weight:700;
}
.btn-primary:hover { background:var(--kdx-tiger-600); color:var(--kdx-white); }
.btn-primary:active { background:var(--kdx-tiger-700); }
.btn-primary[disabled] { background:var(--border-strong); cursor:default; }

.btn-quiet {
  min-height:var(--tap); padding:0 16px;
  background:transparent; border-color:var(--border-strong); color:var(--fg);
  font-size:14px; font-weight:500;
}
.btn-quiet:hover { border-color:var(--fg-3); color:var(--fg); }

@media (min-width:700px) {
  .actions { flex-direction:row; align-items:center; justify-content:flex-end; }
  .actions .btn-primary { order:2; width:auto; min-height:46px; font-size:14px; }
  .actions .btn-quiet { order:1; }
  .actions-hint { order:0; margin-right:auto; text-align:left; }
}

/* ── Filter pills ──────────────────────────────────────── */
.pills { display:flex; flex-wrap:wrap; gap:8px; margin:22px 0 0; }
.pill {
  display:inline-flex; align-items:center; gap:7px; min-height:34px;
  padding:0 14px; border-radius:999px; border:1px solid var(--border-strong);
  color:var(--fg-2); font-size:13px; font-weight:600; text-decoration:none;
}
.pill:hover { color:var(--fg); border-color:var(--fg-3); }
.pill.on { background:var(--kdx-tiger); border-color:var(--kdx-tiger); color:#fff; }
.pill-n { font-size:11px; font-weight:700; opacity:.7; }

/* ── Status ────────────────────────────────────────────── */
.chip {
  display:inline-flex; align-items:center; gap:6px; border-radius:999px;
  padding:4px 10px 4px 8px; font-size:10.5px; font-weight:700;
  letter-spacing:.06em; text-transform:uppercase; white-space:nowrap;
  border:1px solid var(--border);
}
.chip::before { content:""; width:6px; height:6px; border-radius:50%; background:currentColor; }
.chip.awaiting { background:var(--warn-bg);    color:var(--warn); }
.chip.signed   { background:var(--success-bg); color:var(--success); }
.chip.draft    { background:var(--info-bg);    color:var(--fg-2); }
.chip.error    { background:var(--error-bg);   color:var(--error); }
.resend { display:flex; flex-wrap:wrap; gap:4px 14px; margin-top:6px; }
.resend form { display:inline; }
.btn-link { background:none; border:0; padding:0; font:inherit; font-size:12.5px; color:var(--kdx-tiger); cursor:pointer; text-decoration:underline; text-underline-offset:2px; min-height:var(--tap); }
a.sent-title { text-decoration:none; color:inherit; }
a.sent-title:hover { color:var(--kdx-tiger); }
.acct { font-size:10px; font-weight:700; letter-spacing:.12em; text-transform:uppercase; color:var(--fg-3); border:1px solid var(--border); border-radius:999px; padding:2px 8px; }
.acct.sandbox { border-style:dashed; }

.note {
  border-radius:var(--radius-card); border:1px solid var(--border);
  padding:14px 16px; font-size:14px; margin-bottom:14px; text-wrap:pretty;
}
.note.error   { background:var(--error-bg);   border-color:var(--error);   color:var(--error); }
.note.success { background:var(--success-bg); border-color:var(--success); color:var(--success); }
.note.warn    { background:var(--warn-bg);    border-color:rgba(222,153,66,.35); color:var(--warn); }
.note.info    { background:var(--info-bg); color:var(--fg-2); }
.note ul { margin:8px 0 0; padding-left:20px; }
.note li { margin-top:3px; }
.note code { font-family:var(--font-mono); font-size:12.5px; }

/* ── Sent list ─────────────────────────────────────────── */
.sent-row {
  display:flex; align-items:center; gap:12px; min-height:var(--tap);
  padding:15px 2px; border-bottom:1px solid var(--border);
  color:inherit; text-decoration:none;
}
.sent-row:last-child { border-bottom:none; }
.sent-row:hover { color:inherit; }
/* Spans again: without display:block the title and the counterparty run
   together into one sentence. */
.sent-row > span:not([class]) { min-width:0; flex:1 1 auto; }
.sent-title { display:block; font-size:14px; font-weight:600; line-height:1.35; overflow-wrap:anywhere; }
.sent-sub { display:block; font-size:12.5px; color:var(--fg-2); margin-top:3px; }
.sent-meta { margin-left:auto; text-align:right; flex:none; }
.sent-date { display:block; font-family:var(--font-mono); font-size:11px;
             color:var(--fg-3); margin-top:6px; white-space:nowrap; }
@media (max-width:699px) {
  /* Badges under the title, not over it. */
  .sent-row { flex-wrap:wrap; }
  .sent-row > span:not([class]) { flex-basis:100%; }
  .sent-meta { margin-left:0; text-align:left; display:flex; align-items:center; gap:8px; }
  .sent-date { margin-top:0; }
}

.result-file { font-family:var(--font-mono); font-size:12px; color:var(--fg-2);
               margin:12px 0 0; word-break:break-all; }

.footnote { text-align:center; color:var(--fg-3); font-size:11.5px;
            letter-spacing:.04em; margin:24px 0 8px; }
.signed-in { display:inline-flex; align-items:center; gap:7px;
             font-size:12.5px; font-weight:600; color:var(--success); }
.signed-in::before { content:""; width:6px; height:6px; border-radius:50%;
                     background:var(--success); }

/* Typeahead */
.combo { position:relative; }
.combo datalist { display:none; }

/* ── Desktop ───────────────────────────────────────────── */
@media (min-width:700px) {
  .wrap { padding:28px 24px 56px; }
  h1.page { font-size:40px; }
  .row { display:grid; grid-template-columns:1fr 1fr; gap:0 16px; }
  .row > .field { min-width:0; }
  input[type=text],input[type=email],input[type=tel],input[type=date],
  input[type=number],select,textarea { font-size:14px; min-height:40px; }
  .check { min-height:36px; font-size:14px; }
  .check input { width:18px; height:18px; }
}

@media (prefers-reduced-motion:reduce) { * { transition:none !important; } }

/* --- Sign in --------------------------------------------------------------
   Measured off the Punch Walk sign-in screenshot (402pt wide iPhone frame,
   1206px at 3x). Values are points from that frame, so the page is the same
   screen, not a resemblance. Dark ground in both themes, like Punch. */
body:has(.login) { background:var(--bg); color:var(--fg); }
.login, .login * { font-family:-apple-system,BlinkMacSystemFont,"SF Pro Text","Helvetica Neue",Arial,sans-serif; }
body:has(.login) .wrap { padding:0; max-width:none; }
.login {
  width:100%; max-width:402px; margin:0 auto; min-height:100dvh;
  padding:calc(46px + env(safe-area-inset-top)) 25px 40px;
  display:flex; flex-direction:column;
}
.login-eyebrow {
  font-size:12px; line-height:14px; font-weight:700; letter-spacing:.3em;
  text-transform:uppercase; color:#EE6A2E; margin:0;
}
.login-mark { display:block; width:132px; height:132px; margin:102px auto 0; }
.login-title { font-size:28px; line-height:34px; font-weight:700; letter-spacing:-.01em; margin:105px 0 16px; color:var(--fg); }
.login-card {
  display:flex; align-items:center; gap:14px; height:74px; padding:0 15px;
  border:1px solid var(--border-strong); border-radius:8px; color:var(--fg); text-decoration:none;
  background:transparent; transition:background .15s var(--ease);
}
.login-card + .login-card { margin-top:13px; }
.login-card:hover, .login-card:active { background:var(--info-bg); color:var(--fg); text-decoration:none; }
.login-ms { width:26px; height:26px; flex:none; }
.login-card-text { display:flex; flex-direction:column; gap:1px; }
.login-card-title { font-size:18px; line-height:22px; font-weight:600; letter-spacing:-.01em; }
.login-card-sub { font-size:15px; line-height:19px; color:var(--fg-2); }
