/* ------------------------------------------------------------------ *
 * Service One — screen styles, mobile first.
 *
 * Built on the "Industry" design system imported from Claude Design:
 * steel-blue accent, Barlow / Barlow Condensed, and a blueprint look —
 * square corners, hairline borders, registration marks at the corners.
 *
 * One deliberate adaptation: the source system draws cards transparent.
 * This app is dense with forms and tables, so cards are given a white
 * surface for legibility while keeping the squared hairline frame.
 *
 * Light-only on purpose: the sheet is a document and must look the same
 * on screen as it does on paper.
 * ------------------------------------------------------------------ */

:root {
  /* — Industry tokens — */
  --color-bg: #f2f2f3;
  --color-surface: #ffffff;
  --color-surface-2: #e9e9ea;
  --color-text: #1d1f20;
  --color-accent: #5980a6;

  --color-neutral-100: #f5f5f8;
  --color-neutral-200: #e7e7ea;
  --color-neutral-300: #d4d4d7;
  --color-neutral-600: #7a7a7d;
  --color-neutral-800: #424244;
  --color-neutral-900: #2b2b2d;

  --color-accent-100: #eef6ff;
  --color-accent-200: #d6ebff;
  --color-accent-500: #749dc4;
  --color-accent-600: #597ea3;
  --color-accent-700: #416180;
  --color-accent-800: #2c455d;
  --color-accent-900: #1d2d3d;

  --color-divider: color-mix(in srgb, #1d1f20 16%, transparent);
  --muted: color-mix(in srgb, #1d1f20 55%, transparent);

  /* Roboto throughout — interface and printed report alike. Headings use the
     same family at a heavier weight rather than a second condensed face. */
  --font-heading: "Roboto", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: "Roboto", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mark: "Archivo Black", "Roboto", system-ui, sans-serif;

  --shadow-sm: 0 1px 2px color-mix(in srgb, #2b2b2d 14%, transparent);
  --shadow-md: 0 3px 10px color-mix(in srgb, #2b2b2d 16%, transparent);

  /* Slightly rounded: softens the blueprint frame without losing it. */
  --radius: 8px;

  --ok-bg: #e3f3e8;
  --ok-line: #9ecdb0;
  --ok-text: #1f5133;
  --warn-bg: #fbf0d8;
  --warn-line: #e0be76;
  --warn-text: #6b4a10;
  --error-bg: #fbe4e4;
  --error-line: #e0a1a1;
  --error-text: #8a2020;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  color: var(--color-text);
  background: var(--color-bg);
}

h1, h2, h3 {
  font-family: var(--font-heading);
  /* Roboto ships no 600; 700 keeps headings crisp rather than snapping to 500. */
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.005em;
  margin: 0 0 .5rem;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
a { color: var(--color-accent); text-underline-offset: 3px; }

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .9em;
  background: var(--color-neutral-100);
  padding: .1em .35em;
}

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.hint { display: inline-block; font-size: .8rem; font-weight: 400; color: var(--muted); }
.req { color: #b4453f; }
ul.plain { margin: 0; padding-left: 1.1rem; }

:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--color-accent) 28%, transparent); }

/* ------------------------------------------------------------------ *
 * Service One logo
 * ------------------------------------------------------------------ */

.so-logo { display: inline-flex; align-items: center; gap: .55rem; }

.so-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: none;
  color: var(--color-accent-700);
  border: 1px solid var(--color-accent-700);
}

.so-icon svg { width: 62%; height: 62%; }

/* Registration marks — the blueprint signature of the source system. */
.so-icon > .corner {
  position: absolute;
  width: 9px;
  height: 9px;
  color: color-mix(in srgb, var(--color-accent-700) 60%, transparent);
}
.so-icon > .corner::before,
.so-icon > .corner::after { content: ""; position: absolute; background: currentColor; }
.so-icon > .corner::before { left: 4px; top: 0; width: 1px; height: 100%; }
.so-icon > .corner::after { top: 4px; left: 0; width: 100%; height: 1px; }
.so-icon > .corner.tl { top: -5px; left: -5px; }
.so-icon > .corner.tr { top: -5px; right: -5px; }
.so-icon > .corner.bl { bottom: -5px; left: -5px; }
.so-icon > .corner.br { bottom: -5px; right: -5px; }

.so-word {
  font-family: var(--font-mark);
  font-size: 1.05rem;
  line-height: .85;
  letter-spacing: -0.01em;
  text-transform: uppercase;
  display: inline-flex;
  gap: .22em;
}

.so-word-1 { color: var(--color-text); }
.so-word-2 { color: var(--color-accent-700); }

.brand-lg { display: inline-block; margin-bottom: .75rem; }
.brand-lg .so-icon { width: 48px; height: 48px; }
.brand-lg .so-word { font-size: 1.7rem; }

/* ------------------------------------------------------------------ *
 * Top bar
 * ------------------------------------------------------------------ */

.topbar {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-divider);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: .6rem 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .75rem;
}

