/* ============================================================================
   LIFTED PAYMENTS — PARTNER PORTAL (partner.liftedpayments.com)
   Built on the Lifted Design System: /static/ds/styles.css (tokens, fonts) +
   /static/ds/appkit/_appkit.css (the .ap-* app shell). This file adds only the
   agent-portal pieces (auth screens, states, mobile nav) and the light-theme
   overrides the app kit needs (it hard-codes a few dark grounds).

   Rules: DS semantic tokens only — no raw colours. Green is the 10% spice:
   primary buttons, active nav, the one focal number. Mono for every amount,
   MID and id. Every page has loading, empty, error and stale states.
   ============================================================================ */

:root {
  --ag-accent-text: var(--brand);            /* accent AS TEXT (dark: the green itself) */
  --ag-ground: var(--void);
  --ag-field: var(--ink-900);
  --ag-raised: var(--ink-800);
  --ag-bottomnav-h: 64px;
  /* small (10.5-11px) secondary text: --text-muted is ~4.0:1 on dark cards, this is >=5:1 */
  --ag-text-fine: color-mix(in srgb, var(--slate-400) 60%, var(--mist-300));
}
[data-theme="light"] {
  --ag-accent-text: var(--green-ink);        /* green text on white must be the deep ink */
  --ag-ground: var(--bg-base);
  --ag-field: var(--surface-card);
  --ag-raised: var(--surface-card);
  --ag-text-fine: var(--text-muted);         /* slate-500 on white: 6.8:1 */
}

