/* ==========================================================================
   WTC Coal ERP: the only stylesheet. No inline styles anywhere in the app.

   1. Tokens          6. Forms               11. Dashboard            16. Audit log
   2. Base            7. Tables              12. Sign-in & errors     17. Help & guide
   3. App shell       8. Cards & lists       13. Reports and ledgers  18. Search, lists, parties,
   4. Page layout     9. Status & feedback   14. Users & roles            aging, gate pass
   5. Buttons        10. Documents           15. Company & FBR        19. Responsive & print
   ========================================================================== */

/* 1. Tokens --------------------------------------------------------------- */
:root {
    /* Surfaces */
    --bg: #f2f4f7;
    --surface: #ffffff;
    --surface-sunken: #f8f9fb;
    --surface-hover: #f5f8f7;
    --border: #e4e7ec;
    --border-strong: #cdd2da;

    /* Ink */
    --ink: #151923;
    --ink-2: #475061;
    --ink-3: #6f7787;

    /* Brand: deep coal green */
    --brand: #136b58;
    --brand-strong: #0d5243;
    --brand-soft: #e7f3f0;
    --brand-ring: rgba(19, 107, 88, .22);

    /* Sidebar */
    --nav-bg: #10151d;
    --nav-bg-2: #171e29;
    --nav-ink: #b9c0cc;
    --nav-ink-strong: #ffffff;
    --nav-heading: #6c7482;
    --nav-hover: rgba(255, 255, 255, .06);
    --nav-active: rgba(255, 255, 255, .1);
    --nav-accent: #34c79b;

    /* Status: always paired with an icon or label, never colour alone */
    --good: #117a3d;
    --good-bg: #e8f6ee;
    --warn: #8a5300;
    --warn-bg: #fff4dc;
    --warn-line: #f2c46d;
    --bad: #b42318;
    --bad-bg: #fdecea;
    --info: #1c4fd6;
    --info-bg: #e9effd;

    /* Chart series (validated pair: dataviz validate_palette, light surface) */
    --series-1: #2a78d6;
    --series-2: #1baf7a;

    /* Shape & depth */
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
    --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
    --shadow-lg: 0 16px 40px rgba(16, 24, 40, .16);

    /* Type */
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-urdu: "Jameel Noori Nastaleeq", "Noto Nastaliq Urdu", "Urdu Typesetting", "Noto Naskh Arabic", "Segoe UI", Tahoma, sans-serif;
    --text-xs: 12px;
    --text-sm: 13px;
    --text-base: 14px;
    --text-md: 15px;
    --text-lg: 18px;
    --text-xl: 22px;
    --text-2xl: 28px;

    /* Layout */
    --sidebar-w: 256px;
    --topbar-h: 64px;
    --content-max: 1320px;
    --control-h: 38px;
}

/* 2. Base ----------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

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

body {
    margin: 0;
    font-family: var(--font);
    font-size: var(--text-base);
    line-height: 1.5;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; line-height: 1.25; font-weight: 650; }
p { margin: 0 0 12px; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
strong { font-weight: 600; }
small { font-size: var(--text-xs); }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.icon {
    width: 18px;
    height: 18px;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    vertical-align: middle;
}
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 22px; height: 22px; }

.muted { color: var(--ink-3); }
.text-danger { color: var(--bad); }
.text-good { color: var(--good); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
/* .hide-sm: hidden on phones (see section 19) */
.visually-hidden {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link { position: absolute; left: 12px; top: -48px; z-index: 100; padding: 8px 12px; background: var(--surface); border-radius: var(--radius-sm); box-shadow: var(--shadow); }
.skip-link:focus { top: 12px; }

/* 3. App shell ------------------------------------------------------------ */
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    display: flex;
    flex-direction: column;
    width: var(--sidebar-w);
    background: linear-gradient(180deg, var(--nav-bg) 0%, var(--nav-bg-2) 100%);
    color: var(--nav-ink);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    height: var(--topbar-h);
    padding: 0 18px;
    border-bottom: 1px solid rgba(255, 255, 255, .06);
    color: var(--nav-ink-strong);
}
.sidebar-brand:hover { text-decoration: none; }
.brand-mark {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: linear-gradient(145deg, #1e8a70, #0f5a4a);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18);
    color: #fff;
}
.brand-name { display: flex; flex-direction: column; line-height: 1.2; }
.brand-name strong { font-size: var(--text-md); letter-spacing: .01em; }
.brand-name small { color: var(--nav-heading); }

.nav { flex: 1; overflow-y: auto; padding: 12px 10px 24px; scrollbar-width: thin; scrollbar-color: #2a3240 transparent; }
.nav-top { margin-bottom: 8px; }

/* A module: a folding group of pages, the current one open */
.nav-group { margin-bottom: 2px; }
.nav-section {
    display: flex;
    align-items: center;
    gap: 11px;
    min-height: 38px;
    padding: 8px 10px;
    border-radius: 8px;
    font-weight: 600;
    color: var(--nav-ink);
    list-style: none;
    cursor: pointer;
    user-select: none;
}
.nav-section::-webkit-details-marker { display: none; }
.nav-section:hover { background: var(--nav-hover); color: var(--nav-ink-strong); }
.nav-section .icon { color: #8b93a1; }
.nav-section:hover .icon, .nav-group[open] > .nav-section { color: var(--nav-ink-strong); }
.nav-group.has-active > .nav-section .icon:first-child { color: var(--nav-accent); }
.nav-section .nav-chevron { width: 15px; height: 15px; margin-left: auto; color: var(--nav-heading); transition: transform .18s ease; }
.nav-group[open] > .nav-section .nav-chevron { transform: rotate(180deg); }
.nav-items { margin: 2px 0 8px 19px; padding-left: 12px; border-left: 1px solid rgba(255, 255, 255, .08); }
.nav-items .nav-link { min-height: 32px; padding: 6px 10px; font-size: 13.5px; }
.nav-items .nav-link.is-active::before { left: -13px; top: 6px; bottom: 6px; width: 2px; }
.nav-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 11px;
    min-height: 36px;
    padding: 7px 10px;
    border-radius: 8px;
    color: var(--nav-ink);
    font-weight: 500;
}
.nav-link:hover { background: var(--nav-hover); color: var(--nav-ink-strong); text-decoration: none; }
.nav-link .icon { color: #8b93a1; }
.nav-link:hover .icon { color: var(--nav-ink-strong); }
.nav-link.is-active { background: var(--nav-active); color: var(--nav-ink-strong); font-weight: 600; }
.nav-link.is-active .icon { color: var(--nav-accent); }
.nav-link.is-active::before {
    content: "";
    position: absolute;
    left: -10px;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--nav-accent);
}
.nav-link.is-soon { opacity: .5; cursor: default; }
.nav-link.is-soon:hover { background: none; color: var(--nav-ink); }
.nav-link em {
    margin-left: auto;
    padding: 1px 6px;
    border: 1px solid rgba(255, 255, 255, .18);
    border-radius: 999px;
    font-size: 10px;
    font-style: normal;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.sidebar-foot { padding: 12px 18px; border-top: 1px solid rgba(255, 255, 255, .06); font-size: var(--text-xs); color: var(--nav-heading); }

.nav-backdrop { display: none; }

.main { min-height: 100vh; margin-left: var(--sidebar-w); display: flex; flex-direction: column; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 14px;
    height: var(--topbar-h);
    padding: 0 28px;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: saturate(160%) blur(8px);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 0 rgba(16, 24, 40, .02);
}
.topbar-title { flex: 1; min-width: 0; }
.topbar-title h1 { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.breadcrumb { display: flex; align-items: center; gap: 4px; margin-bottom: 1px; font-size: var(--text-xs); line-height: 1.3; color: var(--ink-3); }
.breadcrumb a { color: var(--ink-3); }
.breadcrumb a:hover { color: var(--brand); }
.breadcrumb .crumb-sep { width: 12px; height: 12px; color: var(--border-strong); }
.topbar-tools { display: flex; align-items: center; gap: 10px; }
.topbar-tools form { margin: 0; }
.topbar-divider { width: 1px; height: 28px; background: var(--border); }
.fy-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 11px;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--ink-2);
    background: var(--surface-sunken);
    border: 1px solid var(--border);
    border-radius: 8px;
}
.fy-chip:hover { text-decoration: none; color: var(--ink); border-color: var(--border-strong); }
.fy-chip .icon { color: var(--brand); }
.user-meta { display: flex; flex-direction: column; line-height: 1.25; }
.user-meta small { color: var(--ink-3); }

/* Drop-down menu (the topbar "New" button) */
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu[open] > summary { background: var(--brand-strong); }
.menu-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 50;
    width: 270px;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
}
.menu-heading { margin: 0; padding: 8px 10px 4px; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.menu-heading:not(:first-child) { margin-top: 4px; border-top: 1px solid var(--border); padding-top: 10px; }
.menu-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; font-weight: 500; color: var(--ink); }
.menu-item .icon { color: var(--ink-3); }
.menu-item:hover, .menu-item:focus-visible { background: var(--brand-soft); color: var(--brand-strong); text-decoration: none; }
.menu-item:hover .icon { color: var(--brand); }
.avatar {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--brand-soft);
    color: var(--brand-strong);
    font-size: var(--text-sm);
    font-weight: 700;
}
.topbar .nav-toggle { display: none; }

