/* ── Design tokens (UI brief §3.1 palette) ───────────────────────────────── */
:root {
    --navy: #1F3864;          /* headers, primary text, top bar */
    --blue: #2E5496;          /* secondary emphasis, links, bars */
    --accent: #C55A11;        /* primary action buttons, highlights */
    --accent-on-dark: #F0A868;/* lighter accent for legibility on the navy sidebar */
    --green: #2E7D32;         /* success / approved / within budget */
    --amber: #B7791F;         /* pending / attention */
    --red: #C0392B;           /* blocked / overdue / over budget */
    --light-1: #EAF0FA;       /* panels, surfaces */
    --light-2: #F4F7FC;       /* table stripes, app background */
    --focus-ring: #2E5496;    /* keyboard focus outline */
}

body {
    font-family: 'Calibri', 'Inter', 'Segoe UI', system-ui, sans-serif;
    font-variant-numeric: tabular-nums;
    margin: 0;
}

/* ── Accessibility: visible keyboard focus (UI brief §8.2) ───────────────── */
a:focus-visible,
button:focus-visible,
.btn:focus-visible,
summary:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
    border-radius: 3px;
}

.nav-link:focus-visible {
    outline: 2px solid var(--accent-on-dark);
    outline-offset: -2px;
}

.auth-page {
    background: #EAF0FA;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.dashboard-page {
    background: #F4F7FC;
}

.card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 420px;
    padding: 40px;
}

.card-wide {
    max-width: 440px;
}

.brand {
    text-align: center;
    margin-bottom: 32px;
}

.brand h1 {
    color: #1F3864;
    font-size: 1.4rem;
    margin: 0;
}

.brand p {
    color: #666;
    font-size: 0.85rem;
    margin: 4px 0 0;
}

.brand-sub {
    font-size: 0.8rem !important;
    margin-top: 8px !important;
}

.form-group {
    margin-bottom: 18px;
}

label {
    display: block;
    font-size: 0.85rem;
    color: #333;
    margin-bottom: 6px;
    font-weight: 600;
}

.checkbox-label {
    font-weight: normal;
}

input[type='email'],
input[type='password'],
input[type='text'] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.95rem;
    box-sizing: border-box;
}

input:focus {
    outline: none;
    border-color: #2E5496;
}

/* Password box with its Show / Hide control sitting inside the right-hand edge. */
.password-field {
    position: relative;
}

.password-field input {
    padding-right: 64px;
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: 6px;
    transform: translateY(-50%);
    padding: 4px 8px;
    border: 0;
    background: none;
    color: #2E5496;
    font-size: 0.82rem;
    cursor: pointer;
}

.password-toggle:hover,
.password-toggle:focus-visible {
    text-decoration: underline;
}

.otp-input {
    font-size: 1.1rem;
    text-align: center;
    letter-spacing: 6px;
}