html { scroll-behavior: smooth; }
body.ap { background: var(--ag-ground); min-height: 100vh; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
.ag-skip { position: absolute; left: -9999px; top: 8px; z-index: 100; }
.ag-skip:focus { left: 12px; padding: 8px 12px; border-radius: var(--radius-md);
  background: var(--brand); color: var(--brand-contrast); font-weight: 600; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.ap-btn:focus-visible, .ap-link:focus-visible, .ag-bn a:focus-visible { outline-offset: 1px; }
a { color: var(--ag-accent-text); }

/* ---- boot / noscript ------------------------------------------------------ */
.ag-boot { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 14px;
  color: var(--brand); }
.ag-boot__t { font-family: var(--font-mono); font-size: 11px; letter-spacing: 1.6px;
  text-transform: uppercase; color: var(--text-faint); }
.ag-noscript { padding: 24px; text-align: center; color: var(--text-body); }

/* ---- light theme: app-kit grounds that are hard-coded dark ----------------- */
[data-theme="light"] .ap-main { background:
    radial-gradient(1000px 720px at 78% -6%, var(--brand-tint), transparent 60%),
    var(--bg-base); }
[data-theme="light"] .ap-main::before { opacity: .35; }
[data-theme="light"] .ap-side { background: var(--surface-card); }
[data-theme="light"] .ap-top { background: color-mix(in srgb, var(--surface-card) 86%, transparent); }
[data-theme="light"] .ap-input,
[data-theme="light"] .ap-select { background-color: var(--surface-card); }
[data-theme="light"] .ap-btn--ghost { background: var(--surface-card); }
[data-theme="light"] .ap-btn--ghost:hover { color: var(--ag-accent-text); }
[data-theme="light"] .ap-chip { background: var(--surface-card); }
[data-theme="light"] .ap-seg { background: var(--surface-raised); }
[data-theme="light"] .ap-card .ap-table th { background: var(--surface-card); }
[data-theme="light"] .ap-table th { background: var(--surface-card); }
[data-theme="light"] .ap-link.active,
[data-theme="light"] .ap-eyebrow,
[data-theme="light"] .ap-brand__wm b,
[data-theme="light"] .ap-badge--brand,
[data-theme="light"] .ap-card__hint--link { color: var(--ag-accent-text); }
[data-theme="light"] .ap-link.active::before { background: var(--ag-accent-text); }
[data-theme="light"] .ap-badge--ok { color: var(--green-ink); }
[data-theme="light"] .ap-live { color: var(--green-ink); }
[data-theme="light"] .lds-globe { color: var(--green-ink); }

/* ---- shell additions ------------------------------------------------------ */
.ap-brand { text-decoration: none; }
.ap-link { text-decoration: none; }
.ag-userfoot { gap: 10px; }
.ag-userfoot .ap-userfoot__meta { min-width: 0; flex: 1; }
.ag-userfoot .ap-userfoot__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ag-iconbtn { display: inline-grid; place-items: center; width: 32px; height: 32px; flex: none;
  border-radius: var(--radius-md); border: 1px solid var(--border-default); background: var(--ag-raised);
  color: var(--text-muted); cursor: pointer; transition: color var(--dur-fast) var(--ease-out),
  border-color var(--dur-fast) var(--ease-out); }
.ag-iconbtn:hover { color: var(--text-strong); border-color: var(--border-strong); }
.ag-iconbtn svg { width: 16px; height: 16px; }
.ag-top__title { font-family: var(--font-display); font-weight: 700; font-size: 14px; color: var(--text-strong);
  letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.ag-top__brand { display: none; align-items: center; gap: 9px; text-decoration: none; min-width: 0; }
.ag-top__wm { font-family: var(--font-display); font-weight: 800; letter-spacing: -.02em; font-size: 15px;
  color: var(--text-strong); white-space: nowrap; }
.ag-top__wm b { color: var(--ag-accent-text); font-weight: 800; }
.ag-chip--stale { border-color: color-mix(in srgb, var(--warning) 45%, transparent); color: var(--warning); }
.ag-chip--stale .ap-dot { background: var(--warning); }
.ap-tele .ap-chip svg { width: 13px; height: 13px; }

/* impersonation banner — the operator must never forget whose view this is */
.ag-imp { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap;
  padding: 9px 16px; font-size: 12.5px; color: var(--text-strong); text-align: center;
  background: color-mix(in srgb, var(--warning) 16%, var(--ag-ground));
  border-bottom: 1px solid color-mix(in srgb, var(--warning) 45%, transparent); }
.ag-imp b { font-weight: 700; }
.ag-imp svg { width: 15px; height: 15px; color: var(--warning); flex: none; }

/* ---- page states ---------------------------------------------------------- */
.ag-banner { display: flex; align-items: flex-start; gap: 11px; padding: 12px 14px; margin-bottom: 18px;
  border-radius: var(--radius-md); font-size: 13px; line-height: 1.5; color: var(--text-body);
  border: 1px solid var(--border-default); background: var(--glass-fill); }
.ag-banner svg { width: 17px; height: 17px; flex: none; margin-top: 1px; }
.ag-banner b { color: var(--text-strong); font-weight: 600; }
.ag-banner--warn { border-color: color-mix(in srgb, var(--warning) 40%, transparent);
  background: color-mix(in srgb, var(--warning) 8%, transparent); }
.ag-banner--warn svg { color: var(--warning); }
.ag-banner--err { border-color: color-mix(in srgb, var(--error) 40%, transparent);
  background: color-mix(in srgb, var(--error) 8%, transparent); }
.ag-banner--err svg { color: var(--error); }
.ag-banner--info svg { color: var(--info); }
.ag-banner--ok { border-color: color-mix(in srgb, var(--success) 40%, transparent);
  background: color-mix(in srgb, var(--success) 8%, transparent); }
.ag-banner--ok svg { color: var(--ag-accent-text); }

.ag-skel { display: block; border-radius: var(--radius-md); background: var(--surface-hover);
  animation: ag-pulse 1.4s var(--ease-in-out) infinite; }
.ag-skel--kpi { height: 108px; }
.ag-skel--row { height: 18px; margin: 14px 0; }
.ag-skel--card { height: 220px; }
@keyframes ag-pulse { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }
.ap-empty__ic svg { color: var(--ag-accent-text); }
.ag-empty--err .ap-empty__ic { background: color-mix(in srgb, var(--error) 12%, transparent);
  border-color: color-mix(in srgb, var(--error) 30%, transparent); }
.ag-empty--err .ap-empty__ic svg { color: var(--error); }

/* ---- page head ------------------------------------------------------------ */
.ag-back { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 12px; font-size: 12.5px;
  color: var(--text-muted); text-decoration: none; }
.ag-back:hover { color: var(--text-strong); }
.ag-back svg { width: 14px; height: 14px; }
.ag-headline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ag-mid { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ---- KPIs ------------------------------------------------------------------ */
.ag-kpis { margin-bottom: 16px; }
.ag-kpis--3 { grid-template-columns: 1.35fr 1fr 1fr; }
.ag-kpi--focus { background: var(--ink-900); border-color: var(--ink-900); }
.ag-kpi--focus .ap-kpi__label { color: var(--brand); }
.ag-kpi--focus .ap-kpi__val { color: var(--mist-100); font-size: 30px; }
.ag-kpi--focus .ag-kpi__sub { color: var(--mist-300); }
.ag-kpi__sub { font-size: 12px; color: var(--text-muted); line-height: 1.4; }
.ag-kpi__sub .ap-mono { font-size: 11.5px; }
.ag-kpi__note { font-size: 13px; color: var(--mist-100); font-weight: 600; line-height: 1.35; }
.ap-kpi__val--muted { color: var(--text-muted); }

/* ---- cards / tables -------------------------------------------------------- */
.ag-card { margin-bottom: 16px; }
.ag-card--tbl { padding-bottom: 6px; }
.ag-tblwrap { margin: 0 -18px; }
.ag-tblwrap .ap-table th:first-child, .ag-tblwrap .ap-table td:first-child { padding-left: 18px; }
.ag-tblwrap .ap-table th:last-child, .ag-tblwrap .ap-table td:last-child { padding-right: 18px; }
.ap-table th.r, .ap-table td.r { text-align: right; }
.ap-table tbody tr.ag-rowlink { cursor: pointer; }
.ap-table tbody tr.ag-rowlink:focus-visible { outline: 2px solid var(--ring); outline-offset: -2px; }
.ap-table tfoot td { padding: 12px; border-top: 1px solid var(--border-strong); font-weight: 600;
  color: var(--text-strong); }
.ap-table tfoot td.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; }
.ag-pay { color: var(--ag-accent-text) !important; font-weight: 700; }
.ag-dba { color: var(--text-strong); font-weight: 600; }
.ag-dba small { display: block; font-family: var(--font-mono); font-size: 11px; font-weight: 400;
  color: var(--ag-text-fine); margin-top: 2px; }
.ag-note { font-size: 12px; color: var(--text-muted); line-height: 1.4; text-align: right; }
.ag-chev { width: 15px; height: 15px; color: var(--text-faint); vertical-align: middle; }
.ag-toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.ag-search { position: relative; flex: 1; min-width: 200px; max-width: 340px; }
.ag-search svg { position: absolute; left: 11px; top: 50%; width: 15px; height: 15px; transform: translateY(-50%);
  color: var(--text-faint); pointer-events: none; }
.ag-search .ap-input { padding-left: 34px; background: var(--ag-field); }
.ap-select { appearance: none; -webkit-appearance: none; cursor: pointer; padding-right: 32px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 52%, calc(100% - 12px) 52%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; background-color: var(--ag-field); }
.ag-month { width: auto; min-width: 170px; }

.ag-dl { display: grid; grid-template-columns: max-content 1fr; gap: 10px 18px; margin: 0; font-size: 13px; }
.ag-dl dt { color: var(--text-muted); }
.ag-dl dd { margin: 0; color: var(--text-strong); text-align: right; overflow-wrap: anywhere; }
.ag-fine { font-size: 12px; color: var(--text-muted); line-height: 1.55; margin: 10px 0 0; }
.ag-notes { margin: 4px 0 0; padding-left: 18px; font-size: 12.5px; line-height: 1.6; color: var(--text-muted); }
.ag-notes li + li { margin-top: 4px; }
.ag-split { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.ag-calc { display: flex; flex-direction: column; }
.ag-calc__row { display: flex; justify-content: space-between; gap: 14px; align-items: baseline; padding: 9px 0;
  border-bottom: 1px dashed var(--border-default); font-size: 13.5px; color: var(--text-body); }
.ag-calc__row span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.ag-calc__row .ap-mono { color: var(--text-strong); white-space: nowrap; }
.ag-calc__row small { font-family: var(--font-mono); color: var(--text-faint); margin-left: 6px; font-size: 11.5px; }
.ag-calc__row--total { border-bottom: 0; border-top: 1.5px solid var(--text-strong); margin-top: 2px;
  font-weight: 700; color: var(--text-strong); }

/* ---- settings --------------------------------------------------------------- */
.ag-form { max-width: 420px; }
.ag-form .ap-input { background: var(--ag-field); }
.ag-actions { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; margin-top: 4px; }
.ag-hint { font-size: 12px; color: var(--text-faint); margin-top: -6px; margin-bottom: 12px; }
.ag-err { font-size: 12.5px; color: var(--error); margin: 0 0 12px; }
.ag-ok { font-size: 12.5px; color: var(--ag-accent-text); margin: 0 0 12px; }
.ag-seg { display: inline-flex; }
.ag-seg button:focus-visible { outline: 2px solid var(--ring); }

/* ---- auth screens (two-pane, DS portal login kit) -------------------------- */
.lg-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr; }
.lg-hero { position: relative; overflow: hidden; display: flex; flex-direction: column;
  justify-content: space-between; gap: 32px; padding: 48px 52px 44px; border-right: 1px solid var(--border-subtle);
  background: radial-gradient(900px 520px at 30% -10%, var(--brand-tint), transparent 60%), var(--ag-ground); }
.lg-lockup { display: flex; align-items: center; gap: 14px; }
.lg-lockup .lds-globe { color: var(--brand); }
.lg-wm { font-family: var(--font-display); font-weight: 800; letter-spacing: -.02em; font-size: 19px;
  color: var(--text-strong); line-height: 1; }
.lg-wm b { color: var(--ag-accent-text); }
.lg-wm__sub { font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 1.8px; text-transform: uppercase;
  color: var(--text-faint); margin-top: 5px; }
.lg-hero__mid { max-width: 460px; }
.lg-orbit { width: 168px; height: 168px; margin-bottom: 30px; display: grid; place-items: center; position: relative;
  color: var(--brand); }
.lg-orbit::before, .lg-orbit::after { content: ""; position: absolute; border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--brand) 22%, transparent); }
.lg-orbit::before { inset: 0; }
.lg-orbit::after { inset: 24px; border-color: color-mix(in srgb, var(--brand) 12%, transparent); }
.lg-value { font-family: var(--font-display); font-weight: 700; letter-spacing: -.03em; font-size: 34px;
  line-height: 1.08; color: var(--text-strong); margin: 0 0 14px; }
.lg-value em { font-style: normal; color: var(--ag-accent-text); }
.lg-lede { color: var(--text-muted); font-size: 14.5px; line-height: 1.55; max-width: 400px; margin: 0; }
.lg-trust { display: flex; flex-direction: column; gap: 14px; margin-top: 28px; }
.lg-trust__row { display: flex; align-items: flex-start; gap: 12px; }
.lg-trust__ico { flex: none; width: 30px; height: 30px; border-radius: var(--radius-md); display: grid;
  place-items: center; background: var(--brand-tint); border: 1px solid color-mix(in srgb, var(--brand) 30%, transparent);
  color: var(--ag-accent-text); }
.lg-trust__ico svg { width: 15px; height: 15px; }
.lg-trust__t { font-size: 13px; font-weight: 600; color: var(--text-strong); line-height: 1.3; }
.lg-trust__d { font-size: 12px; color: var(--text-muted); margin-top: 2px; line-height: 1.4; }
.lg-hero__foot { font-family: var(--font-mono); font-size: 11px; color: var(--text-faint); letter-spacing: .4px; }

.lg-form { position: relative; display: grid; place-items: center; padding: 40px 32px;
  background: radial-gradient(700px 380px at 60% -10%, var(--brand-tint), transparent 60%), var(--bg-page); }
.lg-col { width: 100%; max-width: 400px; }
.lg-card { padding: 30px 30px 26px; }
.lg-card__title { font-family: var(--font-display); font-size: 22px; font-weight: 800; letter-spacing: -.4px;
  color: var(--text-strong); margin: 0; }
.lg-card__sub { color: var(--text-muted); font-size: 13px; line-height: 1.5; margin: 7px 0 22px; }
.lg-card__sub b { color: var(--text-strong); font-weight: 600; }
.lg-card .ap-input { background: var(--ag-field); }
.lg-pw-head { display: flex; align-items: baseline; justify-content: space-between; }
.lg-link { font-size: 12px; font-weight: 500; color: var(--ag-accent-text); text-decoration: none;
  background: none; border: 0; padding: 0; cursor: pointer; font-family: inherit; }
.lg-link:hover { text-decoration: underline; }
.lg-btn-full { width: 100%; padding: 12px 15px; font-size: 13.5px; }
.lg-btn-full[disabled] { opacity: .6; cursor: progress; }
.lg-foot { text-align: center; font-size: 12.5px; color: var(--text-muted); margin-top: 20px; }
.lg-meta { margin-top: 20px; display: flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-mono); font-size: 10.5px; color: var(--text-faint); letter-spacing: .4px; text-align: center; }
.lg-meta svg { width: 13px; height: 13px; flex: none; }
.lg-code { font-family: var(--font-mono); font-size: 22px; letter-spacing: .5em; text-align: center;
  padding: 12px 10px 12px calc(10px + .5em); }