.brand { text-decoration: none; margin-right: auto; }

.nav-burger {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 40px;
  height: 36px;
  padding: 0 8px;
  border: 1px solid var(--color-divider);
  cursor: pointer;
}

.nav-burger span { display: block; height: 2px; background: var(--color-text); }

.nav {
  display: none;
  width: 100%;
  flex-direction: column;
  gap: .1rem;
  padding-top: .5rem;
  border-top: 1px solid var(--color-divider);
}

.nav-toggle:checked ~ .nav { display: flex; }

.nav a,
.nav .linkish {
  display: block;
  padding: .55rem .5rem;
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 500;
  color: var(--color-text);
  text-decoration: none;
}

.nav a:hover, .nav .linkish:hover { color: var(--color-accent); }
.nav a.is-active { color: var(--color-accent); font-weight: 700; }

.nav-user { padding: .55rem .5rem; font-size: .88rem; color: var(--muted); }
.nav-form { margin: 0; }

.linkish {
  border: 0;
  background: none;
  font: inherit;
  text-align: left;
  width: 100%;
  cursor: pointer;
}

@media (min-width: 860px) {
  .nav-burger { display: none; }
  .nav {
    display: flex;
    flex-direction: row;
    align-items: center;
    width: auto;
    gap: .9rem;
    padding-top: 0;
    border-top: 0;
  }
  .nav-spacer { width: .5rem; }
  .nav .linkish { width: auto; }
  .nav a, .nav .linkish { padding: .2rem 0; }
}

/* ------------------------------------------------------------------ *
 * Page shell
 * ------------------------------------------------------------------ */

.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.25rem 1rem 4rem;
}

/* The client-facing link: document only, no application furniture. */
body.bare { background: var(--color-neutral-200); }
.page-bare { max-width: 940px; padding-top: 1rem; }

.public-bar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: .75rem;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: 1rem;
}

.page-head h1, .page-head h2 { margin-bottom: .15rem; }
.page-head p { margin: 0; }
.page-head.compact { margin-bottom: .75rem; }

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.15rem;
  margin-bottom: 1rem;
}

.card-narrow { max-width: 420px; }
.center-block { margin-left: auto; margin-right: auto; margin-top: 3rem; }
.auth-card { text-align: left; }

.empty { text-align: center; padding: 2.5rem 1rem; }
.empty p { color: var(--muted); }

.split { display: grid; gap: 1rem; }
@media (min-width: 960px) {
  .split { grid-template-columns: 330px 1fr; align-items: start; }
}

/* ------------------------------------------------------------------ *
 * Forms
 * ------------------------------------------------------------------ */

label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  color: color-mix(in srgb, var(--color-text) 78%, transparent);
  margin-bottom: .3rem;
}

input[type="text"], input[type="email"], input[type="password"], input[type="tel"],
input[type="url"], input[type="search"], input[type="date"], input[type="time"],
input[type="number"], input:not([type]), select, textarea {
  width: 100%;
  padding: .55rem .65rem;
  font: inherit;
  font-size: 1rem; /* 16px stops iOS zooming on focus */
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius);
  caret-color: var(--color-accent);
}

input:hover, select:hover, textarea:hover {
  border-color: color-mix(in srgb, var(--color-text) 40%, transparent);
}

input:focus, select:focus, textarea:focus, [contenteditable]:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 0;
  border-color: var(--color-accent);
}

