/* Ascent Select - UI
   Soft-grey canvas, white cards, Ascent blue accent, Inter. Compact + professional.
   Aesthetic aligned with the Ascent console design system. */

:root {
  --bg:         #fafafa;
  --surface:    #ffffff;
  --soft:       #fafafa;
  --text:       #1a1a1a;
  --head:       #111827;
  --muted:      #6b7280;
  --muted-2:    #9ca3af;
  --line:       #e5e7eb;
  --line-2:     #d1d5db;
  --brand:      #005bea;
  --brand-ink:  #0050cf;
  --brand-soft: #eaf1ff;
  --ok:         #0a7d33;
  --ok-bg:      #e7f6ec;
  --warn:       #8a6d00;
  --warn-bg:    #fbf3d8;
  --err:        #b42318;
  --err-bg:     #fdecea;
  --radius:     8px;
  --radius-sm:  6px;
  --sidebar-w:  224px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-weight: 400;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-weight: 600; color: var(--head); margin: 0; }
h1 { font-size: 18px; letter-spacing: -0.01em; }
h2 { font-size: 15px; }
h3 { font-size: 13px; }

/* ---------- layout shell (Ascent Kanban / Repo) ---------- */
body.has-sidebar .shell { margin-left: var(--sidebar-w); min-width: 0; }
.shell { display: flex; flex-direction: column; min-height: 100vh; }
.wrap { padding: 22px 26px; flex: 1; max-width: 1180px; width: 100%; }
.wrap-narrow { max-width: 560px; }

.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w); background: var(--surface);
  border-right: .5px solid var(--line); display: flex; flex-direction: column;
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 40;
}
.sidebar .brand, .sidebar-brand { padding: 9px 18px 8px; border-bottom: .5px solid var(--line); display: block; }
.sidebar-brand img { height: 45px; width: auto; display: block; }
.sidenav { padding: 4px 10px; flex: 1; overflow-y: auto; }
.sidenav a {
  display: flex; align-items: center; gap: 9px; padding: 4px 10px; border-radius: 6px;
  color: #374151; font-size: 13px; margin-bottom: 1px;
}
.sidenav a:hover { background: var(--soft); text-decoration: none; }
.sidenav a.on { background: var(--brand-soft); color: var(--brand); font-weight: 500; }
.sidenav a svg { width: 16px; height: 16px; flex: 0 0 16px; stroke: currentColor; fill: none; stroke-width: 1.6; }
.sidenav a .badge { margin-left: auto; }
.navgroup { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted-2); padding: 6px 10px 2px; }
.navgroup:first-child { padding-top: 2px; }