.lg-steps { display: flex; gap: 6px; margin-bottom: 18px; }
.lg-steps i { flex: 1; height: 3px; border-radius: 999px; background: var(--surface-raised); }
.lg-steps i.on { background: var(--brand); }
.lg-step-label { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--text-faint); margin-bottom: 6px; }
.lg-choice { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.lg-opt { display: flex; align-items: center; gap: 12px; padding: 13px 14px; border-radius: var(--radius-md);
  border: 1px solid var(--border-default); background: var(--ag-field); cursor: pointer; text-align: left;
  color: var(--text-body); font: inherit; width: 100%;
  transition: border-color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out); }
.lg-opt:hover { border-color: var(--border-strong); }
.lg-opt[aria-checked="true"] { border-color: var(--brand); background: var(--brand-tint); }
.lg-opt__ico { flex: none; width: 34px; height: 34px; border-radius: var(--radius-md); display: grid; place-items: center;
  background: var(--brand-tint); color: var(--ag-accent-text); }
.lg-opt__ico svg { width: 16px; height: 16px; }
.lg-opt__t { display: block; font-size: 13.5px; font-weight: 600; color: var(--text-strong); }
.lg-opt__d { display: block; font-size: 12px; color: var(--text-muted); margin-top: 2px; font-family: var(--font-mono); }
.lg-req { list-style: none; padding: 0; margin: -4px 0 14px; display: flex; flex-direction: column; gap: 4px;
  font-size: 12px; color: var(--text-faint); }