input[type="file"] { padding: .45rem; background: var(--color-neutral-100); }
textarea { resize: vertical; }
.input-short { max-width: 160px; }

.stack > * + * { margin-top: .9rem; }

.grid-2, .grid-3 { display: grid; gap: .9rem; }
@media (min-width: 700px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr 1fr; }
  .span-2 { grid-column: 1 / -1; }
}

.fieldset {
  border: 1px solid var(--color-divider);
  padding: .8rem 1rem 1rem;
  margin: 0;
}

.fieldset legend {
  font-family: var(--font-heading);
  font-size: .95rem;
  font-weight: 600;
  padding: 0 .35rem;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: .55rem;
  font-weight: 400;
  font-size: .95rem;
  margin: .45rem 0;
  cursor: pointer;
}

.check input { width: 18px; height: 18px; margin-top: .2rem; flex: none; accent-color: var(--color-accent); }
.check-grid { display: grid; gap: .1rem; }
@media (min-width: 700px) { .check-grid { grid-template-columns: 1fr 1fr; } }

.check-inline { display: inline-flex; margin: 0 .6rem 0 0; font-size: .82rem; }
.check-inline input { width: 15px; height: 15px; margin-top: .15rem; }

.form-actions { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }

.sticky-actions {
  position: sticky;
  bottom: 0;
  background: linear-gradient(to top, var(--color-bg) 65%, transparent);
  padding: .9rem 0 .5rem;
  z-index: 5;
}

.client-picker > .check { margin: .6rem 0; }
.new-client[hidden] { display: none; }

/* A client dropdown with nothing in it yet reads as broken unless it looks
   deliberately inert. */
.client-picker select:disabled { background: var(--color-bg); color: var(--muted); cursor: not-allowed; }

/* Language choice, shown once before a new sheet opens. */
.lang-choice > .muted { max-width: 54ch; }

.lang-options { display: grid; gap: .9rem; margin-top: 1.2rem; }
@media (min-width: 520px) { .lang-options { grid-template-columns: 1fr 1fr; } }

.btn-lang {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: .2rem;
  padding: 1rem 1.1rem;
  text-align: left;
  height: auto;
}

.btn-lang strong { font-size: 1.05rem; }
.btn-lang span { font-size: .8rem; font-weight: 400; opacity: .85; }

/* ------------------------------------------------------------------ *
 * Buttons — squared, hairline, per the blueprint system
 * ------------------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .55rem 1rem;
  min-height: 42px;
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover { background: color-mix(in srgb, var(--color-text) 6%, transparent); }

.btn-primary { background: var(--color-accent); border-color: var(--color-accent); color: #fff; }
.btn-primary:hover { background: var(--color-accent-600); border-color: var(--color-accent-600); }

.btn-accent { background: var(--color-accent-900); border-color: var(--color-accent-900); color: #fff; }
.btn-accent:hover { background: var(--color-accent-800); border-color: var(--color-accent-800); }

.btn-danger { color: #8a2020; border-color: var(--error-line); background: var(--color-surface); }
.btn-danger:hover { background: var(--error-bg); }

.btn-small { padding: .3rem .6rem; min-height: 32px; font-size: .88rem; }
.btn-block { width: 100%; }
.is-disabled, .btn:disabled { opacity: .45; pointer-events: none; }

.inline { display: inline; margin: 0; }

.inline-form { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin: 0; }
.inline-form input { width: auto; flex: 1 1 8rem; min-width: 0; }

/* ------------------------------------------------------------------ *
 * Flashes and tags
 * ------------------------------------------------------------------ */

.flash {
  padding: .7rem .9rem;
  border: 1px solid var(--color-divider);
  border-left-width: 3px;
  border-radius: var(--radius);
  background: var(--color-surface);
  margin-bottom: 1rem;
  font-size: .92rem;
}

.flash-success { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok-text); }
.flash-error { background: var(--error-bg); border-color: var(--error-line); color: var(--error-text); }
.flash-warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-text); }
.flash[hidden] { display: none; }

.tag {
  display: inline-block;
  padding: .1rem .45rem;
  border: 1px solid var(--color-divider);
  background: var(--color-neutral-100);
  font-size: .72rem;
  font-style: normal;
  font-weight: 600;
  letter-spacing: .03em;
  color: var(--muted);
  vertical-align: middle;
}