.content { width: 100%; max-width: var(--content-max); padding: 24px 28px 48px; }

/* 4. Page layout ---------------------------------------------------------- */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}
.toolbar > p { margin: 0; max-width: 720px; }
/* The page's control bar: filters and the main action on lists, status and actions on documents */
.content > .toolbar {
    padding: 10px 12px 10px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.toolbar-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.search { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.search input[type="search"],
.search select {
    height: var(--control-h);
    padding: 0 12px;
    font: inherit;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 8px;
}
.search input[type="search"] { min-width: 260px; }
.search input:focus, .search select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }

.inline { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); cursor: pointer; }
.inline input { margin: 0; accent-color: var(--brand); }

.section-title { margin: 28px 0 12px; font-size: var(--text-md); }
.section-title:first-child,
input[type="hidden"]:first-child + .section-title { margin-top: 0; }

.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-bottom: 18px; }
.two-col > .card { margin-bottom: 0; }

/* 5. Buttons -------------------------------------------------------------- */
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: var(--control-h);
    padding: 0 16px;
    font: inherit;
    font-weight: 600;
    line-height: 1;
    color: #fff;
    white-space: nowrap;
    background: var(--brand);
    border: 1px solid var(--brand);
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: background-color .15s, border-color .15s, box-shadow .15s;
}
.button:hover { background: var(--brand-strong); border-color: var(--brand-strong); text-decoration: none; }
.button:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--brand-ring); }
.button .icon { width: 17px; height: 17px; }

.button-secondary { color: var(--ink); background: var(--surface); border-color: var(--border-strong); }
.button-secondary:hover { background: var(--surface-sunken); border-color: var(--ink-3); }
.button-danger { background: var(--bad); border-color: var(--bad); }
.button-danger:hover { background: #8f1c13; border-color: #8f1c13; }
.button-block { width: 100%; height: 42px; }
.button-sm { height: 32px; padding: 0 12px; font-size: var(--text-sm); }
.button.is-disabled { opacity: .45; pointer-events: none; }

/* .pager: page links above and below a long report (partials/pager.php) */
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin: 14px 0; font-size: var(--text-sm); }
.pager-links { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.pager-at { padding: 0 8px; color: var(--ink-3); white-space: nowrap; }

.link-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0;
    font: inherit;
    color: var(--brand);
    background: none;
    border: 0;
    cursor: pointer;
}
.link-button:hover { text-decoration: underline; }

.icon-button {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    padding: 0;
    color: var(--ink-2);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
}
.icon-button:hover { background: var(--surface-sunken); border-color: var(--border); color: var(--ink); }

/* 6. Forms ---------------------------------------------------------------- */
.form label { display: block; margin-bottom: 16px; font-weight: 550; color: var(--ink); }
.form input:not([type="checkbox"]):not([type="radio"]),
.form select,
.form textarea {
    display: block;
    width: 100%;
    min-height: var(--control-h);
    margin-top: 6px;
    padding: 8px 11px;
    font: inherit;
    font-weight: 400;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    transition: border-color .15s, box-shadow .15s;
}
.form textarea { min-height: 72px; resize: vertical; }
.form input:focus, .form select:focus, .form textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
.form input[readonly] { color: var(--ink-2); background: var(--surface-sunken); }
.form input[type="number"] { font-variant-numeric: tabular-nums; }
.form .has-error input, .form .has-error select, .form .has-error textarea { border-color: var(--bad); }
.form .has-error input:focus, .form .has-error select:focus { box-shadow: 0 0 0 3px rgba(180, 35, 24, .18); }
.form .checkbox { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.form .checkbox input { flex: none; width: 16px; height: 16px; margin: 0; accent-color: var(--brand); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 20px; }
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span-2 { grid-column: 1 / -1; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; padding-top: 4px; }
.form-actions .help { flex-basis: 100%; }
/* On a form page the action bar stays in view at the bottom while the form scrolls. */
form.card > .form-actions {
    position: sticky;
    bottom: 0;
    z-index: 5;
    margin: 6px -22px -20px;
    padding: 14px 22px;
    background: rgba(255, 255, 255, .96);
    backdrop-filter: blur(6px);
    border-top: 1px solid var(--border);
    border-radius: 0 0 var(--radius) var(--radius);
}
form.card > .form-actions .help { flex: 1 1 360px; margin-top: 0; }

.required { color: var(--bad); }
.help { display: block; margin-top: 5px; font-size: var(--text-xs); font-weight: 400; color: var(--ink-3); }
.field-error { display: block; margin-top: 5px; font-size: var(--text-sm); font-weight: 500; color: var(--bad); }

.fieldset {
    grid-column: 1 / -1;
    margin: 4px 0 18px;
    padding: 16px 18px 2px;
    background: var(--surface-sunken);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.fieldset legend { padding: 0 6px; font-weight: 650; color: var(--ink); }

.segmented {
    display: inline-flex;
    padding: 3px;
    margin-bottom: 10px;
    background: var(--surface-sunken);
    border: 1px solid var(--border);
    border-radius: 10px;
}
.segmented label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 7px 16px;
    border-radius: 7px;
    font-weight: 600;
    color: var(--ink-2);
    cursor: pointer;
}
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:has(input:checked) { color: var(--ink); background: var(--surface); box-shadow: var(--shadow); }
.segmented label:has(input:focus-visible) { outline: 2px solid var(--brand); outline-offset: 1px; }

.form-intro { margin: -2px 0 16px; color: var(--ink-2); }

/* 7. Tables --------------------------------------------------------------- */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 14px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--border); }
.table tr:last-child > td, .table tr:last-child > th { border-bottom: 0; }

/* key / value tables inside cards */
.table-kv th { width: 55%; font-weight: 500; color: var(--ink-2); }
.table-kv td { font-variant-numeric: tabular-nums; }
.table-kv th, .table-kv td { padding: 9px 0; }

/* data lists */
.table-list thead th {
    position: sticky;
    top: 0;
    padding-top: 10px;
    padding-bottom: 10px;
    font-size: 11px;
    font-weight: 650;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--ink-3);
    white-space: nowrap;
    background: var(--surface-sunken);
    border-bottom: 1px solid var(--border);
}
.table-list tbody tr { transition: background-color .1s; }
.table-list tbody tr:hover { background: var(--surface-hover); }
.table-list td:first-child a { font-weight: 600; white-space: nowrap; }
.table .num { text-align: right; }
.table .actions { text-align: right; white-space: nowrap; }
.table .empty { padding: 28px 14px; text-align: center; color: var(--ink-3); }
.total-row td { font-weight: 650; background: var(--surface-sunken); border-top: 1px solid var(--border-strong); }

.table-scroll { overflow-x: auto; }

/* editable lines inside forms */
.table-inputs { margin: 6px 0 10px; }
.table-inputs th, .table-inputs td { padding: 6px 8px; }
.table-inputs thead th { background: transparent; border-bottom: 1px solid var(--border-strong); }
.table-inputs tbody tr:hover { background: transparent; }
.table-inputs td { border-bottom: 1px solid var(--border); }
.form .table-inputs input:not([type="checkbox"]),
.form .table-inputs select { margin-top: 0; min-height: 36px; padding: 6px 9px; }
.table-inputs select { min-width: 210px; }
.table-inputs input.num { min-width: 96px; text-align: right; }
.table-inputs .line-amount { font-weight: 600; }
.table-inputs .is-short { font-weight: 600; color: var(--bad); }