.lg-req li { display: flex; align-items: center; gap: 7px; }
.lg-req li::before { content: ""; width: 6px; height: 6px; border-radius: 999px; background: var(--text-faint); }
.lg-req li.ok { color: var(--ag-accent-text); }
.lg-req li.ok::before { background: var(--ag-accent-text); }
.lg-done { text-align: center; }
.lg-done__ic { width: 52px; height: 52px; margin: 0 auto 14px; border-radius: 999px; display: grid; place-items: center;
  background: var(--brand-tint); color: var(--ag-accent-text); }
.lg-done__ic svg { width: 24px; height: 24px; }
.lg-done--err .lg-done__ic { background: color-mix(in srgb, var(--error) 12%, transparent); color: var(--error); }

/* ---- partner resources: sidebar group, app footer, sign-in screens ---------- */
.ag-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.ag-ext { width: 12px; height: 12px; flex: none; opacity: .55; }
.ap-link.ag-extlink .ag-ext { margin-left: auto; }
.ap-link.ag-extlink:hover .ag-ext, .ap-link.ag-extlink:focus-visible .ag-ext { opacity: .9; }
.ap-main > .ag-foot { position: relative; z-index: 1; }
.ag-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 20px;
  margin: 0 auto; max-width: 1360px; padding: 18px 28px 28px; border-top: 1px solid var(--border-subtle);
  font-size: 12px; color: var(--text-faint); }
.ag-foot__res { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.ag-foot__a, .lg-res__a { display: inline-flex; align-items: center; gap: 6px; color: var(--text-muted);
  text-decoration: none; font-weight: 500; border-radius: var(--radius-md); }
.ag-foot__a svg:first-child, .lg-res__a svg:first-child { width: 14px; height: 14px; flex: none; }
.ag-foot__a:hover, .lg-res__a:hover { color: var(--ag-accent-text); }
.ag-foot__a:hover span:not(.ag-sr), .lg-res__a:hover span:not(.ag-sr) { text-decoration: underline; }
.ag-foot__legal { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .3px; color: var(--ag-text-fine); }
.lg-res { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 20px; margin-top: 14px; font-size: 12.5px; }

/* ---- account tabs, tickets (Task 11) ---------------------------------------- */
.ag-tabs { margin: 4px 0 16px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.ag-tabs::-webkit-scrollbar { display: none; }
.ag-tabs .ap-tab { flex: none; text-decoration: none; white-space: nowrap; }
.ag-tabs .ap-tab:focus-visible { outline: 2px solid var(--ring); outline-offset: -2px; }
[data-theme="light"] .ap-tab.active { color: var(--ag-accent-text); }
[data-theme="light"] .ap-tabs { background: var(--surface-card); box-shadow: var(--shadow-sm); }
.ag-filter { margin-bottom: 14px; }
.ag-tform { max-width: 640px; }
.ag-tform--wide { max-width: 720px; }
.ag-tform .ap-input, .ag-textarea { background-color: var(--ag-field); } /* not the shorthand: keeps .ap-select's arrow */
.ap-table .ap-badge { white-space: nowrap; }
.ag-textarea { display: block; min-height: 108px; resize: vertical; line-height: 1.5; padding: 10px 12px;
  border-radius: var(--radius-md); border: 1px solid var(--border-default); color: var(--text-strong); }
[data-theme="light"] .ap-textarea { background: var(--surface-card); }
.ag-file { padding: 8px 10px; cursor: pointer; }
.ag-file::file-selector-button { margin-right: 10px; padding: 5px 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-default); background: var(--ag-raised); color: var(--text-strong); font: inherit;
  font-size: 12.5px; cursor: pointer; }
.ag-check { display: flex; align-items: flex-start; gap: 10px; margin: 2px 0 16px; cursor: pointer; font-size: 13px;
  color: var(--text-body); }
.ag-check input { width: 16px; height: 16px; margin: 2px 0 0; flex: none; accent-color: var(--brand); }
.ag-check b { display: block; color: var(--text-strong); font-weight: 600; }
.ag-check small { display: block; color: var(--text-muted); font-size: 12px; margin-top: 2px; line-height: 1.4; }
.ag-check input:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

.ag-thread { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.ag-msg { padding: 12px 14px; border-radius: var(--radius-md); border: 1px solid var(--border-subtle);
  background: var(--glass-fill); max-width: 92%; }
.ag-msg--mine { align-self: flex-end; border-color: color-mix(in srgb, var(--brand) 35%, transparent);
  background: var(--brand-tint); }
.ag-msg__meta { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 6px;
  font-size: 12px; color: var(--text-muted); }
.ag-msg__meta b { color: var(--text-strong); font-weight: 600; }
.ag-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13.5px; line-height: 1.55; color: var(--text-body); }
.ag-docs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.ag-doc { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle); text-decoration: none; color: var(--text-strong); font-size: 13px; min-width: 0; }
.ag-doc:hover { border-color: var(--border-strong); }
.ag-doc:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
.ag-doc svg { width: 16px; height: 16px; flex: none; color: var(--ag-accent-text); }
.ag-doc span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ag-doc small { font-family: var(--font-mono); font-size: 11px; color: var(--text-faint); flex: none; }

/* ---- applications (Task 12) ------------------------------------------------ */
.ag-count { font-family: var(--font-mono); font-size: 11px; color: var(--text-faint); margin-left: 4px; }
.ap-seg button.active .ag-count { color: inherit; }
.ag-opt { font-weight: 400; color: var(--text-faint); margin-left: 4px; }
.ag-hint--after { margin-top: 6px; margin-bottom: 0; }
.ag-fine--top { margin-top: 0; }
.ag-actions--top { margin-top: 16px; }
.ag-subhead { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--text-muted); margin: 16px 0 6px; }
.ag-linkbox { margin-bottom: 14px; }
.ag-linkrow { display: flex; gap: 8px; align-items: stretch; flex-wrap: wrap; }
.ag-linkrow .ap-input { flex: 1 1 220px; min-width: 0; background: var(--ag-field); }
.ag-linkrow .ap-btn { flex: none; }
.ag-mono-input { font-family: var(--font-mono); font-size: 12px; text-overflow: ellipsis; }
.ag-copied:empty { display: none; }
.ag-copied { margin: 8px 0 0; }
.ag-sendlink { margin-top: 6px; padding-top: 14px; border-top: 1px solid var(--border-subtle); max-width: none; }
.ag-checks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.ag-check-row { display: flex; align-items: center; gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--border-subtle);
  font-size: 13px; color: var(--text-body); }
