/* ==========================================================================
   MabiznaHub SMS Credit Desk
   A quiet operations console. The one loud element is the credit budget
   gauge on the overview: it is the number every payment is judged against.
   ========================================================================== */

:root {
    --paper: #eef1ef;
    --surface: #ffffff;
    --ink: #14212a;
    --ink-2: #4c5c64;
    --ink-3: #7a888e;
    --line: #d4dbd7;
    --line-soft: #e6ebe8;

    --green: #0b6b55;
    --green-deep: #08523f;
    --green-tint: #e2f0ea;
    --amber: #95600a;
    --amber-bar: #d9a441;
    --amber-tint: #fbf0d9;
    --red: #a3342a;
    --red-tint: #f8e3e0;
    --blue: #285a85;
    --blue-tint: #e2ebf4;
    --grey-tint: #e9ecea;

    --buffer: #b9c3be;
    --amber-bar-2: #e7bd6c;
    --amber-line: #efd6a3;
    --amber-hover: #f7e6c1;
    --red-line: #e2b8b3;
    --red-hover: #8a2b22;
    --row-hover: #f6f8f7;
    --btn-hover: #f4f6f5;
    --control-line: #bfc9c4;
    --on-accent: #ffffff;
    --shadow: 0 18px 48px rgba(20, 33, 42, .22);
    --backdrop: rgba(20, 33, 42, .45);
    color-scheme: light;

    --font: "Public Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
    --gutter: clamp(16px, 2.4vw, 40px);
    --radius-s: 4px;
    --radius-m: 8px;
    --focus: 0 0 0 3px rgba(11, 107, 85, .35);
}

