/* DSPOT Annex — "official paperwork, made humane".
   Paper + ink, a stamp-red accent for actions, and the form's own box grid. */

:root {
  --paper: #f4f0e8;
  --paper-2: #ebe5d8;
  --card: #fffdf8;
  --ink: #1c2230;
  --ink-2: #4a5263;
  --ink-3: #7a8193;
  --rule: #d9d1c1;
  --grid: #b9c3d6;
  --stamp: #b8342a;
  --stamp-ink: #fff8f2;
  --stamp-soft: #f6e3de;
  --ok: #2f6b4f;
  --ok-soft: #dfeee4;
  --wait: #8a6a17;
  --wait-soft: #f5ebcd;
  --focus: #2d5fd3;

  --serif: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  --sans: 'IBM Plex Sans', 'Segoe UI', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;

  --radius: 4px;
  --shadow: 0 1px 0 rgba(28, 34, 48, 0.04), 0 10px 30px -18px rgba(28, 34, 48, 0.35);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #14171e;
    --paper-2: #1b1f28;
    --card: #1d212b;
    --ink: #ece7dc;
    --ink-2: #b9b3a6;
    --ink-3: #8b8678;
    --rule: #333846;
    --grid: #465169;
    --stamp: #e0645a;
    --stamp-ink: #1a0e0c;
    --stamp-soft: #3a2220;
    --ok: #7fc59f;
    --ok-soft: #1f3329;
    --wait: #e2c16c;
    --wait-soft: #352d17;
    --focus: #8fb0ff;
    --shadow: 0 10px 30px -18px rgba(0, 0, 0, 0.8);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(1200px 500px at 85% -10%, var(--paper-2), transparent 60%),
    var(--paper);
  color: var(--ink);
  font: 400 1rem/1.55 var(--sans);
  min-height: 100vh;
}
[hidden] { display: none !important; }

.wrap { width: min(46rem, 100% - 2rem); margin-inline: auto; }
.area-admin .wrap { width: min(80rem, 100% - 2rem); }
.narrow { width: min(26rem, 100% - 2rem); padding-top: clamp(2rem, 10vh, 6rem); }
.login.narrow { padding-top: 0; }

/* ---------- masthead ---------- */
.masthead { border-bottom: 1px solid var(--rule); background: var(--paper); position: sticky; top: 0; z-index: 5; }
.masthead-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 3.5rem; flex-wrap: wrap; }
.brand { font: 600 1.15rem/1 var(--serif); letter-spacing: 0.04em; color: var(--ink); text-decoration: none; }
.brand-dot { color: var(--stamp); }
.brand-sub { font: 500 0.8rem var(--sans); letter-spacing: 0.02em; color: var(--ink-3); margin-left: 0.4rem; }
.brand.big { font-size: 2rem; text-align: center; margin: 3rem 0 1.5rem; }

.langs { display: flex; gap: 0.25rem; }
.langs a { color: var(--ink-2); text-decoration: none; font-size: 0.85rem; padding: 0.3rem 0.6rem; border-radius: 999px; transition: background 0.2s var(--ease); }
.langs a:hover { background: var(--paper-2); }
.langs a[aria-current] { background: var(--ink); color: var(--paper); }

.admin-nav { display: flex; align-items: center; gap: 0.25rem; flex-wrap: wrap; }
.admin-nav a, .admin-nav .link { color: var(--ink-2); text-decoration: none; font-size: 0.9rem; padding: 0.4rem 0.7rem; border-radius: var(--radius); }
.admin-nav a[aria-current] { color: var(--ink); box-shadow: inset 0 -2px 0 var(--stamp); border-radius: 0; }
.admin-nav a:hover, .admin-nav .link:hover { color: var(--ink); }
.admin-nav form { margin: 0; }

/* ---------- type ---------- */
h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: -0.01em; line-height: 1.15; margin: 0; }
h1 { font-size: clamp(2rem, 1.4rem + 2.6vw, 3rem); }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; margin: 1.75rem 0 0.5rem; }
.kicker { font: 600 0.72rem/1 var(--sans); letter-spacing: 0.14em; text-transform: uppercase; color: var(--stamp); margin: 0 0 0.75rem; }
.lede { color: var(--ink-2); margin: 0.4rem 0 0; }
.note { color: var(--ink-3); font-size: 0.85rem; }
.optional { color: var(--ink-3); font-weight: 400; font-size: 0.8rem; }

