/* Toll Refunds portal (phase 1, step 9). Visual direction: DESIGN.md chapter
   10, "Screens of the new portal". Navy from the logo, white surfaces on a
   cool grey page, serif only for page titles and large amounts. */

:root {
  --navy-900: #1d2943;
  --navy-700: #2e3d5f;
  --navy-600: #3b4c72;
  --navy-100: #e4e9f2;
  --navy-50: #f0f3f8;
  --ink: #233554;
  --ink-soft: #52627a;
  --line: #dce3ec;
  --line-strong: #c3cdd9;
  --page: #f3f6fa;
  --surface: #ffffff;

  --ok: #1f7a4d;       --ok-bg: #e6f4ec;
  --none: #2f6b49;     --none-bg: #dff0e5;
  --warn: #8a5a00;     --warn-bg: #fff3d1;
  --bad: #b23b3b;      --bad-bg: #fbe7e7;
  --idle: #5e6f86;     --idle-bg: #eef2f6;

  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --serif: Georgia, "Iowan Old Style", "Times New Roman", serif;

  --radius: 12px;
  --radius-control: 8px;
  --focus: 0 0 0 3px rgba(59, 76, 114, .35);
  --sidebar: 248px;
  --bottom-bar: 64px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 400 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
[hidden] { display: none !important; }
a { color: var(--navy-600); }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius-control); }

.noscript, .fatal { margin: 0; padding: 16px; background: var(--warn-bg); color: var(--warn); font-weight: 600; }
.app-loading { min-height: 100vh; }

.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* ---- Type --------------------------------------------------------------- */

.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; margin-bottom: 24px; }
.page-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.page-title { margin: 0; font: 400 30px/1.15 var(--serif); letter-spacing: -.01em; color: var(--navy-900); }
.page-lead { margin: 6px 0 0; color: var(--ink-soft); max-width: 62ch; }
.section-title { margin: 0 0 4px; font-size: 17px; font-weight: 650; color: var(--navy-900); }
.figure { font-family: var(--serif); font-variant-numeric: lining-nums tabular-nums; }

/* ---- Controls ----------------------------------------------------------- */

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px;
  border: 1px solid transparent; border-radius: var(--radius-control);
  font-weight: 600; font-size: 15px; text-decoration: none; cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease;
}
.button:disabled { cursor: default; opacity: .6; }
.button[aria-busy] { cursor: progress; }
.button-primary { background: var(--navy-700); color: #fff; }
.button-primary:hover:not(:disabled) { background: var(--navy-900); }
.button-secondary { background: var(--surface); border-color: var(--line-strong); color: var(--navy-700); }
.button-secondary:hover:not(:disabled) { background: var(--navy-50); }
.button-quiet { background: transparent; color: var(--ink-soft); padding: 0 12px; }
.button-quiet:hover:not(:disabled) { background: var(--navy-50); color: var(--navy-900); }
.button-danger { background: var(--bad); color: #fff; }
.button-block { width: 100%; }

.form { display: grid; gap: 18px; }
.field { display: grid; gap: 6px; align-content: start; }
.field label { font-size: 14px; font-weight: 600; color: var(--navy-900); }
.field-control { position: relative; display: flex; }
.field input, .field select, .field textarea {
  width: 100%; min-height: 44px; padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-control);
}
.field select { appearance: none; padding-right: 36px; background-image: linear-gradient(45deg, transparent 50%, var(--ink-soft) 50%), linear-gradient(135deg, var(--ink-soft) 50%, transparent 50%); background-position: calc(100% - 18px) 19px, calc(100% - 13px) 19px; background-size: 5px 5px; background-repeat: no-repeat; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--navy-600); box-shadow: var(--focus); }
.field-action {
  position: absolute; right: 4px; top: 4px; bottom: 4px; width: 40px;
  display: grid; place-items: center; border: 0; border-radius: 6px; background: transparent; color: var(--ink-soft); cursor: pointer;
}
.field-action[aria-pressed="true"] { color: var(--navy-700); background: var(--navy-50); }
.field:has(.field-action) input { padding-right: 48px; }
.field-hint { margin: 0; font-size: 13px; color: var(--ink-soft); }
.field-error, .form-error { margin: 0; font-size: 14px; color: var(--bad); }
.field-error:empty, .form-error:empty { display: none; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--bad); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.empty-state { color: var(--ink-soft); }
.empty-state .page-title { margin-bottom: 16px; }

/* ---- Sign-in (K1) ------------------------------------------------------- */

.auth { display: grid; grid-template-columns: minmax(360px, 5fr) 7fr; min-height: 100vh; }
.auth-brand {
  display: flex; flex-direction: column; justify-content: space-between; gap: 48px;
  padding: 48px clamp(32px, 5vw, 72px);
  background: var(--navy-700) linear-gradient(160deg, var(--navy-600) 0%, var(--navy-700) 45%, var(--navy-900) 100%);
  color: #fff;
}
.auth-logo { width: 80px; height: 80px; border-radius: 18px; box-shadow: 0 0 0 1px rgba(255, 255, 255, .18); }
.auth-copy { max-width: 520px; margin-bottom: 8vh; }
.auth-headline { margin: 0 0 16px; max-width: 13em; font: 400 clamp(32px, 3.4vw, 46px)/1.1 var(--serif); letter-spacing: -.01em; }
.auth-text { margin: 0; color: #d3dbe8; font-size: 16px; max-width: 40ch; }
.auth-panel { display: grid; grid-template-rows: 1fr auto; place-items: center; padding: 48px 24px; background: var(--surface); }
.auth-legal { display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: center; padding-top: 32px; font-size: 14px; }
.auth-legal a { color: var(--ink-soft); }
.auth-legal a:hover { color: var(--navy-900); }
.auth-card { width: 100%; max-width: 380px; }
.auth-title { margin: 0 0 24px; font: 400 28px/1.2 var(--serif); color: var(--navy-900); }
.auth-lead { margin: -12px 0 24px; color: var(--ink-soft); }
.auth-footer { margin-top: 32px; padding-top: 24px; border-top: 1px solid var(--line); display: grid; gap: 16px; }
.auth-help { margin: 0; font-size: 14px; color: var(--ink-soft); }
.auth-link { margin: 4px 0 0; font-size: 15px; }
.auth-link a:not(.button) { color: var(--navy-700); }

.choice-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.choice {
  width: 100%; min-height: 64px; display: flex; align-items: center; gap: 14px; padding: 12px 16px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius); text-align: left; cursor: pointer;
}
.choice:hover { border-color: var(--navy-600); background: var(--navy-50); }
.choice .icon { color: var(--navy-600); width: 24px; height: 24px; }
.choice-text { display: grid; }
.choice-text small { color: var(--ink-soft); font-size: 13px; }