/* Dark theme: follows the device unless the user picked a theme with the toggle. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
    --paper: #0f1619;
    --surface: #172126;
    --ink: #e3eae7;
    --ink-2: #a2b1ae;
    --ink-3: #7b8a89;
    --line: #2c3b40;
    --line-soft: #223137;

    --green: #3fb391;
    --green-deep: #62cba8;
    --green-tint: #15362d;
    --amber: #e6b65f;
    --amber-bar: #c9922f;
    --amber-tint: #382c15;
    --red: #f0897d;
    --red-tint: #3c201c;
    --blue: #8db8df;
    --blue-tint: #1a2d3e;
    --grey-tint: #233237;

    --buffer: #4b5c60;
    --amber-bar-2: #a87a26;
    --amber-line: #5c4720;
    --amber-hover: #45361a;
    --red-line: #6a3530;
    --red-hover: #f5a59b;
    --row-hover: #1d292f;
    --btn-hover: #213036;
    --control-line: #3b4d52;
    --on-accent: #0a1c17;
    --focus: 0 0 0 3px rgba(63, 179, 145, .45);
    --shadow: 0 18px 48px rgba(0, 0, 0, .55);
    --backdrop: rgba(4, 8, 10, .7);
    color-scheme: dark;
    }
}
:root[data-theme="dark"] {
    --paper: #0f1619;
    --surface: #172126;
    --ink: #e3eae7;
    --ink-2: #a2b1ae;
    --ink-3: #7b8a89;
    --line: #2c3b40;
    --line-soft: #223137;

    --green: #3fb391;
    --green-deep: #62cba8;
    --green-tint: #15362d;
    --amber: #e6b65f;
    --amber-bar: #c9922f;
    --amber-tint: #382c15;
    --red: #f0897d;
    --red-tint: #3c201c;
    --blue: #8db8df;
    --blue-tint: #1a2d3e;
    --grey-tint: #233237;

    --buffer: #4b5c60;
    --amber-bar-2: #a87a26;
    --amber-line: #5c4720;
    --amber-hover: #45361a;
    --red-line: #6a3530;
    --red-hover: #f5a59b;
    --row-hover: #1d292f;
    --btn-hover: #213036;
    --control-line: #3b4d52;
    --on-accent: #0a1c17;
    --focus: 0 0 0 3px rgba(63, 179, 145, .45);
    --shadow: 0 18px 48px rgba(0, 0, 0, .55);
    --backdrop: rgba(4, 8, 10, .7);
    color-scheme: dark;
}

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

[hidden] { display: none !important; }

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

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    font-variant-numeric: tabular-nums;
}

a { color: var(--green); text-underline-offset: 2px; }
a:hover { color: var(--green-deep); }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius-s); }

h1, h2, h3 { margin: 0; line-height: 1.2; }
p { margin: 0; }

.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.break { word-break: break-all; }
.truncate { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mono-ish { font-feature-settings: "tnum", "zero"; letter-spacing: .02em; font-weight: 500; }
.stack > * + * { margin-top: 14px; }

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

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 10;
}
.topbar__inner {
    padding: 0 var(--gutter);
    display: flex;
    align-items: center;
    gap: 32px;
    min-height: 60px;
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--ink);
    text-decoration: none;
    font-weight: 700;
    font-size: 16px;
}
.brand:hover { color: var(--ink); }
.brand__mark { width: 22px; height: 22px; fill: var(--green); flex: none; }
.brand__name { white-space: nowrap; }
.brand__sub { font-weight: 500; color: var(--ink-2); margin-left: 2px; }
.sandbox-form { margin-top: 10px; }
.brand--large { font-size: 21px; align-items: flex-start; }
.brand--large .brand__name { white-space: normal; line-height: 1.25; }
.brand--large .brand__mark { width: 30px; height: 30px; }

.nav { display: flex; gap: 4px; flex: 1; }
.nav a {
    color: var(--ink-2);
    text-decoration: none;
    font-weight: 500;
    padding: 18px 12px 16px;
    border-bottom: 2px solid transparent;
}
.nav a:hover { color: var(--ink); }
.nav a.is-active { color: var(--ink); border-bottom-color: var(--green); }

.topbar__tools { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.signout { display: flex; align-items: center; gap: 12px; margin: 0; }

/* Theme toggle: shows the moon in light mode and the sun in dark mode. */
.theme-toggle {
    width: 34px;
    height: 34px;
    display: inline-grid;
    place-items: center;
    padding: 0;
    border: 1px solid transparent;
    border-radius: var(--radius-s);
    background: transparent;
    color: var(--ink-2);
    cursor: pointer;
}
.theme-toggle:hover { background: var(--grey-tint); color: var(--ink); }
.theme-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
    :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}
.theme-toggle--corner { position: fixed; top: 16px; right: 16px; }
.signout__user { color: var(--ink-3); font-size: 13px; }

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

.page { padding: 24px var(--gutter) 56px; }
/* Forms and settings stay at a readable width, centred */
.page--narrow { max-width: 980px; margin: 0 auto; }
.page-head { margin-bottom: 20px; }
.page-head .muted { margin-top: 6px; }
.page-head--split { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.page-title { font-size: 26px; font-weight: 700; letter-spacing: -.01em; }
.back { display: inline-block; margin-bottom: 10px; font-size: 13px; color: var(--ink-2); text-decoration: none; }
.back::before { content: "\2039"; margin-right: 6px; }

/* ---------- Credit budget (the hero) ---------- */

.budget {
    background: var(--surface);
    border: 1px solid var(--line);
    border-top: 4px solid var(--green);
    border-radius: var(--radius-m);
    padding: 24px 28px 22px;
    margin-bottom: 18px;
}
.budget--warn { border-top-color: var(--amber-bar); }
.budget__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; flex-wrap: wrap; }
.budget__title { font-size: 15px; font-weight: 600; color: var(--ink-2); }
.budget__figure {
    font-size: clamp(40px, 6vw, 60px);
    font-weight: 700;
    letter-spacing: -.03em;
    line-height: 1.05;
    margin-top: 6px;
}
.budget__figure--off { font-size: 32px; color: var(--amber); }
.budget__unit { font-size: 20px; font-weight: 500; color: var(--ink-2); letter-spacing: 0; margin-left: 6px; }
.budget__refresh { display: flex; align-items: center; gap: 12px; margin: 0; }
.budget__sentence { margin-top: 12px; max-width: 70ch; color: var(--ink-2); }
.budget__sentence strong { color: var(--ink); }
.budget__sentence--warn { color: var(--amber); font-weight: 500; }