.intro { padding: 3rem 0 2rem; }
.intro .lede { font-size: 1.08rem; max-width: 38rem; margin-top: 0.9rem; }

/* ---------- cards ---------- */
.stack { display: grid; gap: 1.25rem; }
.card { background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); padding: clamp(1.25rem, 1rem + 1.5vw, 2rem); box-shadow: var(--shadow); }
.card-head { display: grid; grid-template-columns: auto 1fr auto; gap: 0.9rem; align-items: start; margin-bottom: 1.5rem; }
.step { display: grid; place-items: center; width: 2rem; height: 2rem; border: 1.5px solid var(--stamp); color: var(--stamp); border-radius: 50%; font: 600 0.95rem var(--serif); transform: rotate(-6deg); }
.card-readonly { background: repeating-linear-gradient(135deg, var(--card) 0 14px, color-mix(in srgb, var(--paper-2) 45%, var(--card)) 14px 15px); }
.lock { width: 1.3rem; height: 1.3rem; color: var(--ink-3); }

/* ---------- fields ---------- */
.field { margin: 0 0 1.35rem; border: 0; padding: 0; min-width: 0; }
.field:last-child { margin-bottom: 0; }
label, legend { display: block; font-weight: 600; font-size: 0.92rem; margin-bottom: 0.35rem; }
legend { padding: 0; }
.hint { color: var(--ink-3); font-size: 0.83rem; margin: -0.15rem 0 0.45rem; }
.num { font: 600 0.72rem var(--mono); color: var(--stamp); letter-spacing: 0.04em; margin-right: 0.3rem; }

input:not([type=radio]), select {
  width: 100%; font: inherit; color: var(--ink); background: var(--card);
  border: 1px solid var(--rule); border-radius: var(--radius); padding: 0.62rem 0.75rem;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
input:hover { border-color: var(--ink-3); }
input:focus-visible, button:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
input:focus { border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 18%, transparent); }
.lines input + input, .lines input + .field-error + input { margin-top: 0.4rem; }
input.date { width: auto; min-width: 12rem; }

.has-error input, input.invalid { border-color: var(--stamp); background: color-mix(in srgb, var(--stamp-soft) 45%, var(--card)); }
.field-error { color: var(--stamp); font-size: 0.83rem; margin: 0.35rem 0 0; font-weight: 500; }
.error-summary { border-left: 3px solid var(--stamp); background: var(--stamp-soft); padding: 0.75rem 1rem; border-radius: var(--radius); font-weight: 500; }

/* The form's own box grid: one character per cell, just like the PDF. */
.field:has(> .boxes) { container-type: inline-size; }
.boxes { --boxes: 20; /* BOX_LINE */ --cell: min(1.9rem, calc(100cqw / var(--boxes))); position: relative; width: calc(var(--cell) * var(--boxes)); }
.boxes input {
  --glyph: 0.6em; /* Plex Mono advance */
  font: 500 clamp(0.95rem, calc(var(--cell) * 0.62), 1.15rem) var(--mono);
  text-transform: uppercase;
  height: calc(var(--cell) * 1.35);
  padding: 0 0 0 calc((var(--cell) - var(--glyph)) / 2);
  letter-spacing: calc(var(--cell) - var(--glyph));
  border-radius: 0;
  background:
    repeating-linear-gradient(90deg, transparent 0 calc(var(--cell) - 1px), var(--grid) calc(var(--cell) - 1px) var(--cell)),
    var(--card);
  border-color: var(--ink-3);
}
.boxes input:focus { background-color: var(--card); }
.box-count { font: 0.75rem var(--mono); color: var(--ink-3); margin: 0.3rem 0 0; }
.box-count.full { color: var(--stamp); }