/* ---- Shell -------------------------------------------------------------- */

.shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  grid-row: 1 / span 2; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 24px; padding: 20px 16px;
  background: var(--surface); border-right: 1px solid var(--line); overflow-y: auto;
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 12px; }
.sidebar-brand img { border-radius: 10px; }
.sidebar-brand span { display: grid; line-height: 1.25; }
.sidebar-brand strong { font: 400 17px var(--serif); color: var(--navy-900); }
.sidebar-brand small { font-size: 13px; color: var(--ink-soft); }
.sidebar-nav { display: grid; gap: 2px; align-content: start; flex: 1; }
.nav-link {
  display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px;
  border-radius: var(--radius-control); color: var(--ink-soft); font-weight: 550; text-decoration: none;
}
.nav-link:hover { background: var(--navy-50); color: var(--navy-900); }
.nav-link.is-active { background: var(--navy-100); color: var(--navy-900); font-weight: 650; }
.nav-link.is-active .icon { color: var(--navy-700); }
/* AF9: the contract years under Overview. */
.nav-group-row { display: flex; align-items: center; gap: 2px; }
.nav-group-row .nav-link { flex: 1; min-width: 0; }
.nav-toggle { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: var(--radius-control); background: none; color: var(--ink-soft); cursor: pointer; }
.nav-toggle:hover { background: var(--navy-50); color: var(--navy-900); }
.nav-toggle .icon { transition: transform .15s ease; }
.nav-toggle[aria-expanded="true"] .icon { transform: rotate(180deg); }
.nav-sublist { display: grid; gap: 2px; margin: 2px 0 6px; padding: 0 0 0 36px; list-style: none; }
.nav-sublink { display: flex; align-items: center; min-height: 36px; padding: 0 12px; border-radius: var(--radius-control); color: var(--ink-soft); font-size: 14px; text-decoration: none; }
.nav-sublink:hover { background: var(--navy-50); color: var(--navy-900); }
.nav-sublink.is-active { background: var(--navy-100); color: var(--navy-900); font-weight: 650; }
@media (prefers-reduced-motion: reduce) { .nav-toggle .icon { transition: none; } }
/* A1a: sorting, groups and the count of the Overview list. */
.list-count-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.list-count-row .hint { margin: 0; }
.group-filter { margin: 0; padding: 14px 24px 16px; border: 0; border-bottom: 1px solid var(--line); }
.group-filter legend { float: left; width: 100%; margin-bottom: 8px; padding: 0; font-size: 14px; font-weight: 600; color: var(--navy-900); }
.group-filter-options { clear: both; display: flex; flex-wrap: wrap; gap: 8px 20px; }
.group-filter .hint { clear: both; margin: 0; }
.country-note { white-space: nowrap; }
.sidebar-footer { display: grid; gap: 14px; padding-top: 16px; border-top: 1px solid var(--line); }
.sidebar-user { display: grid; padding: 0 4px; }
.sidebar-user strong { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user small { font-size: 13px; color: var(--ink-soft); }
.sidebar-footer .field label { font-size: 13px; font-weight: 500; color: var(--ink-soft); }
.sidebar-signout { justify-content: flex-start; }

.topbar { display: none; }
.scrim { display: none; }
.main { min-width: 0; padding: 40px clamp(20px, 4vw, 56px) 64px; }
.main:focus, .main:focus-visible { outline: none; box-shadow: none; }
.screen { max-width: 1240px; margin: 0 auto; }
.company-switcher { max-width: 1240px; margin: 0 auto 8px; display: flex; justify-content: flex-end; }
.company-switcher .field { grid-template-columns: auto minmax(200px, 320px); align-items: center; gap: 10px; }
.company-switcher label { font-weight: 500; color: var(--ink-soft); }
.bottom-bar { display: none; }

/* ---- Toast -------------------------------------------------------------- */

.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 50; transform: translate(-50%, 16px);
  max-width: min(520px, calc(100vw - 32px)); padding: 12px 18px; border-radius: var(--radius-control);
  background: var(--navy-900); color: #fff; font-weight: 500; box-shadow: 0 8px 24px rgba(29, 41, 67, .25);
  opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { background: var(--bad); }

/* ---- Narrow screens ----------------------------------------------------- */

@media (max-width: 899px) {
  .auth { grid-template-columns: 1fr; }
  .auth-brand { flex-direction: row; align-items: center; gap: 16px; padding: 20px 24px; }
  .auth-logo { width: 48px; height: 48px; border-radius: 12px; }
  .auth-copy { margin: 0; max-width: none; }
  .auth-headline { margin: 0; font-size: 20px; }
  .auth-text { display: none; }
  .auth-panel { place-items: start center; padding: 32px 16px 48px; }
}

@media (max-width: 819px) {
  .shell { display: block; }
  .topbar {
    position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px;
    min-height: 56px; padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--line);
  }
  .topbar-logo { border-radius: 8px; }
  .topbar-company { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar-signout { margin-left: auto; }
  .topbar-menu { padding: 0 10px; }
  .main { padding: 24px 16px 40px; }
  .page-title { font-size: 26px; }
  .company-switcher { margin-bottom: 20px; }
  .company-switcher .field { grid-template-columns: 1fr; width: 100%; }

  .shell-staff .sidebar {
    position: fixed; z-index: 40; inset: 0 auto 0 0; width: min(300px, 86vw); height: 100%;
    transform: translateX(-100%); visibility: hidden; transition: transform .2s ease, visibility 0s linear .2s;
  }
  .shell-staff .sidebar.is-open { transform: none; visibility: visible; transition: transform .2s ease; box-shadow: 0 0 32px rgba(29, 41, 67, .2); }
  .scrim:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 30; background: rgba(29, 41, 67, .4); }

  .shell-client .sidebar { display: none; }
  .shell-client .main { padding-bottom: calc(var(--bottom-bar) + 32px + env(safe-area-inset-bottom)); }
  .bottom-bar {
    position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    min-height: var(--bottom-bar); padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface); border-top: 1px solid var(--line);
  }
  .bottom-link {
    display: grid; place-items: center; align-content: center; gap: 2px; min-height: var(--bottom-bar);
    color: var(--ink-soft); font-size: 12px; font-weight: 550; text-decoration: none;
  }
  .bottom-link .icon { width: 24px; height: 24px; }
  .bottom-link.is-active { color: var(--navy-900); font-weight: 700; }
  .bottom-link.is-active .icon { color: var(--navy-700); }
  .toast { bottom: calc(var(--bottom-bar) + 16px); }
}