.tag-ok { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok-text); }
.tag-warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-text); }
.tag-error { background: var(--error-bg); border-color: var(--error-line); color: var(--error-text); }
.tag-admin { background: var(--color-accent-100); border-color: var(--color-accent-500); color: var(--color-accent-800); }
.tag-private { background: var(--color-accent-900); border-color: var(--color-accent-900); color: #fff; }
.tag-danger { background: var(--error-bg); border-color: var(--error-line); color: var(--error-text); }

/* ------------------------------------------------------------------ *
 * Tables — stack into cards on narrow screens
 * ------------------------------------------------------------------ */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  font-size: .92rem;
}

.table th, .table td {
  padding: .55rem .7rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid color-mix(in srgb, var(--color-text) 9%, transparent);
}

.table th {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  background: var(--color-neutral-100);
  white-space: nowrap;
}

.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; }
.row-muted { opacity: .55; }

.table-linked tbody tr { cursor: pointer; }
.table-linked tbody tr:hover { background: color-mix(in srgb, var(--color-accent) 7%, transparent); }

.serial { font-weight: 700; text-decoration: none; font-variant-numeric: tabular-nums; }

.sort-link { color: inherit; text-decoration: none; display: inline-flex; gap: .3rem; }
.sort-link:hover { color: var(--color-accent); }
.sort-arrow { font-size: .7em; }

.row-actions { display: flex; flex-wrap: wrap; gap: .35rem; }
.actions-col { width: 1%; }

.reset-pw { margin-top: .4rem; }
.reset-pw summary { font-size: .82rem; color: var(--muted); cursor: pointer; }
.reset-pw .inline-form { margin-top: .4rem; }

@media (max-width: 760px) {
  .table, .table thead, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table thead { display: none; }
  .table { border: 0; background: none; }

  .table tr {
    background: var(--color-surface);
    border: 1px solid var(--color-divider);
    box-shadow: var(--shadow-sm);
    margin-bottom: .7rem;
    padding: .3rem .2rem;
  }

  .table td {
    border-bottom: 1px solid color-mix(in srgb, var(--color-text) 7%, transparent);
    display: grid;
    grid-template-columns: 7.5rem 1fr;
    gap: .5rem;
    align-items: start;
  }

  .table td:last-child { border-bottom: 0; }
  .table .num { text-align: left; }
  .actions-col { width: auto; }

  .table td::before {
    content: attr(data-label);
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
    font-weight: 600;
    padding-top: .15rem;
  }
}

.pager { display: flex; align-items: center; justify-content: center; gap: .8rem; margin-top: 1rem; }
.pager-info { font-size: .88rem; color: var(--muted); }

/* ------------------------------------------------------------------ *
 * Filters
 * ------------------------------------------------------------------ */

.filters { padding: .9rem 1rem; }
.filter-row { display: grid; gap: .75rem; }

@media (min-width: 940px) {
  .filter-row { grid-template-columns: 2fr 1fr 1fr 1fr .8fr auto; align-items: end; }
}

.filter-actions { display: flex; gap: .5rem; }

/* ------------------------------------------------------------------ *
 * Companies and clients
 * ------------------------------------------------------------------ */

.company-grid { display: grid; gap: 1rem; }
@media (min-width: 720px) { .company-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1050px) { .company-grid { grid-template-columns: repeat(3, 1fr); } }

.company-card { display: flex; flex-direction: column; margin-bottom: 0; }

.company-logo {
  display: grid;
  place-items: center;
  height: 90px;
  margin-bottom: .8rem;
  padding: .5rem;
  background: var(--color-neutral-100);
  border: 1px solid var(--color-divider);
}

.company-logo img { max-height: 74px; max-width: 100%; object-fit: contain; }
.company-name { font-size: 1.15rem; }

.logo-preview {
  display: flex;
  align-items: center;
  gap: .8rem;
  padding: .5rem;
  margin-bottom: .5rem;
  background: var(--color-neutral-100);
  border: 1px solid var(--color-divider);
}

.logo-preview img { max-height: 52px; max-width: 140px; object-fit: contain; }