/* ---------- salary help ---------- */
.help { margin-top: 0.25rem; border-top: 1px dashed var(--rule); padding-top: 0.9rem; }
.help summary { cursor: pointer; font-weight: 600; color: var(--stamp); list-style: none; display: inline-flex; align-items: center; gap: 0.45rem; }
.help summary::before { content: '?'; display: grid; place-items: center; width: 1.3rem; height: 1.3rem; border-radius: 50%; background: var(--stamp); color: var(--stamp-ink); font-size: 0.8rem; }
.help summary::-webkit-details-marker { display: none; }
.help ol { padding-left: 1.2rem; margin: 0.9rem 0; color: var(--ink-2); }
.help li + li { margin-top: 0.35rem; }
.contract { margin: 1rem 0 0; }
.contract figcaption { font: 600 0.7rem var(--sans); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 0.5rem; }
.contract-paper { font: 0.9rem/1.6 'Times New Roman', Times, serif; color: #2a2a2a; background: #fffef9; border: 1px solid #e4dccb; padding: 1.1rem 1.25rem; transform: rotate(-0.6deg); box-shadow: 0 12px 24px -16px rgba(0,0,0,.35); }
.contract-paper p { margin: 0 0 0.5rem; }
.contract-par { font-weight: 700; text-align: center; }
.contract-paper mark { background: linear-gradient(transparent 55%, #ffd76a 55%); padding: 0 0.1rem; color: inherit; font-weight: 700; }
.contract-fade { opacity: 0.45; }

/* ---------- job summary ---------- */
.job { display: grid; grid-template-columns: minmax(8rem, 13rem) 1fr; gap: 0.6rem 1.25rem; margin: 0; }
.job dt { color: var(--ink-3); font-size: 0.85rem; padding-top: 0.1rem; }
.job dd { margin: 0; display: grid; gap: 0.1rem; }
@media (max-width: 34rem) { .job { grid-template-columns: 1fr; gap: 0.15rem; } .job dd { margin-bottom: 0.6rem; } }

/* ---------- actions ---------- */
.actions { display: grid; gap: 0.9rem; justify-items: start; padding: 0.5rem 0 3rem; }
.actions.row { display: flex; align-items: center; gap: 1rem; padding-bottom: 0; }
.primary, .ghost, .danger, .link {
  font: 600 0.95rem var(--sans); border-radius: var(--radius); cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; gap: 0.5rem; transition: transform 0.15s var(--ease), background 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.primary { background: var(--stamp); color: var(--stamp-ink); border: 0; padding: 0.8rem 1.25rem; box-shadow: 0 6px 16px -8px color-mix(in srgb, var(--stamp) 80%, transparent); }
.primary:hover { background: color-mix(in srgb, var(--stamp) 88%, #000); transform: translateY(-1px); }
.primary:active { transform: translateY(0); }
.primary svg { width: 1.2rem; height: 1.2rem; }
.primary[aria-busy=true] { opacity: 0.75; cursor: progress; }
.actions .primary { font-size: 1.05rem; padding: 0.95rem 1.6rem; }
.ghost { background: transparent; color: var(--ink); border: 1px solid var(--rule); padding: 0.55rem 0.9rem; }
.ghost:hover { border-color: var(--ink-3); background: var(--card); }
.small { font-size: 0.82rem; padding: 0.35rem 0.65rem; }
.link { background: none; border: 0; padding: 0; }
.danger { background: none; border: 1px solid color-mix(in srgb, var(--stamp) 45%, transparent); color: var(--stamp); padding: 0.55rem 0.9rem; }
.danger:hover { background: var(--stamp-soft); }
.danger-zone { margin: 2rem 0 3rem; padding-top: 1.25rem; border-top: 1px dashed var(--rule); }
.privacy { color: var(--ink-3); font-size: 0.82rem; max-width: 34rem; margin: 0; }

/* ---------- done ---------- */
.done { text-align: center; margin: 1rem 0 3rem; animation: rise 0.5s var(--ease); }
.done-mark { width: 3.5rem; height: 3.5rem; margin: 0 auto 1rem; display: grid; place-items: center; border-radius: 50%; border: 2px solid var(--ok); color: var(--ok); font-size: 1.6rem; transform: rotate(-8deg); }
.done-actions { display: flex; gap: 0.75rem; justify-content: center; margin-top: 1.5rem; flex-wrap: wrap; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- admin ---------- */
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 1rem; padding: 2.5rem 0 1.5rem; flex-wrap: wrap; }
.status-line { display: flex; gap: 0.75rem; align-items: center; margin: 0.75rem 0 0; }
.table-card { background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font: 600 0.72rem var(--sans); letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); padding: 0.85rem 1rem; border-bottom: 1px solid var(--rule); white-space: nowrap; }
td { padding: 0.85rem 1rem; border-bottom: 1px solid var(--rule); vertical-align: middle; font-size: 0.92rem; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background 0.15s; }
tbody tr:hover { background: color-mix(in srgb, var(--paper-2) 50%, transparent); }
.row-title { color: var(--ink); font-weight: 600; text-decoration: none; }
.row-title:hover { text-decoration: underline; text-decoration-color: var(--stamp); }
.sub { display: block; color: var(--ink-3); font-size: 0.8rem; }
.row-actions { text-align: right; white-space: nowrap; }
.row-actions > * + * { margin-left: 0.35rem; }
.pill { display: inline-block; font: 600 0.72rem var(--sans); letter-spacing: 0.04em; padding: 0.22rem 0.6rem; border-radius: 999px; }
.pill-completed { background: var(--ok-soft); color: var(--ok); }
.pill-sent { background: var(--wait-soft); color: var(--wait); }
.empty { text-align: center; padding: 3rem 1.5rem; }
.empty .primary { margin-top: 1.25rem; }

.link-card { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.link-card .kicker { margin-bottom: 0.4rem; }
.link-card.just-created { border-color: var(--stamp); animation: rise 0.5s var(--ease); }
code.link { font: 0.88rem var(--mono); word-break: break-all; color: var(--ink); }
.period { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: 0.75rem; }
.period legend { grid-column: 1 / -1; }
.period label { font-weight: 500; color: var(--ink-2); font-size: 0.85rem; }
.period label input { margin-top: 0.25rem; }
.flash { background: var(--ok-soft); color: var(--ok); padding: 0.75rem 1rem; border-radius: var(--radius); font-weight: 500; }
.decl td { padding: 0.6rem 0.5rem; font-size: 0.88rem; }
.decl td.num { width: 1.5rem; }
.choice { font-weight: 500; font-size: 0.84rem; display: inline-flex; gap: 0.35rem; align-items: center; margin: 0; white-space: nowrap; cursor: pointer; }
.choice input { accent-color: var(--stamp); }
@media (max-width: 40rem) {
  .decl tr { display: grid; grid-template-columns: 1.5rem 1fr; }
  .decl td:nth-child(n+3) { grid-column: 2; padding-top: 0; }
}
.login .card { gap: 1.25rem; }
.toast { position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 0.6rem 1rem; border-radius: 999px; font-size: 0.88rem; animation: rise 0.3s var(--ease); z-index: 10; }
.prefill { border-top: 1px dashed var(--rule); border-bottom: 1px dashed var(--rule); padding: 1rem 0; }
.prefill-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 0.75rem; }
.prefill-grid label { font-weight: 500; color: var(--ink-2); font-size: 0.85rem; }
.prefill-grid label input { margin-top: 0.25rem; }
.prefill-grid .wide { grid-column: 1 / -1; }
form.inline { display: inline; margin: 0; }
select { appearance: none; cursor: pointer; padding-right: 2.5rem;
  background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6' fill='none' stroke='%237a8193' stroke-width='2'/%3E%3C/svg%3E") no-repeat right 0.75rem center / 1.1rem; }
select:focus { border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 18%, transparent); }
.generate select { font-size: 1.05rem; padding-top: 0.8rem; padding-bottom: 0.8rem; }
.card h2 .num { font-size: 0.8rem; vertical-align: middle; }
.note a { color: var(--stamp); text-underline-offset: 2px; }
.nowrap { white-space: nowrap; }
.num-cell { font-variant-numeric: tabular-nums; white-space: nowrap; }
.ends-soon { color: var(--wait); background: var(--wait-soft); padding: 0.1rem 0.4rem; border-radius: 3px; font-weight: 600; }
.table-card td .sub { max-width: 16rem; }
.table-card .pill + .sub { margin-top: 0.25rem; }
.head-actions { display: flex; gap: 0.6rem; align-items: center; }
.pill-muted { background: var(--paper-2); color: var(--ink-3); }
.pill-error { background: var(--stamp-soft); color: var(--stamp); }
.muted-row td { color: var(--ink-3); }
.changes { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.2rem; font-size: 0.85rem; }
.changes .old { color: var(--ink-3); text-decoration: line-through; }
.changes .new { font-weight: 600; }
input[type=file] { padding: 0.5rem; }
.warn { margin: 0.4rem 0 0; font-size: 0.82rem; color: var(--wait); background: var(--wait-soft); padding: 0.35rem 0.55rem; border-radius: 3px; }