.btn {
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-primary {
    width: 100%;
    padding: 12px;
    background: #C55A11;
    color: #fff;
    font-size: 1rem;
}

.btn-primary:hover {
    background: #a84a0d;
}

.btn-secondary {
    padding: 10px 16px;
    background: #1F3864;
    color: #fff;
}

.btn-outline {
    padding: 9px 16px;
    background: #fff;
    color: #1F3864;
    border: 1px solid #1F3864;
}

.btn-outline:hover { background: #eef4ff; }

.btn-ghost {
    padding: 9px 16px;
    background: transparent;
    color: #2E5496;
}

.btn-ghost:hover { background: rgba(46, 84, 150, 0.08); }

.btn:disabled,
.btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-small {
    background: #C55A11;
    color: #fff;
    padding: 6px 14px;
    font-size: 0.85rem;
}

.alert {
    border-radius: 4px;
    padding: 10px 14px;
    margin-bottom: 18px;
    font-size: 0.88rem;
}

.alert-error {
    background: #fde8e8;
    border: 1px solid #C0392B;
    color: #C0392B;
}

.alert-list {
    margin: 8px 0 0;
    padding-left: 18px;
}

.alert-list li + li {
    margin-top: 4px;
}

.alert-list .link {
    font-weight: 600;
}

.alert-success {
    background: #e8f5e9;
    border: 1px solid #2E7D32;
    color: #2E7D32;
}

.alert-info {
    background: #eef4ff;
    border: 1px solid #2E5496;
    color: #1F3864;
    word-break: break-all;
}

.error {
    color: #C0392B;
    font-size: 0.82rem;
    margin-top: 4px;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 18px;
    font-size: 0.88rem;
    color: #555;
}

.forgot-link {
    text-align: right;
    font-size: 0.82rem;
    margin-top: -10px;
    margin-bottom: 18px;
}

.forgot-link a,
.back a {
    color: #2E5496;
    text-decoration: none;
}

.back {
    text-align: center;
    margin-top: 16px;
    font-size: 0.85rem;
}

.info,
.steps {
    color: #555;
    font-size: 0.88rem;
}

.qr-block {
    text-align: center;
    margin: 16px 0;
}

.secret-key {
    background: #f4f7fc;
    padding: 10px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.9rem;
    word-break: break-all;
    text-align: center;
    margin-bottom: 16px;
}

.manual-key-label {
    text-align: center;
    font-size: 0.8rem;
    color: #777;
}

.topbar {
    background: #1F3864;
    color: #fff;
    padding: 14px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.topbar h1 {
    margin: 0;
    font-size: 1.1rem;
}

/* Back to the previous page, beside the page title (pages/app.php). */
.topbar-title {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}
.topbar-back {
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.3);
    text-decoration: none;
}
.topbar-back:hover {
    background: rgba(255, 255, 255, 0.22);
    color: #fff;
}

.topbar .user {
    font-size: 0.88rem;
}

.inline-form {
    display: inline;
    margin-left: 12px;
}

.main {
    padding: 32px 24px;
}

.welcome {
    color: #1F3864;
    font-size: 1.4rem;
    margin-bottom: 8px;
}

.sub {
    color: #666;
    font-size: 0.9rem;
}

.panel {
    margin-top: 24px;
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.panel h2 {
    margin-top: 0;
    color: #1F3864;
    font-size: 1rem;
}

/* ── Authenticated app shell ─────────────────────────────────────────────── */

.app-shell {
    display: flex;
    min-height: 100vh;
    background: #F4F7FC;
}

.sidebar {
    width: 232px;
    flex-shrink: 0;
    background: #1F3864;
    color: #cdd8ee;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-brand {
    font-weight: 700;
    font-size: 1.1rem;
    color: #fff;
    padding: 20px 20px 16px;
    letter-spacing: 0.5px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand span {
    color: var(--accent-on-dark);
    margin-left: 4px;
    font-weight: 400;
}

.nav {
    padding: 12px 0 24px;
}

.nav-group {
    text-transform: uppercase;
    font-size: 0.68rem;
    letter-spacing: 0.6px;
    color: #7d90b8;
    padding: 16px 20px 6px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 20px;
    color: #cdd8ee;
    text-decoration: none;
    font-size: 0.9rem;
    border-left: 3px solid transparent;
}

.nav-ico { width: 20px; text-align: center; font-size: 1rem; flex-shrink: 0; }
.nav-label { flex: 1; }

.nav-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
}

.nav-link.active {
    background: rgba(197, 90, 17, 0.18);
    border-left-color: #C55A11;
    color: #fff;
    font-weight: 600;
}

.content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.content .topbar {
    position: sticky;
    top: 0;
    z-index: 5;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-chip {
    font-size: 0.88rem;
    opacity: 0.9;
}

/* ── Top bar: global search + notifications bell (UI brief §3, §4) ────────── */

.topbar-search { position: relative; }
.topbar-search input {
    width: 220px;
    padding: 7px 12px 7px 30px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 0.85rem;
}
.topbar-search input::placeholder { color: #c7d2e8; }
.topbar-search input:focus { background: rgba(255, 255, 255, 0.2); outline: none; }
.topbar-search .search-ico { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: #c7d2e8; font-size: 0.85rem; pointer-events: none; }

.bell { position: relative; }
.bell > summary { list-style: none; cursor: pointer; position: relative; padding: 4px 6px; font-size: 1.15rem; line-height: 1; }
.bell > summary::-webkit-details-marker { display: none; }
.bell-count {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--accent);
    color: #fff;
    font-size: 0.62rem;
    font-weight: 700;
    min-width: 15px;
    height: 15px;
    line-height: 15px;
    text-align: center;
    border-radius: 999px;
    padding: 0 3px;
}
.bell-panel {
    position: absolute;
    right: 0;
    top: 130%;
    width: 280px;
    background: #fff;
    color: #1f2937;
    border-radius: 8px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    padding: 8px;
    z-index: 40;
}
.bell-panel .bell-title { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.4px; color: #64748b; padding: 6px 8px; }
.bell-item { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 9px 8px; border-radius: 6px; text-decoration: none; color: #1f2937; font-size: 0.85rem; }
.bell-item:hover { background: var(--light-2); }
.bell-item .bell-badge { background: var(--accent); color: #fff; border-radius: 999px; font-size: 0.68rem; font-weight: 700; padding: 1px 7px; }
.bell-empty { padding: 12px 8px; color: #64748b; font-size: 0.85rem; }

/* ── Buttons: reset auth's full-width primary inside the app ──────────────── */

.app-shell .btn-primary,
.app-shell .btn-secondary {
    width: auto;
    padding: 9px 16px;
    font-size: 0.9rem;
}

.btn-secondary:hover { background: #2a4a7a; }
.btn-danger { background: #C0392B; color: #fff; padding: 9px 16px; }
.btn-danger:hover { background: #a5301f; }

/* ── Tables ──────────────────────────────────────────────────────────────── */

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.data-table th,
.data-table td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid #eef1f6;
}

.data-table th {
    color: #64748b;
    font-weight: 600;
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.data-table tbody tr:hover { background: #f9fbfe; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .negative { color: #C0392B; font-weight: 600; }
.data-table .muted-cell { color: #64748b; font-size: 0.82rem; }
.data-table .actions { text-align: right; white-space: nowrap; }

.link { color: #2E5496; text-decoration: none; margin-left: 10px; }
.link:first-child { margin-left: 0; }
.link:hover { text-decoration: underline; }

.empty { color: #64748b; padding: 12px 0; }

/* ── Badges & bars ───────────────────────────────────────────────────────── */

.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: capitalize;
}

.badge-ok { background: #e8f5e9; color: #2E7D32; }
.badge-muted { background: #eceff3; color: #64748b; }
.badge-warn { background: #fbf1de; color: #B7791F; }
.badge-info { background: #eef4ff; color: #2E5496; }
.badge-danger { background: #fde8e8; color: #C0392B; }

/* Brief §3 named status badges (Approved / Pending / Blocked / Overdue / Draft). */
.badge-approved { background: #e8f5e9; color: #2E7D32; }
.badge-pending  { background: #fbf1de; color: #B7791F; }
.badge-blocked,
.badge-overdue  { background: #fde8e8; color: #C0392B; }
.badge-draft    { background: #eceff3; color: #64748b; }

/* State conveyed by an icon glyph as well as colour (UI brief §8.2). */
.badge-ok::before,
.badge-approved::before { content: "\2713\00a0"; }        /* ✓ */
.badge-warn::before,
.badge-pending::before  { content: "\25D4\00a0"; }        /* ◔ */
.badge-danger::before,
.badge-blocked::before,
.badge-overdue::before  { content: "\26A0\00a0"; }        /* ⚠ */
.badge-draft::before    { content: "\25CB\00a0"; }        /* ○ */

.util-bar {
    display: inline-block;
    width: 52px;
    height: 6px;
    background: #eceff3;
    border-radius: 3px;
    overflow: hidden;
    vertical-align: middle;
    margin-right: 6px;
}

.util-bar span { display: block; height: 100%; background: #2E5496; }

/* Budget-vs-actual bar: actual solid over a lighter committed layer (brief §5.2). */
.bva-bar {
    position: relative;
    width: 100%;
    height: 10px;
    background: #eceff3;
    border-radius: 5px;
    overflow: hidden;
}

.bva-bar .committed { position: absolute; inset: 0; height: 100%; background: #b9c9e6; }
.bva-bar .actual { position: absolute; inset: 0; height: 100%; background: #2E5496; }
.bva-bar.over .actual { background: #C0392B; }

/* ── Stat cards ──────────────────────────────────────────────────────────── */

.welcome-row { margin-bottom: 8px; }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-top: 20px;
}

.stat-card {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    text-decoration: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
    border-left: 4px solid #C55A11;
}

.stat-card:hover { box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1); }
.stat-num { font-size: 1.8rem; font-weight: 700; color: #1F3864; }
.stat-label { font-size: 0.82rem; color: #334155; font-weight: 600; }
.stat-sub { font-size: 0.76rem; color: #64748b; }
.stat-card-alert { border-left-color: #C0392B; }
.stat-card-alert .stat-num { color: #C0392B; }

/* ── Dashboard: budget-vs-actual + sign-off queue ────────────────────────── */

.dash-cols {
    display: grid;
    grid-template-columns: 3fr 2fr;
    gap: 16px;
    margin-top: 20px;
}

@media (max-width: 900px) { .dash-cols { grid-template-columns: 1fr; } }

.bva-row { display: flex; align-items: center; gap: 12px; margin: 10px 0; }
.bva-label { width: 150px; flex-shrink: 0; font-size: 0.85rem; color: #1f2937; }
.bva-row .bva-bar { flex: 1; }
.bva-pct { width: 40px; text-align: right; font-size: 0.82rem; color: #64748b; font-variant-numeric: tabular-nums; }

.signoff-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid #eef1f6;
    border-radius: 6px;
    margin-bottom: 8px;
}

.signoff-ref { font-size: 0.86rem; font-weight: 600; color: #1F3864; }
.signoff-meta { font-size: 0.78rem; color: #64748b; }

/* ── Forms (app) ─────────────────────────────────────────────────────────── */

.form-panel { max-width: 720px; }

.stacked-form .field { margin-bottom: 16px; }

.app-shell input[type='text'],
.app-shell input[type='email'],
.app-shell input[type='password'],
.app-shell input[type='number'],
.app-shell input[type='date'],
.app-shell select,
.app-shell textarea {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.92rem;
    box-sizing: border-box;
    font-family: inherit;
}

.field-row {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
}

.field-row .field { flex: 1; margin-bottom: 0; }

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid #eef1f6;
}

.error-list { margin: 0; padding-left: 18px; }

.callout {
    background: #f4f7fc;
    border-radius: 6px;
    padding: 12px 14px;
    font-size: 0.88rem;
    color: #334155;
}

.callout .hint { color: #64748b; font-size: 0.8rem; }
.callout-danger { background: #fdecea; color: #7a2018; border: 1px solid #f0b5ae; margin-top: 12px; }

/* Inline "Return for correction" disclosure inside a panel head / actions cell. */
.inline-return { display: inline-block; vertical-align: top; }
.inline-return > summary { list-style: none; cursor: pointer; }
.inline-return > summary::-webkit-details-marker { display: none; }
.inline-return[open] > summary { margin-bottom: 4px; }

.hint { color: #64748b; font-size: 0.82rem; }

/* ── Detail grid ─────────────────────────────────────────────────────────── */

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
}

.detail-grid > div { font-size: 0.92rem; color: #1f2937; }
.detail-label { display: block; font-size: 0.72rem; text-transform: uppercase; color: #64748b; letter-spacing: 0.4px; margin-bottom: 3px; }

.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }

.inline-add-form {
    display: flex;
    gap: 10px;
    margin-top: 16px;
    flex-wrap: wrap;
    align-items: center;
}

.app-shell .inline-add-form input { width: auto; flex: 1; min-width: 120px; }

/* ── Utility ─────────────────────────────────────────────────────────────── */

code {
    background: #eef1f6;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.85em;
}

/* Read-only JSON preview of an outbound Zoho posting (transaction review screen). */
.payload-preview {
    background: #f7f9fc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 12px 14px;
    font-size: 0.8rem;
    line-height: 1.5;
    color: #334155;
    overflow-x: auto;
    max-height: 460px;
    white-space: pre;
}

/* ── Checkbox grid (role assignment) ─────────────────────────────────────── */

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 8px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: normal;
    font-size: 0.88rem;
    background: #f4f7fc;
    padding: 8px 10px;
    border-radius: 4px;
    margin: 0;
}

.checkbox-item input { width: auto; }

/* ── Filter form ─────────────────────────────────────────────────────────── */

.filter-form {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.app-shell .filter-form select,
.app-shell .filter-form input { width: auto; min-width: 130px; }

/* ── Approval chain ──────────────────────────────────────────────────────── */

.chain { list-style: none; padding: 0; margin: 0; }

.chain-step {
    padding: 10px 14px;
    border-left: 3px solid #d5dbe6;
    margin-bottom: 6px;
    background: #f9fbfe;
    font-size: 0.9rem;
}

/* ── Imprest block banner + ageing legend (brief §5.6) ───────────────────── */

.block-banner {
    background: #fde8e8;
    border: 1px solid #C0392B;
    border-left: 4px solid #C0392B;
    border-radius: 6px;
    padding: 12px 16px;
    margin-bottom: 20px;
}

.block-banner-title { color: #C0392B; font-weight: 700; font-size: 0.95rem; }
.block-banner-body { color: #7f1d1d; font-size: 0.85rem; margin-top: 2px; }

.ageing-legend {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid #eef1f6;
}

.ageing-legend .detail-label { margin-bottom: 0; margin-right: 4px; }

.receipt-checklist { list-style: none; margin: 0; padding: 0; }

.receipt-checklist li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid #eef1f6;
    font-size: 0.88rem;
}

.receipt-checklist .rc-icon { width: 18px; text-align: center; font-weight: 700; }
.receipt-checklist li.done .rc-icon { color: #2E7D32; }
.receipt-checklist li.pending .rc-icon { color: #b0b8c4; }
.receipt-checklist .rc-label { flex: 1; }

.chain-step.done { border-left-color: #2E7D32; }
.chain-step.current { border-left-color: #2E5496; background: #eef4ff; }
.chain-step .badge { margin-left: 8px; }

.report-links { line-height: 2; font-size: 0.92rem; }

/* ── Reports: level tabs + grouping rows ─────────────────────────────────── */

.report-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid #eef1f6;
}

.report-toolbar-end { justify-content: flex-end; }

.export-actions { display: flex; align-items: center; gap: 8px; }
.export-label { font-size: 0.82rem; color: #64748b; font-weight: 600; margin-right: 2px; }
.app-shell .export-actions .btn-small { padding: 7px 18px; min-width: 58px; }

.report-level { display: inline-flex; border: 1px solid #d5dbe6; border-radius: 6px; overflow: hidden; }

.report-tab {
    border: none;
    border-right: 1px solid #d5dbe6;
    background: #fff;
    padding: 7px 14px;
    font-size: 0.84rem;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
}

.report-tab:last-child { border-right: none; }
.report-tab.active { background: #1F3864; color: #fff; }

.data-table .group-row td { background: #eef4ff; color: #1F3864; font-weight: 700; font-size: 0.82rem; }
.data-table .subtotal-row td { background: #f4f7fc; font-weight: 600; }
.data-table .total-row td { border-top: 2px solid #1F3864; font-weight: 700; color: #1F3864; }

/* ── Type-to-filter dropdowns (searchable-select.js) ─────────────────────────
   The real <select> stays in the DOM holding the value; it is hidden from view
   but NOT with display:none, so the browser can still focus it to report a
   validation message on a required field. */
.ss { position: relative; }
.ss .ss-native {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}
.ss-input { width: 100%; }
.ss-list {
    position: absolute;
    z-index: 40;
    top: 100%;
    left: 0;
    right: 0;
    margin: 2px 0 0;
    padding: 4px 0;
    max-height: 260px;
    overflow-y: auto;
    list-style: none;
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.14);
}
.ss-opt { padding: 6px 10px; cursor: pointer; font-size: 0.86rem; }
.ss-opt.is-active { background: #eef4ff; }
.ss-opt.is-current { font-weight: 600; color: #1F3864; }
.ss-group {
    padding: 6px 10px 2px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
}
.ss-empty { padding: 8px 10px; font-size: 0.82rem; color: #64748b; }

/* Inside the item table the list must escape the row without widening it. */
.item-table .ss-list { min-width: 260px; }

/* Budget vs Actual reads project → activity → line, so the three tiers have to be
   distinguishable at a glance: the activity carries the weight (it is the level the
   funder reports against) and its lines sit quieter and indented beneath it. */
.data-table .activity-row td { font-weight: 600; border-top: 1px solid #e2e8f0; }
.data-table .activity-row td:first-child { color: #1F3864; }
.data-table .activity-row .hint { font-weight: 400; margin-left: 6px; }
.data-table .line-row td { font-size: 0.84rem; }
.data-table .line-row td:first-child { border-left: 3px solid #e2e8f0; }

/* ── Budget drill-down: budgets → activities → sub-activities ─────────────────
   The activity sheet is wide (rate, unit, frequency, units, then five money
   columns), so it scrolls inside its panel rather than stretching the page. */
.breadcrumb { margin: 0 0 12px; font-size: 0.84rem; color: #64748b; }
/* Consolidation tiles sit inside a panel, so they lose the dashboard's top gap and
   carry money rather than counts — narrower digits keep four across on one line. */
.consolidation-grid { margin-top: 12px; }
.consolidation-grid .stat-num { font-size: 1.35rem; }
/* A sub-activity with no GL account cannot be coded to the chart — say so in colour. */
.data-table .unmapped-row td { background: #fdf4f3; }
.data-table .unmapped-row td:first-child { color: #C0392B; font-weight: 600; }
.breadcrumb a { color: #1F3864; }
.table-scroll { overflow-x: auto; }
.data-table .cell-sub { display: block; margin-top: 2px; font-size: 0.75rem; font-weight: 400; color: #64748b; }
p.hint.negative { color: #C0392B; font-weight: 600; }

/* ── New request: two-column layout + segmented selector + budget check ──── */

.request-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 16px;
    align-items: start;
}

@media (max-width: 900px) { .request-layout { grid-template-columns: 1fr; } }

.request-layout .form-panel { max-width: none; }

.segment {
    display: inline-flex;
    border: 1px solid #d5dbe6;
    border-radius: 6px;
    overflow: hidden;
    flex-wrap: wrap;
}

.segment-option {
    margin: 0;
    padding: 8px 16px;
    font-size: 0.88rem;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    border-right: 1px solid #d5dbe6;
    background: #fff;
}

.segment-option:last-child { border-right: none; }
.segment-option input { display: none; }
.segment-option.active { background: #C55A11; color: #fff; }

.budget-check { position: sticky; top: 84px; }
.budget-check h2 { font-size: 0.95rem; color: #1F3864; margin-top: 0; }
.bc-empty { color: #64748b; font-size: 0.85rem; }
.bc-line { font-weight: 600; font-size: 0.85rem; margin-bottom: 10px; color: #334155; }

.bc-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.88rem;
    padding: 5px 0;
    color: #475569;
}

.bc-row .num { font-variant-numeric: tabular-nums; }
.bc-available { border-top: 1px solid #eef1f6; margin-top: 4px; padding-top: 8px; font-weight: 700; color: #1F3864; }

.bc-signal {
    margin-top: 12px;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 0.82rem;
    background: #f4f7fc;
    color: #475569;
}

.bc-signal.ok { background: #e8f5e9; color: #2E7D32; }
.bc-signal.over { background: #fde8e8; color: #C0392B; font-weight: 600; }
.budget-check.over { box-shadow: 0 0 0 2px #C0392B inset; }
.bc-realloc { margin-top: 10px; font-size: 0.82rem; }

.bc-chain { margin-top: 16px; border-top: 1px solid #eef1f6; padding-top: 12px; }
.bc-chain-title { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.4px; color: #64748b; margin-bottom: 6px; }
.bc-chain ol { margin: 0; padding-left: 18px; font-size: 0.85rem; color: #334155; }
.bc-chain li { padding: 2px 0; }

@media (max-width: 820px) {
    .sidebar { width: 60px; }
    .sidebar-brand { font-size: 0; padding: 16px 0; text-align: center; }
    .sidebar-brand::before { content: "C"; font-size: 1.2rem; color: #fff; }
    .sidebar-brand span { display: none; }
    .nav-group { display: none; }
    /* Icon-only rail: keep the glyphs, drop the labels (no more blank rail). */
    .nav-link { justify-content: center; padding: 12px 0; gap: 0; }
    .nav-label { display: none; }
    .nav-ico { font-size: 1.15rem; }

    /* Wide tables scroll horizontally instead of overflowing the viewport. */
    .data-table { display: block; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

    .topbar-search { display: none; }
}

/* ── Toasts (UI brief §7 success confirmation) ───────────────────────────── */

.toast-wrap {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 50;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: min(360px, 90vw);
}

.toast {
    background: #fff;
    border-left: 4px solid var(--green);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.16);
    border-radius: 6px;
    padding: 12px 14px;
    font-size: 0.88rem;
    color: #1f2937;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    animation: toast-in 0.25s ease-out;
}

.toast.hiding { opacity: 0; transform: translateX(12px); transition: opacity 0.3s, transform 0.3s; }
.toast .toast-ico { color: var(--green); font-weight: 700; }
.toast .toast-close { margin-left: auto; cursor: pointer; color: #94a3b8; background: none; border: none; font-size: 1rem; line-height: 1; }
@keyframes toast-in { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }

/* ── Skeleton placeholders (UI brief §7 loading) ─────────────────────────── */

.skeleton {
    background: linear-gradient(90deg, #eef1f6 25%, #e2e8f2 37%, #eef1f6 63%);
    background-size: 400% 100%;
    animation: skeleton-shimmer 1.4s ease infinite;
    border-radius: 4px;
    color: transparent !important;
    min-height: 1em;
}

@keyframes skeleton-shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
@media (prefers-reduced-motion: reduce) {
    .skeleton, .toast { animation: none; }
}

/* ── Zoho-shaped documents: bill / payment forms ─────────────────────────── */
.doc-form .panel { margin-bottom: 16px; }
.panel-title { margin: 0 0 12px; font-size: 0.92rem; font-weight: 700; color: #1F3864; }
.req { color: #C0392B; }

/* Header + field blocks lay out as a responsive two/three column grid, matching
   the label-left, control-right rhythm of the Zoho form. */
.doc-head,
.doc-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 4px 24px; }
.doc-head .form-group,
.doc-fields .form-group { margin-bottom: 12px; }
.form-group-wide { grid-column: 1 / -1; }

.item-table input,
.item-table select { width: 100%; margin: 0; }
.item-table td { vertical-align: top; }
.item-table .item-amount { padding-top: 14px; font-variant-numeric: tabular-nums; }
.item-table input.num { text-align: right; }

.doc-totals { margin: 16px 0 0 auto; max-width: 420px; }
.doc-totals .tot-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid #eceff3; }
.doc-totals .tot-row > span:last-child { min-width: 120px; text-align: right; font-variant-numeric: tabular-nums; }
.doc-totals input { width: 100px; margin: 0; }
.doc-totals .tot-grand { border-bottom: none; border-top: 2px solid #1F3864; font-weight: 700; color: #1F3864; }

.doc-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px 24px; }
.doc-summary > div { display: flex; flex-direction: column; gap: 2px; }

/* ── Approval signature pad ──────────────────────────────────────────────── */
.sig-block { margin: 14px 0; }
.sig-block > label { display: block; font-weight: 600; margin-bottom: 6px; }
.sig-reuse { margin-bottom: 6px; }
.sig-saved,
.sig-canvas { display: block; background: #fff; border: 1px dashed #b9c4d4; border-radius: 6px; }
.sig-saved { max-width: 260px; max-height: 90px; padding: 6px; }
.sig-canvas { width: 100%; max-width: 520px; height: 150px; cursor: crosshair; touch-action: none; }
.sig-actions { display: flex; align-items: center; gap: 14px; margin-top: 6px; }
.sig-actions .checkbox-label { margin: 0; }
.sig-inline { display: block; max-width: 120px; max-height: 44px; margin-bottom: 2px; }
.sig-hash { font-size: 0.72rem; color: #94a3b8; }

/* ── Report shell (Doc 07 §2.4) ───────────────────────────────────────────────
   Every report renders inside this shell so screen output already looks like the
   printed page: letterhead, accent rule, navy title bar, parameter chips, body,
   footer. Print rules below drop the app chrome so Ctrl-P gives the same sheet. */
.report-sheet {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    padding: 22px 24px 12px;
    margin-bottom: 16px;
}
.report-letterhead { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.report-org { font-size: 1.5rem; font-weight: 700; color: #1F3864; letter-spacing: 0.01em; }
.report-org-sub { font-size: 0.78rem; color: #64748b; }
.report-logo {
    width: 52px; height: 52px; flex: none;
    border: 1px solid #cbd5e1; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.6rem; color: #94a3b8; letter-spacing: 0.08em;
}
.report-rule { height: 2px; background: #C55A11; margin: 10px 0 14px; }
.report-titlebar {
    background: #1F3864; color: #fff;
    text-align: center; font-weight: 700; font-size: 0.9rem; letter-spacing: 0.03em;
    padding: 8px 12px; border-radius: 3px;
}
.report-params { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 12px 0 14px; }
.report-chip {
    border: 1px solid #cbd5e1; border-radius: 999px;
    padding: 3px 12px; font-size: 0.76rem; color: #334155; background: #f8fafc;
}
.report-generated { margin-left: auto; font-size: 0.72rem; color: #94a3b8; }
.report-table { font-size: 0.82rem; }
.report-table thead th { background: #1F3864; color: #fff; }
.report-note { font-size: 0.75rem; color: #64748b; margin: 10px 0 0; }
.report-footer {
    display: flex; justify-content: space-between; gap: 12px;
    margin-top: 16px; padding-top: 8px; border-top: 1px solid #e2e8f0;
    font-size: 0.68rem; color: #94a3b8;
}
.report-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.report-filters form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.report-filters .field { margin: 0; min-width: 150px; }
.report-filters .field label { font-size: 0.76rem; }

/* Signature blocks on printable statements (R2). */
.report-signatures { display: flex; flex-wrap: wrap; gap: 40px; margin: 26px 0 8px; }
.report-signatures > div { flex: 1 1 240px; }
.report-sig-line { border-bottom: 1px solid #94a3b8; height: 28px; margin-bottom: 4px; }
.report-sig-label { font-size: 0.76rem; color: #475569; }
.report-callout {
    background: #fdf7e7; border: 1px solid #f0e0b6; border-radius: 6px;
    padding: 10px 12px; font-size: 0.78rem; color: #7a5c12; margin-top: 14px;
}

/* Utilisation bars beneath R4. */
.util-chart { margin: 18px 0 4px; }
.util-chart h3 { font-size: 0.8rem; color: #1F3864; margin: 0 0 10px; }
.util-chart-row { display: flex; align-items: center; gap: 10px; margin-bottom: 7px; font-size: 0.76rem; }
.util-chart-name { width: 210px; flex: none; color: #334155; }
.util-chart-track { flex: 1; height: 11px; background: #eef2f7; border-radius: 999px; overflow: hidden; }
.util-chart-fill { display: block; height: 100%; background: #C55A11; border-radius: 999px; }
.util-chart-fill.over { background: #C0392B; }
.util-chart-fill.under { background: #2E5496; }
.util-chart-pct { width: 52px; flex: none; text-align: right; font-variant-numeric: tabular-nums; }

/* Report catalogue on the reports index. */
.report-catalogue .data-table td { vertical-align: top; }
.report-catalogue .report-blurb { display: block; font-size: 0.76rem; color: #64748b; margin-top: 2px; }

@media print {
    .sidebar, .topbar, .page-head, .no-print, .report-filters, .report-actions { display: none !important; }
    .app-shell, .content, .main { display: block !important; margin: 0 !important; padding: 0 !important; background: #fff !important; }
    .report-sheet { box-shadow: none; border-radius: 0; padding: 0; }
    .table-scroll { overflow: visible !important; }
    .report-table { font-size: 0.72rem; }
    .report-table thead th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .report-titlebar { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    @page { size: A4 landscape; margin: 12mm; }
}