/* 8. Cards & lists -------------------------------------------------------- */
.card {
    margin-bottom: 18px;
    padding: 20px 22px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.card > h2, .card-head h2 { font-size: var(--text-md); }
.card > h2 { margin-bottom: 12px; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-head > a:not(.button) { display: inline-flex; align-items: center; gap: 4px; font-size: var(--text-sm); font-weight: 600; }
.card-sub { margin: 2px 0 0; font-size: var(--text-sm); }
.eyebrow { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-xs); font-weight: 650; letter-spacing: .05em; text-transform: uppercase; color: var(--brand); }
.card-flush { padding: 0; overflow-x: auto; }
.card-flush > .card-head { margin: 0; padding: 14px 18px; border-bottom: 1px solid var(--border); }

details.card > summary {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 650;
    list-style: none;
    cursor: pointer;
}
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::before { content: "+"; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: var(--brand-soft); color: var(--brand-strong); font-weight: 700; }
details.card[open] > summary::before { content: "−"; }
details.card[open] > summary { margin-bottom: 16px; }

.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px 28px; margin: 0; }
.facts dt { font-size: var(--text-xs); font-weight: 500; color: var(--ink-3); }
.facts dd { margin: 3px 0 0; font-weight: 500; }
.facts .span-all { grid-column: 1 / -1; }

.flow-steps { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }

/* 9. Status & feedback ---------------------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 9px;
    font-size: var(--text-xs);
    font-weight: 600;
    line-height: 18px;
    color: var(--ink-2);
    white-space: nowrap;
    background: var(--surface-sunken);
    border: 1px solid var(--border);
    border-radius: 999px;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .7; }
.badge-plain::before { display: none; }
.badge-green { color: var(--good); background: var(--good-bg); border-color: transparent; }
.badge-blue { color: var(--info); background: var(--info-bg); border-color: transparent; }
.badge-amber { color: var(--warn); background: var(--warn-bg); border-color: transparent; }
.badge-red { color: var(--bad); background: var(--bad-bg); border-color: transparent; }

.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 18px;
    padding: 12px 14px;
    font-weight: 500;
    border: 1px solid transparent;
    border-radius: var(--radius);
}
.alert .icon { margin-top: 1px; }
.alert-success { color: var(--good); background: var(--good-bg); border-color: #c5e7d2; }
.alert-error { color: var(--bad); background: var(--bad-bg); border-color: #f5c8c3; }
.alert-info { color: var(--info); background: var(--info-bg); border-color: #cbd8f7; }

.notice {
    grid-column: 1 / -1;
    margin-bottom: 16px;
    padding: 12px 14px;
    line-height: 1.8;
    background: var(--surface);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
}
.notice .claim-line { color: var(--ink-3); }
.notice.has-claim { background: var(--warn-bg); border: 1px solid var(--warn-line); }
.notice.has-claim .claim-line { font-weight: 650; color: var(--bad); }

.progress {
    display: block;
    width: 120px;
    height: 8px;
    overflow: hidden;
    background: var(--brand-soft);
    border: 0;
    border-radius: 999px;
    appearance: none;
    -webkit-appearance: none;
}
.progress::-webkit-progress-bar { background: var(--brand-soft); border-radius: 999px; }
.progress::-webkit-progress-value { background: var(--brand); border-radius: 999px; }
.progress::-moz-progress-bar { background: var(--brand); border-radius: 999px; }
.progress-wide { width: 100%; height: 8px; }

.empty-state { padding: 36px 20px; text-align: center; color: var(--ink-2); }
.empty-state .icon { width: 32px; height: 32px; margin-bottom: 8px; color: var(--ink-3); }

/* 10. Documents ----------------------------------------------------------- */
.doc-status, .doc-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.doc-actions form { margin: 0; }

/* Document pipeline: Draft > Posted > Received > Paid */
.doc-steps { display: flex; flex-wrap: wrap; align-items: center; margin: 0 0 0 auto; padding: 0; list-style: none; font-size: var(--text-sm); font-weight: 600; }
.doc-steps + .doc-actions { margin-left: auto; }
.doc-steps li {
    display: flex;
    align-items: center;
    gap: 5px;
    height: 30px;
    margin-left: -4px;
    padding: 0 16px 0 20px;
    color: var(--ink-3);
    background: #eceff3;
    clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 0 100%, 10px 50%);
}
.doc-steps li:first-child { margin-left: 0; padding-left: 12px; border-radius: 6px 0 0 6px; clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 0 100%); }
.doc-steps li.is-done { color: var(--brand-strong); background: var(--brand-soft); }
.doc-steps li.is-partial { color: var(--warn); background: var(--warn-bg); }
.doc-steps small { font-weight: 500; }

#pi-form[data-type="local"] .imported-only,
#pi-form[data-type="imported"] .local-only,
#si-form[data-buyer="Registered"] .unregistered-only { display: none !important; }
#charge-form[data-payee="supplier"] .payee-account,
#charge-form[data-payee="account"] .payee-supplier { display: none !important; }
[data-transport]:not([data-by="us"]) .transport-ours,
[data-transport][data-by="us"] .transport-other { display: none !important; }

.totals {
    display: grid;
    gap: 6px;
    width: min(100%, 380px);
    margin: 8px 0 20px auto;
    padding: 14px 16px;
    background: var(--surface-sunken);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.totals div { display: flex; align-items: baseline; gap: 10px; }
.totals div > span:first-child { color: var(--ink-2); }
.totals strong { margin-left: auto; font-variant-numeric: tabular-nums; }
.totals .grand { padding-top: 8px; border-top: 1px solid var(--border-strong); font-size: var(--text-md); }

.inline-form { position: relative; display: inline-block; }
.inline-form > summary { list-style: none; cursor: pointer; }
.inline-form > summary::-webkit-details-marker { display: none; }
.inline-form[open] > form {
    position: absolute;
    right: 0;
    z-index: 20;
    width: 320px;
    margin-top: 8px;
    padding: 16px;
    text-align: left;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
}
.inline-form[open] > form .button { width: 100%; }

.journal-entry { margin-bottom: 12px; }
.journal-entry-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--surface-sunken);
    border-bottom: 1px solid var(--border);
}
.journal-entry .table-list thead th { background: var(--surface); }

.totals .is-over strong { color: var(--bad); }

.tabs {
    display: inline-flex;
    gap: 4px;
    margin-bottom: 18px;
    padding: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
}
.tabs a { padding: 7px 16px; border-radius: 7px; font-weight: 600; color: var(--ink-2); }
.tabs a:hover { text-decoration: none; color: var(--ink); background: var(--surface-sunken); }
.tabs a[aria-current="page"] { color: var(--brand-strong); background: var(--brand-soft); }

.buyer-card { grid-column: 1 / -1; margin: -4px 0 16px; padding: 10px 14px; font-size: var(--text-sm); color: var(--ink-2); background: var(--surface-sunken); border-radius: var(--radius-sm); }
.stock-hint { display: block; margin-top: 5px; font-size: var(--text-xs); color: var(--ink-3); }
.stock-hint.is-short { font-weight: 600; color: var(--bad); }

/* 11. Dashboard ----------------------------------------------------------- */
.welcome { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.welcome h2 { font-size: var(--text-xl); }
.welcome p { margin: 4px 0 0; color: var(--ink-2); }

.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 22px; }
.kpi {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 16px 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.kpi-label { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; font-size: var(--text-sm); font-weight: 600; color: var(--ink-2); }
.kpi-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--brand-soft); color: var(--brand); }
.kpi-icon .icon { width: 17px; height: 17px; }
.kpi.is-warning .kpi-icon { background: var(--warn-bg); color: var(--warn); }
.kpi-value { font-size: var(--text-2xl); font-weight: 650; letter-spacing: -.01em; }
.kpi-value small { margin-left: 4px; font-size: var(--text-sm); font-weight: 500; color: var(--ink-3); }
.kpi-sub { font-size: var(--text-sm); color: var(--ink-3); }
.kpi-sub.is-warning { font-weight: 600; color: var(--warn); }
a.kpi { color: inherit; transition: border-color .15s, box-shadow .15s; }
a.kpi:hover { text-decoration: none; border-color: var(--border-strong); box-shadow: var(--shadow); }