.whoami { padding: 6px 16px 5px; border-top: .5px solid var(--line); }
.whoami-name { font-weight: 500; font-size: 13px; color: #111827; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.whoami-mail { font-size: 11.5px; color: var(--muted-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar .signout { padding: 2px 10px 6px; }
.sidebar .signout a { display: flex; align-items: center; gap: 9px; padding: 6px 10px; border-radius: 6px; color: #374151; font-size: 13.5px; }
.sidebar .signout a:hover { background: var(--err-bg); color: var(--err); text-decoration: none; }
.sidebar .signout a svg { width: 16px; height: 16px; flex: 0 0 16px; stroke: currentColor; fill: none; stroke-width: 1.6; }
.sidebar .powered { padding: 9px 18px; border-top: .5px solid var(--line); }
.sidebar .powered img { height: 28px; width: auto; display: block; }

/* ---------- mobile top bar (checkbox toggle) ---------- */
.navtoggle { display: none; }
.mobilebar { display: none; align-items: center; gap: 10px; padding: 10px 14px; background: var(--surface); border-bottom: .5px solid var(--line); position: sticky; top: 0; z-index: 30; }
.mobilebar .brand img { height: 26px; display: block; }
.burger { display: inline-flex; flex-direction: column; gap: 4px; border: .5px solid var(--line-2); background: #fff; border-radius: 6px; padding: 8px 9px; cursor: pointer; }
.burger span { width: 16px; height: 1.7px; background: #374151; display: block; border-radius: 2px; }
.nav-scrim { display: none; position: fixed; inset: 0; background: rgba(17,24,39,.35); z-index: 35; }

/* ------------------------------------------------------------- Headings */
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 18px; flex-wrap: wrap;
}
.page-head h1 { margin-bottom: 3px; }
.lede { margin: 0; color: var(--muted); font-size: 13px; max-width: 60ch; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- Cards */
.card {
  background: var(--surface);
  border: 0.5px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
.card + .card { margin-top: 16px; }
.card-h {
  padding: 13px 16px; border-bottom: 0.5px solid var(--line);
  font-weight: 500; font-size: 13.5px; color: var(--head);
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
.card-b { padding: 16px; }
.table-card { padding: 0; overflow: hidden; }
.empty { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty p { margin: 0 0 16px; }

/* --------------------------------------------------------------- Tables */
.grid { width: 100%; border-collapse: collapse; background: var(--surface); }
.grid thead th {
  text-align: left; font-size: 11.5px; font-weight: 500;
  letter-spacing: 0.03em; text-transform: uppercase; color: var(--muted);
  padding: 11px 16px; border-bottom: 0.5px solid var(--line);
  background: var(--soft); white-space: nowrap;
}
.grid tbody td { padding: 11px 16px; border-bottom: 0.5px solid var(--line); vertical-align: middle; font-size: 13px; }
.grid tbody tr:last-child td { border-bottom: none; }
.grid tbody tr:hover { background: #fcfcfd; }

.col-price, .col-total, .col-qty { white-space: nowrap; }
.col-action { width: 1%; white-space: nowrap; }
.col-desc { color: var(--muted); max-width: 380px; }

.sku { font-size: 12px; color: var(--muted-2); font-variant-numeric: tabular-nums; }
.name { display: block; font-weight: 500; color: var(--head); }
.col-name .sku { display: block; margin-top: 2px; }
.price { font-variant-numeric: tabular-nums; }
.tag {
  display: inline-block; margin-top: 4px;
  font-size: 10.5px; color: var(--muted); background: var(--soft);
  border: 0.5px solid var(--line); border-radius: 999px; padding: 1px 8px;
}

/* --------------------------------------------------------------- Badges */
.badge {
  display: inline-flex; align-items: center; min-width: 18px; justify-content: center;
  padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 500;
  color: #fff; background: var(--brand); line-height: 1.6;
}
.pill {
  display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 500; border: 0.5px solid var(--line-2);
  color: var(--muted); background: var(--surface); line-height: 1.6;
}
.pill.green { color: var(--ok); background: var(--ok-bg); border-color: #bfe6cb; }
.pill.blue  { color: var(--brand); background: var(--brand-soft); border-color: #c9dcff; }
.pill.amber { color: var(--warn); background: var(--warn-bg); border-color: #ecdca0; }
.pill.red   { color: var(--err); background: var(--err-bg); border-color: #f0c4bf; }
.pill.grey  { color: var(--muted); background: var(--soft); }

.row-actions { display: flex; gap: 14px; }
.row-actions a { color: var(--brand); font-size: 13px; }
.link-remove {
  background: none; border: none; color: var(--muted-2);
  font: inherit; font-size: 12.5px; cursor: pointer; padding: 0;
}
.link-remove:hover { color: var(--err); }

/* ------------------------------------------------------------- Stepper */
.add-row { display: flex; align-items: center; gap: 10px; }
.stepper {
  display: inline-flex; align-items: center;
  border: 0.5px solid var(--line-2); border-radius: var(--radius-sm);
  overflow: hidden; height: 32px; background: var(--surface);
}
.step {
  width: 30px; height: 30px; border: none; background: var(--surface);
  color: var(--text); font-size: 15px; cursor: pointer; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
}
.step:hover { background: var(--soft); }
.step-qty {
  width: 34px; height: 30px; border: none; text-align: center;
  font: inherit; font-size: 13px; color: var(--text);
  font-variant-numeric: tabular-nums; background: transparent;
  border-left: 0.5px solid var(--line-2); border-right: 0.5px solid var(--line-2);
}
.step-qty:focus { outline: none; }

/* --------------------------------------------------------------- Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font: inherit; font-size: 13px; font-weight: 500;
  padding: 8px 13px; border-radius: var(--radius-sm);
  border: 0.5px solid var(--line-2); background: var(--surface); color: var(--text);
  cursor: pointer; white-space: nowrap;
  transition: background .14s ease, border-color .14s ease, color .14s ease;
}
.btn:hover { background: var(--soft); text-decoration: none; }
.btn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.7; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-ink); border-color: var(--brand-ink); color: #fff; }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--line-2); }
.btn-ghost:hover { background: var(--soft); }
.btn-add { padding: 8px 18px; }
.btn-block { display: flex; width: 100%; margin-top: 14px; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }

/* ------------------------------------------------------------- Summary */
.cart-layout, .checkout-layout, .confirm-layout {
  display: grid; grid-template-columns: 1fr 320px; gap: 20px; align-items: start;
}
.summary h2 { margin-bottom: 16px; }
.sum-row {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 7px 0; font-size: 13.5px; color: var(--muted);
}
.sum-row span:last-child { color: var(--text); font-variant-numeric: tabular-nums; }
.sum-total {
  margin-top: 6px; padding-top: 12px; border-top: 0.5px solid var(--line);
  font-size: 15px; font-weight: 600; color: var(--head);
}
.sum-total span:last-child { font-weight: 600; }
.sum-items { list-style: none; margin: 0 0 8px; padding: 0 0 8px; border-bottom: 0.5px solid var(--line); }
.sum-items li { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; font-size: 13px; }
.sum-items .sum-name { color: var(--text); }
.sum-items em { color: var(--muted-2); font-style: normal; }
.fine { margin: 10px 0 0; font-size: 11.5px; color: var(--muted-2); text-align: center; }

/* --------------------------------------------------------------- Forms */
.form-card h2 { margin-bottom: 18px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field-wide { grid-column: 1 / -1; }
.field > span { font-size: 12.5px; color: #374151; font-weight: 500; }
.field em { color: var(--muted-2); font-style: normal; font-weight: 400; }
.field input, .field textarea, .field select {
  font: inherit; font-size: 13px; color: var(--text);
  padding: 8px 11px; border: 0.5px solid var(--line-2);
  border-radius: var(--radius-sm); background: var(--surface); width: 100%;
}
.field select { appearance: none; -webkit-appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; padding-right: 30px;
}
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}
.field input[readonly] { background: var(--soft); color: var(--muted); }
.field textarea { resize: vertical; min-height: 70px; }
.check { display: flex; align-items: center; gap: 9px; margin: 16px 0 4px; font-size: 13px; color: var(--muted); }
.check input { width: 15px; height: 15px; accent-color: var(--brand); }
.checkout-note {
  font-size: 13px; color: var(--muted); background: var(--soft);
  border: 0.5px solid var(--line); border-radius: var(--radius-sm);
  padding: 10px 14px; margin: 0 0 16px;
}
.checkout-note a { color: var(--brand); }
.pay-intro { font-size: 13.5px; color: var(--muted); margin: 0 0 18px; line-height: 1.5; }
.pay-note { font-size: 12px; color: var(--muted-2); margin: 14px 0 0; }

/* --------------------------------------------------------------- Auth */
.auth-wrap { max-width: 400px; margin: 6vh auto 0; }
.auth-card { padding: 30px 28px; border-radius: 12px; }
.auth-card h1 { font-size: 17px; margin-bottom: 6px; }
.auth-card .lede { margin-bottom: 20px; }
.auth-card .field { margin-bottom: 14px; }
.otp-input { letter-spacing: 8px; text-align: center; font-size: 18px; font-variant-numeric: tabular-nums; }
.resend { margin-top: 14px; text-align: center; }
.link-plain { background: none; border: none; color: var(--brand); font: inherit; font-size: 13px; cursor: pointer; }

/* --------------------------------------------------------------- Confirm */
.confirm-banner {
  display: flex; align-items: center; gap: 14px; margin-bottom: 20px;
  border: 0.5px solid #bfe6cb; background: var(--ok-bg);
}
.confirm-banner .tick {
  width: 34px; height: 34px; border-radius: 50%; background: var(--ok);
  color: #fff; display: inline-flex; align-items: center; justify-content: center;
  font-size: 18px; flex: none;
}
.confirm-ref { font-size: 15px; color: var(--head); font-weight: 600; }
.confirm-meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

/* --------------------------------------------------------------- Flash */
.flash { border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 16px; font-size: 13px; border: 0.5px solid; }
.flash-success { background: var(--ok-bg); border-color: #bfe6cb; color: var(--ok); }
.flash-error   { background: var(--err-bg); border-color: #f0c4bf; color: var(--err); }
.flash-info    { background: var(--brand-soft); border-color: #c9dcff; color: var(--brand); }

/* --------------------------------------------------------------- Toast */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--head); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.show-cart { display: none; }

/* ---------------------------------------------------------- Policy pages */
.policy { max-width: 820px; line-height: 1.6; }
.policy h2 { font-size: 15px; margin: 26px 0 8px; color: var(--head); }
.policy h2:first-child { margin-top: 0; }
.policy h3 { font-size: 13.5px; margin: 18px 0 6px; color: var(--head); }
.policy p { margin: 0 0 12px; color: #374151; font-size: 14px; }
.policy ul, .policy ol { margin: 0 0 14px; padding-left: 20px; color: #374151; font-size: 14px; }
.policy li { margin: 4px 0; }
.policy a { color: var(--brand); }
.policy .policy-address { line-height: 1.7; }
.policy .policy-eff { color: var(--muted-2); font-size: 12.5px; margin-top: 14px; }
.policy .policy-legend { font-size: 12.5px; color: var(--muted-2); }
.policy-table-wrap { overflow-x: auto; margin: 0 0 16px; }
.policy-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 460px; }
.policy-table th, .policy-table td { border: 0.5px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
.policy-table th { background: var(--soft); font-weight: 500; color: var(--head); }
.policy-table td { color: #374151; }

/* ------------------------------------------------- Site footer (policies) */
.site-footer { margin-top: 44px; padding-top: 20px; border-top: 0.5px solid var(--line); }
.footer-links { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-bottom: 10px; }
.footer-links a { font-size: 12.5px; color: var(--muted); }
.footer-links a:hover { color: var(--head); }
.footer-meta { font-size: 12px; color: var(--muted-2); }

/* ============================================================== Responsive */
.overlay { display: none; position: fixed; inset: 0; background: rgba(17,24,39,.35); z-index: 35; }
@media (max-width: 860px) {
  body.has-sidebar .shell { margin-left: 0; }
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: 0 0 30px rgba(0,0,0,.12); }
  .navtoggle:checked ~ .sidebar { transform: translateX(0); }
  .navtoggle:checked ~ .nav-scrim { display: block; }
  .mobilebar { display: flex; }
  .wrap { padding: 16px 14px; }

  .page-head { flex-direction: column; gap: 12px; }
  .cart-layout, .checkout-layout, .confirm-layout { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .show-cart { display: inline-flex; }

  /* Tables become stacked cards */
  table[data-cards] thead { display: none; }
  table[data-cards], table[data-cards] tbody { display: block; }
  table[data-cards] tr {
    display: block; background: var(--surface);
    border: 0.5px solid var(--line); border-radius: var(--radius);
    padding: 6px 4px; margin: 0 0 10px;
  }
  table[data-cards] tr:hover { background: var(--surface); }
  table[data-cards] td {
    display: flex; align-items: center; justify-content: space-between;
    gap: 14px; padding: 9px 14px; border-bottom: 0.5px solid var(--line) !important;
  }
  table[data-cards] td:last-child { border-bottom: 0 !important; }
  table[data-cards] td::before {
    content: attr(data-label); font-size: 11px; letter-spacing: 0.03em;
    text-transform: uppercase; color: var(--muted); font-weight: 500; flex: 0 0 auto;
  }
  table[data-cards] td[data-label=""]::before { display: none; }
  table[data-cards] .col-name { flex-direction: column; align-items: flex-start; gap: 2px; }
  table[data-cards] .col-name::before { order: -1; }
  table[data-cards] .col-desc { color: var(--muted); font-size: 13px; }
  table[data-cards] .col-action { display: block; }
  table[data-cards] .col-action::before { display: block; margin-bottom: 8px; }
  table[data-cards] .add-row { justify-content: space-between; }
  table[data-cards] .row-actions { justify-content: flex-end; }
  .col-desc { max-width: none; }
}
@media (max-width: 420px) {
  table[data-cards] .add-row { flex-direction: column; align-items: stretch; gap: 10px; }
  .btn-add { width: 100%; }
}

/* Accessibility */
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ------------------------------------------------------------------- Admin */
.admin-shell { min-height: 100vh; background: var(--bg); }
.admin-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px; background: var(--surface); border-bottom: 0.5px solid var(--line);
  position: sticky; top: 0; z-index: 30;
}
.admin-brand { display: inline-flex; align-items: center; gap: 10px; }
.admin-brand:hover { text-decoration: none; }
.admin-brand img { width: 116px; height: auto; display: block; }
.admin-badge {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600;
  color: var(--brand); background: var(--brand-soft); border: 0.5px solid #c9dcff;
  padding: 2px 8px; border-radius: 999px;
}
.admin-user { display: inline-flex; align-items: center; gap: 12px; font-size: 13px; color: var(--muted); }
.admin-user .acct-email { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-main { max-width: 1080px; margin: 0 auto; padding: 24px; }
.admin-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: stretch; }
.admin-cards .card { display: flex; flex-direction: column; }
.admin-cards .card .card-b { flex: 1; }
.admin-status { list-style: none; margin: 0; padding: 0; font-size: 13.5px; color: var(--muted); }
.admin-status li { padding: 5px 0; display: flex; gap: 8px; align-items: center; }
.admin-auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); padding: 24px; }
.admin-auth .auth-card { width: 100%; max-width: 380px; }
.admin-auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.admin-auth-brand img { width: 120px; height: auto; }
@media (max-width: 720px) {
  .admin-cards { grid-template-columns: 1fr; }
  .admin-top { padding: 10px 14px; }
  .admin-main { padding: 16px 14px; }
}

/* ------------------------------------------------- Admin order builder */
.inline-search { display: flex; gap: 8px; }
.inline-search input[type=text] {
  flex: 1; font: inherit; font-size: 13px; padding: 8px 11px;
  border: 0.5px solid var(--line-2); border-radius: var(--radius-sm); background: var(--surface);
}
.inline-search input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.qty-input {
  width: 60px; font: inherit; font-size: 13px; text-align: center;
  padding: 6px 6px; border: 0.5px solid var(--line-2); border-radius: var(--radius-sm);
}
.admin-main .add-row { gap: 8px; }

/* Admin badge under the sidebar brand + live search results */
.brand-wrap .admin-badge { margin-top: 10px; }
.search-results { margin-top: 4px; }
.result-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 2px; border-bottom: 0.5px solid var(--line);
}
.result-row:last-child { border-bottom: none; }
.result-main { min-width: 0; }
.result-main .name { display: block; }
.result-main .sku { display: block; margin-top: 2px; }
.result-row form { margin: 0; display: flex; align-items: center; gap: 8px; }

/* Fix: second grid card was inheriting .card + .card top margin (misaligned tops) */
.admin-cards .card + .card { margin-top: 0; }

/* Clickable search-result rows (whole row is the button) */
.rowform { margin: 0; }
.result-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; text-align: left; cursor: pointer;
  background: var(--surface); border: none; border-bottom: 0.5px solid var(--line);
  padding: 11px 4px; font: inherit; color: var(--text);
  transition: background .12s;
}
.result-row:hover:not(:disabled) { background: var(--brand-soft); }
.result-row:disabled { cursor: not-allowed; opacity: .6; }
.rowform:last-child .result-row { border-bottom: none; }
.result-go { font-size: 12.5px; color: var(--brand); white-space: nowrap; flex: 0 0 auto; }
.result-row:disabled .result-go { color: var(--muted-2); }

/* Editable cart */
.cart-desc { width: 100%; min-width: 150px; font: inherit; font-size: 12.5px; padding: 6px 8px; border: 0.5px solid var(--line-2); border-radius: var(--radius-sm); background: var(--surface); }
.cart-qty { width: 64px; font: inherit; font-size: 13px; text-align: center; padding: 6px; border: 0.5px solid var(--line-2); border-radius: var(--radius-sm); background: var(--surface); }
.cart-desc:focus, .cart-qty:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.cart-grid td { vertical-align: middle; }
.line-total { font-variant-numeric: tabular-nums; }

/* ADMIN badge in the sidebar foot (above email) */
.whoami .admin-badge { display: inline-block; margin-bottom: 3px; }

/* Payments report: stat row + filter bar */
.muted { color: var(--muted-2); }
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 0.5px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat-n { font-size: 20px; font-weight: 600; color: var(--head); font-variant-numeric: tabular-nums; }
.stat-l { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted-2); margin-top: 3px; }
.filter-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.filter-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.fpill { font-size: 12.5px; padding: 6px 12px; border-radius: 999px; border: 0.5px solid var(--line-2); color: var(--muted); background: var(--surface); }
.fpill:hover { background: var(--soft); text-decoration: none; }
.fpill.on { background: var(--brand-soft); color: var(--brand); border-color: #c9dcff; font-weight: 500; }
.filter-search input { font: inherit; font-size: 13px; padding: 7px 11px; border: 0.5px solid var(--line-2); border-radius: var(--radius-sm); background: var(--surface); min-width: 240px; }
.filter-search input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
@media (max-width: 700px) { .stat-row { grid-template-columns: repeat(2, 1fr); } }

/* Payments filter: FY dropdown next to status pills */
.filter-left { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.fy-form { margin: 0; }
.fy-select { font: inherit; font-size: 13px; padding: 6px 10px; border: 0.5px solid var(--line-2); border-radius: var(--radius-sm); background: var(--surface); color: var(--head); cursor: pointer; }
.fy-select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }

/* Payments table: invoice as PDF link + date sub-row */
.inv-link { color: var(--text); font: inherit; text-decoration: none; }
.inv-link:hover { color: var(--brand); text-decoration: underline; }
.sub-date { font-size: 11px; color: var(--muted-2); margin-top: 2px; }
.stat-caption { font-size: 11.5px; color: var(--muted-2); margin: 16px 2px 10px; text-transform: uppercase; letter-spacing: .04em; }

/* Zoho entities settings form */
.cred-note { font-size: 12px; color: var(--muted-2); margin: 16px 0 8px; }
.check-row { display: flex; gap: 20px; margin-top: 12px; flex-wrap: wrap; }
.check { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text); }

/* Payments filter form (labelled controls, all on one line) */
.filter-form { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.fl { display: flex; flex-direction: column; gap: 4px; width: 160px; }
.fl > span { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted-2); }
.fl select, .fl input { width: 100%; height: 36px; font: inherit; font-size: 13px; padding: 6px 10px; border: 0.5px solid var(--line-2); border-radius: var(--radius-sm); background: var(--surface); color: var(--head); }
.fl select { cursor: pointer; }
.fl input:focus, .fl select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.fl-entity { width: 160px; }
.fl-client { width: 240px; }
.fl-fy { width: 150px; }
.fl-pay { width: 120px; }
.fl-search { flex: 1 1 auto; min-width: 180px; width: auto; }

/* Client portal */
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 20px; }
.auth-brand img { height: 42px; width: auto; display: block; }
.portal { background: var(--bg); }
.portal-top { display: flex; align-items: center; gap: 16px; padding: 12px 26px; background: var(--surface); border-bottom: 0.5px solid var(--line); position: sticky; top: 0; z-index: 20; }
.portal-brand img { height: 40px; width: auto; display: block; }
.portal-acct { margin-left: auto; text-align: right; line-height: 1.35; }
.portal-acct .pa-co { font-size: 13px; font-weight: 600; color: var(--head); }
.portal-acct .pa-mail { font-size: 11.5px; color: var(--muted-2); }
.portal-main { max-width: 960px; margin: 0 auto; padding: 26px; }
.portal-foot { max-width: 960px; margin: 0 auto; padding: 20px 26px 40px; color: var(--muted-2); font-size: 12px; }

/* Client login - aligned to Ascent Kanban */
body.mapp-auth { background: var(--bg); }
body.mapp-auth .auth-wrap { min-height: 100vh; max-width: none; margin: 0; display: flex; align-items: center; justify-content: center; padding: 20px; }
body.mapp-auth .auth-card { width: 100%; max-width: 380px; }
.auth-card .logo { margin-bottom: 20px; text-align: left; }
.auth-card .logo img { height: 45px; width: auto; display: block; }
.actions { display: flex; gap: 10px; margin-top: 14px; }
.auth-powered { text-align: center; margin-top: 22px; }
.auth-powered img { height: 30px; width: auto; }

/* Contact type pill (Tech) + client-details group separator */
.pill.teal { background: #e6f7f4; color: #0f766e; }
.group-start:not(:first-child) td { border-top: 0.5px solid var(--line-2); }

/* Client invoices: filters + stat cards on one row (desktop) */
.inv-bar { display: flex; flex-wrap: wrap; gap: 16px 24px; align-items: flex-end; justify-content: space-between; }
.inv-bar .filter-form { flex: 0 1 auto; margin: 0; }
.inv-stats { display: flex; gap: 12px; flex: 0 0 auto; }
.inv-stats .stat { min-width: 150px; }
@media (max-width: 640px) { .inv-stats { flex: 1 1 100%; } .inv-stats .stat { flex: 1; min-width: 0; } }

/* Outstanding balance shown under the amount */
.sub-bal { font-size: 11px; color: var(--err); margin-top: 2px; }

/* ---- Kanban tickets (thread) ---- */
.kb-back { margin: 0 0 6px; font-size: 12.5px; }
.kb-back a { color: var(--muted); }
.kb-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 20px; font-size: 13px; }
.kb-facts span { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted-2); margin-bottom: 2px; }
.kb-facts em { color: var(--muted-2); font-style: normal; font-size: 12px; }
.kb-thread { display: flex; flex-direction: column; gap: 12px; }
.kb-msg { background: var(--surface); border: .5px solid var(--line); border-left: 3px solid var(--line-2); border-radius: var(--radius); padding: 14px 16px; }
.kb-msg.kb-out { border-left-color: var(--brand); background: #fbfcff; }
.kb-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; font-size: 12.5px; margin-bottom: 8px; }
.kb-who { font-weight: 600; color: var(--head); }
.kb-mail { color: var(--muted-2); }
.kb-dir { font-size: 11px; color: var(--muted); background: var(--soft); border: .5px solid var(--line); border-radius: 999px; padding: 0 8px; }
.kb-out .kb-dir { color: var(--brand); background: var(--brand-soft); border-color: #c9dcff; }
.kb-date { margin-left: auto; color: var(--muted-2); white-space: nowrap; }
.kb-rcpt { font-size: 12px; color: var(--muted); margin: -4px 0 8px; overflow-wrap: anywhere; }
.kb-body { font-size: 13.5px; line-height: 1.55; color: var(--text); overflow-wrap: anywhere; overflow-x: auto; }
.kb-body p { margin: 0 0 8px; }
.kb-body blockquote { margin: 8px 0; padding-left: 10px; border-left: 2px solid var(--line-2); color: var(--muted); }
.kb-body table { border-collapse: collapse; max-width: 100%; }
.kb-body td, .kb-body th { border: .5px solid var(--line); padding: 4px 6px; }
.kb-body pre { white-space: pre-wrap; }
.kb-atts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; padding-top: 10px; border-top: .5px dashed var(--line); }
.kb-att { font-size: 12.5px; border: .5px solid var(--line-2); border-radius: 6px; padding: 3px 9px; background: var(--soft); color: var(--text); }
.kb-att span { color: var(--muted-2); margin-left: 6px; }
.kb-att:hover { background: var(--brand-soft); text-decoration: none; }
@media (max-width: 860px) { .kb-date { margin-left: 0; } }

/* ---- Kanban tickets: spacing, clear filters, conversation list, client/Ascent colours ---- */
.inv-bar + .card, .inv-bar + .table-card { margin-top: 16px; }
.fl-clear { height: 36px; display: inline-flex; align-items: center; white-space: nowrap; }
.kb-layout { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 16px; align-items: start; }
.kb-msg { scroll-margin-top: 16px; transition: box-shadow .3s; }
.kb-msg.kb-in { border-left-color: var(--ok); }
.kb-in .kb-dir { color: var(--ok); background: var(--ok-bg); border-color: #bfe6cb; }
.kb-msg.kb-flash { box-shadow: 0 0 0 3px var(--brand-soft); }
.kb-convo { position: sticky; top: 16px; background: var(--surface); border: .5px solid var(--line); border-radius: var(--radius); padding: 12px 8px; max-height: calc(100vh - 32px); overflow-y: auto; }
.kb-convo-h { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted-2); padding: 2px 10px 8px; }
.kb-ci { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: 6px; color: var(--text); }
.kb-ci:hover { background: var(--soft); text-decoration: none; }
.kb-ci.on { background: var(--brand-soft); }
.kb-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex: 0 0 8px; background: var(--brand); }
.kb-ci-in .kb-dot { background: var(--ok); }
.kb-ci-t { display: flex; flex-direction: column; min-width: 0; }
.kb-ci-n { font-size: 13px; font-weight: 500; color: var(--head); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kb-ci.on .kb-ci-n { color: var(--brand); }
.kb-ci-d { font-size: 11.5px; color: var(--muted-2); }
@media (max-width: 980px) { .kb-layout { grid-template-columns: 1fr; } .kb-convo { display: none; } }

/* ---- Stack services ---- */
.st-tabs { display: flex; gap: 6px; margin: 4px 0 12px; flex-wrap: wrap; }
.st-tabs a { padding: 6px 14px; border-radius: 999px; border: .5px solid var(--line-2); background: var(--surface); color: var(--text); font-size: 13px; }
.st-tabs a:hover { background: var(--soft); text-decoration: none; }
.st-tabs a.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.st-h { font-size: 15px; font-weight: 600; color: var(--head); margin: 22px 0 10px; display: flex; align-items: center; gap: 8px; scroll-margin-top: 16px; }
.st-h:first-child { margin-top: 0; }
.st-h span { font-size: 11.5px; font-weight: 500; color: var(--muted); background: var(--soft); border: .5px solid var(--line); border-radius: 999px; padding: 0 8px; }
.st-card { overflow: hidden; scroll-margin-top: 16px; }
.st-card + .st-card { margin-top: 12px; }
.st-ch { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.st-title { font-weight: 600; color: var(--head); font-size: 14px; }
.st-sub { font-size: 12px; color: var(--muted); font-weight: 400; }
.st-desc { flex-basis: 100%; font-size: 12.5px; color: var(--muted); font-weight: 400; line-height: 1.45; }
.st-none { padding: 14px 16px; font-size: 13px; color: var(--muted-2); }
.st-svc tbody td { vertical-align: top; }
.st-inactive td { opacity: .55; }
.st-login { min-width: 200px; }
.st-login-box { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0; }
.st-login-box > * { display: block; max-width: 100%; }
@media (max-width: 860px) { .st-login-box { align-items: flex-end; text-align: right; } .st-pw { justify-content: flex-end; } }
.st-url { overflow-wrap: anywhere; }
.st-user, .st-lm { font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
.st-pw { display: flex !important; align-items: center; gap: 8px; margin-top: 4px; }
.st-pw-v { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; color: var(--head); overflow-wrap: anywhere; user-select: all; }
.st-pw .btn { padding: 2px 9px; font-size: 11.5px; }
.st-soon { color: var(--warn); }
.st-exp { color: var(--err); }
.st-soon em, .st-exp em { font-style: normal; font-size: 11.5px; }
.lede-wide { max-width: none; }

/* ---- Payments report: action row under the filters ---- */
.filter-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; padding-top: 12px; border-top: .5px solid var(--line); }
.fa-left, .fa-right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.fa-right { margin-left: auto; }
.btn-toggle-on { background: var(--brand-soft); color: var(--brand); border-color: #c9dcff; font-weight: 500; }
.btn-toggle-on:hover { background: #dce8ff; text-decoration: none; }

/* ---- Payments report: 6 cards in 3 columns + notes ---- */
.stat-row-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 700px) { .stat-row-3 { grid-template-columns: repeat(2, 1fr); } }
.pay-notes { display: flex; flex-direction: column; gap: 4px; margin: -6px 2px 14px; font-size: 12px; color: var(--muted); }
.pay-warn { color: var(--warn); }
.stat-row-5 { grid-template-columns: repeat(5, 1fr); margin-bottom: 6px; }
.stat-row-5 .stat-n { font-size: 20px; }
@media (max-width: 1100px) { .stat-row-5 .stat-n { font-size: 17px; } }
@media (max-width: 860px) { .stat-row-5 { grid-template-columns: repeat(2, 1fr); } }
.stat-foot { font-size: 11.5px; color: var(--muted-2); margin: 0 2px 14px; }
.sub-note { font-size: 11.5px; color: var(--muted-2); margin-top: 2px; font-variant-numeric: tabular-nums; }

/* ---- Kanban projects: hours ---- */
.hrs-cell { min-width: 150px; }
.hrs { display: block; font-variant-numeric: tabular-nums; }
.hbar { display: block; height: 5px; background: var(--soft); border: .5px solid var(--line); border-radius: 999px; overflow: hidden; margin: 5px 0 2px; max-width: 160px; }
.hbar i { display: block; height: 100%; background: var(--brand); }
.hbar.warn i { background: #d89b00; }
.hbar.over i { background: var(--err); width: 100% !important; }
.stat-of { font-size: 13px; font-weight: 500; color: var(--muted); }

/* ==========================================================================
   CLIENT PORTAL - MOBILE BASELINE (app.ascentcts.com, <= 860px)
   Scoped to body.mapp so Ops / Management are unaffected.

   App shell  : .m-appbar (logo + account menu) on top, .m-tabbar at the bottom.
   Card roles : give any portal table class "mcard" and tag its cells:
     .m-title   primary line (top-left)            .m-aside   key figure / status (top-right)
     .m-meta    secondary lines (left, muted)      .m-aside2  second right-hand item (row 2)
     .m-full    full-width block (bars, logins)    .m-hide    hidden on mobile
     .m-label   prefix the cell with its data-label ("Ref 123")
     .m-link    on the row's main link - makes the whole card tappable
   .mcard-flat  rows as a divided list inside an existing card (no card-in-card).
   Rules: tap targets >= 44px, form controls 16px (prevents iOS zoom), money
   right-aligned with tabular figures, same tokens/colours as desktop.
   ========================================================================== */
.m-appbar, .m-tabbar { display: none; }

@media (max-width: 860px) {
  /* ---- shell ---- */
  body.mapp .mobilebar, body.mapp .sidebar, body.mapp .nav-scrim { display: none !important; }
  body.mapp { background: var(--bg); }
  body.mapp .wrap { padding: 14px 16px calc(84px + env(safe-area-inset-bottom)); }

  body.mapp .m-appbar {
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 40; height: 62px;
    padding: 0 12px 0 16px; padding-top: env(safe-area-inset-top);
    background: rgba(255,255,255,.92); -webkit-backdrop-filter: saturate(1.4) blur(12px); backdrop-filter: saturate(1.4) blur(12px);
    border-bottom: .5px solid var(--line);
  }
  body.mapp .m-brand img { height: 36px; width: auto; display: block; }

  /* account menu (details/summary - works without JS) */
  body.mapp .m-acct { position: relative; }
  body.mapp .m-acct summary { list-style: none; cursor: pointer; padding: 5px; border-radius: 999px; }
  body.mapp .m-acct summary::-webkit-details-marker { display: none; }
  body.mapp .m-avatar {
    width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
    background: var(--brand-soft); color: var(--brand); font-size: 13px; font-weight: 600; letter-spacing: .02em;
  }
  body.mapp .m-acct[open] .m-avatar { background: var(--brand); color: #fff; }
  body.mapp .m-acct-sheet {
    position: absolute; right: 0; top: calc(100% + 6px); width: min(290px, calc(100vw - 24px));
    background: var(--surface); border: .5px solid var(--line-2); border-radius: 14px;
    box-shadow: 0 12px 32px rgba(17,24,39,.14); padding: 14px 6px 6px;
  }
  body.mapp .m-acct-co { font-weight: 600; color: var(--head); padding: 0 12px; font-size: 14px; }
  body.mapp .m-acct-mail { color: var(--muted); font-size: 12.5px; padding: 2px 12px 12px; overflow-wrap: anywhere; border-bottom: .5px solid var(--line); }
  body.mapp .m-acct-out { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px; margin-top: 4px; border-radius: 10px; color: var(--err); font-size: 14px; }
  body.mapp .m-acct-out svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.7; }
  body.mapp .m-acct-out:active { background: var(--err-bg); }

  /* bottom tab bar */
  body.mapp .m-tabbar {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    background: rgba(255,255,255,.95); -webkit-backdrop-filter: saturate(1.4) blur(12px); backdrop-filter: saturate(1.4) blur(12px);
    border-top: .5px solid var(--line);
  }
  body.mapp .m-tabbar a {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    min-height: 50px; border-radius: 12px; color: var(--muted); font-size: 11px; font-weight: 500;
    -webkit-tap-highlight-color: transparent;
  }
  body.mapp .m-tabbar a:hover { text-decoration: none; }
  body.mapp .m-tabbar svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.6; }
  body.mapp .m-tabbar a.on { color: var(--brand); }
  body.mapp .m-tabbar a.on svg { stroke-width: 2; }
  body.mapp .m-tabbar a:active { background: var(--soft); }

  /* ---- page head: large title ---- */
  body.mapp .page-head { margin-bottom: 14px; gap: 6px; }
  body.mapp .page-head h1 { font-size: 24px; line-height: 1.2; letter-spacing: -.01em; }
  body.mapp .page-head .lede { font-size: 13.5px; line-height: 1.45; }
  body.mapp .kb-back { margin-bottom: 8px; }
  body.mapp .kb-back a { display: inline-flex; align-items: center; min-height: 36px; font-size: 14px; color: var(--brand); }

  /* ---- filters + summary ---- */
  body.mapp .inv-bar { flex-direction: column; align-items: stretch; gap: 12px; margin-bottom: 14px; }
  body.mapp .filter-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  body.mapp .filter-form .fl { width: auto; min-width: 0; }
  body.mapp .filter-form > .fl:only-of-type { grid-column: 1 / -1; }
  /* search sits beside the select; its placeholder says the same as its label */
  body.mapp .fl-search > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  body.mapp .fl-search { align-self: end; }
  body.mapp .fl > span { font-size: 11.5px; }
  body.mapp .fl select, body.mapp .fl input { height: 44px; font-size: 16px; border-radius: 10px; }
  body.mapp .fl-clear { grid-column: 1 / -1; justify-self: end; height: 32px; border: 0; background: none; color: var(--brand); padding: 0 2px; font-size: 13.5px; }
  body.mapp .inv-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  body.mapp .inv-stats .stat { min-width: 0; padding: 12px 14px; border-radius: 12px; }
  body.mapp .inv-stats .stat-n { font-size: 19px; }
  body.mapp .stat-caption { margin: 2px 2px 8px; }
  body.mapp .stat-foot { margin: 6px 2px 0; }

  /* ---- lists: rows become cards ---- */
  body.mapp .table-card { background: none; border: 0; border-radius: 0; overflow: visible; }
  body.mapp .table-card .empty { background: var(--surface); border: .5px solid var(--line); border-radius: 14px; }
  body.mapp table.mcard, body.mapp table.mcard tbody { display: block; background: none; }
  body.mapp table.mcard thead { display: none; }
  body.mapp table.mcard tr {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-auto-flow: row dense;
    column-gap: 12px; row-gap: 4px; position: relative;
    background: var(--surface); border: .5px solid var(--line); border-radius: 14px;
    padding: 14px 16px; margin: 0 0 10px;
  }
  body.mapp table.mcard tr:hover { background: var(--surface); }
  body.mapp table.mcard tr:has(.m-link):active { background: var(--soft); }
  body.mapp table.mcard td {
    display: block; padding: 0; border: 0 !important; min-width: 0; font-size: 13.5px;
  }
  body.mapp table.mcard td::before { content: none; display: none; }
  body.mapp table.mcard .m-title  { grid-column: 1; grid-row: 1; }
  body.mapp table.mcard .m-title .name, body.mapp table.mcard .m-title > a { font-size: 15px; font-weight: 600; color: var(--head); display: block; }
  body.mapp table.mcard .m-title .sku, body.mapp table.mcard .m-title .sub-date { display: block; font-size: 12.5px; margin-top: 2px; }
  body.mapp table.mcard .m-aside  { grid-column: 2; grid-row: 1; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
  body.mapp table.mcard .m-aside2 { grid-column: 2; grid-row: 2; text-align: right; align-self: start; }
  body.mapp table.mcard .m-meta   { grid-column: 1; font-size: 13px; color: var(--muted); }
  body.mapp table.mcard .m-meta .sku { display: inline !important; margin-left: 4px; }
  body.mapp table.mcard .m-label::before { content: attr(data-label) " "; display: inline; color: var(--muted-2); font-size: 12.5px; text-transform: none; letter-spacing: 0; font-weight: 400; }
  body.mapp table.mcard .m-full   { grid-column: 1 / -1; margin-top: 8px; }
  body.mapp table.mcard .m-hide   { display: none; }
  body.mapp table.mcard .m-link::after { content: ""; position: absolute; inset: 0; border-radius: 14px; }
  body.mapp table.mcard .m-link { -webkit-tap-highlight-color: transparent; }
  body.mapp table.mcard .m-aside .sub-bal, body.mapp table.mcard .m-aside .sub-note { font-weight: 400; }
  body.mapp table.mcard .pill { font-size: 11.5px; }

  /* flat variant: divided rows inside an existing card */
  body.mapp table.mcard-flat tr { border: 0; border-top: .5px solid var(--line); border-radius: 0; margin: 0; padding: 14px 16px; background: none; }
  body.mapp table.mcard-flat tr:first-child { border-top: 0; }

  /* ---- Systems and Infra ---- */
  body.mapp .st-card { border-radius: 14px; }
  body.mapp .st-ch { padding: 14px 16px 12px; }
  body.mapp .st-title { font-size: 15px; }
  body.mapp .st-h { font-size: 17px; margin: 22px 2px 10px; }
  body.mapp .st-login-box { align-items: flex-start !important; text-align: left !important; background: var(--soft); border-radius: 10px; padding: 10px 12px; }
  body.mapp .st-pw { justify-content: flex-start !important; }
  body.mapp .st-pw .btn { min-height: 34px; padding: 4px 14px; font-size: 13px; }
  body.mapp .hrs-cell { min-width: 0; }
  body.mapp .hbar { max-width: none; height: 6px; }

  /* ---- ticket thread ---- */
  body.mapp .kb-msg { border-radius: 14px; padding: 14px; }
  body.mapp .kb-meta { gap: 2px 8px; }
  body.mapp .kb-date { flex-basis: 100%; margin-left: 0; font-size: 12px; }
  body.mapp .kb-body { font-size: 14.5px; line-height: 1.55; }
  body.mapp .kb-att { min-height: 36px; display: inline-flex; align-items: center; }
  body.mapp .fine { margin-top: 14px; }

  /* ---- sign-in ---- */
  body.mapp-auth { height: 100vh; height: 100dvh; overflow: hidden; }
  body.mapp-auth .auth-wrap, body.mapp-auth .admin-auth {
    position: fixed; inset: 0; margin: 0; min-height: 0; max-width: none;
    display: flex; align-items: center; justify-content: center;
    padding: calc(16px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom));
    overflow-y: auto;            /* only scrolls if the keyboard leaves too little room */
  }
  body.mapp-auth .auth-card .logo, body.mapp-auth .admin-auth-brand { text-align: center; margin-bottom: 18px; }
  body.mapp-auth .auth-card .logo img, body.mapp-auth .admin-auth-brand img { margin: 0 auto; display: block; }
  body.mapp-auth .auth-card h1, body.mapp-auth .auth-card > .lede { text-align: center; }
  body.mapp-auth .auth-card > .lede { margin-left: auto; margin-right: auto; }
  body.mapp-auth .auth-powered { margin-top: 18px; }
  body.mapp-auth .auth-card { width: 100%; padding: 26px 20px; border-radius: 16px; }
  body.mapp-auth .field input { height: 48px; font-size: 16px; border-radius: 10px; }
  body.mapp-auth .btn-block { min-height: 48px; font-size: 15px; border-radius: 10px; }
  body.mapp-auth .actions .btn { min-height: 40px; }
}
@media (max-width: 860px) and (prefers-reduced-motion: no-preference) {
  body.mapp table.mcard tr:has(.m-link) { transition: background .12s ease; }
}

/* ---- Installed-app launch animation (see portal_splash) ---- */
.app-splash { display: none; position: fixed; inset: 0; z-index: 1000; background: #fafafa; place-items: center; transition: opacity .38s ease; }
html.splashing .app-splash { display: grid; animation: spFailsafe 0s 2.5s forwards; }
@keyframes spFailsafe { to { opacity: 0; visibility: hidden; pointer-events: none; } }
.sp-inner { display: flex; flex-direction: column; align-items: center; gap: 22px; transition: transform .42s cubic-bezier(.2,.7,.2,1); }
.sp-mark { width: 88px; height: 88px; border-radius: 50%; overflow: hidden; box-shadow: 0 10px 28px rgba(0,91,234,.16); animation: spSettle .6s cubic-bezier(.2,.7,.2,1) both; }
.sp-mark img { width: 100%; height: 100%; display: block; }
.sp-line { display: block; width: 44px; height: 2px; border-radius: 2px; background: var(--brand); transform: scaleX(0); animation: spDraw .55s .15s cubic-bezier(.65,0,.35,1) forwards; }
.app-splash.out { opacity: 0; }
.app-splash.out .sp-inner { transform: translateY(-10px) scale(.94); }
@keyframes spSettle { from { transform: scale(1.06); } to { transform: scale(1); } }
@keyframes spDraw { to { transform: scaleX(1); } }
@media (prefers-reduced-motion: reduce) {
  .sp-mark, .sp-line { animation: none; }
  .sp-line { transform: none; }
  .app-splash.out .sp-inner { transform: none; }
}

/* ---- Project detail: time entries ---- */
.pj-stats { display: flex; gap: 12px; flex-wrap: wrap; }
.pj-stats .stat { min-width: 170px; }
.pj-stats .hbar { margin-top: 8px; }
.te-table .te-date { white-space: nowrap; }
.te-table .te-by-m { display: none; }
.te-first { display: block; color: var(--head); }
.te-rest { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.te-table tfoot td { padding: 11px 16px; font-weight: 600; border-top: .5px solid var(--line-2); background: var(--soft); }
@media (max-width: 860px) {
  body.mapp .pj-stats { display: grid; grid-template-columns: 1fr 1fr; }
  body.mapp .pj-stats .stat { min-width: 0; }
  body.mapp .pj-stats .stat:first-child:nth-last-child(odd) { grid-column: 1 / -1; }
  body.mapp .te-table tfoot { display: none; }
  body.mapp .te-table .te-by-m { display: inline; }
  body.mapp .te-table .te-first { font-size: 14.5px; font-weight: 600; }
  body.mapp .te-table .te-rest { font-size: 13px; }
  body.mapp table.mcard.te-table .m-title { grid-row: 1; }
  body.mapp table.mcard.te-table .te-date { grid-row: 2; font-size: 12.5px; }
}

/* ---- Payments report: column proportions (screen) ---- */
@media (min-width: 861px) {
  .pay-cols { table-layout: fixed; }
  .pay-cols .w-client { width: 27%; }
  .pay-cols .w-inv    { width: 17%; }
  .pay-cols .w-ref    { width: 13%; }
  .pay-cols .w-amt    { width: 16.5%; }
  .pay-cols .w-st     { width: 10%; }
  .pay-cols td { overflow-wrap: anywhere; }
}

/* ---- Mobile app baseline: Management additions ---- */
@media (max-width: 860px) {
  body.mapp table.mcard .m-meta .sub-date { display: inline; margin-left: 6px; font-size: 12.5px; }
  body.mapp table.mcard .m-meta .inv-link { font-weight: 500; color: var(--head); }
  body.mapp table.mcard .m-title > .sku:only-child { font-size: 15px; font-weight: 600; color: var(--head); }
  body.mapp table.mcard .m-title .sub-date { display: block; }
  /* 5 summary cards: two per row, last one full width */
  body.mapp .stat-row-5 { grid-template-columns: 1fr 1fr; gap: 10px; }
  body.mapp .stat-row-5 .stat:last-child:nth-child(odd) { grid-column: 1 / -1; }
  body.mapp .stat-row, body.mapp .stat-row-5 { margin-bottom: 8px; }
  body.mapp .stat-row .stat { padding: 12px 14px; border-radius: 12px; }
  body.mapp .stat-row .stat-n { font-size: 19px; }
  /* filters inside a card (payments, clients) */
  body.mapp .card > .card-b > .filter-form { margin: 0; }
  body.mapp .filter-actions { flex-direction: column; align-items: stretch; }
  body.mapp .filter-actions .fa-left, body.mapp .filter-actions .fa-right { justify-content: space-between; margin-left: 0; }
  body.mapp .filter-actions .btn { min-height: 40px; flex: 1; justify-content: center; }
  body.mapp .page-head .head-actions { width: 100%; }
}
@media (max-width: 860px) {
  body.mapp table.mcard colgroup { display: none; }            /* desktop column widths off in card view */
  body.mapp .card-b { padding: 16px; }
  body.mapp .card-h { padding: 14px 16px; }
  body.mapp .stat-caption { margin-top: 14px; }
}

/* ---- Debt module ---- */
.pay-pop { position: relative; display: inline-block; }
.pay-pop > summary { list-style: none; cursor: pointer; }
.pay-pop > summary::-webkit-details-marker { display: none; }
.pay-form { position: absolute; right: 0; top: calc(100% + 6px); z-index: 50; width: min(520px, calc(100vw - 48px));
  background: var(--surface); border: .5px solid var(--line-2); border-radius: 12px; box-shadow: 0 14px 36px rgba(17,24,39,.16); padding: 16px; text-align: left; }
.pay-form .form-grid { grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.pay-form .field input, .pay-form .field select { height: 36px; font-size: 13px; }
@media (max-width: 860px) {
  body.mapp .pay-pop { display: block; }
  body.mapp .pay-form { position: static; width: auto; box-shadow: none; margin-top: 10px; }
  body.mapp .pay-pop > summary { width: 100%; text-align: center; }
}

/* ---- Keys Management ---- */
/* Key actions sit at the LEFT of a full-width card, so their popovers open
   rightwards. Anchoring right (as the debt table does, where the trigger is at
   the right edge) would push a 520px panel off the page and under the sidebar. */
.key-actions .pay-form { left: 0; right: auto; }
.key-actions .pay-pop { position: relative; }

/* The collapse-into-flow rule in the mobile baseline is scoped to body.mapp,
   and Ops is not a mapp surface, so its popovers stayed absolutely positioned
   on a phone and ran off the screen. This repeats it unscoped, so every
   surface behaves the same at narrow widths. */
@media (max-width: 860px) {
  .pay-pop { display: block; }
  .pay-pop > summary { width: 100%; text-align: center; }
  .pay-form { position: static; width: auto; box-shadow: none; margin-top: 10px; }
  .key-actions .pay-form { left: auto; right: auto; }
}

.btn-soft { background: var(--brand-soft); color: var(--brand); border-color: #c9dcff; }
.btn-soft:hover { background: #dce8ff; color: var(--brand-ink); }
.btn-xs { padding: 3px 9px; font-size: 11.5px; }

.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px 24px; }
.kv > div { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.kv span { font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted-2); }
.kv strong { font-weight: 500; font-size: 13.5px; color: var(--head); overflow-wrap: anywhere; }
.kv .sku { margin-left: 6px; }

.keymask { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; color: var(--head); }
.key-dots { letter-spacing: .14em; color: var(--muted-2); margin-left: 3px; }

.key-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; margin-top: 16px; }
.key-actions form { margin: 0; }

.keynew { border-color: #c9dcff; background: var(--brand-soft); }
.keynew-h { font-size: 13px; font-weight: 600; color: var(--brand-ink); margin-bottom: 4px; }
.keybox { display: flex; align-items: center; gap: 10px; background: var(--surface);
  border: .5px solid #c9dcff; border-radius: 10px; padding: 10px 12px; }
.keybox code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px; color: var(--head); overflow-wrap: anywhere; flex: 1; }
.keybox .btn { flex: none; }

@media (max-width: 860px) {
  body.mapp .kv { grid-template-columns: 1fr 1fr; gap: 12px 16px; }
  body.mapp .key-actions .btn, body.mapp .key-actions > form { width: 100%; }
  body.mapp .key-actions .btn { justify-content: center; min-height: 40px; }
  body.mapp .keybox { flex-direction: column; align-items: stretch; }
  body.mapp .keybox .btn { justify-content: center; min-height: 40px; }
}

/* ---- Portal: invoices ----
   Red is reserved for one thing on this page: an invoice past its due date.
   Everything else that is merely unpaid stays in ordinary ink, so the colour
   means something when it does appear. */
.inv-top { display: flex; align-items: flex-end; justify-content: space-between;
  gap: 24px; flex-wrap: wrap; margin-bottom: 26px; }
.inv-owed-n { font-size: 40px; line-height: 1.05; font-weight: 600; letter-spacing: -.02em;
  color: var(--head); font-variant-numeric: tabular-nums; }
.inv-owed-n.inv-clear { font-size: 28px; color: var(--ok); }
.inv-owed-s { margin: 8px 0 0; font-size: 13.5px; color: var(--muted-2); }
.inv-late { color: var(--err); }
.inv-filters { flex: 0 1 auto; }

.inv-sec { font-size: 13px; font-weight: 600; color: var(--muted-2); margin: 0 0 10px;
  letter-spacing: .01em; }
.inv-sec + .table-card { margin-top: 0; }
.inv-settled { margin-bottom: 8px; }
.inv-due + .inv-foot, .inv-foot { margin: 10px 2px 28px; font-size: 12.5px; color: var(--muted-2); }

.inv-amt { font-weight: 600; color: var(--head); }
.inv-act { text-align: right; white-space: nowrap; width: 1%; padding-left: 28px; }
.inv-due .sub-bal, .inv-settled .sub-bal { color: var(--muted-2); }
.inv-note { font-size: 12.5px; color: var(--muted-2); }
.inv-note.inv-ok { color: var(--ok); }
.inv-paid { font-size: 12.5px; color: var(--ok); font-weight: 500; }
.inv-pay { padding: 8px 18px; }
.inv-settled tbody td { color: var(--muted-2); }
.inv-settled .inv-link { color: var(--muted); }
.inv-settled .inv-link:hover { color: var(--brand); }

@media (max-width: 860px) {
  body.mapp .inv-top { display: block; margin-bottom: 20px; }
  body.mapp .inv-owed-n { font-size: 34px; }
  body.mapp .inv-filters { margin-top: 18px; }
  body.mapp .inv-sec { margin-top: 22px; }
  body.mapp .inv-act { text-align: left; width: auto; padding-left: 0; }
  body.mapp .inv-pay { display: flex; justify-content: center; width: 100%; min-height: 44px; margin-top: 4px; }
  body.mapp table.mcard tbody tr.is-late { box-shadow: inset 3px 0 0 var(--err); }
}

/* ---- Portal: paying an invoice ---- */
.inv-pay { margin-top: 6px; }
.paylist { display: grid; gap: 10px; margin-bottom: 16px; }
.payopt { display: flex; align-items: center; gap: 12px; padding: 14px 16px; cursor: pointer;
  border: .5px solid var(--line-2); border-radius: 12px; background: var(--surface); }
.payopt:hover { border-color: #c9dcff; }
.payopt input { accent-color: var(--brand); width: 18px; height: 18px; flex: none; }
.payopt:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.payopt-b { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.payopt-name { font-weight: 500; color: var(--head); }
.payopt-sub { font-size: 12px; color: var(--muted-2); }
@media (max-width: 860px) {
  body.mapp .payopt { min-height: 56px; }
  body.mapp .inv-pay { display: inline-flex; min-height: 36px; align-items: center; }
}

/* ---- Ops: payment gateway setup ----
   One company and one gateway at a time. The tab row doubles as the status
   display, so the state of each gateway is readable without leaving the form. */
.gw-on > td { background: var(--brand-soft); }
.gw-pick { display: flex; gap: 14px; align-items: flex-end; margin-bottom: 18px; }
.gw-pick .fl { min-width: 260px; }

.gw-tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: .5px solid var(--line);
  margin: 0 0 20px; }
.gw-tabs a { display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px 11px;
  font-size: 13.5px; color: var(--muted); border-bottom: 2px solid transparent;
  margin-bottom: -1px; text-decoration: none; }
.gw-tabs a:hover { color: var(--head); text-decoration: none; }
.gw-tabs a.on { color: var(--brand); border-bottom-color: var(--brand); font-weight: 500; }
.gw-tabs .pill { transform: scale(.92); }

.gw-intro { margin: 0 0 16px; font-size: 13px; color: var(--muted-2); }
.gw-form .field-hint { display: block; margin-top: 4px; font-size: 11.5px; color: var(--muted-2); font-style: normal; }
.gw-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 16px; }
.gw-actions .fine { margin: 0; text-align: left; }

.gw-check { display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin-top: 18px; padding-top: 16px; border-top: .5px solid var(--line); }
.gw-check .fine { margin: 0; text-align: left; }

/* ---- Connection check results ---- */
.gwtest { margin-bottom: 16px; padding: 0; }
.gwtest .card-b { padding: 4px 18px 16px; }
.gwtest-row { display: flex; gap: 14px; align-items: flex-start;
  padding: 14px 0; border-bottom: .5px solid var(--line); }
.gwtest-row:last-of-type { border-bottom: 0; }
.gwtest-flag { flex: 0 0 auto; margin-top: 1px; font-size: 11px; font-weight: 600;
  letter-spacing: .02em; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.gwtest-row.is-ok  .gwtest-flag { background: var(--ok-bg);  color: var(--ok); }
.gwtest-row.is-bad .gwtest-flag { background: var(--err-bg); color: var(--err); }
.gwtest-b { min-width: 0; }
.gwtest-who { margin: 0 0 2px; font-size: 12px; color: var(--muted-2); }
.gwtest-msg { margin: 0; font-size: 13.5px; color: var(--head); max-width: 86ch; }
.gwtest-notes { margin: 8px 0 0; padding-left: 18px; font-size: 12.5px; color: var(--muted); }
.gwtest-notes li { margin-bottom: 3px; }
.gwtest .fine { margin: 12px 0 0; text-align: left; }

@media (max-width: 860px) {
  .gw-pick { display: block; }
  .gw-pick .fl { min-width: 0; width: 100%; }
  .gw-tabs { gap: 0; }
  .gw-tabs a { flex: 1 1 auto; justify-content: center; padding: 10px 8px 11px; }
  .gw-tabs a .pill { display: none; }
  .gwtest-row { flex-direction: column; gap: 6px; }
}

/* ---- Portal: paying several invoices at once ---- */
.inv-tick { width: 34px; padding-right: 0; }
.inv-tick input { width: 17px; height: 17px; accent-color: var(--brand); cursor: pointer; }
.inv-due tbody tr.is-off { opacity: .45; }
.paybar[hidden] { display: none; }   /* display:flex below would beat the attribute */
.paybar { display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 18px; border-top: .5px solid var(--line); background: var(--brand-soft); }
.paybar-t { font-size: 13.5px; color: var(--head); }

.paycard .card-b { padding-top: 20px; }
.paysum { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.paysum-n { font-size: 30px; font-weight: 600; letter-spacing: -.015em; color: var(--head);
  font-variant-numeric: tabular-nums; line-height: 1.1; }
.paysum-s { margin: 4px 0 0; font-size: 12.5px; color: var(--muted-2); }
.paylines { list-style: none; margin: 16px 0 20px; padding: 0; border-top: .5px solid var(--line); }
.paylines li { display: flex; align-items: baseline; gap: 12px; padding: 8px 0;
  border-bottom: .5px solid var(--line); font-size: 13px; }
.payline-n { font-weight: 500; color: var(--head); }
.payline-d { color: var(--muted-2); font-size: 12px; flex: 1; }
.payline-a { font-variant-numeric: tabular-nums; color: var(--head); }

@media (max-width: 860px) {
  body.mapp .inv-tick { display: none; }
  body.mapp .paybar { position: sticky; bottom: 0; border-radius: 0 0 14px 14px; }
  body.mapp .paysum-n { font-size: 26px; }
}

/* A stored secret reads as settled, not as an empty box waiting for input. */
.seclock { display: flex; gap: 8px; align-items: stretch; }
.seclock input { flex: 1; min-width: 0; }
.seclock input[readonly] { background: var(--soft); color: var(--muted-2); cursor: default; }
.seclock input[readonly]::placeholder { color: var(--muted-2); }
.seclock.is-open input { background: var(--surface); color: var(--text); }
.seclock .btn { flex: none; }

/* ========================================================================
   Kanban report (daily ticket MIS from Kanban)
   One loud thing on the page: "Waiting over a day", the figure that means a
   client has been left. Everything else stays in the house greys.
   ======================================================================== */
.kmis-day { margin-bottom: 18px; }
.kmis-dayhead { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 0 2px 10px; }
.kmis-dayhead h2 { margin: 0; font-size: 15px; font-weight: 600; color: var(--head); }
.kmis-step { display: flex; gap: 14px; font-size: 12.5px; }
.kmis-step a { color: var(--muted); }
.kmis-step a:hover { color: var(--brand); }
.kmis-note { margin: -4px 2px 10px; font-size: 12px; color: var(--warn); }
.kmis-tiles { margin-bottom: 8px; }
.kmis-tiles .stat { cursor: default; }
.kmis-tiles .stat-n { font-size: 26px; line-height: 1.1; }
.kmis-chg { margin-top: 6px; font-size: 11.5px; color: var(--muted); }
.kmis-tiles .kmis-late { background: var(--err-bg); border-color: #f0c4bf; }
.kmis-tiles .kmis-late .stat-n, .kmis-tiles .kmis-late .stat-l { color: var(--err); }
.kmis-tiles .kmis-clear .stat-n { color: var(--ok); }
.kmis-live { margin: 4px 2px 0; font-size: 12.5px; color: var(--muted); }
.kmis-live strong { color: var(--head); font-weight: 600; }

.kmis-bh { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.kmis-bh form { margin: 0; }
.kmis-segs { display: inline-flex; gap: 8px; flex-wrap: wrap; }
.kmis-seg { display: inline-flex; border: .5px solid var(--line-2); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.kmis-seg a { padding: 4px 10px; font-size: 12px; font-weight: 500; color: var(--muted); border-left: .5px solid var(--line-2); }
.kmis-seg a:first-child { border-left: 0; }
.kmis-seg a:hover { color: var(--head); background: var(--soft); }
.kmis-seg a.on { background: var(--brand-soft); color: var(--brand); }
.kmis-seg a:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }

.kmis-break td.kmis-latecell, .kmis-days td.kmis-latecell { color: var(--err); font-weight: 600; }
.kmis-none .name, .kmis-none td { color: var(--muted); }
@media (min-width: 861px) { .kmis-days tr.kmis-on td { background: var(--brand-soft); } }
.kmis-gap td { color: var(--muted-2); }
.kmis-gaptext { font-style: italic; }
.kmis-gap form { margin: 0; }
.kmis-src span { font-size: 11px; color: var(--muted-2); border-bottom: 1px dotted var(--line-2); cursor: help; }
.kmis-sum { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px; border-top: .5px solid var(--line); font-size: 12.5px; color: var(--muted); }
.kmis-sum strong { color: var(--head); font-variant-numeric: tabular-nums; }

.kmis-kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 0 0 14px; font-size: 13px; }
.kmis-kv dt { color: var(--muted); }
.kmis-kv dd { margin: 0; color: var(--head); min-width: 0; overflow-wrap: anywhere; }
.kmis-kv code { font-size: 12.5px; background: var(--soft); border: .5px solid var(--line); border-radius: 4px; padding: 2px 6px; }
.kmis-kv .fine { display: block; margin-top: 4px; text-align: left; }
.kmis-detail { font-size: 12px; color: var(--muted); }

/* Dashboard card */
a.kmis-dash { display: block; color: inherit; transition: border-color .15s; }
a.kmis-dash, a.kmis-dash * { text-decoration: none !important; }
@media (hover: hover) { a.kmis-dash:hover { border-color: var(--brand); } }
a.kmis-dash:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.kmis-dash-n { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; font-size: 13px; color: var(--muted); }
.kmis-dash-n strong { font-size: 18px; color: var(--head); font-variant-numeric: tabular-nums; margin-right: 3px; }
.kmis-dash-late, .kmis-dash-late strong { color: var(--err); }
.kmis-dash-go { display: inline-block; margin-top: 12px; font-size: 12.5px; color: var(--brand); font-weight: 500; }

@media (min-width: 861px) {
  .kmis-break .num, .kmis-days .num { text-align: right; font-variant-numeric: tabular-nums; width: 1%; white-space: nowrap; padding-left: 22px; }
}
@media (max-width: 860px) {
  .kmis-kv { grid-template-columns: 1fr; gap: 2px; }
  .kmis-kv dd { margin-bottom: 10px; }
  .kmis-bh { align-items: flex-start; }
  .kmis-tiles .stat-n { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) { a.kmis-dash { transition: none; } }

/* Kanban report on the phone (Ascent One): the four figures sit across one
   row under the name instead of four lines each, so a day is one short card. */
@media (max-width: 860px) {
  body.mapp table.mcard.kmis-figs tr { grid-template-columns: repeat(4, minmax(0, 1fr)); column-gap: 8px; row-gap: 8px; }
  body.mapp table.mcard.kmis-figs .m-title { grid-column: 1 / -1; grid-row: 1; }
  body.mapp table.mcard.kmis-figs td.num { grid-column: auto; grid-row: 2; font-size: 17px; font-weight: 600;
    color: var(--head); font-variant-numeric: tabular-nums; }
  body.mapp table.mcard.kmis-figs td.num.m-label::before { display: block; font-size: 11.5px; font-weight: 400;
    color: var(--muted-2); margin-bottom: 1px; }
  body.mapp table.mcard.kmis-figs td.num.kmis-latecell { color: var(--err); }
  body.mapp table.mcard.kmis-figs .kmis-none td.num { color: var(--muted); }
  body.mapp table.mcard.kmis-figs .m-full { grid-column: 1 / -1; grid-row: 2; margin-top: 0; }
  body.mapp table.mcard.kmis-figs tr.kmis-on { border-color: var(--brand); }
  body.mapp .kmis-feed .card-b { padding: 14px 16px; }
}
@media (max-width: 860px) {
  body.mapp table.mcard.kmis-figs td.kmis-fetchcell { grid-row: 3; }
  body.mapp table.mcard.kmis-figs td.kmis-fetchcell:empty { display: none; }
}

/* ==========================================================================
   VELOCITY UI BASELINE  (Ops, Ascent One, client portal)
   Ascent's shared UI rules, handed over from Ascent Velocity (Nov 2026).
   Everything here is scoped to body.app-ui, which only the signed-in shells
   set, so the public storefront keeps its own look. Desktop rules first; the
   phone rules sit in the one body.mapp block at the end.
   ========================================================================== */

/* ---- tokens: Velocity's names and values, with Select's names pointed at them ---- */
body.app-ui {
  --bg-soft: #f7f8fa; --ink: #1a1a1a; --ink-2: #4b5563; --ink-3: #6b7280;
  --line-strong: #d7dae0; --blue: #005bea; --blue-soft: rgba(0,91,234,.08);
  --shadow: 0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.06);

  --bg: #f7f8fa; --soft: #f7f8fa; --surface: #ffffff;
  --text: #1a1a1a; --head: #1a1a1a; --muted: #6b7280; --muted-2: #9ca3af;
  --line: #e4e6ea; --line-2: #d7dae0;
  --brand: #005bea; --brand-ink: #0050cf; --brand-soft: #eaf1ff;
  --ok: #0a8f5b;  --ok-bg: rgba(10,143,91,.08);
  --warn: #b7791f; --warn-bg: rgba(183,121,31,.12);
  --err: #c0392b; --err-bg: rgba(192,57,43,.08);
  --radius: 10px; --radius-sm: 8px;

  font-size: 13.5px;
}
body.app-ui h1, body.app-ui h2, body.app-ui h3 { font-weight: 500; }

/* ---- page header becomes the sticky top bar ----
   Views keep their own .page-head (title, a line under it, actions on the
   right), so nothing on a detail page is lost. On desktop it sits first in
   the content column, sticks to the top, white at 85% with a light blur and a
   hairline, and runs out to the right edge of the window. */
body.app-ui .shell { overflow-x: clip; }
body.app-ui .wrap { display: flex; flex-direction: column; }
body.app-ui .wrap > * { min-width: 0; }
body.app-ui .wrap > .page-head { order: -1; }
@media (min-width: 861px) {
  body.app-ui .wrap > .page-head {
    position: sticky; top: 0; z-index: 25; align-items: center;
    margin: -22px -26px 20px; padding: 13px 26px;
    background: rgba(255,255,255,.85); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
    border-bottom: .5px solid var(--line);
  }
  body.app-ui .wrap > .page-head::after {
    content: ""; position: absolute; top: 0; bottom: 0; left: 100%; width: 100vw;
    background: inherit; box-shadow: 0 .5px 0 0 var(--line); pointer-events: none;
  }
  body.app-ui .wrap > .page-head h1 { font-size: 16px; font-weight: 500; letter-spacing: 0; margin-bottom: 1px; }
  body.app-ui .wrap > .page-head .lede { font-size: 12.5px; }
  body.app-ui .wrap > .page-head .kb-back { margin: 0 0 2px; font-size: 12.5px; }
  body.app-ui .wrap > .page-head .fl { width: 170px; }
}

/* ---- panels ----
   A panel that holds a header or body section takes its padding from them,
   not from itself as well (that doubled the space round every filter bar). */
body.app-ui .card { border-radius: var(--radius); box-shadow: var(--shadow); }
body.app-ui .card:has(> .card-b), body.app-ui .card:has(> .card-h) { padding: 0; }
body.app-ui .card-h { padding: 14px 18px; font-size: 14px; font-weight: 500; }
body.app-ui .card-b { padding: 18px; }

/* ---- tables (desktop only: on phones the rows are cards) ---- */
body.app-ui .grid thead th { color: var(--ink-3); }
@media (min-width: 861px) {
  body.app-ui .grid thead th { padding: 10px 12px; }
  body.app-ui .grid thead th:first-child, body.app-ui .grid tbody td:first-child { padding-left: 18px; }
  body.app-ui .grid thead th:last-child, body.app-ui .grid tbody td:last-child { padding-right: 18px; }
  body.app-ui .grid tbody td { padding: 11px 12px; }
  body.app-ui .grid tbody tr:hover { background: var(--bg-soft); }
  body.app-ui .grid .num, body.app-ui .num { text-align: right; font-variant-numeric: tabular-nums; }
}
body.app-ui .cell-sub, body.app-ui .sub-note { color: var(--ink-3); font-size: 12px; }

/* ---- buttons: 38px, 8px radius, one primary per area ---- */
body.app-ui .btn { min-height: 38px; padding: 0 14px; border-radius: 8px; border-color: var(--line-strong); }
body.app-ui .btn-sm { min-height: 38px; padding: 0 12px; font-size: 12.5px; }
body.app-ui .btn-xs { min-height: 30px; padding: 0 10px; }
body.app-ui .btn-ghost { border-color: var(--line-strong); }
body.app-ui .btn-danger { color: var(--err); background: transparent; border-color: transparent; }
body.app-ui .btn-danger:hover { background: var(--err-bg); }
body.app-ui .btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---- inputs: 38px, 8px radius, blue focus ring ---- */
body.app-ui .field input:not([type=checkbox]):not([type=radio]), body.app-ui .field select,
body.app-ui .fl input, body.app-ui .fl select {
  min-height: 38px; height: 38px; border-radius: 8px; font-size: 13.5px; border-color: var(--line-strong);
}
body.app-ui .field textarea { border-radius: 8px; font-size: 13.5px; border-color: var(--line-strong); }
body.app-ui .field > span { color: var(--ink-2); }
body.app-ui .fl > span { font-size: 11.5px; letter-spacing: .03em; color: var(--ink-3); }

/* ---- pills: coloured text on a tint of the same colour ---- */
body.app-ui .pill { border-color: transparent; }
body.app-ui .pill.green { color: var(--ok); background: var(--ok-bg); }
body.app-ui .pill.amber { color: var(--warn); background: var(--warn-bg); }
body.app-ui .pill.red   { color: var(--err); background: var(--err-bg); }
body.app-ui .pill.blue  { color: var(--brand); background: var(--blue-soft); }
body.app-ui .pill.grey  { color: var(--ink-3); background: #eef0f3; }

/* ---- flash ---- */
body.app-ui .flash { border-radius: 8px; }
body.app-ui .flash-success { background: rgba(10,143,91,.08); border-color: rgba(10,143,91,.3); color: #0a8f5b; }
body.app-ui .flash-error   { background: rgba(192,57,43,.07); border-color: rgba(192,57,43,.3); color: #c0392b; }
body.app-ui .flash-info    { background: var(--blue-soft); border-color: rgba(0,91,234,.25); color: var(--blue); }

/* ---- stat tiles: big number over a short grey label ---- */
body.app-ui .stat { border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
body.app-ui .stat-n { font-size: 24px; font-weight: 600; letter-spacing: -.02em; }
body.app-ui .stat-row-5 .stat-n { font-size: 21px; }
body.app-ui .stat-l { font-size: 12px; text-transform: none; letter-spacing: 0; color: var(--ink-3); margin-top: 2px; }

/* ---- segmented switch: grey track, white active segment, blue text ---- */
body.app-ui .kmis-seg { background: var(--bg-soft); border: .5px solid var(--line-strong); border-radius: 8px; padding: 2px; gap: 2px; overflow: visible; }
body.app-ui .kmis-seg a { border: 0; border-radius: 6px; padding: 5px 12px; font-size: 13px; color: var(--ink-2); }
body.app-ui .kmis-seg a:hover { background: transparent; color: var(--ink); }
body.app-ui .kmis-seg a.on { background: #fff; color: var(--blue); box-shadow: 0 1px 2px rgba(16,24,40,.08); }

/* ---- empty state ---- */
body.app-ui .empty strong { display: block; color: var(--ink-2); font-weight: 500; margin-bottom: 4px; }

/* ---- in-page confirm (no browser dialogs) ---- */
.ui-modal[hidden] { display: none; }
.ui-modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: flex-start; justify-content: center; padding: 12vh 16px 16px; }
.ui-modal-scrim { position: fixed; inset: 0; background: rgba(15,23,42,.5); }
.ui-modal-box { position: relative; z-index: 1; width: 100%; max-width: 420px; background: #fff; border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25); padding: 20px 20px 18px; }
.ui-modal-box h2 { font-size: 15px; font-weight: 500; margin: 0 0 8px; color: var(--ink, #1a1a1a); }
.ui-modal-box p { margin: 0 0 20px; font-size: 14px; line-height: 1.55; color: var(--ink, #1a1a1a); }
.ui-modal-actions { display: flex; gap: 8px; justify-content: flex-end; }
body.modal-open { overflow: hidden; }

/* ---- account sheet: the menu items that are not tabs ---- */
.m-acct-nav { display: none; }

/* ==========================================================================
   Phones (<= 860px). One block, body.mapp only, so desktop cannot be touched.
   ========================================================================== */
@media (max-width: 860px) {
  body.mapp.app-ui .wrap { overflow-x: clip; }

  /* large title, no sticky header */
  body.mapp.app-ui .page-head h1 { font-size: 26px; font-weight: 600; letter-spacing: -.02em; line-height: 1.2; }

  /* 44px targets, 16px form text so iPhone does not zoom on focus */
  body.mapp.app-ui .btn, body.mapp.app-ui .btn-sm { min-height: 44px; font-size: 14px; }
  body.mapp.app-ui .btn-xs { min-height: 36px; }
  body.mapp.app-ui .field input:not([type=checkbox]):not([type=radio]), body.mapp.app-ui .field select,
  body.mapp.app-ui .field textarea, body.mapp.app-ui .fl input, body.mapp.app-ui .fl select { font-size: 16px; min-height: 44px; height: auto; }
  body.mapp.app-ui .form-grid { grid-template-columns: 1fr; }
  body.mapp.app-ui .gw-actions .btn, body.mapp.app-ui .form-actions .btn { flex: 1 1 auto; }

  /* tiles two to a row */
  body.mapp.app-ui .stat-row, body.mapp.app-ui .stat-row-3, body.mapp.app-ui .stat-row-5 { grid-template-columns: 1fr 1fr; gap: 10px; }

  /* segmented switches become full-width rows of equal buttons */
  body.mapp.app-ui .kmis-segs { display: grid; width: 100%; gap: 8px; }
  body.mapp.app-ui .kmis-seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; width: 100%; }
  body.mapp.app-ui .kmis-seg a { min-height: 36px; display: flex; align-items: center; justify-content: center; font-size: 14px; padding: 0 6px; }

  /* the account sheet carries what is not a tab */
  body.mapp .m-acct-nav { display: block; padding: 6px 0 4px; border-bottom: .5px solid var(--line); max-height: 52vh; overflow-y: auto; }
  body.mapp .m-acct-nav a { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 10px; color: var(--ink, #1a1a1a); font-size: 14.5px; }
  body.mapp .m-acct-nav a:hover { text-decoration: none; }
  body.mapp .m-acct-nav a:active, body.mapp .m-acct-nav a.on { background: var(--brand-soft); color: var(--brand); }
  body.mapp .m-acct-nav svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.6; flex: 0 0 18px; }

  /* modals are bottom sheets */
  .ui-modal { align-items: flex-end; padding: 0; }
  .ui-modal-box { max-width: none; border-radius: 16px 16px 0 0; padding: 20px 16px calc(16px + env(safe-area-inset-bottom)); }
  .ui-modal-actions .btn { flex: 1; min-height: 44px; }
}
.st-pw-err { color: var(--err); font-size: 12.5px; letter-spacing: 0; }
/* Save and Cancel sit bottom right above a hairline, primary last. */
body.app-ui .form-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap;
  margin-top: 20px; padding-top: 16px; border-top: .5px solid var(--line); }

/* ==========================================================================
   SPREADSHEET GRID (Velocity baseline, driven by assets/js/leads-grid.js)
   Desktop: hairline cells, inputs look like plain cells until hovered or
   focused. Phones (body.mapp): each row is a card. Ported from Velocity with
   .wrap in place of .content and white cards in place of Velocity's --bg.
   ========================================================================== */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
body.app-ui .wrap:has(.pgrid) { max-width: 1640px; }
.grid-bar { display: flex; justify-content: flex-start; margin: 0 0 12px; }
.seg { display: inline-flex; background: var(--bg-soft); border: .5px solid var(--line-strong); border-radius: 8px; padding: 2px; gap: 2px; flex-wrap: wrap; }
.seg-btn { border: none; background: none; cursor: pointer; padding: 5px 12px; border-radius: 6px; font-size: 13px; color: var(--ink-2); font-weight: 500; }
a.seg-btn { text-decoration: none; display: inline-block; }
.seg-btn:hover { color: var(--ink); text-decoration: none; }
.seg-btn.on { background: #fff; color: var(--blue); box-shadow: 0 1px 2px rgba(16,24,40,.08); }

.pg-wrap { overflow-x: auto; position: relative; }
table.pgrid { width: 100%; min-width: 1160px; border-collapse: collapse; table-layout: fixed; font-size: 13px; background: #fff; }
table.pgrid th { text-align: left; font-weight: 500; color: var(--ink-3); font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em;
  padding: 9px 10px; background: var(--bg-soft); border-bottom: .5px solid var(--line); border-right: .5px solid var(--line); white-space: nowrap; }
table.pgrid td { padding: 0; border-bottom: .5px solid var(--line); border-right: .5px solid var(--line); vertical-align: middle; position: relative; }
table.pgrid th:last-child, table.pgrid td:last-child { border-right: 0; }
table.pgrid tbody tr:last-child td { border-bottom: 0; }
table.pgrid input, table.pgrid select { width: 100%; height: 38px; border: 1px solid transparent; border-radius: 0; background: transparent;
  padding: 0 10px; font: inherit; font-size: 13px; box-shadow: none; color: var(--ink); }
table.pgrid select { padding: 0 2px 0 8px; cursor: pointer; }
table.pgrid input:hover, table.pgrid select:hover { background: var(--bg-soft); }
table.pgrid input:focus, table.pgrid select:focus { outline: none; border-color: var(--blue); background: #fff; box-shadow: none; position: relative; z-index: 1; }
table.pgrid input::placeholder { color: #a3a8b1; }
table.pgrid input[type=date] { padding-right: 4px; }
table.pgrid input[type=date][data-empty]:not(:focus) { color: #a3a8b1; }
table.pgrid input[type=number] { text-align: right; font-variant-numeric: tabular-nums; }
table.pgrid .pg-name input { font-weight: 500; }
table.pgrid tr.pg-new td { background: #fcfcfd; }
table.pgrid tr.pg-saved td { background: rgba(10,143,91,.06); transition: background .6s; }
table.pgrid tr.pg-err td { background: rgba(192,57,43,.05); }
.pg-act { text-align: center; white-space: nowrap; }
.pg-form { display: inline; }
.pg-del { display: inline; margin: 0; }
.pg-del[hidden] { display: none; }
/* locked rows read like plain cells: no hover, no pickers, no select arrows */
table.pgrid tr.pg-locked input, table.pgrid tr.pg-locked select { opacity: 1; color: var(--ink); -webkit-text-fill-color: currentColor; cursor: default;
  background: transparent; appearance: none; -webkit-appearance: none; -moz-appearance: none; }
table.pgrid tr.pg-locked input:hover, table.pgrid tr.pg-locked select:hover { background: transparent; }
table.pgrid tr.pg-locked input[type=date]::-webkit-calendar-picker-indicator { display: none; }
table.pgrid tr.pg-locked input[type=date][data-empty] { color: transparent; -webkit-text-fill-color: transparent; }
table.pgrid tr.pg-locked input::placeholder { color: transparent; }
table.pgrid tr.pg-editing td { background: rgba(0,91,234,.035); }
table.pgrid tr.pg-editing td.pg-act { box-shadow: inset 2px 0 0 var(--blue); }
.pg-edit { display: inline-flex; align-items: center; justify-content: center; gap: 5px; width: 28px; height: 28px; border: 0; background: transparent;
  color: var(--ink-3); border-radius: 6px; cursor: pointer; padding: 0; vertical-align: middle; font: inherit; }
.pg-edit[hidden] { display: none; }
.pg-edit:hover { background: var(--blue-soft); color: var(--blue); }
.pg-edit svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; display: block; }
.pg-i-done, .pg-edit-lbl { display: none; }
.pg-i-edit { display: inline-flex; }
tr.pg-editing .pg-edit { color: var(--blue); background: var(--blue-soft); }
tr.pg-editing .pg-i-edit { display: none; }
tr.pg-editing .pg-i-done { display: inline-flex; }
.pg-x { width: 28px; height: 28px; border: 0; background: transparent; color: var(--ink-3); font-size: 18px; line-height: 1; border-radius: 6px; cursor: pointer; vertical-align: middle; }
.pg-x:hover { background: rgba(192,57,43,.08); color: #c0392b; }
.pg-state { position: absolute; right: 46px; top: 50%; transform: translateY(-50%); font-size: 11px; color: var(--ink-3); pointer-events: none; display: none; }
/* desktop: a red "!" in the row's last cell, message on hover; phones show the message in full */
tr.pg-err .pg-state { display: inline-flex; align-items: center; justify-content: center; position: static; transform: none; width: 18px; height: 18px;
  border-radius: 50%; background: #c0392b; color: transparent; font-size: 0; pointer-events: auto; cursor: help; vertical-align: middle; }
tr.pg-err .pg-state::before { content: "!"; color: #fff; font-size: 12px; font-weight: 600; }
tr.pg-err .pg-del { display: none; }
.pg-foot { padding: 10px 14px; border-top: .5px solid var(--line); }
.pg-help { margin: 10px 2px 0; }
.pg-note { margin-bottom: 12px; }
.pg-note[hidden] { display: none; }

/* read-only cells and pinned columns (the code and the main name stay in view) */
table.lgrid .lg-ro { display: block; padding: 0 10px; line-height: 38px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
table.lgrid td.lg-c-id { padding: 0 10px; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.lgrid td.lg-c-id a { font-weight: 500; }
table.lgrid th:nth-child(1), table.lgrid td.lg-c-id { position: sticky; left: 0; z-index: 2; }
table.lgrid th:nth-child(2), table.lgrid td.lg-c-client { position: sticky; left: 64px; z-index: 2; box-shadow: 1px 0 0 var(--line), -1px 0 0 var(--line); }
table.lgrid td.lg-c-id, table.lgrid td.lg-c-client { background: #fff; }
table.lgrid th:nth-child(1), table.lgrid th:nth-child(2) { background: var(--bg-soft); z-index: 3; }
table.lgrid tr.pg-new td.lg-c-id, table.lgrid tr.pg-new td.lg-c-client { background: #fcfcfd; }
table.lgrid tr.pg-editing td.lg-c-id, table.lgrid tr.pg-editing td.lg-c-client { background: #f7faff; }
table.lgrid tr.pg-saved td.lg-c-id, table.lgrid tr.pg-saved td.lg-c-client { background: #f2faf6; }
table.lgrid tr.pg-err td.lg-c-id, table.lgrid tr.pg-err td.lg-c-client { background: #fdf6f5; }
table.pgrid.dgrid { min-width: 1720px; }
table.pgrid.kgrid2 { min-width: 1700px; }
table.pgrid.plgrid { min-width: 900px; }
table.plgrid th, table.plgrid td { position: static !important; box-shadow: none !important; }
table.plgrid th:nth-child(1), table.plgrid th:nth-child(2) { background: var(--bg-soft); }
table.dgrid .dg-c-next .lg-ro, table.plgrid .pl-c-n .lg-ro { font-variant-numeric: tabular-nums; }
table.plgrid .pl-c-n .lg-ro { text-align: right; padding-right: 16px; }
table.kgrid2 .kg2-c-key .keymask { font-size: 12px; }

/* live filters apply as you go, so a Filter button is only a no-JS fallback */
form.filters-live button[type=submit] { display: none; }

@media (max-width: 860px) {
  body.mapp .grid-bar .seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; width: 100%; }
  body.mapp .grid-bar .seg-btn { text-align: center; min-height: 36px; display: flex; align-items: center; justify-content: center; font-size: 14px; }
  body.mapp .pg-wrap { overflow: visible; position: static; }
  body.mapp .panel.clip:has(.pgrid) { background: transparent; border: 0; box-shadow: none; overflow: visible; }
  body.mapp table.pgrid { min-width: 0 !important; table-layout: auto; display: block; background: none; }
  body.mapp table.pgrid colgroup, body.mapp table.pgrid thead { display: none; }
  body.mapp table.pgrid tbody { display: flex; flex-direction: column; gap: 12px; }
  body.mapp table.pgrid tr { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; background: #fff; border: .5px solid var(--line);
    border-radius: 14px; padding: 14px 14px 10px; box-shadow: 0 1px 3px rgba(16,24,40,.06); position: relative; }
  body.mapp table.pgrid tr.pg-new { border-style: dashed; }
  body.mapp table.pgrid tr.pg-new td { background: transparent; }
  body.mapp table.pgrid td { display: flex; flex-direction: column; gap: 3px; border: 0; padding: 0; min-width: 0; background: transparent !important; position: static !important; box-shadow: none !important; }
  body.mapp table.pgrid td[data-label]::before { content: attr(data-label); font-size: 11px; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-3); }
  body.mapp table.pgrid td.pg-wide, body.mapp table.pgrid td.pg-notes { grid-column: 1 / -1; }
  body.mapp table.pgrid input, body.mapp table.pgrid select { height: 44px; font-size: 16px; border: .5px solid var(--line-strong); border-radius: 8px; background: #fff; padding: 0 11px; text-align: left; }
  body.mapp table.pgrid select { padding-right: 26px; }
  body.mapp table.pgrid td.pg-act { grid-column: 1 / -1; flex-direction: row; justify-content: flex-end; align-items: center; gap: 8px; order: 99;
    border-top: .5px solid var(--line); padding-top: 8px; margin-top: 2px; }
  body.mapp table.pgrid tr.pg-new td.pg-act { display: none; }
  body.mapp .pg-x { width: auto; height: 36px; padding: 0 12px; font-size: 13px; border: .5px solid var(--line); border-radius: 8px; }
  body.mapp .pg-x::after { content: " Delete"; font-size: 12.5px; }
  body.mapp .pg-edit { width: auto; height: 36px; padding: 0 12px; border: .5px solid var(--line); border-radius: 8px; color: var(--ink); }
  body.mapp .pg-edit-lbl { display: inline; font-size: 12.5px; }
  body.mapp tr.pg-editing .pg-edit { border-color: var(--blue); color: var(--blue); }
  body.mapp table.pgrid tr.pg-locked input, body.mapp table.pgrid tr.pg-locked select { border-color: transparent; background: transparent; padding: 0; height: auto; min-height: 24px; }
  body.mapp table.pgrid tr.pg-locked td.pg-name input { font-size: 17px; }
  body.mapp table.pgrid tr.pg-locked { gap: 6px 10px; }
  body.mapp table.pgrid tr.pg-editing td { background: transparent; }
  body.mapp table.pgrid tr.pg-editing { border-color: var(--blue); }
  body.mapp table.pgrid tr.pg-editing td.pg-act { box-shadow: none; }
  body.mapp .pg-state { position: static; transform: none; }
  body.mapp tr.pg-saved .pg-state, body.mapp tr.pg-saving .pg-state { display: inline; }
  body.mapp tr.pg-err .pg-state { width: auto; height: auto; border-radius: 0; background: none; color: #c0392b; font-size: 12.5px; margin-right: auto; }
  body.mapp tr.pg-err .pg-state::before { content: none; }
  body.mapp tr.pg-err .pg-del { display: inline; }
  body.mapp tr.pg-new.pg-err td.pg-act { display: flex; }
  body.mapp .pg-foot { border: 0; padding: 12px 2px; }
  body.mapp table.lgrid .lg-ro { padding: 0; line-height: 1.4; white-space: normal; text-align: left !important; }
  body.mapp table.lgrid td.lg-c-id { padding: 0; }
  body.mapp table.lgrid tr.pg-new td.lg-c-id { display: none; }
  /* locked cards show only what is filled in; unlocking a card shows every field */
  body.mapp table.lgrid tr.pg-locked td:has(> input[value=""]) { display: none; }

  /* Debt card: Lender, Company, Principal + Rate, Interest + Status, dates, Next interest, Code, Notes */
  body.mapp table.dgrid td.dg-c-lender { order: 1; }
  body.mapp table.dgrid td.dg-c-entity { order: 2; }
  body.mapp table.dgrid td.dg-c-principal { order: 3; }
  body.mapp table.dgrid td.dg-c-rate { order: 4; }
  body.mapp table.dgrid td.dg-c-freq { order: 5; }
  body.mapp table.dgrid td.dg-c-status { order: 6; }
  body.mapp table.dgrid td.dg-c-from { order: 7; }
  body.mapp table.dgrid td.dg-c-to { order: 8; }
  body.mapp table.dgrid td.dg-c-next { order: 9; }
  body.mapp table.dgrid td.lg-c-id { order: 10; }
  body.mapp table.dgrid td.dg-c-notes { order: 11; }

  /* Key instance card: Instance, Client, Platform + Environment, Status + Version, URL, Key + Code, Notes */
  body.mapp table.kgrid2 td.kg2-c-label { order: 1; }
  body.mapp table.kgrid2 td.kg2-c-client { order: 2; }
  body.mapp table.kgrid2 td.kg2-c-plat { order: 3; }
  body.mapp table.kgrid2 td.kg2-c-env { order: 4; }
  body.mapp table.kgrid2 td.kg2-c-status { order: 5; }
  body.mapp table.kgrid2 td.kg2-c-ver { order: 6; }
  body.mapp table.kgrid2 td.kg2-c-url { order: 7; }
  body.mapp table.kgrid2 td.kg2-c-key { order: 8; }
  body.mapp table.kgrid2 td.lg-c-id { order: 9; }
  body.mapp table.kgrid2 td.kg2-c-notes { order: 10; }

  /* Platform card: Name, Code + Status, Instances, Description */
  body.mapp table.plgrid td.pl-c-name { order: 1; }
  body.mapp table.plgrid td.pl-c-code { order: 2; }
  body.mapp table.plgrid td.pl-c-status { order: 3; }
  body.mapp table.plgrid td.pl-c-n { order: 4; }
  body.mapp table.plgrid td.pl-c-desc { order: 5; }
}
@media (max-width: 860px) {
  /* the blank card leaves out what only exists once saved (next interest, key, instance count) */
  body.mapp table.pgrid tr.pg-new td:empty { display: none; }
}

/* ==========================================================================
   New order: one page. Client and products on the left, a summary with the
   one action on the right (it follows you down the page on desktop).
   ========================================================================== */
.ord { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.ord-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
body.app-ui .ord-main > .card + .card { margin-top: 0; }
.ord-sum { position: sticky; top: 84px; }
.ord-sum .btn-block { margin-top: 16px; min-height: 42px; }
.ord-sum .fine { text-align: left; }
.ord-sum-client { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink) !important; }

.opick { position: relative; }
.opick .field { margin: 0; }
.opick-list { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 30; background: #fff;
  border: .5px solid var(--line-strong); border-radius: 8px; box-shadow: 0 8px 24px rgba(16,24,40,.12); max-height: 300px; overflow-y: auto; padding: 4px; }
.opick-list[hidden] { display: none; }
.opick-opt { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.opick-opt.hi { background: var(--blue-soft); }
.opick-opt.off { cursor: not-allowed; opacity: .55; }
.opick-name { font-weight: 500; color: var(--ink); grid-column: 1; }
.opick-meta { font-size: 12px; color: var(--ink-3); grid-column: 1; }
.opick-price { grid-column: 2; grid-row: 1 / span 2; align-self: center; font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: 13px; }
.opick-none { padding: 10px; color: var(--ink-3); font-size: 13px; }

.ord-client { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  padding: 12px 14px; border: .5px solid var(--line); border-radius: 8px; background: var(--bg-soft); }
.ord-client[hidden] { display: none; }
.ord-client-name { font-weight: 600; color: var(--ink); font-size: 14.5px; }
.ord-client-meta { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }
.ord-client-mail { font-size: 12.5px; color: var(--ink-2); margin-top: 6px; overflow-wrap: anywhere; }
.ord-client-mail.warn { color: var(--warn); }

.ord-add { padding-bottom: 14px; }
.ord-lines[hidden], .ord-empty[hidden] { display: none; }
.ord-empty { padding: 26px 20px; border-top: .5px solid var(--line); }
.ord-empty p { margin: 0; }
.ord-lines { border-top: .5px solid var(--line); }
.ord-lines input { font: inherit; font-size: 13px; height: 34px; padding: 0 9px; border: .5px solid var(--line-strong); border-radius: 6px; background: #fff; color: var(--ink); width: 100%; }
.ord-lines input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.ord-lines .ord-qty { width: 72px; text-align: right; font-variant-numeric: tabular-nums; }
.ord-lines td.num { white-space: nowrap; }
@media (min-width: 861px) {
  .ord-lines { table-layout: fixed; }
  .ord-lines th:nth-child(1) { width: 19%; }
  .ord-lines th:nth-child(2) { width: auto; }
  .ord-lines th:nth-child(3) { width: 106px; }
  .ord-lines th:nth-child(4) { width: 58px; }
  .ord-lines th:nth-child(5) { width: 86px; }
  .ord-lines th:nth-child(6) { width: 116px; }
  .ord-lines th:nth-child(7) { width: 46px; }
  body.app-ui .ord-lines tbody td:nth-child(n+3), body.app-ui .ord-lines thead th:nth-child(n+3) { padding-left: 8px; padding-right: 8px; }
  .ord-lines td { overflow-wrap: anywhere; }
}
.ord-amt { font-weight: 500; }
.ord-x { width: 28px; height: 28px; border: 0; background: transparent; color: var(--ink-3); font-size: 18px; line-height: 1; border-radius: 6px; cursor: pointer; }
.ord-x:hover { background: rgba(192,57,43,.08); color: #c0392b; }

@media (max-width: 1080px) {
  .ord { grid-template-columns: minmax(0, 1fr); }
  .ord-sum { position: static; }
}
@media (max-width: 860px) {
  body.mapp .ord-lines { border-top: 0; margin: 0 14px 14px; width: auto; }
  body.mapp .ord-lines input { height: 44px; font-size: 16px; border-radius: 8px; }
  body.mapp .ord-lines .ord-qty { text-align: left; }
  /* line card: name + amount, price + GST, description, quantity + remove */
  body.mapp table.mcard.ord-lines tr { grid-template-columns: minmax(0, 1fr) auto; row-gap: 6px; }
  body.mapp table.mcard.ord-lines td:nth-child(1) { grid-column: 1; grid-row: 1; }
  body.mapp table.mcard.ord-lines td.ord-amt { grid-column: 2; grid-row: 1; }
  body.mapp table.mcard.ord-lines td:nth-child(3) { grid-column: 1; grid-row: 2; }
  body.mapp table.mcard.ord-lines td:nth-child(4) { grid-column: 2; grid-row: 2; text-align: right; }
  body.mapp table.mcard.ord-lines td:nth-child(2) { grid-column: 1 / -1; grid-row: 3; margin-top: 4px; }
  body.mapp table.mcard.ord-lines td.ord-qtycell { grid-column: 1; grid-row: 4; margin-top: 0; display: flex; align-items: center; gap: 10px; text-align: left; }
  body.mapp table.mcard.ord-lines td.ord-qtycell::before { content: "Qty"; display: inline; font-size: 13px; color: var(--ink-3); }
  body.mapp table.mcard.ord-lines .ord-qty { width: 96px; }
  body.mapp table.mcard.ord-lines td.col-action { grid-column: 2; grid-row: 4; align-self: center; }
  body.mapp .ord-x { width: auto; height: 40px; padding: 0 12px; font-size: 13px; border: .5px solid var(--line); border-radius: 8px; color: var(--ink-2); }
  body.mapp .ord-x::after { content: " Remove"; }
  body.mapp .opick-list { max-height: 50vh; }
  body.mapp .ord-sum .btn-block { min-height: 48px; }
}
