:root {
    --navy-950: #071a33;
    --navy-900: #0b2345;
    --navy-800: #123764;
    --blue-600: #1f5fa8;
    --blue-100: #eaf2fb;
    --gold-500: #e7b928;
    --gold-100: #fff7d8;
    --ink: #172033;
    --muted: #657187;
    --line: #dfe5ee;
    --surface: #ffffff;
    --canvas: #f4f7fb;
    --success: #157a5a;
    --danger: #b5483f;
    --warning: #b87b12;
    --shadow: 0 18px 50px rgba(11, 35, 69, .12);
}

* { box-sizing: border-box; }
html { font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--ink); background: var(--canvas); }
body { margin: 0; min-height: 100vh; }
button, input { font: inherit; }
a { color: inherit; }

.auth-page { display: grid; place-items: center; padding: 32px; background: radial-gradient(circle at 15% 15%, #1d4e82 0, var(--navy-950) 45%, #04101f 100%); }
.auth-card { width: min(1060px, 100%); min-height: 650px; display: grid; grid-template-columns: 1.05fr .95fr; overflow: hidden; border: 1px solid rgba(255,255,255,.15); border-radius: 24px; box-shadow: 0 30px 90px rgba(0,0,0,.32); background: var(--surface); }
.auth-intro { position: relative; padding: 68px; color: #fff; background: linear-gradient(145deg, rgba(7,26,51,.96), rgba(18,55,100,.9)), linear-gradient(135deg, var(--navy-900), var(--blue-600)); }
.auth-intro::after { content: ""; position: absolute; right: -70px; bottom: -70px; width: 260px; height: 260px; border: 42px solid rgba(231,185,40,.16); border-radius: 50%; }
.auth-brand { display: inline-grid; place-items: center; width: 82px; height: 48px; margin-bottom: 74px; border-top: 4px solid var(--gold-500); color: var(--gold-500); font-size: 30px; font-weight: 900; letter-spacing: -.06em; }
.auth-intro h1 { max-width: 460px; margin: 12px 0 18px; font-size: clamp(38px, 5vw, 58px); line-height: 1.02; letter-spacing: -.045em; }
.auth-intro > p:not(.eyebrow) { max-width: 480px; color: #d8e5f5; font-size: 17px; line-height: 1.7; }
.auth-intro ul { margin: 36px 0 0; padding: 0; list-style: none; color: #edf4fc; }
.auth-intro li { margin: 14px 0; }
.auth-intro li::before { content: ""; display: inline-block; width: 7px; height: 7px; margin: 0 12px 2px 0; border-radius: 50%; background: var(--gold-500); }
.auth-form-panel { display: grid; place-items: center; padding: 60px; background: #fff; }
.auth-form-wrap { width: min(360px, 100%); }
.auth-form-wrap h2 { margin: 8px 0 6px; color: var(--navy-900); font-size: 34px; letter-spacing: -.03em; }
.form-lead { margin: 0 0 32px; color: var(--muted); }
.eyebrow { margin: 0; color: var(--blue-600); font-size: 11px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.auth-form { display: grid; gap: 10px; }
.auth-form label:not(.remember-row) { margin-top: 10px; font-size: 13px; font-weight: 750; }
.auth-form input[type="email"], .auth-form input[type="password"] { width: 100%; height: 48px; padding: 0 14px; border: 1px solid #cbd4e2; border-radius: 8px; outline: 0; background: #fbfcfe; }
.auth-form input:focus { border-color: var(--blue-600); box-shadow: 0 0 0 3px rgba(31,95,168,.12); }
.remember-row { display: flex; align-items: center; gap: 9px; margin: 12px 0; color: var(--muted); font-size: 13px; }
.remember-row input { width: 17px; height: 17px; accent-color: var(--blue-600); }
.primary-button { min-height: 50px; border: 0; border-radius: 8px; color: #fff; background: var(--navy-800); font-weight: 800; cursor: pointer; box-shadow: 0 9px 22px rgba(18,55,100,.2); }
.primary-button:hover { background: var(--blue-600); }
.field-error { margin: 0; color: var(--danger); font-size: 12px; }
.security-note { margin: 26px 0 0; color: #8791a2; font-size: 11px; line-height: 1.55; text-align: center; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 260px 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 28px 20px; color: #dfe9f5; background: var(--navy-950); }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 9px 30px; text-decoration: none; border-bottom: 1px solid rgba(255,255,255,.1); }
.brand-mark { padding-top: 4px; border-top: 3px solid var(--gold-500); color: var(--gold-500); font-size: 25px; font-weight: 900; letter-spacing: -.06em; }
.brand-copy { font-size: 13px; font-weight: 800; line-height: 1.25; }
.brand-copy small { display: block; margin-top: 4px; color: #8ca2bb; font-size: 10px; font-weight: 500; }
.main-nav { display: grid; gap: 5px; padding-top: 25px; }
.main-nav a { display: flex; align-items: center; justify-content: space-between; min-height: 42px; padding: 0 12px; border-radius: 7px; color: #c5d2e1; text-decoration: none; font-size: 13px; }
.main-nav a.active { color: #fff; background: var(--navy-800); box-shadow: inset 3px 0 var(--gold-500); }
.main-nav a.disabled { cursor: default; opacity: .72; }
.main-nav a small { color: #8298b0; font-size: 9px; text-transform: uppercase; }
.nav-heading { margin: 22px 12px 7px; color: #6f879f; font-size: 9px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.main-panel { min-width: 0; }
.topbar { height: 78px; display: flex; align-items: center; justify-content: space-between; padding: 0 36px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.95); }
.topbar strong { display: block; margin-top: 3px; color: var(--navy-900); font-size: 15px; }
.user-menu { display: flex; align-items: center; gap: 16px; color: var(--muted); font-size: 13px; }
.user-menu form { margin: 0; }
.user-menu button { padding: 8px 12px; border: 1px solid var(--line); border-radius: 6px; color: var(--navy-800); background: #fff; font-size: 12px; font-weight: 700; cursor: pointer; }
.content { padding: 38px; }
.page-intro { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.page-intro h1 { margin: 7px 0; color: var(--navy-900); font-size: 31px; letter-spacing: -.035em; }
.page-intro p:last-child { margin: 0; color: var(--muted); }
.date-chip { padding: 9px 12px; border: 1px solid var(--line); border-radius: 7px; color: var(--muted); background: #fff; font-size: 12px; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 16px; }
.metric-card { min-height: 148px; padding: 22px; border: 1px solid var(--line); border-radius: 12px; background: #fff; box-shadow: 0 7px 20px rgba(11,35,69,.05); }
.metric-card > span { color: var(--muted); font-size: 12px; font-weight: 700; }
.metric-card strong { display: block; margin: 18px 0 7px; color: var(--navy-900); font-size: 25px; letter-spacing: -.03em; }
.metric-card small { color: #8a94a5; font-size: 10px; }
.metric-positive { border-top: 3px solid var(--success); }
.metric-negative { border-top: 3px solid var(--gold-500); }
.dashboard-grid { display: grid; grid-template-columns: 1.3fr .7fr; gap: 18px; margin-top: 18px; }
.panel { padding: 25px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.panel h2 { margin: 6px 0 0; color: var(--navy-900); font-size: 19px; letter-spacing: -.02em; }
.status-pill { padding: 5px 8px; border-radius: 999px; color: var(--success); background: #e9f7f1; font-size: 9px; font-weight: 800; text-transform: uppercase; }
.commitment-row { display: flex; align-items: center; justify-content: space-between; padding: 17px 2px; border-top: 1px solid #edf0f5; }
.commitment-row div { display: flex; align-items: center; gap: 10px; }
.commitment-row strong { font-size: 13px; }
.commitment-row b { color: var(--navy-800); font-size: 20px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; }
.status-dot-positive { background: var(--success); }
.status-dot-warning { background: var(--warning); }
.panel-accent { position: relative; overflow: hidden; color: #d8e5f5; border: 0; background: linear-gradient(145deg, var(--navy-900), var(--navy-800)); }
.panel-accent::after { content: ""; position: absolute; right: -52px; bottom: -52px; width: 150px; height: 150px; border: 24px solid rgba(231,185,40,.18); border-radius: 50%; }
.panel-accent .eyebrow { color: var(--gold-500); }
.panel-accent h2 { color: #fff; font-size: 24px; }
.panel-accent p:last-child { position: relative; z-index: 1; color: #c6d5e5; font-size: 13px; line-height: 1.7; }

@media (max-width: 1050px) {
    .metric-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .dashboard-grid { grid-template-columns: 1fr; }
}
@media (max-width: 780px) {
    .auth-page { padding: 0; }
    .auth-card { min-height: 100vh; grid-template-columns: 1fr; border-radius: 0; }
    .auth-intro { display: none; }
    .auth-form-panel { padding: 34px 24px; }
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; padding: 18px; }
    .brand { padding-bottom: 16px; }
    .main-nav { display: none; }
    .topbar { height: auto; padding: 16px 20px; }
    .topbar > div:first-child { display: none; }
    .user-menu { width: 100%; justify-content: space-between; }
    .content { padding: 24px 18px; }
    .page-intro { display: block; }
    .date-chip { display: inline-block; margin-top: 16px; }
    .metric-grid { grid-template-columns: 1fr; }
}

/* Stage 3: receipt allocation and banking */
.header-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; justify-content: flex-end; }
.detail-grid { display: grid; grid-template-columns: 1.25fr repeat(3, minmax(0,1fr)); gap: 15px; }
.detail-summary, .detail-card { min-height: 140px; }
.detail-summary { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; border-top: 3px solid var(--success); }
.detail-summary > strong { margin: 13px 0 12px; color: var(--navy-900); font-size: 27px; }
.detail-card > span { color: var(--muted); font-size: 11px; font-weight: 750; }
.detail-card > strong { display: block; margin: 20px 0 8px; color: var(--navy-900); font-size: 17px; }
.detail-card > small { color: #8490a1; font-size: 10px; }
.detail-history { margin-top: 18px; }
.panel-title-row { padding: 22px 24px 18px; }
.panel-title-row h2 { margin: 5px 0 0; color: var(--navy-900); font-size: 18px; }
.compact-empty { padding-top: 35px; padding-bottom: 43px; }
.receipt-context { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 1px; max-width: 1120px; margin-bottom: 16px; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: var(--line); }
.receipt-context > div { padding: 15px 17px; background: #fff; }
.receipt-context span { display: block; color: #7d899b; font-size: 9px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.receipt-context strong { display: block; margin-top: 6px; color: var(--navy-900); font-size: 13px; }

@media (max-width: 1050px) {
    .detail-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .receipt-context { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 780px) {
    .header-actions { justify-content: stretch; }
    .header-actions > * { flex: 1; }
    .detail-grid, .receipt-context { grid-template-columns: 1fr; }
}

/* Stage 2: branded assets, records, tables and responsive navigation */
.auth-logo { display: block; width: 190px; height: 64px; margin-bottom: 62px; object-fit: contain; object-position: left center; }
.brand-logo { width: 58px; height: 35px; object-fit: contain; }
.password-field { position: relative; }
.password-field input { padding-right: 66px !important; }
.password-field button { position: absolute; right: 7px; top: 7px; height: 34px; padding: 0 10px; border: 0; border-radius: 6px; color: var(--blue-600); background: var(--blue-100); font-size: 11px; font-weight: 800; cursor: pointer; }
.menu-toggle { display: none; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 7px; color: var(--navy-900); background: #fff; font-size: 20px; cursor: pointer; }
.alert { margin-bottom: 22px; padding: 14px 17px; border: 1px solid; border-radius: 9px; font-size: 13px; }
.alert ul { margin: 7px 0 0; padding-left: 20px; }
.alert-success { color: #0c6649; border-color: #b7e3d2; background: #eaf8f3; }
.alert-notice { color: #76570d; border-color: #f0d889; background: #fff9e6; }
.alert-error { color: #8c342d; border-color: #efc1bd; background: #fff1f0; }
.page-intro-actions { align-items: center; }
.primary-link, .secondary-link { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 0 16px; border-radius: 7px; text-decoration: none; font-size: 12px; font-weight: 800; }
.primary-link { color: #fff; background: var(--navy-800); box-shadow: 0 7px 18px rgba(18,55,100,.16); }
.primary-link:hover { background: var(--blue-600); }
.secondary-link { color: var(--navy-800); border: 1px solid var(--line); background: #fff; }
.secondary-button { min-height: 42px; padding: 0 15px; border: 1px solid #c8d2df; border-radius: 7px; color: var(--navy-800); background: #fff; font-size: 12px; font-weight: 800; cursor: pointer; }
.text-link { color: var(--blue-600); font-size: 12px; font-weight: 750; text-decoration: none; }
.filter-bar { display: flex; align-items: center; gap: 10px; margin: 0 0 17px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.filter-bar input, .filter-bar select { height: 42px; padding: 0 12px; border: 1px solid #cbd4e2; border-radius: 7px; color: var(--ink); background: #fbfcfe; outline: none; }
.filter-search { flex: 1; }
.filter-search input { width: 100%; }
.filter-bar-wide .filter-search { min-width: 240px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.table-panel { padding: 0; overflow: hidden; }
.table-wrap { width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.data-table th { padding: 15px 17px; color: #738096; background: #f8fafc; font-size: 9px; font-weight: 850; letter-spacing: .09em; text-align: left; text-transform: uppercase; white-space: nowrap; }
.data-table td { padding: 16px 17px; border-top: 1px solid #e9edf3; color: #4c596d; vertical-align: middle; }
.data-table td > strong { color: var(--navy-900); }
.data-table td small { display: block; margin-top: 4px; color: #8590a1; font-size: 10px; line-height: 1.35; }
.data-table tr:hover td { background: #fbfcfe; }
.data-table .row-overdue td { background: #fffafa; }
.table-action { text-align: right; white-space: nowrap; }
.table-action a { color: var(--blue-600); font-weight: 800; text-decoration: none; }
.table-action span { color: #9aa4b3; font-size: 10px; }
.reference-code { display: inline-flex; padding: 4px 7px; border-radius: 5px; color: var(--navy-800); background: var(--blue-100); font-size: 10px; font-weight: 850; letter-spacing: .05em; }
.status-badge { display: inline-flex; padding: 5px 8px; border-radius: 999px; font-size: 9px; font-weight: 850; white-space: nowrap; text-transform: uppercase; }
.status-open { color: #126348; background: #e8f6f0; }
.status-partial { color: #7a5b0e; background: #fff5d6; }
.status-overdue { color: #9b342d; background: #ffebe9; }
.status-paid { color: #176879; background: #e5f6fa; }
.status-cancelled { color: #687385; background: #eef1f5; }
.empty-state { max-width: 560px; margin: 0 auto; padding: 62px 25px; text-align: center; }
.empty-state strong { color: var(--navy-900); font-size: 20px; }
.empty-state p { margin: 9px 0 22px; color: var(--muted); line-height: 1.6; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 18px; padding: 17px; border-top: 1px solid var(--line); color: #8791a1; font-size: 11px; }
.pagination a { color: var(--blue-600); font-weight: 800; text-decoration: none; }
.pagination strong { color: var(--navy-900); font-size: 10px; }
.record-form { max-width: 1120px; padding: 28px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.form-grid-four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-field { display: flex; flex-direction: column; gap: 7px; }
.form-field-small { max-width: 310px; }
.form-field-wide { grid-column: span 1; }
.form-field-full { grid-column: 1 / -1; }
.form-field label { color: var(--navy-900); font-size: 11px; font-weight: 800; }
.form-field label > span { color: var(--danger); }
.form-field label a { float: right; color: var(--blue-600); font-size: 10px; text-decoration: none; }
.form-field input, .form-field select, .form-field textarea { width: 100%; min-height: 45px; padding: 10px 12px; border: 1px solid #cbd4e2; border-radius: 7px; color: var(--ink); background: #fbfcfe; outline: 0; }
.form-field textarea { resize: vertical; line-height: 1.5; }
.form-field input:focus, .form-field select:focus, .form-field textarea:focus { border-color: var(--blue-600); box-shadow: 0 0 0 3px rgba(31,95,168,.1); background: #fff; }
.form-field > small:not(.field-error) { color: #8490a1; font-size: 9px; line-height: 1.4; }
.form-field .field-error { color: var(--danger); font-size: 10px; }
.input-suffix { display: flex; }
.input-suffix input { border-radius: 7px 0 0 7px; }
.input-suffix span { display: inline-flex; align-items: center; padding: 0 10px; border: 1px solid #cbd4e2; border-left: 0; border-radius: 0 7px 7px 0; color: var(--muted); background: #f0f3f7; font-size: 10px; }
.check-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
.check-card { display: flex; align-items: flex-start; gap: 11px; padding: 13px; border: 1px solid var(--line); border-radius: 8px; background: #fafbfd; cursor: pointer; }
.check-card input { width: 17px; height: 17px; accent-color: var(--blue-600); }
.check-card strong { display: block; color: var(--navy-900); font-size: 11px; }
.check-card small { display: block; margin-top: 3px; color: #8490a1; font-size: 9px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 28px; padding-top: 22px; border-top: 1px solid var(--line); }
.button-inline { width: auto; min-width: 155px; padding: 0 19px; }
.form-section-heading { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 22px; }
.form-section-heading h2 { margin: 5px 0 0; color: var(--navy-900); font-size: 18px; }
.form-section-heading > span { color: #8994a4; font-size: 9px; }
.form-section-divider { margin-top: 30px; padding-top: 27px; border-top: 1px solid var(--line); }
[hidden] { display: none !important; }
.receivable-metrics { margin-bottom: 18px; }

@media (max-width: 1100px) {
    .form-grid-four { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .filter-bar-wide { flex-wrap: wrap; }
}

@media (max-width: 780px) {
    .sidebar { position: fixed; left: -280px; top: 0; z-index: 50; width: 260px; height: 100vh; padding: 22px 18px; box-shadow: 15px 0 35px rgba(0,0,0,.2); transition: left .2s ease; }
    .sidebar.sidebar-open { left: 0; }
    .main-nav { display: grid; max-height: calc(100vh - 95px); overflow-y: auto; }
    .topbar { gap: 12px; }
    .menu-toggle { display: inline-grid; flex: 0 0 auto; place-items: center; }
    .page-intro-actions { display: flex; align-items: flex-start; }
    .filter-bar { align-items: stretch; flex-direction: column; }
    .filter-bar input, .filter-bar select, .filter-bar button { width: 100%; }
    .form-grid, .form-grid-four, .check-grid { grid-template-columns: 1fr; }
    .form-field-small { max-width: none; }
    .record-form { padding: 20px 17px; }
    .form-section-heading > span { display: none; }
    .form-actions { flex-direction: column-reverse; }
    .form-actions > * { width: 100%; }
    .auth-logo { width: 170px; height: 58px; margin-bottom: 45px; }
}