.quick-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.quick-action {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    color: var(--ink);
    font-weight: 600;
    background: var(--surface-sunken);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.quick-action:hover { text-decoration: none; border-color: var(--brand); background: var(--brand-soft); }
.quick-action .icon-tile { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--surface); color: var(--brand); box-shadow: var(--shadow-sm); }
.quick-action small { display: block; font-weight: 400; color: var(--ink-3); }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.dashboard-side .quick-actions { gap: 8px; }
.dashboard-side .quick-action { gap: 10px; padding: 9px 10px; font-size: var(--text-sm); line-height: 1.3; }
.dashboard-side .quick-action small { display: none; }
.dashboard-side .quick-action .icon-tile { flex: none; width: 30px; height: 30px; }
.table-kv-compact th, .table-kv-compact td { padding: 7px 0; font-size: var(--text-sm); }
.table-kv-compact th { width: 46%; }

/* Needs attention */
.attention-list { margin: 0 -8px; padding: 0; list-style: none; }
.attention-list a { display: flex; align-items: center; gap: 12px; padding: 9px 8px; border-radius: 8px; color: var(--ink); }
.attention-list a:hover { background: var(--surface-hover); text-decoration: none; }
.attention-icon { display: grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 9px; }
.attention-icon .icon { width: 17px; height: 17px; }
.tone-red { color: var(--bad); background: var(--bad-bg); }
.tone-amber { color: var(--warn); background: var(--warn-bg); }
.tone-blue { color: var(--info); background: var(--info-bg); }
.attention-text { display: flex; flex: 1; flex-direction: column; min-width: 0; line-height: 1.35; }
.attention-text small { color: var(--ink-3); }
.attention-go { color: var(--ink-3); }
.all-clear { display: flex; align-items: flex-start; gap: 10px; margin: 0; font-size: var(--text-sm); color: var(--ink-2); }
.all-clear .icon { flex: none; color: var(--good); }

/* Purchases and sales chart: columns, hairline grid, tooltip per month */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-grid { stroke: var(--border); stroke-width: 1; }
.chart-baseline { stroke: var(--border-strong); }
.chart-axis { font-size: 11px; fill: var(--ink-3); font-variant-numeric: tabular-nums; }
.chart-axis.is-current { font-weight: 700; fill: var(--ink); }
.chart-hit { fill: transparent; }
.chart-month:hover .chart-hit, .chart-month.is-hover .chart-hit { fill: rgba(16, 24, 40, .04); }
.bar-purchases { fill: var(--series-1); }
.bar-sales { fill: var(--series-2); }
.chart-tip {
    position: absolute;
    z-index: 10;
    min-width: 170px;
    padding: 8px 10px;
    font-size: var(--text-sm);
    line-height: 1.5;
    white-space: pre-line;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    pointer-events: none;
}
.chart-tip::first-line { font-weight: 700; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0; padding: 0; list-style: none; font-size: var(--text-sm); color: var(--ink-2); }
.legend li { display: flex; align-items: center; gap: 7px; }
.legend strong { color: var(--ink); }
.swatch { width: 10px; height: 10px; border-radius: 3px; }
.swatch-purchases { background: var(--series-1); }
.swatch-sales { background: var(--series-2); }
.chart-empty { margin: 8px 0; padding: 28px 16px; text-align: center; color: var(--ink-3); background: var(--surface-sunken); border-radius: var(--radius-sm); }
.chart-table { margin-top: 8px; }
.chart-table > summary { cursor: pointer; font-size: var(--text-sm); font-weight: 600; color: var(--ink-2); }
.chart-table[open] > summary { margin-bottom: 6px; }
.chart-table .table th, .chart-table .table td { padding: 6px 10px; font-size: var(--text-sm); }