.gauge {
    display: flex;
    height: 14px;
    margin-top: 22px;
    border-radius: 3px;
    overflow: hidden;
    background: var(--grey-tint);
}
.gauge__seg { display: block; height: 100%; transition: width .6s cubic-bezier(.2, .7, .2, 1); }
.gauge__seg--available { background: var(--green); }
.gauge__seg--held {
    background: repeating-linear-gradient(135deg, var(--amber-bar) 0 6px, var(--amber-bar-2) 6px 12px);
}
.gauge__seg--buffer { background: var(--buffer); }

.legend {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 12px 24px;
    margin: 14px 0 0;
}
.legend__item dt { font-size: 13px; color: var(--ink-2); display: flex; align-items: center; gap: 8px; }
.legend__item dd { margin: 2px 0 0; font-size: 17px; font-weight: 600; }
.legend__item--total { border-top: 1px solid var(--line-soft); padding-top: 10px; }
.budget { container-type: inline-size; }
@container (min-width: 720px) {
    .legend { grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(0, 1.1fr); }
    .legend__item--total { border-top: 0; padding-top: 0; border-left: 1px solid var(--line); padding-left: 20px; }
}
.swatch { width: 10px; height: 10px; border-radius: 2px; display: inline-block; flex: none; }
.swatch--available { background: var(--green); }
.swatch--held { background: var(--amber-bar); }
.swatch--buffer { background: var(--buffer); }

/* ---------- Today strip ---------- */

.today {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 1px;
    background: var(--line-soft);
    border: 1px solid var(--line);
    border-radius: var(--radius-m);
    overflow: hidden;
}
.today__item {
    background: var(--surface);
    padding: 14px 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    text-decoration: none;
    color: inherit;
    min-width: 0;
}
.today__item--link:hover { background: var(--row-hover); }
.today__label { font-size: 13px; color: var(--ink-2); }
.today__value { font-size: 20px; font-weight: 600; color: var(--ink); text-decoration: none; }
.today__item--attention { background: var(--amber-tint); grid-column: 1 / -1; }
.today__item--attention .today__label { color: var(--amber); font-weight: 600; }
.today__item--attention:hover { background: var(--amber-hover); }

/* ---------- Dashboard grid ---------- */

.dash {
    display: grid;
    gap: 18px;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "budget" "today" "recent";
}
.dash > * { margin-bottom: 0; min-width: 0; }
.dash__budget { grid-area: budget; }
.dash__today { grid-area: today; }
.dash__recent { grid-area: recent; }

/* Wide screens: budget and today's figures side by side, payments below at full width */
@media (min-width: 1200px) {
    .dash { grid-template-columns: minmax(0, 1fr) minmax(320px, 400px); grid-template-areas: "budget today" "recent recent"; }
    .dash__today { grid-template-columns: 1fr 1fr; align-content: stretch; }
}
@media (min-width: 1800px) {
    .dash { grid-template-columns: minmax(0, 1fr) 480px; }
}

/* Live indicator */
.live { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.live__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 0 var(--green); animation: live-pulse 2s infinite; }
.live--offline .live__dot { background: var(--amber-bar); animation: none; }
.live--offline { color: var(--amber); }
@keyframes live-pulse {
    0% { box-shadow: 0 0 0 0 rgba(11, 107, 85, .45); }
    70% { box-shadow: 0 0 0 7px rgba(11, 107, 85, 0); }
    100% { box-shadow: 0 0 0 0 rgba(11, 107, 85, 0); }
}
.is-updated { animation: value-flash 1.2s ease-out; border-radius: 3px; }
@keyframes value-flash { from { background: var(--green-tint); } to { background: transparent; } }