.meta { display: grid; grid-template-columns: auto 1fr; gap: .2rem .7rem; margin: 0 0 .7rem; font-size: .88rem; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; }
@media (min-width: 700px) { .meta-columns { grid-template-columns: auto 1fr auto 1fr; } }

.client-rows { display: flex; flex-direction: column; }

.client-row {
  display: flex;
  align-items: flex-start;
  gap: .6rem;
  padding: .6rem 0;
  border-bottom: 1px solid color-mix(in srgb, var(--color-text) 9%, transparent);
}

.client-row:last-child { border-bottom: 0; }
.client-edit { flex: 1; display: grid; gap: .4rem; margin: 0; }
.client-edit-main { display: grid; gap: .4rem; }
@media (min-width: 620px) { .client-edit-main { grid-template-columns: 2fr 1fr; } }
.client-edit-companies { display: flex; flex-wrap: wrap; }
.client-edit-actions { display: flex; align-items: center; gap: .6rem; }

/* ------------------------------------------------------------------ *
 * Rich text editor
 * ------------------------------------------------------------------ */

.editor-field + .editor-field { margin-top: 1rem; }

.editor {
  position: relative;
  border: 1px solid var(--color-divider);
  background: var(--color-surface);
}

.editor:focus-within { border-color: var(--color-accent); box-shadow: 0 0 0 1px var(--color-accent); }
.editor.is-resizing { user-select: none; }

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .15rem;
  padding: .3rem;
  background: var(--color-neutral-100);
  border-bottom: 1px solid var(--color-divider);
}

.editor-toolbar button {
  min-width: 34px;
  min-height: 32px;
  padding: 0 .5rem;
  font: inherit;
  font-size: .85rem;
  color: var(--color-text);
  background: none;
  border: 1px solid transparent;
  cursor: pointer;
}

.editor-toolbar button:hover {
  background: var(--color-surface);
  border-color: var(--color-divider);
}

.editor-sep { width: 1px; height: 20px; background: var(--color-divider); margin: 0 .25rem; }

.editor-body {
  height: 8rem;
  overflow-y: auto;
  padding: .7rem;
  font-size: 1rem;
  line-height: 1.6;
}

/* Operations done carries most of the writing, so it starts much taller. */
.editor-tall .editor-body { height: 22rem; }

.editor-body:focus { outline: none; }
.editor-body > *:first-child { margin-top: 0; }
.editor-body > *:last-child { margin-bottom: 0; }
.editor-body ul, .editor-body ol { padding-left: 1.3rem; margin: .4rem 0; }

/* Drag handle. Mirrors the native textarea grip, but works on a
   contenteditable and remembers the height per field. */
.editor-grip {
  height: 14px;
  cursor: ns-resize;
  background: var(--color-neutral-100);
  border-top: 1px solid var(--color-divider);
  position: relative;
  touch-action: none;
}

.editor-grip::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 34px;
  height: 4px;
  transform: translate(-50%, -50%);
  background:
    linear-gradient(var(--color-neutral-300) 1px, transparent 1px) 0 0 / 100% 2px repeat-y;
}

.editor-grip:hover { background: var(--color-accent-100); }

/* ------------------------------------------------------------------ *
 * Import verification — scan on the left, transcription on the right
 * ------------------------------------------------------------------ */

.verify-layout { display: grid; gap: 1rem; align-items: start; }

@media (min-width: 1100px) {
  .verify-layout { grid-template-columns: minmax(380px, 44%) 1fr; }
  /* The scan stays put while the form scrolls, so a field can always be
     checked against the original without scrolling back. */
  .verify-source { position: sticky; top: 4.5rem; }
}

.verify-source {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: .9rem;
}

.verify-source-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  margin-bottom: .6rem;
}

.verify-source-head h2 { margin: 0; font-size: 1.05rem; }

.verify-pdf {
  display: block;
  width: 100%;
  height: 60vh;
  min-height: 420px;
  border: 1px solid var(--color-divider);
  border-radius: var(--radius);
  background: var(--color-neutral-200);
}

@media (min-width: 1100px) { .verify-pdf { height: calc(100vh - 15rem); } }

.verify-form { min-width: 0; }

