/* ============================================================================
 * Endurance Evolution Design System — Vendors app theme
 *
 * DROP-IN REPLACEMENT for app/assets/stylesheets/application.css
 *
 * This re-skins the existing markup to the Endurance Evolution Design System:
 * navy chrome, light canvas, cyan spark. It keeps every selector your views
 * already use (.app-header, .page-header, .summary-card, .table-wrap
 * table.responsive, .button, .tag-*, .empty-state, .field, .grid, …) so NO
 * Ruby/controller changes are required. The only view edits are additive
 * (stat-tile row on index, "Latest order" card on show) — see the revised
 * index.html.erb / show.html.erb in this bundle.
 *
 * Tokens are mirrored from the design system's tokens.css. Fonts are
 * self-hosted via Propshaft (app/assets/fonts/*.woff2) — Propshaft digests
 * and resolves the relative url() refs below at build time.
 * ========================================================================== */

@font-face {
  font-family: "Archivo";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/assets/archivo-700-05cdd14e.woff2") format("woff2");
}
@font-face {
  font-family: "Archivo";
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url("/assets/archivo-800-ab4513af.woff2") format("woff2");
}
@font-face {
  font-family: "Archivo";
  font-style: normal;
  font-weight: 900;
  font-display: swap;
  src: url("/assets/archivo-900-bc412e70.woff2") format("woff2");
}
@font-face {
  font-family: "Hanken Grotesk";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/hanken-grotesk-400-1f96358d.woff2") format("woff2");
}
@font-face {
  font-family: "Hanken Grotesk";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/assets/hanken-grotesk-500-0da6d705.woff2") format("woff2");
}
@font-face {
  font-family: "Hanken Grotesk";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/assets/hanken-grotesk-600-2e88b567.woff2") format("woff2");
}
@font-face {
  font-family: "Hanken Grotesk";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/assets/hanken-grotesk-700-36d7fd0b.woff2") format("woff2");
}
@font-face {
  font-family: "Hanken Grotesk";
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url("/assets/hanken-grotesk-800-89d46301.woff2") format("woff2");
}

:root {
  /* --- Brand constants --- */
  --ee-navy: #0B1E4D;        /* the chrome / top bar */
  --ee-navy-deep: #08152E;   /* chrome borders, shadows */
  --ee-blue: #2563EB;        /* secondary brand blue */

  --accent: #22D3EE;         /* cyan — THE primary action color */
  --accent-fg: #06283A;      /* text/icon on a cyan fill */
  --accent-text: #0E7C90;    /* cyan-family text/links on light (AA on white) */
  --accent-strong: #2563EB;  /* eyebrows / strong small labels on light */

  /* Vendors identity hue (suggested blue; reconcile with brand if needed) */
  --app-accent: #2563EB;

  /* --- Light working canvas --- */
  --bg: #F4F7FB;
  --surface: #FFFFFF;
  --surface-2: #EEF2F8;      /* zebra rows, wells, hover */
  --border: #E2E8F2;
  --border-strong: #CBD6E6;
  --ink: #0B1E4D;            /* primary text */
  --body: #33415A;
  --muted: #6B7A92;
  --subtle: #93A1B5;

  /* --- Status (shared, semantic) --- */
  --ok: #1F9D6B;   --ok-bg: #E2F6ED;
  --warn: #B7791F; --warn-bg: #FCEFD3;
  --err: #D64545;  --err-bg: #FCE6E6;
  --info: #2563EB; --info-bg: #E4EDFC;

  /* --- Geometry / elevation / motion --- */
  --focus-ring: 0 0 0 3px rgba(34,211,238,0.30);
  --radius: 8px;
  --radius-card: 14px;
  --radius-pill: 100px;
  --tap: 44px;
  --shadow-sm: 0 1px 2px rgba(11,30,77,0.06);
  --shadow-card: 0 2px 8px rgba(11,30,77,0.08);
  --shadow-pop: 0 12px 32px rgba(11,30,77,0.16);
  --font-display: 'Archivo', system-ui, sans-serif;
  --font-ui: 'Hanken Grotesk', system-ui, sans-serif;
  --space: 0.75rem;

  /* --- Back-compat aliases for the original scaffold variable names --- */
  --color-text: var(--body);
  --color-muted: var(--muted);
  --color-border: var(--border);
  --color-bg: var(--surface);
  --color-bg-soft: var(--surface-2);
  --color-accent: var(--accent-text);
  --color-danger: var(--err);
  --color-notice: var(--ok);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-ui);
  color: var(--body);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: normal;
}