/* ---- Shared pieces ------------------------------------------------------ */

.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.loading, .muted { color: var(--ink-soft); }
.hint { margin: 0; font-size: 13px; color: var(--ink-soft); }
.icon-button { min-height: 40px; width: 40px; padding: 0; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; justify-self: start; width: max-content; max-width: 100%;
  padding: 4px 10px 4px 7px; border-radius: 6px; font-size: 13px; font-weight: 600; line-height: 1.3;
}
.chip .icon { width: 16px; height: 16px; stroke-width: 2; }
.chip-ok { color: var(--ok); background: var(--ok-bg); }
.chip-none { color: var(--none); background: var(--none-bg); }
.chip-warn { color: var(--warn); background: var(--warn-bg); }
.chip-bad { color: var(--bad); background: var(--bad-bg); }
.chip-idle { color: var(--idle); background: var(--idle-bg); }
.chip-compact { padding: 3px 8px 3px 6px; font-size: 12.5px; }

.notice { display: flex; gap: 10px; align-items: flex-start; margin: 0; padding: 12px 14px; border-radius: var(--radius-control); font-size: 14px; }
.notice .icon { margin-top: 1px; }
.notice-text { display: grid; gap: 2px; }
.notice-ok { color: var(--ok); background: var(--ok-bg); }
.notice-bad { color: var(--bad); background: var(--bad-bg); }
.notice-none { color: var(--none); background: var(--none-bg); }
.notice-idle { color: var(--idle); background: var(--idle-bg); }
/* AE1-AE4: the missing Toll Collect number, with the one-time field. */
.toll-box { display: grid; gap: 12px; margin: 0 0 20px; padding: 16px; border-radius: var(--radius-control); color: var(--bad); background: var(--bad-bg); }
.profile-column .toll-box { margin: 0; }
.toll-box-text { display: flex; gap: 10px; align-items: flex-start; margin: 0; font-size: 15px; font-weight: 600; }
.toll-box-text .icon { flex: none; margin-top: 2px; }
.toll-box-form { display: grid; gap: 6px; }
.toll-box-form .field { max-width: 460px; margin: 0; }
.toll-box-form .field-control { flex-wrap: wrap; gap: 8px 12px; }
.toll-box-form .field-control input { flex: 1 1 200px; min-width: 0; }
.toll-box-form label { color: var(--navy-900); }
.toll-box.is-saved { color: var(--ok); background: var(--ok-bg); }
.mail-reminders { display: grid; gap: 8px; margin-top: 8px; }
/* Activity (A8, H9). */
.list-toolbar.activity-toolbar { display: grid; gap: 12px; align-items: stretch; }
.list-toolbar.activity-toolbar .section-title { margin: 0; }
.activity-filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px 16px; align-items: end; }
.activity-filters .field-inline { min-width: 0; }
.activity-filters select, .activity-filters input { width: 100%; }
.list-count { margin: 0; padding: 12px 24px 0; }
/* Rejected invoices (S2): selecting rows and deleting them at once. */
.list-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; padding: 12px 24px; border-bottom: 1px solid var(--line); }
.list-actions .list-count { padding: 0; margin-right: auto; }
.select-cell { width: 44px; }
.select-cell input { width: 20px; height: 20px; accent-color: var(--navy-700); }
.rejected-table small { display: block; color: var(--ink-soft); }
.rejected-file a { overflow-wrap: anywhere; }
.panel-message { margin: 0; padding: 16px 24px; }
.activity-table th[scope="row"] { white-space: nowrap; font-weight: 500; }
.activity-details { max-width: 420px; font-size: 13px; color: var(--ink-soft); overflow-wrap: anywhere; }
.activity-error { display: block; margin-top: 4px; color: var(--bad); overflow-wrap: anywhere; }
.link-button { padding: 0; border: 0; background: none; color: var(--navy-700); font: inherit; text-align: left; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.link-button:hover { color: var(--navy-900); }
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px; padding: 16px 24px; border-top: 1px solid var(--line); }
.email-text { margin: 16px 0 0; padding: 14px 16px; background: var(--navy-50); border-radius: var(--radius-control); font: 14px/1.55 var(--sans); white-space: pre-wrap; overflow-wrap: anywhere; }
.mail-reminders p { margin: 0; }