.env-banner {
  position: sticky;
  top: 0;
  z-index: 30;
  padding: .35rem 1rem;
  background: repeating-linear-gradient(
    45deg, #8a5a00, #8a5a00 12px, #a06b00 12px, #a06b00 24px
  );
  color: #fff;
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  text-align: center;
}

.cmd-steps {
  margin: .6rem 0 .4rem;
  padding-left: 1.2rem;
  font-size: .9rem;
  color: var(--muted);
}

.cmd-steps li { margin: .3rem 0; }
.cmd-steps code { font-size: .88em; }

.review-cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-left: 3px solid var(--color-accent);
}

.review-cta h2 { margin-bottom: .15rem; }
.review-cta p { margin: 0; }

.review-progress { display: flex; align-items: baseline; gap: .5rem; }
.review-remaining { font-size: 1.6rem; font-weight: 700; line-height: 1; }

.key-hint {
  display: inline-grid;
  place-items: center;
  min-width: 1.25rem;
  height: 1.25rem;
  margin-left: .15rem;
  padding: 0 .25rem;
  border: 1px solid currentColor;
  border-radius: 4px;
  font-size: .7rem;
  font-weight: 700;
  opacity: .7;
}

/* No keyboard on a phone, so the hints would only take up room. */
@media (max-width: 760px) { .key-hint { display: none; } }

.card-confidential { border-left: 3px solid var(--color-accent-900); }
.card-confidential h2 { display: flex; align-items: center; gap: .5rem; }

.confidential-block {
  border-left: 3px solid var(--color-accent-900);
  margin-top: 1.25rem;
}

.confidential-block h2 { display: flex; align-items: center; gap: .5rem; }

/* ------------------------------------------------------------------ *
 * Signature pads
 * ------------------------------------------------------------------ */

.signature-field {
  margin-top: 1rem;
  padding: .8rem;
  border: 1px solid var(--color-divider);
  background: var(--color-neutral-100);
}

.signature-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .5rem; margin-bottom: .5rem; }
.signature-label { font-family: var(--font-heading); font-weight: 600; font-size: 1rem; }

.signature-canvas {
  display: block;
  width: 100%;
  /* Twice the old 190/220px: there was not enough room to sign. Capped so a
     phone held sideways still shows the whole pad. The stored image is
     trimmed to the ink and shown at the old size on the sheet regardless. */
  height: min(380px, 70vh);
  background: var(--color-surface);
  border: 1px dashed var(--color-divider);
  /* Without this a finger drag scrolls the page instead of drawing. */
  touch-action: none;
  cursor: crosshair;
}

.has-ink .signature-canvas { border-style: solid; border-color: var(--color-accent); }
.pad-missing .signature-canvas { border-color: #b4453f; background: #fffafa; }

.signature-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  margin-top: .45rem;
}

.signature-baseline { font-size: .8rem; color: var(--muted); }

@media (min-width: 700px) { .signature-canvas { height: min(440px, 70vh); } }

/* ------------------------------------------------------------------ *
 * Sheet toolbar
 * ------------------------------------------------------------------ */

.sheet-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .6rem;
  margin-bottom: 1rem;
}

.toolbar-left, .toolbar-right { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.share-hint { margin: -.5rem 0 1rem; word-break: break-all; }
.add-note { margin-top: 1.5rem; }
.summary-card details summary { cursor: pointer; font-size: .9rem; color: var(--muted); }

/* ------------------------------------------------------------------ *
 * The document itself
 * ------------------------------------------------------------------ */

.document {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  /* On screen only — print.css squares this back off. */
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 1.25rem;
  max-width: 900px;
  margin: 0 auto;
}

@media (min-width: 800px) { .document { padding: 2.5rem 2.75rem; } }

.doc-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--color-text);
}

/* The logo is the brand mark; it sits alone at the top left. */
.doc-brand { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.doc-logo { max-height: 70px; max-width: 230px; object-fit: contain; object-position: left center; }
.doc-issuer-name { font-size: 1.3rem; font-weight: 700; }
.doc-issuer { display: flex; flex-direction: column; gap: .1rem; font-size: .82rem; min-width: 0; }
.doc-issuer-contact { color: var(--muted); }

.doc-ident { display: flex; flex-direction: column; text-align: left; }
@media (min-width: 620px) { .doc-ident { text-align: right; } }

.doc-kind {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--muted);
}