/* ---------- Notifications ---------- */

.block { display: block; margin-top: 2px; }
.text-bad { color: var(--red); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.today--strip { margin-bottom: 18px; }
.message-cell { min-width: 220px; max-width: 420px; }
.message summary { cursor: pointer; color: var(--ink); list-style: none; }
.message summary::-webkit-details-marker { display: none; }
.message summary::after { content: " more"; color: var(--green); font-size: 12.5px; font-weight: 600; }
.message[open] summary { display: none; }
.message p { margin: 0 0 4px; white-space: pre-wrap; }
.actions-cell { white-space: nowrap; text-align: right; }
.actions-cell form { display: inline-block; margin: 0 0 0 4px; }

/* ---------- Panels & tables ---------- */

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-m);
    padding: 18px 20px;
    margin-bottom: 18px;
}
.panel__head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.panel__title { font-size: 16px; font-weight: 600; }
.panel > .muted.small { margin-bottom: 12px; }

.table-wrap { overflow-x: auto; margin: 0 -20px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 10px 20px; text-align: left; vertical-align: middle; }
.table th {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--ink-2);
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.table td { border-bottom: 1px solid var(--line-soft); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; white-space: nowrap; }
.row-link { cursor: pointer; }
.row-link:hover td { background: var(--row-hover); }

.empty { padding: 28px 0 12px; color: var(--ink-2); display: flex; flex-direction: column; align-items: flex-start; gap: 12px; }
.empty p { max-width: 60ch; }

.pager { display: flex; justify-content: flex-end; align-items: center; gap: 12px; padding-top: 14px; }
.pager__info { font-size: 13px; color: var(--ink-2); }

/* ---------- Status pills ---------- */

.pill {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 600;
    white-space: nowrap;
    border: 1px solid transparent;
}
.pill--ok { background: var(--green-tint); color: var(--green-deep); }
.pill--info { background: var(--blue-tint); color: var(--blue); }
.pill--warn { background: var(--amber-tint); color: var(--amber); border-color: var(--amber-line); }
.pill--bad { background: var(--red-tint); color: var(--red); }
.pill--muted { background: var(--grey-tint); color: var(--ink-2); }

/* ---------- Forms & buttons ---------- */

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field--grow { flex: 1 1 260px; }
.field__label { font-size: 13px; font-weight: 600; color: var(--ink); }
.field__hint { font-size: 12.5px; color: var(--ink-2); }
.field__error { font-size: 12.5px; color: var(--red); font-weight: 500; }
.field__error:empty { display: none; }

input, select, textarea {
    font: inherit;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--control-line);
    border-radius: var(--radius-s);
    padding: 8px 10px;
    min-height: 38px;
    width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--green); box-shadow: var(--focus); }
textarea { resize: vertical; }

/* Password with show/hide eye */
.password-field { position: relative; display: block; }
.password-field input { padding-right: 46px; }
.password-field__toggle {
    position: absolute;
    top: 50%;
    right: 4px;
    transform: translateY(-50%);
    width: 36px;
    height: 32px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: var(--radius-s);
    background: transparent;
    color: var(--ink-2);
    cursor: pointer;
}
.password-field__toggle:hover { color: var(--ink); background: var(--grey-tint); }
.password-field__toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.password-field__toggle .icon-eye-off { display: none; }
.password-field__toggle[aria-pressed="true"] .icon-eye { display: none; }
.password-field__toggle[aria-pressed="true"] .icon-eye-off { display: block; }

.has-error input, .has-error textarea, .has-error select { border-color: var(--red); }

.form > * + * { margin-top: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 6px; }

.filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
    margin-bottom: 18px;
}
.filters .field:not(.field--grow) { flex: 0 1 170px; }
.filters__actions { display: flex; gap: 8px; }
.filters--flat { margin: 0 0 12px; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 38px;
    padding: 0 16px;
    font: inherit;
    font-weight: 600;
    font-size: 14px;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--control-line);
    border-radius: var(--radius-s);
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}
.btn:hover { background: var(--btn-hover); color: var(--ink); }
.btn--sm { min-height: 32px; padding: 0 12px; font-size: 13px; }
.btn--block { width: 100%; }
.btn--primary { background: var(--green); border-color: var(--green); color: var(--on-accent); }
.btn--primary:hover { background: var(--green-deep); border-color: var(--green-deep); color: var(--on-accent); }
.btn--quiet { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn--quiet:hover { background: var(--grey-tint); color: var(--ink); }
.btn--danger { background: var(--red); border-color: var(--red); color: var(--on-accent); }
.btn--danger:hover { background: var(--red-hover); border-color: var(--red-hover); color: var(--on-accent); }
.btn--danger-quiet { color: var(--red); border-color: var(--red-line); }
.btn--danger-quiet:hover { background: var(--red-tint); color: var(--red); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- Flash & callouts ---------- */

.flash-stack:empty { display: none; }
.flash-stack { margin-bottom: 16px; display: grid; gap: 8px; }
.flash {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-s);
    font-weight: 500;
    border-left: 4px solid;
}
.flash--ok { background: var(--green-tint); border-color: var(--green); color: var(--green-deep); }
.flash--bad { background: var(--red-tint); border-color: var(--red); color: var(--red); }
.flash__close { background: none; border: 0; font-size: 20px; line-height: 1; color: inherit; cursor: pointer; padding: 0 4px; }

.callout { padding: 12px 16px; border-radius: var(--radius-s); margin-bottom: 18px; border-left: 4px solid; }
.callout--ok { background: var(--green-tint); border-color: var(--green); }
.callout--info { background: var(--blue-tint); border-color: var(--blue); }
.callout--warn { background: var(--amber-tint); border-color: var(--amber-bar); }
.callout--bad { background: var(--red-tint); border-color: var(--red); }
.callout--muted { background: var(--grey-tint); border-color: var(--buffer); }
.panel .callout { margin: 12px 0 0; }

/* ---------- Detail page ---------- */

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-2 > .panel { margin-bottom: 18px; }

.facts { margin: 0; display: grid; gap: 0; }
.facts > div {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--line-soft);
}
.facts > div:last-child { border-bottom: 0; }
.facts dt { color: var(--ink-2); font-size: 13.5px; }
.facts dd { margin: 0; font-weight: 500; min-width: 0; }
.facts--urls { margin: 10px 0 12px; }