/* ---- Months (K2) -------------------------------------------------------- */

/* minmax(0, 1fr): the wide year table scrolls inside its panel instead of
   stretching the page on phones. */
.months { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; }
.year-tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--line); }
.year-tab {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px; margin-bottom: -1px;
  background: none; border: 0; border-bottom: 2px solid transparent; color: var(--ink-soft); font-weight: 600; cursor: pointer;
}
.year-tab:hover { color: var(--navy-900); }
.year-tab[aria-pressed="true"] { color: var(--navy-900); border-bottom-color: var(--navy-700); }
.year-badge { min-width: 22px; padding: 1px 6px; border-radius: 6px; background: var(--bad-bg); color: var(--bad); font-size: 12.5px; font-weight: 700; text-align: center; }

.month-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.tile {
  display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; gap: 10px; min-height: 120px; height: 100%; padding: 16px 16px 16px 18px;
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--idle); border-radius: var(--radius);
  color: var(--ink); text-decoration: none; transition: background-color .15s ease;
}
.tile:hover { background: var(--navy-50); }
.tile:focus-visible { border-radius: var(--radius); }
.tile-month { font: 400 20px/1.2 var(--serif); color: var(--navy-900); }
.tile-detail { font-size: 13px; color: var(--ink-soft); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.tile-ok { border-left-color: var(--ok); }
.tile-none { border-left-color: var(--none); }
.tile-warn { border-left-color: #c48a12; }
.tile-bad { border-left-color: var(--bad); }
/* F16: what a reminder will list, before it is sent. */
.reminder-preview-box { max-height: 40vh; overflow-y: auto; margin: 4px 0 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.reminder-preview-box p { margin: 0 0 4px; }
.reminder-preview { margin: 0 0 10px; padding-left: 20px; font-size: 14px; }
/* C15: a company without a Toll Collect number. */
.toll-missing { display: flex; align-items: center; gap: 10px; margin: 12px 0 0; padding: 12px 16px; border-radius: var(--radius); background: var(--bad-bg); color: var(--bad); border: 1px solid var(--bad); }
.toll-missing strong { font-size: 15px; font-weight: 750; letter-spacing: .04em; text-transform: uppercase; }
.toll-missing-note { display: block; font-weight: 650; }
.tile-idle { border-style: dashed; border-left: 4px solid var(--line-strong); background: transparent; }
/* T1-T4: "Upload for the whole year" closes the grid as a navy bar. */
.month-grid-year { grid-column: 1 / -1; }
.tile-year { grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 16px; min-height: 0; padding: 18px 20px; background: var(--navy-700); border-color: var(--navy-700); color: #fff; }
.tile-year:hover { background: var(--navy-900); }
.tile-year > .icon { width: 26px; height: 26px; }
.tile-year-text { display: grid; gap: 4px; min-width: 0; }
.tile-year .tile-month { color: #fff; font-size: 19px; }
.tile-year .tile-detail { color: rgba(255, 255, 255, .86); }
.tile-year .tile-year-unsorted { color: #ffd9d2; font-weight: 650; }
.tile-idle .tile-month { color: var(--ink-soft); }

.estimate { display: grid; gap: 6px; }
.estimate-range { margin: 4px 0 0; font-size: clamp(30px, 4vw, 40px); line-height: 1.1; color: var(--navy-900); }
.estimate-note, .estimate-empty { margin: 0; font-size: 14px; color: var(--ink-soft); max-width: 70ch; }

.overview .section-title { margin-bottom: 12px; }
.overview-scroll { overflow-x: auto; }
.overview-table { border-collapse: collapse; width: 100%; min-width: 560px; }
.overview-table th { padding: 6px 4px; font-size: 13px; font-weight: 600; color: var(--ink-soft); text-align: center; }
.overview-table th[scope="row"] { text-align: left; color: var(--navy-900); padding-right: 12px; }
.overview-table abbr { text-decoration: none; }
.overview-table td { padding: 3px; text-align: center; }
.dot { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 6px; }
.dot .icon { width: 16px; height: 16px; stroke-width: 2; }
.dot-ok { color: var(--ok); background: var(--ok-bg); }
.dot-none { color: var(--none); background: var(--none-bg); }
.dot-warn { color: var(--warn); background: var(--warn-bg); }
.dot-bad { color: var(--bad); background: var(--bad-bg); }
.dot-idle { color: var(--idle); background: var(--idle-bg); }

/* ---- Drawer (K3) -------------------------------------------------------- */

body.has-drawer { overflow: hidden; }
.drawer-backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(29, 41, 67, .45); animation: fade-in .2s ease; }
.drawer {
  position: fixed; z-index: 61; top: 0; right: 0; bottom: 0; width: min(500px, 100vw);
  display: flex; flex-direction: column; background: var(--surface); box-shadow: -12px 0 40px rgba(29, 41, 67, .2);
  animation: slide-in .22s ease;
}
.drawer:focus { outline: none; box-shadow: -12px 0 40px rgba(29, 41, 67, .2); }
.drawer-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 20px 20px 16px 24px; border-bottom: 1px solid var(--line); }
.drawer-header > div { display: grid; gap: 8px; }
.drawer-title { margin: 0; font: 400 26px/1.2 var(--serif); color: var(--navy-900); }
.drawer-close { flex: none; width: 44px; padding: 0; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px 24px 32px; display: grid; align-content: start; gap: 28px; }
.drawer-section { display: grid; gap: 12px; }
.drawer-section-title { margin: 0; font-size: 16px; font-weight: 650; color: var(--navy-900); }

.dropzone {
  position: relative; display: grid; justify-items: center; gap: 6px; padding: 24px 16px; text-align: center; cursor: pointer;
  border: 2px dashed var(--line-strong); border-radius: var(--radius); color: var(--ink-soft);
}
.dropzone > .icon { width: 28px; height: 28px; color: var(--navy-600); }
.dropzone strong { color: var(--navy-700); }
.dropzone small { font-size: 13px; }
.dropzone:hover, .dropzone.is-over { border-color: var(--navy-600); background: var(--navy-50); }
.dropzone:focus-within { border-color: var(--navy-600); box-shadow: var(--focus); }

.upload-list, .file-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.upload-list:empty { display: none; }
.upload-item, .file-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-control);
}
.upload-item > .icon, .file-row > .icon { color: var(--ink-soft); }
.file-name { display: grid; min-width: 0; }
.file-name strong { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-name small { font-size: 13px; color: var(--ink-soft); }
.upload-item progress { grid-column: 2 / -1; width: 100%; height: 6px; accent-color: var(--navy-700); }
.upload-done small { color: var(--ok); }
.upload-error { border-color: #e6b8b8; }
.upload-error small { color: var(--bad); }
.disclosure { justify-content: flex-start; padding: 0 10px; width: max-content; max-width: 100%; color: var(--navy-700); }
.field textarea { resize: vertical; min-height: 88px; }

/* ---- Documents (K4) ----------------------------------------------------- */

.text-bad { color: var(--bad) !important; }
.doc-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.doc-category {
  display: grid; gap: 12px; padding: 18px 20px 18px 22px;
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--line-strong); border-radius: var(--radius);
}
.doc-ok { border-left-color: var(--ok); }
.doc-warn { border-left-color: #c48a12; }
.doc-bad { border-left-color: var(--bad); }
.doc-head { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 12px 16px; }
.doc-title { display: grid; gap: 2px; }
.doc-name { margin: 0; font: 400 19px/1.25 var(--serif); color: var(--navy-900); }
.doc-required { font-size: 13px; color: var(--ink-soft); }
.doc-upload { position: relative; cursor: pointer; }
.doc-upload:focus-within { box-shadow: var(--focus); }
.doc-empty { margin: 0; font-size: 14px; }
.doc-category .hint:empty { display: none; }
/* D8: a file dragged over a category card. */
.doc-category.is-over { border-color: var(--navy-600); border-left-color: var(--navy-600); background: var(--navy-50); }
/* I9: the one-file rule in the upload drawer. */
.one-file-warning { margin: 0; font-size: 17px; font-weight: 750; letter-spacing: .03em; text-transform: uppercase; color: var(--bad); }
.file-side { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }

/* ---- Profile (K5) ------------------------------------------------------- */

.profile { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.profile-section { display: grid; gap: 14px; }
.profile-column { display: grid; gap: 16px; }
.facts { display: grid; grid-template-columns: minmax(140px, 38%) minmax(0, 1fr); gap: 10px 16px; margin: 0; }
.facts dt { font-size: 14px; color: var(--ink-soft); }
.facts dd { margin: 0; font-size: 15px; overflow-wrap: anywhere; }
.subsection-title { margin: 10px 0 0; padding-top: 18px; border-top: 1px solid var(--line); font-size: 16px; font-weight: 650; color: var(--navy-900); }

@media (max-width: 1099px) {
  .profile { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 639px) {
  .doc-head { grid-template-columns: minmax(0, 1fr) auto; }
  .doc-head .chip { grid-row: 2; }
  .doc-upload { grid-column: 2; grid-row: 1 / span 2; }
  .facts { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .facts dd { margin-bottom: 10px; }
  .file-row { grid-template-columns: auto minmax(0, 1fr); }
  .file-row .file-side, .file-row > .chip { grid-column: 2; }
}

/* ---- Administration: overview (A1) -------------------------------------- */

.text-warn { color: var(--warn) !important; }
/* The 1px gap on the line colour draws the dividers, however the tiles wrap. */
.stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1px; margin-bottom: 24px;
  background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
.stat { display: grid; align-content: start; gap: 4px; padding: 18px 22px; background: var(--surface); color: var(--ink); text-decoration: none; }
a.stat:hover { background: var(--navy-50); }
.stat-label { font-size: 14px; font-weight: 600; color: var(--ink-soft); }
.stat-value { font-size: 30px; font-weight: 650; line-height: 1.15; color: var(--navy-900); font-variant-numeric: tabular-nums; }
.stat-value.figure { font-family: var(--serif); font-weight: 400; }
.stat-detail { font-size: 13px; color: var(--ink-soft); }
.stat-warn { box-shadow: inset 0 4px 0 #c48a12; }
.stat-warn .stat-value { color: var(--warn); }
.stat-bad .stat-value { color: var(--bad); }

.list-panel { padding: 0; }
.list-toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 20px; padding: 20px 24px; border-bottom: 1px solid var(--line); }
.list-toolbar .section-title { margin: 0 auto 10px 0; }
.list-toolbar .hint { margin: 0 0 12px; }
.field-inline { min-width: 200px; }
.field-inline label { font-size: 13px; font-weight: 500; color: var(--ink-soft); }
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th, .data-table td { padding: 12px 16px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.data-table thead th { font-size: 13px; font-weight: 600; color: var(--ink-soft); background: var(--navy-50); white-space: nowrap; }
.data-table tbody th, .data-table td { font-weight: 400; }
.data-table tbody th small, .data-table td small { display: block; font-size: 13px; color: var(--ink-soft); }
.data-table .nowrap { white-space: nowrap; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
/* Georgia has old-style numerals (a zero reads like "o"); amounts in tables use the sans with even digits. */
.data-table .figure-cell { font-size: 15px; font-weight: 500; font-variant-numeric: tabular-nums; }
.data-table tr.clickable { cursor: pointer; }
.data-table tr.clickable:hover { background: var(--navy-50); }
.row-link { font-weight: 650; color: var(--navy-900); text-decoration: none; }
.row-link:hover { text-decoration: underline; }
.doc-marks { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.doc-mark { display: inline-flex; align-items: center; gap: 4px; padding: 2px 7px 2px 5px; border-radius: 6px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.doc-mark .icon { width: 14px; height: 14px; stroke-width: 2; }
.doc-mark-ok { color: var(--ok); background: var(--ok-bg); }
.doc-mark-warn { color: var(--warn); background: var(--warn-bg); }
.doc-mark-bad { color: var(--bad); background: var(--bad-bg); }
.doc-mark-idle { color: var(--idle); background: var(--idle-bg); }

/* ---- Company detail (A2) ------------------------------------------------ */

.back-link { display: inline-flex; align-items: center; min-height: 44px; margin-bottom: 4px; color: var(--ink-soft); font-weight: 550; text-decoration: none; }
.back-link:hover { color: var(--navy-900); }
.company-header { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 44%); gap: 16px 32px; align-items: start; margin-bottom: 20px; }
.company-identity { display: grid; gap: 6px; min-width: 0; }
.company-identity .chip { width: auto; }
.company-meta { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 0; color: var(--ink-soft); font-size: 14px; }
.company-meta .code { font-weight: 650; color: var(--navy-700); }
.company-figures { display: flex; flex-wrap: wrap; gap: 8px 28px; margin: 0; grid-column: 1; }
.company-figures dt { font-size: 13px; color: var(--ink-soft); }
.company-figures dd { margin: 0; font-size: 22px; color: var(--navy-900); }
.company-actions { grid-column: 2; grid-row: 1; display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.tabs { display: flex; gap: 4px; margin-bottom: 24px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tab { display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; margin-bottom: -1px; border-bottom: 2px solid transparent; color: var(--ink-soft); font-weight: 600; text-decoration: none; white-space: nowrap; }
.tab:hover { color: var(--navy-900); }
.tab.is-active { color: var(--navy-900); border-bottom-color: var(--navy-700); }
.tile-amount { font-size: 15px; color: var(--navy-900); }
.drawer-amount { font-size: 18px; color: var(--navy-900); }
.drawer-header-extra { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }

.invoice-cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.invoice-card { display: grid; gap: 10px; padding: 14px 16px; border: 1px solid var(--line); border-left: 4px solid var(--line-strong); border-radius: var(--radius-control); }
.invoice-ok { border-left-color: var(--ok); }
.invoice-warn { border-left-color: #c48a12; }
.invoice-bad { border-left-color: var(--bad); }
.invoice-card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.invoice-card-name { font-size: 14px; overflow-wrap: anywhere; }
.invoice-facts { display: grid; grid-template-columns: fit-content(50%) minmax(0, 1fr); gap: 4px 16px; margin: 0; font-size: 14px; }
.invoice-facts dt { color: var(--ink-soft); }
.invoice-facts dd { margin: 0; overflow-wrap: anywhere; }
.card-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.card-actions .button { min-height: 40px; padding: 0 12px; font-size: 14px; }
.card-form:empty { display: none; }
.card-form { padding-top: 12px; border-top: 1px solid var(--line); }
/* What the AI read and which rule decided, inside an invoice card. */
.ai-box { display: grid; gap: 6px; padding: 10px 12px; background: var(--navy-50); border-radius: var(--radius-control); }
.ai-box p { margin: 0; }
.ai-box-reason { font-size: 14px; }
.ai-usage { margin-bottom: 4px; }

/* ---- Manual checks (A3) ------------------------------------------------- */

.waiting-count { display: inline-block; min-width: 28px; padding: 2px 8px; border-radius: 6px; background: var(--warn-bg); color: var(--warn); font-weight: 700; text-align: center; }
.review-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; margin-bottom: 20px; }
.review-nav { display: flex; align-items: center; gap: 10px; }
.review-position { min-width: 5em; text-align: center; font-weight: 600; color: var(--navy-900); font-variant-numeric: tabular-nums; }
.review { display: grid; grid-template-columns: minmax(0, 3fr) minmax(320px, 2fr); gap: 16px; align-items: start; }
.review-preview { position: sticky; top: 16px; display: grid; gap: 8px; }
.review-frame, .review-image { width: 100%; height: calc(100vh - 220px); min-height: 480px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.review-image { object-fit: contain; }
.review-newtab { justify-self: start; }
.review-side { display: grid; gap: 12px; padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.review-month { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; font-size: 14px; color: var(--ink-soft); }
.review-month strong { color: var(--navy-900); }
.review-side > .button-quiet { justify-self: start; }

/* Phone browsers do not show a PDF inside a frame (Android) or only its first
   page (iOS); there the file opens in its own tab instead. */
@media (max-width: 819px) {
  .review-frame { display: none; }
  .review-newtab { justify-self: stretch; background: var(--surface); border: 1px solid var(--line-strong); color: var(--navy-700); }
}
@media (max-width: 1099px) {
  .review { grid-template-columns: minmax(0, 1fr); }
  .review-preview { position: static; }
  .review-frame, .review-image { height: 60vh; min-height: 320px; }
}

/* ---- Settings (A4) and staff (A5) --------------------------------------- */

.settings, .staff { display: grid; gap: 16px; }
.settings-panel { display: grid; gap: 14px; }
.settings-panel .table-wrap { border: 1px solid var(--line); border-radius: var(--radius-control); }
.settings-panel .data-table tbody tr:last-child > * { border-bottom: 0; }
.row-actions { text-align: right; white-space: nowrap; }
.row-actions .button { min-height: 36px; padding: 0 10px; font-size: 14px; }
.settings-add { display: grid; gap: 12px; justify-items: start; }
.settings-add > div { width: 100%; }
.settings-form { padding: 16px; border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--navy-50); }
.issuer-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.issuer { display: grid; gap: 10px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius-control); }
.issuer.is-inactive { background: var(--navy-50); }
.issuer-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 8px; }
.issuer-name { margin: 0; font: 400 18px/1.25 var(--serif); color: var(--navy-900); }
.issuer-head .hint { margin-top: 2px; }

.staff-create { padding: 0; }
.staff-create summary { display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 0 20px; font-weight: 650; color: var(--navy-700); cursor: pointer; list-style: none; }
.staff-create summary::-webkit-details-marker { display: none; }
.staff-create[open] summary { border-bottom: 1px solid var(--line); }
.staff-create .form { padding: 20px; }
.staff-list { list-style: none; margin: 0; padding: 0; }
.staff-list > li + li { border-top: 1px solid var(--line); }
.staff-person { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 16px; align-items: center; padding: 14px 24px; }
.staff-who { display: grid; gap: 2px; min-width: 0; }
.staff-who .hint { overflow-wrap: anywhere; }
.staff-detail { font-size: 13px; color: var(--ink-soft); }
.staff-person .card-actions, .staff-person .card-form { grid-column: 1 / -1; }
.staff-empty { margin: 0; padding: 16px 24px; }
.check-list { display: grid; gap: 2px; }

/* ---- Upload client (A6) ------------------------------------------------- */

.import { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 24px; }
.steps li { display: flex; align-items: center; gap: 8px; color: var(--ink-soft); font-weight: 600; }
.step-number { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line-strong); font-size: 13px; }
.steps .is-active { color: var(--navy-900); }
.steps .is-active .step-number { border-color: var(--navy-700); background: var(--navy-700); color: #fff; }
.steps .is-done .step-number { border-color: var(--ok); color: var(--ok); }
.import-panel { display: grid; gap: 14px; }
.import-panel p { margin: 0; }
.dropzone-large { padding: 40px 16px; }
.import-notes { margin: 0; padding-left: 20px; display: grid; gap: 4px; color: var(--ink-soft); font-size: 14px; }
.import-panel progress { width: 100%; height: 10px; accent-color: var(--navy-700); }
.import-counter { font-weight: 600; color: var(--navy-900); font-variant-numeric: tabular-nums; }
.import-refused { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 14px; }
.import-refused li { display: grid; gap: 2px; padding: 8px 12px; border-radius: var(--radius-control); background: var(--bad-bg); }
.import-refused span { color: var(--bad); }
.notice-panel { display: grid; gap: 10px; }
.import-rows select { min-height: 40px; max-width: 260px; padding: 6px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-control); background: var(--surface); }
.import-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.import-list li { display: grid; grid-template-columns: minmax(0, 1fr) minmax(160px, 240px) auto auto; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-control); }
.import-list select { min-height: 40px; padding: 6px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-control); background: var(--surface); }
.import-paths { margin: 8px 0 0; padding-left: 20px; display: grid; gap: 4px; font-size: 14px; overflow-wrap: anywhere; }
.import-panel details summary { cursor: pointer; font-weight: 600; color: var(--navy-700); }
.import-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
/* The optional AI check of an import (K17). */
.import-ai-progress { display: grid; gap: 6px; }
.import-ai-progress p { margin: 0; }
.import-ai-progress progress { width: 100%; max-width: 420px; }
.import-ai { display: grid; gap: 6px; margin-top: 6px; justify-items: start; }
.import-ai-difference { display: grid; gap: 2px; margin: 0; padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--radius-control); }
.import-ai-difference legend { padding: 0 4px; font-size: 13px; color: var(--ink-soft); }
.import-ai-choice { display: flex; align-items: center; gap: 8px; min-height: 32px; font-size: 14px; }
.import-ai-proposal { display: block; color: var(--ink); }
.import-actions .hint { flex-basis: 100%; margin: 0; }

@media (max-width: 639px) {
  .import-list li { grid-template-columns: minmax(0, 1fr); }
  .import-rows select { max-width: none; width: 100%; }
}

/* ---- Forms and dialogs -------------------------------------------------- */

.form-compact { gap: 12px; }
.form-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.form-section { margin: 0; padding: 0; border: 0; display: grid; gap: 14px; }
.form-section + .form-section { padding-top: 22px; border-top: 1px solid var(--line); }
.form-section legend { float: left; width: 100%; padding: 0; margin-bottom: 14px; font-size: 16px; font-weight: 650; color: var(--navy-900); }
.form-section legend + * { clear: both; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.form-grid > .field:has(textarea), .form-grid > .check, .form-grid-nested, .form-grid > [data-field="name"] { grid-column: 1 / -1; }
.form-grid-nested { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.company-form { gap: 22px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.check input { width: 20px; height: 20px; accent-color: var(--navy-700); }
.check label { font-size: 15px; }
.profile-edit { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; align-items: start; }
.admin-section { display: grid; gap: 12px; }
.admin-inline { display: grid; gap: 8px; padding-top: 14px; border-top: 1px solid var(--line); justify-items: start; }
/* F17: the contact's last sign-in, the first line of the login panel. */
.last-sign-in { margin: 0; font-size: 14px; color: var(--navy-900); }
.danger-zone { border-color: #e6b8b8; }

.dialog { width: min(480px, calc(100vw - 32px)); padding: 0; border: 0; border-radius: var(--radius); box-shadow: 0 24px 64px rgba(29, 41, 67, .3); color: var(--ink); }
.dialog::backdrop { background: rgba(29, 41, 67, .45); }
.dialog-body { display: grid; gap: 16px; padding: 24px; }
.dialog-body p { margin: 0; }
.dialog-title { margin: 0; font: 400 24px/1.2 var(--serif); color: var(--navy-900); }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.credentials { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 16px; margin: 0; align-items: center; }
.credentials dt { color: var(--ink-soft); font-size: 14px; }
.credentials dd { margin: 0; }
.credentials code { display: inline-block; padding: 6px 10px; border-radius: 6px; background: var(--navy-50); font: 600 15px/1.4 ui-monospace, SFMono-Regular, Consolas, monospace; overflow-wrap: anywhere; }

@media (max-width: 1099px) {
  .profile-edit { grid-template-columns: minmax(0, 1fr); }
  .company-header { grid-template-columns: minmax(0, 1fr); }
  .company-actions { grid-column: 1; grid-row: auto; justify-content: flex-start; }
}
@media (max-width: 819px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { padding: 14px 16px; }
  .stat-value { font-size: 24px; }
  .responsive-table thead { display: none; }
  .responsive-table, .responsive-table tbody, .responsive-table tr, .responsive-table th, .responsive-table td { display: block; }
  .responsive-table tr { padding: 14px 16px; border-bottom: 1px solid var(--line); }
  .responsive-table th, .responsive-table td { padding: 3px 0; border: 0; text-align: left; }
  .responsive-table td[data-label] { display: grid; grid-template-columns: 9.5em minmax(0, 1fr); gap: 0 8px; }
  .responsive-table td[data-label]::before { content: attr(data-label); grid-row: 1; color: var(--ink-soft); font: 400 13px/1.5 var(--sans); }
  .responsive-table td[data-label] > * { grid-column: 2; }
  .responsive-table td { overflow-wrap: anywhere; }
  .responsive-table .num { text-align: left; }
  .responsive-table tbody th { margin-bottom: 6px; font-size: 16px; }
  .list-toolbar { padding: 16px; }
  .list-actions { padding: 12px 16px; }
  .field-inline { min-width: 0; flex: 1 1 100%; }
  .form-grid, .form-grid-nested, .form-pair { grid-template-columns: minmax(0, 1fr); }
}

/* Wide tables (the overview of companies, the import rows with the AI result,
   the activity and the e-mails) become cards on laptops too, so their last
   columns never hide behind a scroll bar. */
@media (min-width: 820px) and (max-width: 1279px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .table-laptop-cards thead { display: none; }
  .table-laptop-cards, .table-laptop-cards tbody, .table-laptop-cards tr, .table-laptop-cards th, .table-laptop-cards td { display: block; }
  .table-laptop-cards tr { padding: 14px 16px; border-bottom: 1px solid var(--line); }
  .table-laptop-cards th, .table-laptop-cards td { padding: 3px 0; border: 0; text-align: left; }
  .table-laptop-cards td[data-label] { display: grid; grid-template-columns: 9.5em minmax(0, 1fr); gap: 0 8px; }
  .table-laptop-cards td[data-label]::before { content: attr(data-label); grid-row: 1; color: var(--ink-soft); font: 400 13px/1.5 var(--sans); }
  .table-laptop-cards td[data-label] > * { grid-column: 2; }
  .table-laptop-cards td { overflow-wrap: anywhere; }
  .table-laptop-cards .num { text-align: left; }
  .table-laptop-cards tbody th { margin-bottom: 6px; font-size: 16px; }
}

@keyframes slide-in { from { transform: translateX(32px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

@media (max-width: 1099px) {
  .month-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 639px) {
  .month-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tile { min-height: 104px; padding: 12px 12px 12px 14px; gap: 8px; }
  .tile-month { font-size: 18px; }
  .drawer { width: 100vw; }
  .drawer-body { padding: 16px 16px 32px; }
  .year-tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; gap: 0; }
  .year-tab { flex: none; padding: 0 10px; }
}

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

/* Activity: the Visual tabs (AM1-AM6) */
.text-ok { color: var(--ok) !important; }
.visual-days { padding: 4px 24px 20px; }
.visual-day { display: grid; grid-template-columns: 132px minmax(0, 1fr); gap: 16px; padding: 18px 0; border-top: 1px solid var(--line); }
.visual-date { margin: 0; padding-top: 6px; font-size: 15px; font-weight: 600; color: var(--navy-900); }
.visual-date small { display: block; margin-top: 2px; font-size: 12.5px; font-weight: 400; color: var(--ink-soft); }
.visual-bubbles { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start; }
.bubble { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-width: 150px; max-width: 280px; padding: 10px 18px; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: var(--ink); font-size: 13px; line-height: 1.35; text-align: center; text-decoration: none; }
.bubble strong { font-size: 14px; color: var(--navy-900); }
.bubble small { font-size: 12px; color: var(--ink-soft); }
.bubble-line { display: block; }
.bubble-line.text-ok, .bubble-line.text-bad, .bubble-line.text-warn { font-weight: 600; }
.bubble-muted { color: var(--ink-soft); font-size: 12px; }
.bubble-m { min-width: 190px; padding: 16px 24px; background: var(--navy-50); }
.bubble-l { min-width: 230px; padding: 22px 30px; background: var(--navy-100); font-size: 14px; }
.bubble-xl { min-width: 270px; padding: 30px 38px; background: var(--navy-100); border: 2px solid var(--navy-700); font-size: 14px; }
a.bubble:hover, a.bubble:focus-visible { border-color: var(--navy-700); box-shadow: var(--focus); outline: none; }
@media (max-width: 639px) {
  .visual-days { padding: 4px 16px 16px; }
  .visual-day { grid-template-columns: 1fr; gap: 10px; }
  .visual-bubbles { flex-direction: column; align-items: stretch; }
  .bubble { max-width: none; min-width: 0; border-radius: 28px; }
}

/* AK3: CEO fields that follow the contact person */
.field input.is-mirrored { background: var(--navy-50); color: var(--ink-soft); }

/* Power of attorney & contract (AJ) */
.contract-form .field-wide { grid-column: 1 / -1; }
.contract-years { grid-column: 1 / -1; margin: 0; }
.contract-downloads { display: grid; gap: 10px; justify-items: start; }
.contract-downloads[hidden] { display: none; }
.contract-flash { margin-bottom: 16px; }
.contracts-table tbody th a { font-weight: 600; }