::selection { background: var(--accent); color: var(--accent-fg); }

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px;
}

main.ee-main--narrow { max-width: 48rem; }

h1, h2, h3 {
  line-height: 1.2;
  margin-top: 0;
  font-family: var(--font-display);
  color: var(--ink);
  letter-spacing: -0.02em;
}

a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============================================================================
   NAVY CHROME — the suite top bar (binding element across all apps)
   ========================================================================== */
header.app-header {
  background: var(--ee-navy);
  border-bottom: 1px solid var(--ee-navy-deep);
  padding: 0 32px;
  min-height: 60px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 20px;
  color: #fff;
}
header.app-header .brand {
  margin-right: 8px;
  display: inline-flex;
  align-items: center;
  line-height: 0;
}
header.app-header .brand-logo {
  width: 1.6rem;
  height: 1.6rem;
  display: block;
  /* If the favicon is dark, this keeps it legible on navy. Replace the
     icon with ee-mark-white.png for a crisp suite mark. */
  filter: brightness(0) invert(1);
}
header.app-header nav a,
header.app-header nav .nav-links a {
  margin-right: 4px;
  padding: 4px 2px;
  color: rgba(230,238,251,0.82);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  position: relative;
}
header.app-header nav a:hover { color: #fff; text-decoration: none; }
header.app-header nav a[aria-current="page"] {
  color: #fff;
  text-decoration: none;
}
header.app-header nav a[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 2px; right: 2px; bottom: -19px;
  height: 3px;
  background: var(--accent);
  border-radius: 3px 3px 0 0;
}
header.app-header .session {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9rem;
  color: rgba(157,180,221,0.95);
}
header.app-header .session span { color: #C9D6EE; }

/* ============================================================================
   FLASH / NOTICES — uniform 4-side border, solid tint, no left stripe
   ========================================================================== */
.notice, .alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
}
.notice { background: var(--ok-bg);  color: #0F6B47; border-color: #BCE6D2; }
.alert  { background: var(--err-bg); color: #A52A2A; border-color: #F3C9C9; }

/* ============================================================================
   TABLES
   ========================================================================== */
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
}
th, td {
  text-align: left;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
th {
  background: var(--surface-2);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink);
}
tr:hover td { background: #F2FBFD; }   /* faint cyan row hover */

/* Tables inside a wrap become rounded "cards". */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}
.table-wrap > table { margin-bottom: 0; }
.table-wrap > table th:first-child,
.table-wrap > table td:first-child { padding-left: 22px; }
.table-wrap > table th:last-child,
.table-wrap > table td:last-child { padding-right: 22px; }
.table-wrap > table tr:last-child td { border-bottom: none; }

th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
td.num { font-weight: 700; color: var(--ink); }

tr.booking-total-row td { border-top: 2px solid var(--border-strong); }

/* Row is hidden from the vendor share view. Dim item cells; keep the toggle
   cell (last child) at full opacity so the eye button stays obviously clickable. */
tr.item-row-hidden td { opacity: 0.45; }
tr.item-row-hidden td.share-toggle-cell { opacity: 1; }
tr .share-toggle-cell button:hover { background: var(--surface-2); color: var(--body); }

/* ============================================================================
   FORMS
   ========================================================================== */
form { margin-bottom: 16px; }
form .field {
  display: flex;
  flex-direction: column;
  margin-bottom: 20px;
  max-width: 36rem;
}
form .field label {
  font-weight: 600;
  font-size: 13px;
  color: var(--body);
  margin-bottom: 6px;
}
form .field .hint {
  color: var(--subtle);
  font-size: 0.8rem;
  margin-top: 6px;
}
form input[type="text"],
form input[type="email"],
form input[type="number"],
form input[type="date"],
form input[type="time"],
form input[type="url"],
form input[type="password"],
form select,
form textarea {
  padding: 0 13px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--surface);
  transition: border-color var(--dur-fast, 120ms) ease, box-shadow var(--dur-fast, 120ms) ease;
}
form textarea { min-height: 96px; padding: 11px 13px; resize: vertical; }
form input:focus,
form select:focus,
form textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}
/* Checkbox row (e.g. "Preferred vendor") reads as a horizontal pair. */
form .field:has(> input[type="checkbox"]) {
  flex-direction: row;
  align-items: center;
  gap: 10px;
}
form .field > input[type="checkbox"] {
  width: 18px; height: 18px;
  accent-color: var(--accent);
  margin: 0;
}
form .field:has(> input[type="checkbox"]) label { margin-bottom: 0; }