.ag-check-row:last-child { border-bottom: 0; }
.ag-check-row__n { flex: 1; min-width: 0; overflow-wrap: anywhere; }

/* ---- forms & e-sign (Task 15, web/agent/forms.js) ----------------------------
   Box geometry over a page image is the only thing set from JS (element.style
   left/top/width/height, font-size in cqw); everything else is a class. Page images
   are white paper in both themes, so marks ON a page use ink (--fm-sc); signer
   colours in the app chrome use --fm-ui, which brightens on the dark theme. */
.fm-s0 { --fm-sc: var(--green-700); --fm-ui: var(--brand); }
.fm-s1 { --fm-sc: var(--indigo-600); --fm-ui: var(--indigo-bright); }
[data-theme="light"] .fm-s0 { --fm-ui: var(--green-700); }
[data-theme="light"] .fm-s1 { --fm-ui: var(--indigo-600); }
.fm-tabs { margin-top: 0; }
.fm-fine { margin: 6px 0 16px; max-width: 720px; }
.fm-fine--tight { margin: 8px 0 0; }
.ag-fine svg { width: 13px; height: 13px; vertical-align: -2px; }
.fm-for a { font-weight: 600; margin-left: 4px; }
.fm-for .ap-mono { color: var(--text-muted); font-size: 12px; }

/* library */
.fm-lib { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; margin-bottom: 8px; }
.fm-card { display: flex; flex-direction: column; gap: 8px; padding: 18px; text-decoration: none; color: var(--text-body);
  min-height: 176px; transition: border-color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out); }
.fm-card:hover { border-color: color-mix(in srgb, var(--brand) 45%, transparent); transform: translateY(-1px); }
.fm-card:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.fm-card__ic { width: 34px; height: 34px; border-radius: var(--radius-md); display: grid; place-items: center;
  background: var(--brand-tint); color: var(--ag-accent-text); }
.fm-card__ic svg { width: 17px; height: 17px; }
.fm-card__t { font-family: var(--font-display); font-weight: 700; font-size: 15px; letter-spacing: -.01em;
  color: var(--text-strong); line-height: 1.25; }