.actions-panel { border-color: var(--amber-line); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline__item {
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: 16px;
    padding: 10px 0;
    position: relative;
}
.timeline__item + .timeline__item { border-top: 1px dashed var(--line); }
.timeline__time { font-size: 13px; color: var(--ink-2); padding-top: 1px; }
.timeline__type { font-weight: 600; margin-right: 6px; }
.timeline__detail { margin-top: 3px; color: var(--ink-2); font-size: 14px; max-width: 75ch; }

.steps { margin: 0; padding-left: 20px; display: grid; gap: 16px; }
.steps li { padding-left: 4px; }
.steps li > form { margin-top: 4px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* ---------- Dialog ---------- */

.dialog {
    border: 1px solid var(--line);
    border-radius: var(--radius-m);
    padding: 22px 24px;
    width: min(480px, calc(100vw - 32px));
    color: var(--ink);
    box-shadow: var(--shadow);
    background: var(--surface);
}
.dialog::backdrop { background: var(--backdrop); }
.dialog[open] { animation: dialog-in .16s ease-out; }
.dialog__title { font-size: 18px; font-weight: 700; }
.dialog__actions { display: flex; justify-content: flex-end; gap: 10px; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Login ---------- */

.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login__panel {
    width: min(440px, 100%);
    grid-template-columns: minmax(0, 1fr);
    background: var(--surface);
    border: 1px solid var(--line);
    border-top: 4px solid var(--green);
    border-radius: var(--radius-m);
    padding: 32px 30px;
    display: grid;
    gap: 18px;
}
.login__lede { color: var(--ink-2); }

/* ---------- Responsive ---------- */

@media (max-width: 860px) {
    .topbar__inner { flex-wrap: wrap; gap: 0 16px; padding: 0 16px; }
    .nav { order: 3; flex-basis: 100%; overflow-x: auto; margin: 0 -12px; }
    .nav a { padding: 10px 12px 12px; }
    .topbar__tools { margin-left: auto; }
    .page { padding: 20px 16px 48px; }
    .grid-2, .form-row { grid-template-columns: 1fr; }
    .facts > div { grid-template-columns: 1fr; gap: 2px; }
    .timeline__item { grid-template-columns: 1fr; gap: 2px; }
    .table-wrap { margin: 0 -20px; }
    .today { grid-template-columns: 1fr 1fr; }
}

/* Less important table columns step aside on smaller screens */
@media (max-width: 1000px) {
    .hide-md { display: none; }
}
@media (max-width: 640px) {
    .hide-sm { display: none; }

    /* Generic card rows: each cell on its own line with its column name */
    .table--cards thead { display: none; }
    .table--cards, .table--cards tbody, .table--cards tr, .table--cards td { display: block; }
    .table--cards tr { padding: 12px 20px; border-bottom: 1px solid var(--line-soft); }
    .table--cards tbody tr:last-child { border-bottom: 0; }
    .table--cards td {
        display: grid;
        grid-template-columns: 92px minmax(0, 1fr);
        column-gap: 10px;
        align-items: baseline;
        padding: 3px 0;
        border: 0;
        max-width: none;
        min-width: 0;
        text-align: left;
        white-space: normal;
    }
    .table--cards td > * { grid-column: 2; }
    .table--cards td > .pill { justify-self: start; }
    .table--cards td[data-label]:not([data-label=""])::before {
        content: attr(data-label);
        grid-column: 1;
        grid-row: 1 / span 4;
        font-size: 12px;
        font-weight: 600;
        color: var(--ink-2);
    }
    .table--cards td[data-label=""] { display: block; }
    .table--cards .actions-cell { text-align: left; padding-top: 8px; }
    .table--cards .actions-cell form { margin: 0 6px 0 0; }

    /* Payment tables become compact cards: account + amount, ref + status, time */
    .table--stack thead { display: none; }
    .table--stack, .table--stack tbody { display: block; }
    .table--stack tr {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas: "account amount" "ref status" "time time";
        gap: 4px 12px;
        padding: 12px 20px;
        border-bottom: 1px solid var(--line-soft);
    }
    .table--stack tbody tr:last-child { border-bottom: 0; }
    .table--stack td { display: block; padding: 0; border: 0; min-width: 0; }
    .table--stack .hide-md, .table--stack .hide-sm { display: none; }
    .table--stack .c-account { grid-area: account; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .table--stack .c-amount { grid-area: amount; font-weight: 600; text-align: right; }
    .table--stack .c-ref { grid-area: ref; font-size: 13px; }
    .table--stack .c-status { grid-area: status; text-align: right; }
    .table--stack .c-time { grid-area: time; font-size: 12.5px; color: var(--ink-2); }
    .filters .field:not(.field--grow) { flex: 1 1 140px; }
    .filters__actions { flex: 1 1 100%; }
    .filters__actions .btn { flex: 1; }
    .page-title { font-size: 22px; }
    .budget { padding: 18px 18px 16px; }
    .table th, .table td { padding: 9px 14px; }
    .table-wrap { margin: 0 -20px; }
}

@media (prefers-reduced-motion: reduce) {
    .live__dot, .is-updated { animation: none; }
    .gauge__seg { transition: none; }
    body { transition: none !important; }
    .dialog[open] { animation: none; }
}