form .actions { display: flex; gap: 10px; align-items: center; }

/* ============================================================================
   BUTTONS — one cyan primary per view; secondary is outlined
   ========================================================================== */
button, input[type="submit"], .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--accent);
  color: var(--accent-fg);
  border: 1px solid var(--accent);
  padding: 0 16px;
  min-height: 40px;
  border-radius: var(--radius);
  text-decoration: none;
  font: inherit;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: filter var(--dur-fast, 120ms) ease, transform var(--dur-fast, 120ms) ease;
}
button:hover, input[type="submit"]:hover, .button:hover {
  filter: brightness(0.96);
  text-decoration: none;
}
button:active, .button:active { transform: scale(0.98); }
button:focus-visible, .button:focus-visible { outline: none; box-shadow: var(--focus-ring); }

button.secondary, .button.secondary, input[type="submit"].secondary {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border-strong);
}
button.secondary:hover, .button.secondary:hover { background: var(--surface-2); filter: none; }

button.danger, input[type="submit"].danger, .button.danger {
  background: var(--err);
  border-color: var(--err);
  color: #fff;
}

/* ============================================================================
   ERRORS
   ========================================================================== */
.errors {
  background: var(--err-bg);
  color: #A52A2A;
  padding: 12px 16px;
  border: 1px solid #F3C9C9;
  border-radius: var(--radius);
  margin-bottom: 16px;
}
.errors ul { margin: 0; padding-left: 1.25rem; }

/* ============================================================================
   BADGES (tag_for helper → .tag / .tag-*)
   ========================================================================== */