.fm-card__d { font-size: 12.5px; line-height: 1.5; color: var(--text-muted); flex: 1; }
.fm-card__meta { display: flex; align-items: center; gap: 10px; min-width: 0; }
.fm-card__meta .ap-badge { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fm-card__pg { white-space: nowrap; }
.fm-card__pg { font-family: var(--font-mono); font-size: 11px; color: var(--text-faint); }
.fm-card__go { margin-left: auto; display: inline-flex; align-items: center; gap: 2px; font-size: 12.5px; font-weight: 600;
  color: var(--ag-accent-text); }
.fm-card__go svg { width: 14px; height: 14px; }

/* stepper */
.fm-steps { list-style: none; margin: 0 0 18px; padding: 0; display: flex; gap: 6px; }
.fm-steps__i { flex: 1; min-width: 0; }
.fm-steps__i > a, .fm-steps__i > button, .fm-steps__i > span { display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 9px 10px 10px; border: 0; border-top: 3px solid var(--surface-raised); background: none; font: inherit;
  font-size: 12.5px; color: var(--text-faint); text-decoration: none; text-align: left; }
.fm-steps__i > a, .fm-steps__i > button { cursor: pointer; }
.fm-steps__i > a:hover, .fm-steps__i > button:hover { color: var(--text-strong); }
.fm-steps__i > a:focus-visible, .fm-steps__i > button:focus-visible { outline: 2px solid var(--ring); outline-offset: -2px; }
.fm-steps__n { flex: none; width: 22px; height: 22px; border-radius: 999px; display: grid; place-items: center;
  font-family: var(--font-mono); font-size: 11px; border: 1px solid var(--border-default); }
.fm-steps__n svg { width: 12px; height: 12px; }
.fm-steps__l { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fm-steps__i--done > * { border-top-color: var(--brand); color: var(--text-muted); }
.fm-steps__i--done .fm-steps__n { background: var(--brand-tint); border-color: transparent; color: var(--ag-accent-text); }
.fm-steps__i--on > span { border-top-color: var(--brand); color: var(--text-strong); font-weight: 600; }
.fm-steps__i--on .fm-steps__n { background: var(--brand); border-color: var(--brand); color: var(--brand-contrast); }

/* merchant picker */
.fm-pickcard { max-width: 760px; padding: 8px; }
.fm-pick { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: var(--radius-md);
  text-decoration: none; color: var(--text-body); }
.fm-pick:hover { background: var(--surface-hover); }
.fm-pick:focus-visible { outline: 2px solid var(--ring); outline-offset: -2px; }
.fm-pick + .fm-pick { border-top: 1px solid var(--border-subtle); }
.fm-pick__ic { flex: none; width: 32px; height: 32px; border-radius: var(--radius-md); display: grid; place-items: center;
  background: var(--surface-raised); color: var(--text-muted); }
.fm-pick__ic svg { width: 16px; height: 16px; }
.fm-pick__b { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.fm-pick__b b { color: var(--text-strong); font-weight: 600; font-size: 13.5px; overflow-wrap: anywhere; }
.fm-pick__b small { font-size: 12px; color: var(--text-muted); }
.fm-pick--new { margin-bottom: 6px; border: 1px dashed color-mix(in srgb, var(--brand) 45%, transparent); }
.fm-pick--new .fm-pick__ic { background: var(--brand-tint); color: var(--ag-accent-text); }
.fm-pick__search { display: block; max-width: none; margin: 6px 4px 8px; }
.fm-picklist .ap-empty { padding: 18px 12px; }

/* fill in */
.fm-fill { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.fm-form { min-width: 0; }
.fm-group .ap-card__head { margin-bottom: 4px; }
.fm-group h2.ap-card__title { margin: 0; }
.fm-group--merchant { background: transparent; border-style: dashed; }
.fm-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 2px 14px; }
.fm-f { min-width: 0; margin-bottom: 10px; }
.fm-f--wide, .fm-checks { grid-column: 1 / -1; }
.fm-f .ap-input, .fm-f .ag-textarea { width: 100%; background-color: var(--ag-field); }
.fm-in[aria-invalid="true"] { border-color: var(--error); }
.fm-ferr { font-size: 12px; color: var(--error); margin: 4px 0 0; }
.fm-ferr:empty { display: none; }
.fm-fnote { font-size: 11.5px; color: var(--text-faint); margin: 5px 0 0; line-height: 1.45; }
.fm-adorn { position: relative; }
.fm-adorn__pre, .fm-adorn__suf { position: absolute; top: 50%; transform: translateY(-50%); font-family: var(--font-mono);
  font-size: 13px; color: var(--text-faint); pointer-events: none; }
.fm-adorn__pre { left: 11px; }
.fm-adorn__suf { right: 11px; }
.fm-in--pre { padding-left: 24px; }
.fm-in--suf { padding-right: 26px; }
.fm-locked { display: flex; align-items: center; gap: 8px; min-height: 38px; padding: 8px 11px; border-radius: var(--radius-md);
  border: 1px dashed var(--border-default); background: var(--surface-sunken); color: var(--text-muted); font-size: 13px; }
.fm-locked svg { width: 14px; height: 14px; flex: none; color: var(--text-faint); }
.fm-locked span { min-width: 0; overflow-wrap: anywhere; }
.fm-locked--calc { border-style: solid; color: var(--text-strong); font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.fm-locked--calc svg { color: var(--ag-accent-text); }
.fm-f input[type="date"] { color-scheme: dark; }
[data-theme="light"] .fm-f input[type="date"] { color-scheme: light; }
.fm-mbox { margin: 2px 0 8px; padding: 10px 12px; border-radius: var(--radius-md); border: 1px dashed var(--border-default);
  background: var(--surface-sunken); }
.fm-mbox__h { display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 600; color: var(--text-muted); }
.fm-mbox__h svg, .fm-mbox__i svg, .fm-mbox .fm-fnote svg { width: 13px; height: 13px; flex: none; color: var(--text-faint); }
.fm-mbox__list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.fm-mbox__i { display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px; border-radius: 999px;
  border: 1px solid var(--border-subtle); background: var(--ag-raised); font-size: 12px; color: var(--text-body); }
.fm-mbox .fm-fnote { display: flex; gap: 6px; align-items: flex-start; }
.fm-checks { border: 0; padding: 0; margin: 0 0 8px; min-width: 0; }
.fm-checks legend { margin-bottom: 6px; padding: 0; }
.fm-check { margin: 0 0 8px; }
.fm-sumlist { margin: 4px 0 0; padding-left: 18px; }
.fm-bar { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: center; margin: 4px 0 16px; }
.fm-bar .ap-btn svg { width: 15px; height: 15px; }
.fm-bar--page { margin-top: 16px; }
.fm-busy { cursor: progress; opacity: .7; }

/* preview pane + pages */
.fm-preview { position: sticky; top: 72px; min-width: 0; border: 1px solid var(--border-subtle); border-radius: var(--radius-lg);
  background: var(--glass-fill); padding: 10px; }
.fm-preview__sum { display: flex; align-items: center; gap: 8px; padding: 4px 4px 10px; cursor: pointer; list-style: none;
  font-size: 13px; font-weight: 600; color: var(--text-strong); }
.fm-preview__sum::-webkit-details-marker { display: none; }
.fm-preview__sum svg { width: 15px; height: 15px; color: var(--ag-accent-text); }
.fm-preview__sum small { margin-left: auto; font-weight: 400; font-size: 11.5px; color: var(--text-faint); }
.fm-preview__sum:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: var(--radius-sm); }
.fm-preview:not([open]) .fm-preview__sum { padding-bottom: 4px; }
.fm-preview__pages { max-height: calc(100vh - 150px); overflow: auto; display: flex; flex-direction: column; gap: 12px; }
.fm-page { position: relative; container-type: inline-size; background: var(--white); border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm); overflow: hidden; line-height: 0; flex: none; /* never squeezed by a scrolling column: the boxes are % of it */ }
.fm-page__img { display: block; width: 100%; height: auto; user-select: none; -webkit-user-drag: none; border-radius: inherit; }
.fm-page__img--loading { opacity: .45; }
.fm-page__n { position: absolute; right: 8px; bottom: 8px; padding: 2px 7px; border-radius: 999px; line-height: 1.6;
  font-family: var(--font-mono); font-size: 10.5px; background: var(--ink-900); color: var(--mist-100); }
.fm-layer { position: absolute; inset: 0; }
.fm-ov { position: absolute; box-sizing: border-box; display: flex; align-items: center; overflow: hidden; line-height: 1.1;
  font-family: Helvetica, Arial, sans-serif; color: var(--ink-900); white-space: nowrap; padding: 0 1px; }
.fm-ov--box[data-focus] { cursor: pointer; }
.fm-ov--box[data-focus]:hover { background: color-mix(in srgb, var(--blue) 10%, transparent); }
.fm-ov--multi { white-space: pre-wrap; align-items: flex-start; overflow-wrap: anywhere; }
.fm-ov--check { justify-content: center; }
.fm-ov--check svg { width: 90%; height: 90%; }
.fm-ov--merchant { border: 1px dashed color-mix(in srgb, var(--green-700) 70%, transparent);
  background: color-mix(in srgb, var(--green) 10%, transparent); border-radius: 2px; }
.fm-ov--active { outline: 2px solid var(--blue-600); outline-offset: 1px; background: color-mix(in srgb, var(--blue) 12%, transparent); }

/* signature editor */
.fm-editor { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 18px; align-items: start; }
.fm-tools { position: sticky; top: 72px; padding: 16px; }
.fm-tools__sec + .fm-tools__sec { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border-subtle); }
.fm-tools .ag-subhead { margin-top: 0; }
.fm-signer { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; margin-bottom: 6px; border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle); background: none; font: inherit; color: var(--text-body); cursor: pointer; text-align: left; }
.fm-signer:hover { border-color: var(--border-strong); }
.fm-signer:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
.fm-signer--on { border-color: var(--fm-ui); background: color-mix(in srgb, var(--fm-ui) 12%, transparent); }
.fm-signer__b { display: flex; flex-direction: column; min-width: 0; }
.fm-signer__b b { font-size: 13px; color: var(--text-strong); font-weight: 600; }
.fm-signer__b small { font-size: 11.5px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fm-swatch { flex: none; width: 12px; height: 12px; border-radius: 3px; background: var(--fm-ui); }
.fm-addsigner { margin-top: 4px; }
.fm-palette { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.fm-pal { display: flex; align-items: center; gap: 7px; padding: 8px 9px; border-radius: var(--radius-md); border: 1px solid var(--border-default);
  background: var(--ag-raised); color: var(--text-strong); font: inherit; font-size: 12.5px; cursor: pointer; text-align: left; min-width: 0; }
.fm-pal:hover { border-color: var(--brand); }
.fm-pal:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
.fm-pal svg { width: 14px; height: 14px; flex: none; color: var(--ag-accent-text); }
.fm-pal span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fm-prop__t { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text-strong); margin-bottom: 10px; }
.fm-prop__t svg { width: 15px; height: 15px; color: var(--ag-accent-text); flex: none; }
.fm-prop__seg { display: flex; margin-bottom: 10px; }
.fm-prop__seg button { flex: 1; }
.fm-prop__seg button[disabled] { opacity: .45; cursor: not-allowed; }
.fm-prop__req { margin-bottom: 10px; }
.fm-prop__del[disabled] { opacity: .45; cursor: not-allowed; }
.fm-canvas { min-width: 0; padding: 4px 12px 12px 4px; } /* room for a corner handle / focus ring past the page edge */
/* the editor page doesn't clip: a box flush with the edge keeps its whole resize handle and focus ring */
.fm-editor .fm-page { overflow: visible; }
.fm-live { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.fm-pages { display: flex; flex-direction: column; gap: 16px; }
.fm-fld { position: absolute; box-sizing: border-box; display: flex; align-items: center; gap: 4px; padding: 0 4px; overflow: visible;
  border: 1.5px solid var(--fm-sc); border-radius: 4px; background: color-mix(in srgb, var(--fm-sc) 14%, transparent);
  color: var(--fm-sc); cursor: move; touch-action: none; line-height: 1; font-family: var(--font-sans); }
.fm-fld:focus-visible { outline: 2px solid var(--blue-600); outline-offset: 2px; z-index: 6; }
.fm-fld--sel { z-index: 5; box-shadow: 0 0 0 3px color-mix(in srgb, var(--fm-sc) 30%, transparent); }
.fm-fld--opt { border-style: dashed; }
.fm-fld__ic { flex: none; display: flex; }
.fm-fld__ic svg { width: 12px; height: 12px; }
.fm-fld__l { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: clamp(6px, 1.25cqw, 10.5px); font-weight: 700; }
@container (max-width: 560px) { .fm-fld__ic { display: none; } .fm-fld { padding: 0 2px; } }
.fm-fld--tiny { padding: 0; justify-content: center; }
.fm-fld--tiny .fm-fld__l { display: none; }
.fm-fld--tiny .fm-fld__ic svg { width: 9px; height: 9px; }
.fm-fld__rz { position: absolute; right: -6px; bottom: -6px; width: 12px; height: 12px; border-radius: 3px; background: var(--fm-sc);
  border: 2px solid var(--white); cursor: nwse-resize; touch-action: none; }
@media (pointer: coarse) { .fm-fld__rz { right: -11px; bottom: -11px; width: 22px; height: 22px; } }
.fm-fld--ro { cursor: default; background: color-mix(in srgb, var(--fm-sc) 10%, transparent); }

/* recipient */
.fm-recip { max-width: 760px; }
.fm-signerset { border: 1px solid var(--border-subtle); border-left: 3px solid var(--fm-ui); border-radius: var(--radius-md);
  padding: 12px 14px 10px; margin: 0 0 14px; min-width: 0; }
.fm-signerset__l { display: flex; align-items: center; gap: 8px; padding: 0 6px; font-size: 13px; font-weight: 600; color: var(--text-strong); }
.fm-signerset .ap-btn { margin-top: 4px; }
.fm-msg { margin-top: 14px; }

/* review */
.fm-review { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.fm-review__pages { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.fm-review__side { position: sticky; top: 72px; }
.fm-dl { grid-template-columns: max-content minmax(0, 1fr); margin-bottom: 16px; }
.fm-dl dd small { display: block; font-size: 11.5px; color: var(--text-muted); margin-top: 2px; font-family: var(--font-mono); }
.fm-dl__msg { white-space: pre-wrap; text-align: left !important; font-size: 12.5px; color: var(--text-body) !important; }
.fm-send { width: 100%; justify-content: center; padding: 12px 15px; }
.fm-send[disabled] { opacity: .6; cursor: not-allowed; }
.fm-review__edit { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border-subtle); }

/* sent list */
.fm-cellstack { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.fm-cellstack small { font-family: var(--font-mono); font-size: 11px; color: var(--text-faint); }
.fm-who { display: flex; align-items: baseline; gap: 8px; font-size: 13px; }
.fm-who b { font-weight: 500; color: var(--text-strong); }
.fm-who__st { font-size: 11px; font-family: var(--font-mono); color: var(--text-faint); }
.fm-who__st--signed { color: var(--ag-accent-text); }
.fm-who__st--viewed { color: var(--warning); }
.fm-who__st--declined { color: var(--error); }
.fm-acts { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.fm-acts .ap-btn { white-space: nowrap; text-decoration: none; }
.fm-acts .ap-btn svg { width: 13px; height: 13px; }
.fm-danger:hover { color: var(--error); border-color: color-mix(in srgb, var(--error) 50%, transparent); }
.fm-subcard { max-width: 640px; }
.fm-table td { vertical-align: top; }

@media (max-width: 1180px) {
  .fm-review { grid-template-columns: minmax(0, 1fr) 300px; }
}
@media (max-width: 1000px) {
  .fm-fill { grid-template-columns: 1fr; }
  .fm-preview { position: static; order: -1; }
  .fm-preview__pages { max-height: 70vh; }
  .fm-editor { grid-template-columns: 1fr; }
  .fm-tools { position: static; order: 1; }
  .fm-canvas { order: 0; }
  .fm-palette { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); }
  .fm-review { grid-template-columns: 1fr; }
  .fm-review__side { position: static; order: -1; }
}
@media (max-width: 640px) {
  .fm-steps { gap: 3px; }
  .fm-steps__i > a, .fm-steps__i > button, .fm-steps__i > span { justify-content: center; padding: 8px 2px; }
  .fm-steps__l { display: none; }
  .fm-steps__i--on .fm-steps__l { display: inline; }
  .fm-steps__i--on { flex: 2.4; }
  .fm-fields { grid-template-columns: 1fr; }
  .fm-bar .ap-btn { flex: 1; justify-content: center; }
  .fm-lib { grid-template-columns: 1fr; }
  .fm-card { min-height: 0; }
  .fm-acts { justify-content: flex-start; }
  .ag-tblwrap .ag-stack td.fm-acts-td { display: block; text-align: left; }
  .ag-stack td.fm-acts-td::before { display: block; margin-bottom: 6px; }
}

/* ---- mobile bottom nav ------------------------------------------------------ */
.ag-bn { display: none; }
.lg-mobile-brand { display: none; align-items: center; gap: 12px; margin: 8px 0 22px; }

@media (max-width: 1100px) {
  .ag-kpis--3 { grid-template-columns: 1fr 1fr; }
  .ag-kpis--3 > :first-child { grid-column: 1 / -1; }
}
@media (max-width: 900px) {
  /* WCAG 2.4.11: a focused control scrolled into view clears the fixed bottom bar */
  html { scroll-padding-bottom: calc(var(--ag-bottomnav-h) + env(safe-area-inset-bottom) + 8px); }
  .ap-shell { grid-template-columns: 1fr; }
  .ap-side { display: none; }
  .ap-top { padding: 0 16px; }
  .ag-top__brand { display: inline-flex; }
  .ag-top__title { display: none; }
  .ap-page { padding: 20px 16px 28px; }
  .ag-foot { padding: 16px 16px calc(var(--ag-bottomnav-h) + env(safe-area-inset-bottom) + 24px);
    flex-direction: column; align-items: flex-start; }
  .ap-h1 { font-size: 23px; }
  .ag-split { grid-template-columns: 1fr; }
  .ag-bn { display: grid; grid-template-columns: repeat(7, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    height: calc(var(--ag-bottomnav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--ag-ground) 90%, transparent);
    -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); border-top: 1px solid var(--border-subtle); }
  [data-theme="light"] .ag-bn { background: color-mix(in srgb, var(--surface-card) 92%, transparent); }
  .ag-bn a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    font-size: 11px; font-weight: 500; color: var(--text-muted); text-decoration: none; }
  .ag-bn a svg { width: 20px; height: 20px; }
  .ag-bn a.active { color: var(--ag-accent-text); font-weight: 600; }
  .lg-wrap { grid-template-columns: 1fr; }
  .lg-hero { display: none; }
  .lg-form { padding: 28px 16px; align-content: start; }
  .lg-mobile-brand { display: flex; }
}
@media (max-width: 640px) {
  .ap-grid--kpi, .ag-kpis--3 { grid-template-columns: 1fr 1fr; gap: 12px; }
  .ap-grid--kpi > :first-child, .ag-kpis--3 > :first-child { grid-column: 1 / -1; }
  .ap-grid--kpi .ap-card:not(:first-child), .ag-kpis--3 .ap-card:not(:first-child) { padding: 14px; }
  .ap-grid--kpi .ap-card:not(:first-child) .ap-kpi__val,
  .ag-kpis--3 .ap-card:not(:first-child) .ap-kpi__val { font-size: var(--fs-metric-sm); }
  .ag-hide-sm { display: none !important; }
  .ap-head { align-items: stretch; }
  .ap-actions, .ag-toolbar { width: 100%; }
  .ag-search { max-width: none; }
  .ag-month { flex: 1; }
  .ap-tele .ag-chip-hide { display: none; }
  .lg-card { padding: 24px 20px 22px; }
  /* tables become stacked cards: one record per block, label on the left */
  .ag-stack thead { display: none; }
  .ag-stack, .ag-stack tbody, .ag-stack tfoot, .ag-stack tr, .ag-stack td { display: block; width: 100%; }
  .ag-stack tr { padding: 10px 18px; border-bottom: 1px solid var(--border-subtle); }
  .ag-stack tbody tr:hover { background: transparent; }
  .ag-tblwrap .ag-stack td, .ag-tblwrap .ag-stack td:first-child, .ag-tblwrap .ag-stack td:last-child {
    display: flex; justify-content: space-between; gap: 14px; padding: 4px 0; border: 0; text-align: right; }
  .ag-stack td::before { content: attr(data-label); font-family: var(--font-mono); font-size: 10px; letter-spacing: 1px;
    text-transform: uppercase; color: var(--text-muted); text-align: left; padding-top: 2px; flex: none; }
  .ag-stack td.ag-td-head { padding-bottom: 6px; }
  .ag-stack td.ag-td-head::before { content: none; }
  .ag-stack td.ag-td-head > * { text-align: left; }
  .ag-stack td.ag-td-chev { display: none !important; }
  .ag-stack tfoot tr { border-top: 1px solid var(--border-strong); border-bottom: 0; }
  .ag-stack tfoot td { border-top: 0; }
  .ag-note { max-width: 62%; }
  .ag-msg { max-width: 100%; }
  .ag-tabs { display: flex; width: 100%; }
  .ag-tabs .ap-tab { flex: 1 1 auto; min-width: 0; padding: 7px 6px; font-size: 12.5px; text-align: center; }
  .ag-msg__meta { flex-direction: column; gap: 2px; }
  .ag-bn a { font-size: 10.5px; }
}
@media (prefers-reduced-motion: reduce) {
  .ag-skel { animation: none; }
  html { scroll-behavior: auto; }
}