/* The date is what identifies an intervention to a reader; the serial is a
   filing reference, so it is set smaller and lighter than the date. */
.doc-date {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.25;
}

.doc-serial {
  font-size: .82rem;
  font-weight: 400;
  letter-spacing: .04em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.doc-draft-banner {
  margin: 1rem 0 0;
  padding: .5rem .8rem;
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  font-size: .85rem;
  font-weight: 600;
  color: var(--warn-text);
}

.doc-parties {
  display: grid;
  gap: 1.1rem;
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--color-divider);
}

@media (min-width: 620px) { .doc-parties { grid-template-columns: 1fr 1fr; } }
@media (min-width: 900px) { .doc-parties { grid-template-columns: repeat(4, 1fr); } }

.doc-parties h3,
.doc-section h3,
.doc-postnotes h3 {
  font-family: var(--font-body);
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--muted);
  margin-bottom: .4rem;
}

.doc-parties p { margin: 0 0 .3rem; font-size: .9rem; }
.party-name { font-weight: 600; font-size: .98rem !important; }
.ticked::before { content: "☑ "; }

.doc-section { padding: 1.15rem 0; border-bottom: 1px solid var(--color-divider); }

/* A field nobody filled in is still shown, so the reader can see it was asked
   — but on one line, with the heading and the dash side by side. */
.doc-section-empty { padding: .45rem 0; display: flex; align-items: baseline; gap: .5rem; }
.doc-section-empty h3 { margin: 0; }
.doc-section-empty .rich-empty { margin: 0; color: var(--muted); }

.rich { font-size: .95rem; line-height: 1.6; }
.rich > *:first-child { margin-top: 0; }
.rich > *:last-child { margin-bottom: 0; }
.rich ul, .rich ol { padding-left: 1.3rem; margin: .4rem 0; }
.rich p { margin: 0 0 .5rem; }

.doc-signatures { display: grid; gap: 1.5rem; padding: 1.5rem 0 .5rem; }
@media (min-width: 620px) { .doc-signatures { grid-template-columns: 1fr 1fr; gap: 2.5rem; } }

.sig-block { display: flex; flex-direction: column; }

.sig-role {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--muted);
}

.sig-image {
  height: 88px;
  display: flex;
  align-items: flex-end;
  border-bottom: 1px solid var(--color-text);
  margin-bottom: .35rem;
}

.sig-image img { max-height: 84px; max-width: 100%; object-fit: contain; object-position: left bottom; }
.sig-name { font-weight: 600; font-size: .92rem; }
.sig-time { font-size: .78rem; color: var(--muted); }

.doc-postnotes {
  margin-top: 1.5rem;
  padding: 1.1rem;
  background: var(--color-neutral-100);
  border: 1px solid var(--color-divider);
  border-left: 3px solid var(--color-accent);
}

.doc-postnotes h3 { color: var(--color-accent-800); }
.postnotes-caption { font-size: .8rem; color: var(--muted); margin-bottom: .8rem; }
.postnote + .postnote { margin-top: .9rem; padding-top: .9rem; border-top: 1px solid var(--color-divider); }
.postnote-meta { font-size: .76rem; color: var(--muted); margin-bottom: .25rem; }

.doc-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: .5rem;
  margin-top: 1.5rem;
  padding-top: .8rem;
  border-top: 1px solid var(--color-divider);
  font-size: .7rem;
  color: var(--muted);
}

/* ------------------------------------------------------------------ *
 * Company hours report
 * ------------------------------------------------------------------ */

@media (min-width: 940px) {
  .report-filters { grid-template-columns: 2fr 1fr 1fr auto auto; }
}

.report-drafts { align-self: end; margin: 0 0 .55rem; }

.report-document { max-width: 1000px; }
.report-document .table-wrap { margin-top: 1.25rem; }
.report-empty { padding: 1.5rem 0; text-align: center; }

.report-table { border: 0; }
.report-table .serial { font-weight: 600; }

.report-total td {
  font-weight: 700;
  border-top: 2px solid var(--color-text);
  border-bottom: 0;
  background: var(--color-neutral-100);
}

@media (max-width: 760px) {
  .report-total td[colspan] { display: none; }
}