/* Setup guide: the dashboard card and the full page */
.setup-card { padding: 22px 24px; background: linear-gradient(135deg, #f1faf7 0%, #ffffff 55%); border-color: #cfe7df; }
.setup-card-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 16px 24px; margin-bottom: 16px; }
.setup-card-head > div:first-child { flex: 1 1 420px; }
.setup-card-head h2 { margin: 6px 0 4px; font-size: var(--text-xl); }
.setup-card-head p { margin: 0; max-width: 640px; color: var(--ink-2); }
.setup-card-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.setup-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 0; padding: 0; list-style: none; }
.setup-chips li { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px 5px 8px; font-size: var(--text-sm); font-weight: 500; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; }
.setup-chips li .icon { color: var(--ink-3); }
.setup-chips li a { color: var(--ink); }
.setup-chips li small { color: var(--ink-3); }
.setup-chips li.is-done { color: var(--ink-3); background: var(--good-bg); border-color: transparent; }
.setup-chips li.is-done .icon { color: var(--good); }
.setup-chips li.is-next { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
.setup-chips li.is-next .icon { color: var(--brand); }
.setup-hide { margin: 14px 0 0; font-size: var(--text-sm); }

.setup-hero { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 20px 32px; padding: 24px 26px; background: linear-gradient(135deg, #f1faf7 0%, #ffffff 60%); border-color: #cfe7df; }
.setup-hero > div:first-child { flex: 1 1 420px; }
.setup-hero h2 { margin: 6px 0 6px; font-size: var(--text-xl); }
.setup-hero p { margin: 0; max-width: 620px; color: var(--ink-2); }
.setup-meter { display: grid; gap: 4px; width: min(100%, 280px); }
.setup-meter strong { font-size: var(--text-2xl); line-height: 1.1; }
.setup-meter span { color: var(--ink-2); }
.setup-meter .progress { margin: 6px 0 2px; }
.setup-steps { display: grid; gap: 10px; margin: 0 0 18px; padding: 0; list-style: none; }
.setup-step {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 16px;
    padding: 16px 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.setup-step.is-next { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
.setup-step.is-done { background: var(--surface-sunken); }
.step-mark { display: grid; place-items: center; width: 34px; height: 34px; font-weight: 700; color: var(--ink-2); background: var(--surface-sunken); border: 1px solid var(--border-strong); border-radius: 50%; }
.setup-step.is-next .step-mark { color: #fff; background: var(--brand); border-color: var(--brand); }
.setup-step.is-done .step-mark { color: var(--good); background: var(--good-bg); border-color: transparent; }
.step-body h3 { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 3px; font-size: var(--text-md); }
.step-body p { margin: 0; font-size: var(--text-sm); color: var(--ink-2); }
.setup-step.is-done .step-body h3 { color: var(--ink-2); }
.step-action { display: flex; align-items: center; gap: 12px; white-space: nowrap; }
.step-action code { font-size: var(--text-xs); }
.setup-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; font-size: var(--text-sm); }
.setup-foot form { margin: 0; }

/* 12. Sign-in & errors ---------------------------------------------------- */
.guest { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); background: var(--surface); }
.guest-brand {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 44px 52px;
    overflow: hidden;
    color: #e8ecf1;
    background:
        radial-gradient(900px 500px at 110% 110%, rgba(52, 199, 155, .22), transparent 60%),
        radial-gradient(600px 400px at -10% -10%, rgba(52, 199, 155, .12), transparent 60%),
        linear-gradient(160deg, #0d1219 0%, #16202c 100%);
}
.guest-brand .sidebar-brand { height: auto; padding: 0; border: 0; }
.guest-brand h2 { max-width: 460px; margin-bottom: 14px; font-size: 32px; line-height: 1.2; color: #fff; }
.guest-brand p { max-width: 460px; color: #a9b2bf; }
.guest-flow { display: grid; gap: 10px; max-width: 440px; margin: 26px 0 0; padding: 0; list-style: none; }
.guest-flow li { display: flex; align-items: center; gap: 12px; color: #cfd6df; }
.guest-flow .icon { color: var(--nav-accent); }
.guest-foot { font-size: var(--text-xs); color: #6c7482; }

.guest-main { display: grid; place-items: center; padding: 32px 24px; background: var(--bg); }
.guest-card {
    width: 100%;
    max-width: 400px;
    padding: 32px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}
.guest-card h1 { margin-bottom: 6px; font-size: var(--text-xl); }
.guest-card > p { color: var(--ink-2); }
.guest-card .form { margin-top: 22px; }

.guest-simple { display: grid; place-items: center; min-height: 100vh; padding: 24px; background: var(--bg); }
.error-code { font-size: 44px; font-weight: 700; color: var(--brand); }
.error-detail { max-height: 320px; overflow: auto; padding: 12px; font-size: var(--text-xs); white-space: pre-wrap; background: var(--surface-sunken); border-radius: var(--radius-sm); }

/* 13. Reports and ledgers ------------------------------------------------- */
.report-filter input[type="date"],
.report-filter input[type="text"] {
    height: var(--control-h);
    padding: 0 10px;
    font: inherit;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 8px;
}
.report { max-width: 980px; }
.report-wide { max-width: none; }
/* Many-column statements scroll sideways on phones instead of squeezing their text. */
.report-wide .table-scroll .statement { min-width: 980px; }
.report-actions { margin: 18px 0 0; }
.report-head { margin-bottom: 18px; text-align: center; }
.report-head h2 { font-size: var(--text-xl); }
.report-head p { margin: 4px 0 0; }
.report-company { font-weight: 650; letter-spacing: .02em; text-transform: uppercase; color: var(--ink-2); }

.statement { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.statement th, .statement td { padding: 7px 12px; text-align: left; }
.statement thead th { font-size: var(--text-xs); font-weight: 600; color: var(--ink-2); border-bottom: 1px solid var(--border-strong); }
.statement .num { text-align: right; white-space: nowrap; }
.statement .row-section td { padding-top: 16px; font-weight: 650; }
.statement .row-heading td { padding-top: 22px; font-size: var(--text-md); font-weight: 700; color: var(--brand-strong); }
.statement .row-subtotal td { font-weight: 600; border-top: 1px solid var(--border); }
.statement .row-total td { font-weight: 700; border-top: 1px solid var(--ink-3); }
.statement .row-grand td { font-weight: 700; font-size: var(--text-md); border-top: 1px solid var(--ink); border-bottom: 3px double var(--ink); }
.statement .row-muted td { color: var(--ink-3); }
.statement tbody tr:hover { background: #fafbfc; }
.statement td.indent-1, .table td.indent-1 { padding-left: 32px; }
.statement td.indent-2, .table td.indent-2 { padding-left: 52px; }
.statement td.indent-3, .table td.indent-3 { padding-left: 72px; }
.statement td.indent-4, .table td.indent-4 { padding-left: 92px; }
.negative { color: var(--bad); }

.check-ok, .check-bad { display: flex; align-items: center; gap: 8px; margin-top: 14px; font-weight: 600; }
.check-ok { color: var(--good); }
.check-bad { color: var(--bad); }

.periods { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.period {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    background: var(--surface-sunken);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.period.is-closed { background: var(--bg); color: var(--ink-3); }
.period form { margin: 0; }
.balance-strip { display: flex; flex-wrap: wrap; gap: 24px; margin: 0 0 16px; }
.balance-strip div { display: flex; flex-direction: column; }
.balance-strip dt { font-size: var(--text-xs); color: var(--ink-3); }
.balance-strip dd { margin: 2px 0 0; font-size: var(--text-lg); font-weight: 650; font-variant-numeric: tabular-nums; }

@media print {
    .no-print, .report-filter { display: none !important; }
    .report { max-width: none; }
    .card.report { border: 0; padding: 0; }
    .report a { color: inherit; }
    .report-wide .table-scroll .statement { min-width: 0; }
    .report-wide .statement th, .report-wide .statement td { padding: 5px 6px; font-size: 12px; }
}

/* 14. Users & roles ------------------------------------------------------- */
.topbar-account { display: flex; align-items: center; gap: 10px; color: inherit; border-radius: var(--radius); }
.topbar-account:hover { text-decoration: none; }
.topbar-account:hover .avatar { box-shadow: 0 0 0 3px var(--brand-ring); }

.choice-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.form .choice {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0;
    padding: 11px 13px;
    font-weight: 600;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
}
.form .choice:hover { border-color: var(--border-strong); }
.form .choice:has(input:checked) { background: var(--brand-soft); border-color: var(--brand); }
.form .choice:has(input:disabled) { cursor: default; }
.form .choice input { flex: none; width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--brand); }
.choice small, .permission small { display: block; margin-top: 2px; font-size: var(--text-xs); font-weight: 400; color: var(--ink-3); }
.choice-list.has-error .choice { border-color: var(--bad); }
.form-options { display: grid; gap: 12px; margin: 18px 0; }
.form-options .checkbox, .form-options p { margin: 0; }

.permission-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; margin-bottom: 18px; }
.permission-group { min-width: 0; margin: 0; padding: 12px 14px 6px; background: var(--surface-sunken); border: 1px solid var(--border); border-radius: var(--radius); }
.permission-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.form .permission-head .checkbox { margin: 0; font-weight: 700; }
.permission-head .muted { font-size: var(--text-xs); white-space: nowrap; }
.form .permission { align-items: flex-start; margin: 0; padding: 7px 0; font-weight: 500; }
.form .permission input { margin-top: 2px; }

.plain-list { margin: 0; padding: 0; list-style: none; }
.plain-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.plain-list li:last-child { border-bottom: 0; }

/* 15. Company & FBR, sales tax invoice ------------------------------------ */
.icon-flip { transform: scaleX(-1); }
.field { min-width: 0; }
.form .field > .checkbox { margin: -8px 0 16px; font-weight: 500; }
.checklist { display: grid; gap: 8px; margin: 0 0 20px; padding: 0; list-style: none; }
.checklist li { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; font-size: var(--text-sm); background: var(--surface-sunken); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.checklist li > .icon { flex: none; margin-top: 1px; }
.checklist strong { margin-right: 4px; }
.checklist .is-ok > .icon { color: var(--good); }
.checklist .is-bad > .icon { color: var(--bad); }
.checklist .is-warn > .icon { color: var(--warn); }
.checklist .is-off > .icon { color: var(--ink-3); }
.code-block { overflow-x: auto; margin: 8px 0 10px; padding: 10px 12px; font: 13px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace; color: var(--ink); background: var(--surface-sunken); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.logo-field { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 18px; }
.logo-field .field { flex: 1 1 320px; }
.logo-preview { display: grid; place-items: center; width: 132px; height: 96px; padding: 8px; background: #fff; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); }
.logo-preview img { max-width: 100%; max-height: 100%; }
details.advanced { margin: 4px 0 18px; }
details.advanced > summary { cursor: pointer; font-weight: 600; color: var(--brand-strong); }
details.advanced[open] > summary { margin-bottom: 8px; }

.fbr-card .card-head { margin-bottom: 12px; }
.table tr.is-muted td { color: var(--ink-3); }
.section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin: 28px 0 12px; }
.section-head .section-title { margin: 0; }
.report-filter .input-sm { width: 130px; }
.help code { padding: 1px 4px; font: 12px ui-monospace, SFMono-Regular, Consolas, monospace; background: var(--surface-sunken); border-radius: 4px; }
.gd-rates { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 0 14px; }
.gd-rates input { text-align: right; }
.gd-lines td:first-child .field-error { margin-top: 2px; }
@media (max-width: 900px) { .gd-rates { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 520px) { .gd-rates { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.fbr-accepted { display: flex; flex-wrap: wrap; align-items: center; gap: 20px; }
.fbr-accepted .facts { flex: 1 1 320px; }
.qr-mini { width: 104px; height: 104px; flex: none; }
.fbr-report { margin-top: 12px; }
.fbr-log { margin-top: 16px; }
.fbr-log > summary { cursor: pointer; font-size: var(--text-sm); font-weight: 600; color: var(--ink-2); }
.fbr-log .table-scroll { margin-top: 10px; }
.inline-fields { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.inline-fields label { flex: 1 1 260px; margin-bottom: 0; }

/* The printed sales tax invoice (A4). FBR: QR code version 2 (25 x 25) at 1 x 1 inch; the SVG
   carries a 4-module quiet zone, so it is 33/25 inch wide for the symbol itself to be 1 inch. */
.print-page { background: var(--bg); }
.print-toolbar { display: flex; justify-content: center; gap: 10px; padding: 16px; }
.tax-invoice {
    position: relative;
    max-width: 210mm;
    margin: 0 auto 32px;
    padding: 14mm 14mm 12mm;
    color: #111;
    background: #fff;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    font-size: 12.5px;
    overflow: hidden;
}
.tax-invoice .muted { color: #555; }
.ti-stamp { position: absolute; top: 44%; left: 50%; z-index: 0; font-size: 54px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; color: rgba(180, 35, 24, .12); transform: translate(-50%, -50%) rotate(-24deg); pointer-events: none; }
.tax-invoice > *:not(.ti-stamp) { position: relative; z-index: 1; }
.ti-head { display: flex; justify-content: space-between; gap: 20px; padding-bottom: 12px; border-bottom: 2px solid #111; }
.ti-seller h1 { margin: 0 0 4px; font-size: 20px; }
.ti-seller p { margin: 2px 0; }
.ti-sep { margin: 0 6px; color: #888; }
.ti-fbr { display: flex; align-items: center; gap: 10px; }
.ti-fbr-logo { display: grid; place-items: center; width: 1.1in; height: 1.1in; }
.ti-fbr-logo img { max-width: 100%; max-height: 100%; }
.ti-missing { padding: 6px; font-size: 10px; line-height: 1.3; text-align: center; color: var(--bad); border: 1px dashed var(--bad); }
.ti-qr { display: block; width: 1.32in; height: 1.32in; }
.ti-qr-empty { display: grid; place-items: center; padding: 8px; font-size: 10px; line-height: 1.3; text-align: center; color: #666; border: 1px dashed #aaa; }
.ti-title { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 10px; margin: 14px 0 10px; }
.ti-title h2 { margin: 0; font-size: 18px; letter-spacing: .04em; text-transform: uppercase; }
.ti-fbr-no { margin: 0; font-size: 13px; }
.ti-parties { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; margin-bottom: 14px; }
.ti-parties section { padding: 10px 12px; border: 1px solid #ccc; border-radius: 4px; }
.ti-parties h3 { margin: 0 0 6px; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: #555; }
.ti-parties p { margin: 2px 0; }
.ti-name { font-size: 14px; font-weight: 700; }
.ti-kv { width: 100%; margin-top: 6px; border-collapse: collapse; }
.ti-kv th { width: 42%; padding: 2px 8px 2px 0; font-weight: 500; text-align: left; color: #555; }
.ti-kv td { padding: 2px 0; }
.ti-lines { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.ti-lines th, .ti-lines td { padding: 6px 6px; text-align: left; vertical-align: top; border: 1px solid #ccc; }
.ti-lines thead th { font-size: 11px; background: #f2f2f2; }
.ti-lines .num { text-align: right; }
.ti-summary { display: flex; justify-content: space-between; gap: 20px; margin-top: 12px; }
.ti-words { flex: 1; margin: 0; }
.ti-totals { min-width: 250px; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.ti-totals th { padding: 3px 12px 3px 0; font-weight: 500; text-align: left; }
.ti-totals td { padding: 3px 0; text-align: right; }
.ti-grand th, .ti-grand td { padding-top: 6px; font-size: 14px; font-weight: 800; border-top: 2px solid #111; }
.ti-remarks { margin: 10px 0 0; }
.ti-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 18px 40px; margin-top: 36px; }
.ti-sign { flex: 1 1 200px; padding-top: 6px; font-size: 11px; color: #555; border-top: 1px solid #111; }
.ti-note { flex-basis: 100%; margin: 0; font-size: 11px; color: #555; }

/* 16. Audit log ----------------------------------------------------------- */
.audit-filter input[type="date"] { height: var(--control-h); padding: 0 10px; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; }
.audit-filter input[type="search"] { min-width: 220px; }
.audit-table { min-width: 880px; }
.audit-table td { vertical-align: top; }
.audit-summary { max-width: 420px; font-size: var(--text-sm); color: var(--ink-2); overflow-wrap: anywhere; }
.audit-changes th[scope="row"] { width: 28%; font-weight: 600; color: var(--ink-2); }
.audit-changes td { overflow-wrap: anywhere; white-space: pre-wrap; }
.audit-changes tr.is-changed .audit-before { color: var(--bad); background: var(--bad-bg); }
.audit-changes tr.is-changed .audit-after { color: var(--good); background: var(--good-bg); font-weight: 600; }
.audit-context .table-kv th { width: 40%; }
.audit-context .table-kv td { overflow-wrap: anywhere; }
.audit-filter input[type="search"] { flex: 1 1 240px; }

/* A record's history: who did what, oldest first */
.timeline { position: relative; margin: 0 0 18px; padding: 16px 22px; list-style: none; }
.timeline li { position: relative; display: flex; gap: 14px; padding: 8px 0 12px; }
.timeline li:not(:last-child)::before { content: ""; position: absolute; left: 5px; top: 24px; bottom: -4px; width: 2px; background: var(--border); }
.timeline-dot { flex: none; width: 12px; height: 12px; margin-top: 6px; border-radius: 50%; box-shadow: 0 0 0 3px var(--surface); }
.timeline-dot.tone-plain { background: var(--border-strong); }
.timeline-dot.tone-green { background: var(--good); }
.timeline-dot.tone-blue { background: var(--info); }
.timeline-dot.tone-amber { background: var(--warn-line); }
.timeline-dot.tone-red { background: var(--bad); }
.timeline-body { flex: 1; min-width: 0; }
.timeline-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: var(--text-sm); }
.timeline-body p { margin: 4px 0 0; font-size: var(--text-sm); color: var(--ink-2); overflow-wrap: anywhere; }
.timeline-link { margin-left: auto; font-size: var(--text-sm); }
.timeline li.is-current { margin: 0 -10px; padding-left: 10px; padding-right: 10px; background: var(--brand-soft); border-radius: 8px; }

/* 17. Help & guide -------------------------------------------------------- */
.help-hero { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 18px 32px; padding: 24px 26px; background: linear-gradient(135deg, #f1faf7 0%, #ffffff 60%); border-color: #cfe7df; }
.help-hero > div { flex: 1 1 420px; }
.help-hero h2 { margin: 6px 0 6px; font-size: var(--text-xl); }
.help-hero p { margin: 0; max-width: 640px; color: var(--ink-2); }
.help-search { display: flex; flex: 1 1 360px; align-items: center; gap: 8px; padding: 6px 6px 6px 12px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px; }
.help-search:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
.help-search .icon { color: var(--ink-3); }
.help-search input { flex: 1; min-width: 0; height: 34px; font: inherit; color: var(--ink); background: none; border: 0; outline: none; }

.help-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; margin-bottom: 18px; }
.help-card { display: flex; gap: 14px; padding: 16px 18px; color: var(--ink); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); transition: border-color .15s, box-shadow .15s; }
.help-card:hover { text-decoration: none; border-color: var(--brand); box-shadow: var(--shadow); }
.help-card.is-start { border-color: #cfe7df; background: linear-gradient(135deg, #f1faf7 0%, #ffffff 70%); }
.help-card-icon { display: grid; place-items: center; flex: none; width: 38px; height: 38px; border-radius: 10px; background: var(--brand-soft); color: var(--brand); }
.help-card-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.help-card-body small { font-size: var(--text-xs); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); }
.help-card-body strong { font-size: var(--text-md); }
.help-card-body span { font-size: var(--text-sm); color: var(--ink-2); }
.help-card-body em { font-size: var(--text-xs); font-style: normal; color: var(--brand-strong); }
.help-results { margin: 0 0 18px; padding: 6px 22px; list-style: none; }
.help-results li { padding: 12px 0; border-bottom: 1px solid var(--border); }
.help-results li:last-child { border-bottom: 0; }
.help-results p { margin: 4px 0 0; font-size: var(--text-sm); color: var(--ink-2); }

.help-layout { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 18px; align-items: start; }
.help-nav { position: sticky; top: calc(var(--topbar-h) + 16px); font-size: var(--text-sm); }
.help-nav-search input { width: 100%; height: 34px; margin-bottom: 10px; padding: 0 10px; font: inherit; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; }
.help-nav ol { margin: 0 0 12px; padding: 0; list-style: none; counter-reset: chapter; }
.help-nav li a { display: flex; gap: 8px; padding: 6px 10px; border-radius: 7px; color: var(--ink-2); }
.help-nav li a::before { counter-increment: chapter; content: counter(chapter); min-width: 16px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.help-nav li a:hover { text-decoration: none; background: var(--surface); color: var(--ink); }
.help-nav li a[aria-current="page"] { font-weight: 650; color: var(--brand-strong); background: var(--brand-soft); }
.help-nav-print { display: inline-flex; align-items: center; gap: 6px; padding: 0 10px; font-weight: 600; }

.help-article { padding: 26px 32px 18px; }
.help-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.help-head h2 { margin-top: 2px; font-size: var(--text-2xl); }
.help-toc { margin: 0 0 22px; padding: 12px 16px; background: var(--surface-sunken); border: 1px solid var(--border); border-radius: var(--radius); font-size: var(--text-sm); }
.help-toc ol { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 6px 0 0; padding: 0; list-style: none; }

/* The chapter text: comfortable reading width and spacing */
.help-body { max-width: 860px; font-size: 14.5px; line-height: 1.65; }
.help-body h2 { margin: 30px 0 10px; padding-top: 6px; font-size: var(--text-lg); scroll-margin-top: calc(var(--topbar-h) + 16px); }
.help-body h2:first-child { margin-top: 0; }
.help-body p, .help-body ul, .help-body ol, .help-body dl, .help-body table { margin: 0 0 14px; }
.help-body ul, .help-body ol { padding-left: 22px; }
.help-body li { margin-bottom: 5px; }
.help-body li > ul { margin: 6px 0 0; }
.help-body .lead { font-size: var(--text-md); color: var(--ink-2); }
.help-where { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 9px 12px; font-size: var(--text-sm); background: var(--brand-soft); border-radius: 8px; color: var(--brand-strong); }
.help-where a { display: inline-flex; align-items: center; gap: 4px; margin-left: auto; font-weight: 650; }
.ui { display: inline-flex; align-items: center; gap: 4px; padding: 0 7px; font-size: .92em; font-weight: 600; line-height: 1.6; white-space: nowrap; color: var(--ink); background: var(--surface); border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 6px; }
.help-steps { list-style: none; padding-left: 0 !important; counter-reset: step; }
.help-steps > li { position: relative; margin-bottom: 9px; padding-left: 36px; counter-increment: step; }
.help-steps > li::before { content: counter(step); position: absolute; left: 0; top: 1px; display: grid; place-items: center; width: 24px; height: 24px; font-size: var(--text-xs); font-weight: 700; color: #fff; background: var(--brand); border-radius: 50%; }
.callout { margin: 0 0 14px; padding: 12px 14px; font-size: var(--text-sm); background: var(--info-bg); border-left: 3px solid var(--info); border-radius: 0 8px 8px 0; }
.callout-warn { background: var(--warn-bg); border-left-color: var(--warn-line); }
.callout ul { margin: 6px 0 0; }
.help-dl dt { margin-top: 10px; font-weight: 650; }
.help-dl dd { margin: 2px 0 0; color: var(--ink-2); }
.help-table { font-size: var(--text-sm); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.help-table th, .help-table td { padding: 8px 12px; vertical-align: top; }
.help-table thead th { font-size: 11px; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); background: var(--surface-sunken); }

/* The business cycle, step by step */
.flow { display: grid; gap: 10px; padding-left: 0 !important; list-style: none; }
.flow li { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 14px; margin: 0; padding: 12px 14px; background: var(--surface-sunken); border: 1px solid var(--border); border-radius: var(--radius); }
.flow li:not(:last-child)::after { content: ""; position: absolute; left: 32px; bottom: -11px; width: 2px; height: 10px; background: var(--border-strong); }
.flow-icon { grid-row: span 3; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; background: var(--surface); color: var(--brand); box-shadow: var(--shadow-sm); }
.flow strong small { margin-left: 6px; padding: 1px 6px; font-size: 11px; color: var(--brand-strong); background: var(--brand-soft); border-radius: 999px; }
.flow span:not(.flow-icon) { font-size: var(--text-sm); color: var(--ink-2); }
.flow a { font-size: var(--text-sm); font-weight: 600; }

.help-pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 26px; padding-top: 16px; border-top: 1px solid var(--border); }
.help-pager a { display: flex; flex-direction: column; padding: 10px 14px; font-weight: 650; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.help-pager a:hover { text-decoration: none; border-color: var(--brand); }
.help-pager a.is-next { margin-left: auto; text-align: right; }
.help-pager small { font-size: var(--text-xs); font-weight: 500; color: var(--ink-3); }

/* The printed guide */
.help-book { max-width: 900px; padding: 32px 40px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.help-cover { display: grid; place-items: center; gap: 6px; padding: 80px 0 60px; text-align: center; }
.help-cover .brand-mark { width: 56px; height: 56px; border-radius: 14px; color: #fff; }
.help-cover h1 { font-size: 34px; }
.help-cover-sub { font-size: var(--text-xl); color: var(--brand-strong); }
.help-contents ol { padding-left: 22px; }
.help-contents li { margin-bottom: 6px; }
.help-book-chapter { margin-top: 40px; padding-top: 28px; border-top: 2px solid var(--border); }

/* Language switch and the Urdu chapters: right to left, in a Nastaliq face where the computer has one */
.help-lang { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface-sunken); border: 1px solid var(--border); border-radius: 9px; }
.help-lang a { padding: 4px 12px; font-size: var(--text-sm); font-weight: 600; color: var(--ink-2); border-radius: 6px; }
.help-lang a:hover { text-decoration: none; color: var(--ink); }
.help-lang a[aria-current="true"] { color: var(--brand-strong); background: var(--surface); box-shadow: var(--shadow-sm); }
.help-lang a[lang="ur"] { font-size: 15px; }
.help-hero .help-lang { margin-top: 12px; }
.help-head .help-lang { margin-left: auto; }
.help-untranslated { margin: 0 0 18px; }
.help-lang-note { margin: 10px 0 0; font-size: 17px; line-height: 1.9; }
[lang="ur"] { font-family: var(--font-urdu); }
[lang="ur"] [dir="ltr"], [lang="ur"] .ui, [lang="ur"] kbd, [lang="ur"] code, [lang="ur"] [lang="en"] { font-family: var(--font); }
.help-card-body[lang="ur"] { line-height: 1.9; }
.help-card-body[lang="ur"] strong { font-size: 18px; }
.help-card-body[lang="ur"] small, .help-card-body[lang="ur"] span, .help-card-body[lang="ur"] em { font-size: 16px; letter-spacing: 0; text-transform: none; }
.help-card-body[lang="ur"] strong { font-size: 20px; }
.help-nav [lang="ur"], .help-pager [lang="ur"], .help-results [lang="ur"] { font-size: 15.5px; line-height: 1.7; }
.help-article[lang="ur"] .help-head h2 { font-size: 30px; line-height: 1.8; }
.help-article[lang="ur"] .help-head small, .help-article[lang="ur"] .help-toc { font-size: 15.5px; line-height: 1.9; }
.help-article[lang="ur"] .help-head .help-lang { margin-left: 0; margin-right: auto; }
.help-book-chapter[lang="ur"] .help-head h2 { font-size: 28px; line-height: 1.8; }
.help-body[lang="ur"] { font-family: var(--font-urdu); font-size: 19px; line-height: 2.15; }
.help-body[lang="ur"] h2 { font-size: 23px; line-height: 1.9; }
.help-body[lang="ur"] .lead { font-size: 20px; }
.help-body[dir="rtl"] ul, .help-body[dir="rtl"] ol { padding-left: 0; padding-right: 24px; }
.help-body[dir="rtl"] .help-steps > li { padding-left: 0; padding-right: 40px; }
.help-body[dir="rtl"] .help-steps > li::before { left: auto; right: 0; top: 9px; font-family: var(--font); }
.help-body[dir="rtl"] .help-where a { margin-left: 0; margin-right: auto; }
.help-body[dir="rtl"] .help-where, .help-body[dir="rtl"] .callout, .help-body[dir="rtl"] .help-table { font-size: 17px; }
.help-body[dir="rtl"] .callout { border-left: 0; border-right: 3px solid var(--info); border-radius: 8px 0 0 8px; }
.help-body[dir="rtl"] .callout-warn { border-right-color: var(--warn-line); }
.help-body[dir="rtl"] .help-table th, .help-body[dir="rtl"] .help-table td { text-align: right; }
.help-body[dir="rtl"] .ui, .help-body[dir="rtl"] kbd { font-family: var(--font); font-size: 14px; line-height: 1.7; }
/* English screen names inside Urdu text: the app's own face, a little smaller than the Nastaliq around them */
.help-body[lang="ur"] [dir="ltr"]:not(.ui) { font-size: 16px; }
.help-where bdi { margin-inline-start: 6px; }
.help-body[dir="rtl"] .flow li:not(:last-child)::after { left: auto; right: 32px; }

/* 18. Search, lists, parties, aging, gate pass ---------------------------- */
/* The search box in the top bar ("/" jumps to it); on phones an icon opens /search instead */
.topbar-search { display: flex; flex: 0 1 320px; align-items: center; gap: 8px; height: 36px; padding: 0 8px 0 11px; color: var(--ink-3); background: var(--surface-sunken); border: 1px solid var(--border); border-radius: 9px; transition: border-color .15s, box-shadow .15s, background-color .15s; }
.topbar-search:hover { border-color: var(--border-strong); }
.topbar-search:focus-within { background: var(--surface); border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
.topbar-search input { flex: 1; min-width: 0; height: 100%; font: inherit; font-size: var(--text-sm); color: var(--ink); background: none; border: 0; outline: none; }
.topbar-search:focus-within kbd { visibility: hidden; }
.search-button { display: none; }
kbd { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; font: 600 11px/1 ui-monospace, SFMono-Regular, Consolas, monospace; color: var(--ink-2); background: var(--surface); border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 5px; }

.search-hero { display: grid; gap: 10px; }
.search-hero .help-search { flex: none; }
.search-hero p { margin: 0; font-size: var(--text-sm); }
.search-hero code, .search-hero kbd { font-size: 12px; }
.search-count { margin: 0 0 12px; }
.search-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 440px), 1fr)); gap: 14px; align-items: start; }
.search-group { margin-bottom: 0; }
.search-group .card-head h2 { display: flex; align-items: center; gap: 8px; }
.search-group .card-head h2 .icon { color: var(--brand); }
.search-results { margin: 0; padding: 2px 18px 6px; list-style: none; }
.search-results li { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.search-results li:last-child { border-bottom: 0; }
.search-results a { font-weight: 600; }
.search-results .muted { flex-basis: 100%; font-size: var(--text-sm); overflow-wrap: anywhere; }

/* Status tabs with counts on top of a list (partials/status_tabs.php) */
.status-tabs { display: flex; gap: 2px; padding: 0 10px; overflow-x: auto; background: var(--surface); border-bottom: 1px solid var(--border); }
.status-tabs a { display: inline-flex; align-items: center; gap: 7px; margin-bottom: -1px; padding: 11px 10px 10px; font-size: var(--text-sm); font-weight: 600; color: var(--ink-2); white-space: nowrap; border-bottom: 2px solid transparent; }
.status-tabs a:hover { color: var(--ink); text-decoration: none; border-bottom-color: var(--border-strong); }
.status-tabs a[aria-current="page"] { color: var(--brand-strong); border-bottom-color: var(--brand); }
.status-tabs .count { min-width: 22px; padding: 1px 7px; font-size: 11px; font-weight: 650; text-align: center; font-variant-numeric: tabular-nums; color: var(--ink-3); background: var(--surface-sunken); border-radius: 999px; }
.status-tabs a[aria-current="page"] .count { color: var(--brand-strong); background: var(--brand-soft); }
.table-list tfoot td { white-space: nowrap; }
.strong-link { font-weight: 600; }
.table-list td:first-child a.muted { font-size: var(--text-sm); font-weight: 500; color: var(--ink-3); }
.table-list td:first-child a.muted:hover { color: var(--brand); }

/* A supplier's or customer's page */
.kpis-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* Aging: one tile per age bucket, then a row per party (and per document with "Show each") */
.aging-strip { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin: 0 0 18px; }
.aging-tile { min-width: 0; margin: 0; padding: 10px 12px; background: var(--surface-sunken); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.aging-tile dt { font-size: var(--text-xs); font-weight: 600; color: var(--ink-2); }
.aging-tile dd { margin: 2px 0 0; font-size: var(--text-lg); font-weight: 650; font-variant-numeric: tabular-nums; }
.aging-tile dd.muted { font-size: var(--text-xs); font-weight: 500; }
.aging-tile.is-overdue { background: var(--warn-bg); border-color: var(--warn-line); }
.aging-strip-flush { margin: 0; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.aging-doc td { padding-top: 4px; padding-bottom: 4px; font-size: var(--text-sm); color: var(--ink-2); }
.aging-doc-meta { display: block; font-size: var(--text-xs); color: var(--ink-3); }
.aging-doc-meta .text-warn { font-weight: 600; color: var(--warn); }
.report-note { margin: 16px 0 0; font-size: var(--text-sm); }

/* Gate pass: the sales tax invoice's paper, with the truck and its freight instead of prices */
.gp-number { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; text-align: right; }
.gp-number span:first-child { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: #555; }
.gp-number strong { font-size: 22px; letter-spacing: .02em; }
.gp-vehicle { margin: 0; font-size: 14px; }
.gp-vehicle strong { margin-left: 6px; padding: 2px 10px; font-size: 20px; letter-spacing: .08em; border: 2px solid #111; border-radius: 4px; }
.gate-pass .ti-lines td { font-size: 14px; }
.gp-freight, .gp-receipt { margin-top: 14px; padding: 10px 12px; border: 1px solid #ccc; border-radius: 4px; }
.gp-freight h3, .gp-receipt h3 { margin: 0 0 6px; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: #555; }
.gp-freight p, .gp-receipt p { margin: 4px 0; }
.gp-freight .ti-totals { width: min(100%, 360px); min-width: 0; }
.gp-receipt .ti-foot { margin-top: 34px; }
.gp-blank { display: inline-block; min-width: 90px; border-bottom: 1px solid #111; }

/* 19. Responsive & print -------------------------------------------------- */
@media (max-width: 1100px) {
    .dashboard-grid { grid-template-columns: minmax(0, 1fr); }
    .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .topbar-search { flex-basis: 220px; }
    .topbar-search kbd { display: none; }
}

@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
    .nav-open .sidebar { transform: translateX(0); }
    .nav-open .nav-backdrop { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(15, 20, 28, .45); }
    .main { margin-left: 0; }
    .topbar .nav-toggle { display: inline-grid; }
    .topbar { padding: 0 16px; gap: 10px; }
    .user-meta, .topbar-divider, .fy-chip span { display: none; }
    .breadcrumb { display: none; }
    .topbar-search { display: none; }
    .search-button { display: inline-grid; }
    .help-layout { grid-template-columns: minmax(0, 1fr); }
    .help-nav { position: static; }
    .help-nav ol, .help-nav-print { display: none; }
    .content { padding: 18px 16px 40px; }
    .guest { grid-template-columns: 1fr; }
    .guest-brand { display: none; }
}

@media (max-width: 700px) {
    .form-grid, .form-grid-3, .two-col, .kpis, .quick-actions { grid-template-columns: minmax(0, 1fr); }
    .search input[type="search"] { min-width: 0; width: 100%; }
    .hide-sm { display: none; }
    .totals { width: 100%; }
    .tax-invoice { padding: 16px; border-left: 0; border-right: 0; }
    .ti-head, .ti-summary { flex-direction: column; }
    .ti-parties { grid-template-columns: minmax(0, 1fr); }
    .ti-lines { display: block; overflow-x: auto; }
    .setup-step { grid-template-columns: auto minmax(0, 1fr); }
    .step-action { grid-column: 2; white-space: normal; }
    .help-article, .help-book { padding: 18px 16px; }
    .help-head h2 { font-size: var(--text-xl); }
    .help-table { display: block; overflow-x: auto; }
    .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .kpi { padding: 12px 14px; }
    .kpi-value { font-size: var(--text-xl); }
    .kpi-icon { display: none; }
    .aging-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .gp-number { align-items: flex-start; text-align: left; }
    /* The chart's SVG scales down to about half its size on a phone, so its text is drawn twice as big. */
    .chart-axis { font-size: 20px; }
    .doc-steps { margin-left: 0; }
}

@media print {
    .sidebar, .topbar, .toolbar .doc-actions, .nav-backdrop, details.card, .inline-form, .skip-link, .setup-card, .status-tabs { display: none !important; }
    .aging-tile.is-overdue { background: none; }
    .content > .toolbar { padding: 0; border: 0; box-shadow: none; }
    .help-book, .help-article { max-width: none; padding: 0; border: 0; }
    .help-cover { padding-top: 220px; break-after: page; }
    .help-contents { break-after: page; }
    .help-book-chapter { margin-top: 0; padding-top: 0; border-top: 0; break-before: page; }
    .help-body h2, .help-dl dt { break-after: avoid; }
    .flow li, .callout, .help-table tr { break-inside: avoid; }
    .help-body a { color: inherit; }
    .main { margin: 0; }
    .content { max-width: none; padding: 0; }
    body { background: #fff; }
    .card { box-shadow: none; break-inside: avoid; }
}

@media print {
    @page { size: A4; margin: 10mm; }
    .print-page { background: #fff; }
    .tax-invoice { max-width: none; margin: 0; padding: 0; border: 0; box-shadow: none; }
    .ti-lines tr, .ti-summary, .ti-foot { break-inside: avoid; }
}