.muted { color: var(--muted); }
.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 11px;
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--body);
  vertical-align: middle;
}
.tag-neutral { background: var(--surface-2); color: var(--body); }
.tag-info    { background: var(--info-bg); color: #1D4ED8; }
.tag-success { background: #CFFAFE; color: var(--accent-text); }  /* cyan "Preferred" */
.tag-warning { background: var(--warn-bg); color: #92600F; }

/* ============================================================================
   PAGE HEADER (shared/_page_header)
   ========================================================================== */
.page-header { margin-bottom: 24px; }
.breadcrumbs {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 12px;
}
.breadcrumbs a { color: var(--muted); font-weight: 600; }
.page-header-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.page-header-title {
  font-size: 32px;
  font-weight: 900;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--ink);
}
.page-header-actions {
  margin-left: auto;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.page-header-context {
  margin: 9px 0 0;
  font-size: 15px;
  color: var(--muted);
}

/* ============================================================================
   SECTION HEADER (shared/_section_header)
   ========================================================================== */
.section { margin-bottom: 32px; }
.section h3 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 800;
  color: var(--ink);
}
.section-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.section-header-title { margin: 0; font-family: var(--font-display); font-size: 18px; font-weight: 800; }
.section-header-actions {
  margin-left: auto;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Collapsible tight section (bookings/show share-link etc.) */
.section-tight { margin-bottom: 12px; }
.section-tight .section-header { margin-bottom: 8px; }
.section-tight > summary {
  font-weight: 700;
  padding: 4px 0;
  list-style: none;
  cursor: pointer;
  color: var(--ink);
}
.section-tight > summary::-webkit-details-marker { display: none; }
.section-tight > summary::before {
  content: "▸ ";
  display: inline-block;
  width: 1em;
  font-size: 0.8em;
  color: var(--muted);
}
.section-tight[open] > summary::before { content: "▾ "; }
.section-tight[open] > * + * { margin-top: 8px; }
details { margin-block: 12px; }
details > summary { cursor: pointer; padding: 4px 0; }

/* ============================================================================
   STAT TILES (card-grid + summary-card → the StatTile look)
   ========================================================================== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.card-grid.compact {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}
.summary-card {
  display: block;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  text-decoration: none;
  color: inherit;
}
.summary-card-link { transition: box-shadow var(--dur, 200ms) ease, transform var(--dur, 200ms) ease; }
.summary-card-link:hover { box-shadow: var(--shadow-pop); text-decoration: none; }
.summary-card-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.summary-card-value {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 900;
  line-height: 1.05;
  margin-top: 8px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.card-grid.compact .summary-card { padding: 12px 14px; }
.card-grid.compact .summary-card-value { font-size: 18px; }
.card-grid.compact .summary-card-label { font-size: 10px; }
.summary-card-sub {
  font-size: 13px;
  margin-top: 6px;
  color: var(--subtle);
}

/* ============================================================================
   EMPTY STATE (shared/_empty)
   ========================================================================== */
.empty-state {
  padding: 48px 32px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-card);
  background: var(--surface);
  text-align: center;
}
.empty-state-headline {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 18px;
  color: var(--ink);
  margin: 0 0 6px;
}
.empty-state-guidance { margin: 0 0 16px; color: var(--muted); font-size: 14px; }
.empty-state-cta { margin: 0; }

/* ============================================================================
   ORDER LINE-ITEM CARD (vendors/show "Latest order" — see revised ERB).
   GL-code chip + tabular amounts + invoice-style total row.
   ========================================================================== */
.order-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
}
.order-card-head .order-card-edition { font-size: 12.5px; color: var(--subtle); margin-top: 2px; }
.order-card-count { font-size: 13px; color: var(--muted); white-space: nowrap; }
.gl-code {
  font-family: var(--font-display);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
  background: var(--surface-2);
  padding: 3px 8px;
  border-radius: 6px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.order-total-row td {
  background: #FBFCFE;
  border-top: 1px solid var(--border) !important;
  border-bottom: none;
  font-family: var(--font-display);
  font-weight: 800;
  color: var(--ink);
}
.order-total-row td.num { font-size: 18px; font-weight: 900; }

/* ============================================================================
   LOGISTICS GRID (sticky headers / first column) — re-themed
   ========================================================================== */
.grid-filter { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.grid-filter form { display: flex; align-items: center; gap: 10px; margin-bottom: 0; }
.grid-filter label { font-weight: 600; font-size: 13px; color: var(--body); margin: 0; }
.grid-filter select { min-width: 14rem; }

.grid-scroll {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  max-height: 80vh;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  margin-bottom: 16px;
  box-shadow: var(--shadow-card);
}
/* On wide viewports, escape the 1200px ee-main cap so only the grid uses the
   full screen width. Left/right margins pull the box past its parent by
   (viewport - parent) / 2 on each side, minus a 24px gutter. */
@media (min-width: 1264px) {
  .grid-scroll {
    margin-left: calc(50% - 50vw + 24px);
    margin-right: calc(50% - 50vw + 24px);
  }
}
.grid {
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.9rem;
  width: max-content;
  margin: 0;
}
.grid th, .grid td {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  padding: 6px 10px;
  white-space: nowrap;
  vertical-align: top;
}
.grid thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-2);
  text-transform: none;
  letter-spacing: 0;
}
.grid thead tr:nth-child(2) th { top: 2.5rem; }
.grid .vendor-header { text-align: center; border-bottom: 2px solid var(--border); }
.grid .vendor-header[data-stripe="0"] { border-top: 4px solid var(--info); }
.grid .vendor-header[data-stripe="1"] { border-top: 4px solid var(--ok); }
.grid .vendor-header[data-stripe="2"] { border-top: 4px solid var(--warn); }
.grid .vendor-header[data-stripe="3"] { border-top: 4px solid var(--muted); }
.grid .item-header { text-align: left; font-weight: 700; }
.grid .item-header small { display: block; font-weight: 400; }
.grid .vendor-group-end { border-right: 2px solid var(--border-strong); }
.grid tbody tr:nth-child(even) td,
.grid tbody tr:nth-child(even) th { background: #FBFCFE; }
.grid .row-head {
  position: sticky; left: 0; z-index: 1;
  background: var(--surface-2);
  text-align: left; font-weight: 700;
  max-width: 12rem; white-space: normal; padding-right: 12px;
}
.grid thead .grid-corner { position: sticky; left: 0; top: 0; z-index: 3; background: var(--surface-2); }
.grid tfoot th, .grid tfoot td {
  background: var(--surface-2);
  font-weight: 700;
  border-top: 2px solid var(--border-strong);
}
.grid tfoot th.row-head { position: sticky; left: 0; z-index: 1; }
.grid td.num { text-align: right; font-variant-numeric: tabular-nums; }
.grid td .alloc-note {
  display: block; font-size: 0.75rem; color: var(--muted);
  white-space: normal; max-width: 12rem; margin-top: 0.15rem;
}

/* Compact grid (per-vendor, screenshot-friendly). Spreadsheet-style tabular
   layout — every location as a row, every item as a column, quantity + any
   allocation note stacked in each cell, totals row at the bottom. The
   fit-to-screen Stimulus controller zooms the wrapper as needed so the whole
   thing fits the viewport without scrolling. */
.grid--compact {
  width: auto;
  box-shadow: none;
  font-size: 10.5px;
  border: 1px solid #4a4a4a;
}
.grid--compact th, .grid--compact td {
  position: static;
  padding: 3px 6px;
  border-right: 1px solid #9aa4b2;
  border-bottom: 1px solid #9aa4b2;
  white-space: nowrap;
  vertical-align: top;
  line-height: 1.25;
}
.grid--compact tbody tr:nth-child(even) td,
.grid--compact tbody tr:nth-child(even) th { background: #fff; }
.grid--compact .vendor-banner th {
  background: #F6A821;
  color: #06283A;
  text-align: center;
  font-weight: 800;
  font-family: 'Archivo', sans-serif;
  font-size: 13px;
  padding: 5px 8px;
  border-color: #4a4a4a;
}
.grid--compact .vendor-banner th:first-child { background: #fff; border-right: 1px solid #4a4a4a; }
.grid--compact thead th.item-header {
  background: #C9EBC5;
  text-align: center;
  font-weight: 700;
  vertical-align: bottom;
  min-width: 5.5rem;
  max-width: 8rem;
  padding: 5px 6px;
  white-space: normal;
}
.grid--compact .item-header small {
  display: block;
  font-weight: 400;
  color: #4a4a4a;
  margin-top: 2px;
  font-size: 9.5px;
}
.grid--compact .row-head {
  position: static;
  max-width: none;
  padding: 3px 8px;
  font-weight: 700;
  background: #F8FAFD;
  min-width: 10rem;
  text-align: left;
  white-space: normal;
}
.grid--compact td.num {
  text-align: center;
  font-variant-numeric: tabular-nums;
  min-width: 3rem;
}
.grid--compact td.num .alloc-note {
  display: block;
  font-size: 9px;
  color: #33415A;
  white-space: normal;
  margin-top: 2px;
  font-weight: 400;
  text-align: left;
}
.grid--compact tfoot .totals-row th,
.grid--compact tfoot .totals-row td {
  background: #D8E9C6;
  font-weight: 800;
  border-top: 2px solid #4a4a4a;
}

/* Inline cell edit affordances (logistics grid). */
.grid-hint { margin-top: 0; color: var(--muted); }
.cell-frame { display: inline-block; min-width: 2rem; }
.cell-frame .cell-value { display: inline-block; padding: 0.1rem 0.35rem; border-radius: var(--radius); text-decoration: none; color: inherit; }
.cell-frame .cell-value:hover { background: var(--surface-2); outline: 1px dashed var(--border-strong); }
.cell-frame .cell-empty { display: inline-block; padding: 0.1rem 0.5rem; border-radius: var(--radius); color: var(--muted); opacity: 0.25; text-decoration: none; font-weight: 700; }
.cell-frame .cell-empty:hover { opacity: 1; background: var(--surface-2); outline: 1px dashed var(--border-strong); color: var(--accent); }
.cell-editing form { margin: 0; display: inline-block; }
.cell-frame .cell-input {
  width: 5rem; padding: 0.15rem 0.35rem;
  border: 1px solid var(--accent); border-radius: var(--radius);
  text-align: right; font: inherit; font-variant-numeric: tabular-nums;
  box-shadow: var(--focus-ring);
}
@keyframes cell-saved { 0% { background-color: #CFFAFE; } 100% { background-color: transparent; } }
.cell-frame.just-saved { animation: cell-saved 800ms ease-out; }

/* ============================================================================
   TYPE RADIO CHIPS / CONTACT + DOCUMENT LISTS
   ========================================================================== */
.type-radios { display: flex; gap: 8px; flex-wrap: wrap; }
.type-radio { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.type-radio input[disabled] + .tag { opacity: 0.5; }

.contact-list, .document-list {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 8px;
}
.contact-row, .document-row {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
}
.contact-row-main, .document-row-main { flex: 1 1 auto; min-width: 0; }
.contact-row-channels, .document-row-meta { font-size: 0.9rem; margin-top: 4px; color: var(--muted); }
.document-row-notes { margin-top: 8px; font-size: 0.9rem; }
.contact-row-actions, .document-row-actions { display: flex; gap: 8px; align-items: center; margin-left: auto; }

.document-group + .document-group { margin-top: 12px; }
.document-group-title { font-size: 0.95rem; margin: 0 0 8px; color: var(--muted); font-weight: 700; }
.document-source-toggle, .document-type-toggle { display: flex; gap: 1.25rem; margin-bottom: 8px; flex-wrap: wrap; align-items: center; }
.document-source-toggle label, .document-type-toggle label { display: inline-flex; align-items: center; gap: 6px; font-weight: normal; cursor: pointer; }
.document-source-toggle input, .document-type-toggle input { margin: 0; accent-color: var(--accent); }
.document-source-pane { margin-top: 8px; }
form.form-compact .field { margin-bottom: 12px; }
form.form-compact .field label { margin-bottom: 3px; }
form.form-compact .field .hint { margin-top: 3px; }

/* ============================================================================
   AUTH + SHARE (re-themed)
   ========================================================================== */
.auth { max-width: 26rem; margin: 48px auto; }
.auth input[type="email"], .auth input[type="text"] { width: 100%; }
.auth .remember-me { display: flex; align-items: center; gap: 8px; margin: 12px 0; font-weight: normal; cursor: pointer; }
.auth .remember-me input { margin: 0; accent-color: var(--accent); }

.share-link-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.share-link-row input[type="text"] { flex: 1 1 20rem; font-family: ui-monospace, monospace; font-size: 0.9rem; }
.share-link-row form { margin: 0; }
.share-header { margin-bottom: 24px; }
.share-header h1 { margin: 0; }
.invoice-table tfoot tr td { border-top: 1px solid var(--border); }
.invoice-table tfoot tr.invoice-subtotal td,
.invoice-table tfoot tr.invoice-total td { border-top: 2px solid var(--border-strong); }

/* ============================================================================
   PRINT
   ========================================================================== */
@media print {
  header.app-header, .grid-hint, .page-header-actions { display: none !important; }
  .grid-scroll { overflow: visible !important; max-height: none !important; border: none !important; box-shadow: none !important; }
  .grid th, .grid td { position: static !important; }
  .grid { width: 100%; font-size: 0.75rem; }
  main { max-width: none; padding: 0; }
}

/* ============================================================================
   RESPONSIVE — card-stack tables, stacked header, full-width forms
   ========================================================================== */
@media (max-width: 640px) {
  main { padding: 16px; }

  header.app-header { padding: 12px 16px; flex-wrap: wrap; gap: 8px; min-height: 0; }
  header.app-header nav { flex-basis: 100%; order: 3; }
  header.app-header nav a[aria-current="page"]::after { display: none; }
  header.app-header .session { flex-basis: 100%; order: 4; justify-content: flex-start; }
  header.app-header nav details > summary {
    padding: 0.7rem 0; font-weight: 600; list-style: none; color: #fff;
  }
  header.app-header nav details > summary::-webkit-details-marker { display: none; }
  header.app-header nav details[open] > .nav-links,
  header.app-header nav .nav-links { display: flex; flex-direction: column; gap: 0; }
  header.app-header nav .nav-links a {
    display: block; padding: 0.7rem 0; margin: 0; min-height: 44px;
    border-top: 1px solid rgba(255,255,255,0.12);
  }

  .page-header-title { font-size: 26px; }
  .page-header-actions, .section-header-actions { margin-left: 0; flex-basis: 100%; }
  .page-header-actions > *, .section-header-actions > * { flex: 1 1 auto; }

  form .field { max-width: none; }
  form .actions { flex-direction: column; align-items: stretch; }
  form .actions > * { width: 100%; }

  button, input[type="submit"], .button { padding: 0.7rem 1rem; min-height: 44px; }

  /* table → card stack (opt-in via table.responsive; each td needs data-label) */
  .table-wrap { border: none; box-shadow: none; background: transparent; }
  table.responsive thead { display: none; }
  table.responsive tbody, table.responsive tr, table.responsive td { display: block; width: 100%; }
  table.responsive tr {
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    background: var(--surface);
    box-shadow: var(--shadow-card);
    padding: 12px 16px;
    margin-bottom: 12px;
  }
  table.responsive tr:hover td { background: transparent; }
  table.responsive td {
    border-bottom: none; padding: 6px 0;
    display: flex; align-items: baseline; flex-wrap: wrap; gap: 0 12px;
  }
  table.responsive td::before {
    content: attr(data-label);
    font-weight: 700; color: var(--muted); font-size: 0.85rem; margin-right: auto;
  }
  table.responsive td[data-label=""]::before { content: none; }
  table.responsive td.num { font-variant-numeric: tabular-nums; }

  .grid { font-size: 0.8rem; }
  .grid th, .grid td { padding: 4px 6px; }
  .grid .row-head { max-width: 8rem; }
}

@media (min-width: 641px) {
  header.app-header nav details > summary { display: none; }
  header.app-header nav details[open] > .nav-links,
  header.app-header nav .nav-links { display: flex; flex-direction: row; gap: 20px; }
  header.app-header nav details > .nav-links { display: flex !important; }
}
