:root {
    --navy: #1C3A6B;
    --navy2: #0F1E30;
    --navy3: #162D54;
    --gold: #C8980E;
    --gold2: #E8B832;
    --teal: #0C6E5E;
    --teal2: #0A5A4C;
    --red: #C0392B;
    --orange: #E67E22;
    --green: #1E8449;
    --purple: #6C3483;
    --white: #FFFFFF;
    --bg: #F0F4F8;
    --bg2: #E8EDF4;
    --card: #FFFFFF;
    --border: #D4DCE8;
    --text: #1C2B3A;
    --muted: #6A7A8A;
    --sidebar-w: 360px;
}

* {
    box-sizing: border-box;
}

html {
    scrollbar-gutter: stable;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: "DM Sans", Arial, sans-serif;
    font-size: 16px;
    overflow-x: hidden;
}

a {
    color: inherit;
}

button,
input,
select,
textarea {
    font: inherit;
}

.auth-block {
    max-width: 520px;
    margin: 12vh auto;
    padding: 32px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 8px 28px rgba(15, 30, 48, .12);
}

.auth-block h1 {
    margin: 0 0 8px;
    color: var(--navy);
    font-family: "DM Serif Display", serif;
}

.auth-logo {
    display: block;
    width: 92px;
    height: 92px;
    margin: 0 0 22px;
    object-fit: contain;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: linear-gradient(180deg, var(--navy2) 0%, var(--navy) 100%);
    display: flex;
    flex-direction: column;
    z-index: 100;
    box-shadow: 4px 0 20px rgba(0, 0, 0, .2);
}

.sidebar-brand {
    padding: 38px 30px 26px;
    border-bottom: 1px solid rgba(200, 152, 14, .3);
}

.sidebar-brand-link {
    display: flex;
    align-items: center;
    gap: 16px;
    text-decoration: none;
}

.sidebar-brand-mark {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    padding: 8px;
    background: #fff;
    border: 1px solid rgba(200, 152, 14, .38);
    border-radius: 6px;
    box-shadow: 0 8px 18px rgba(0, 0, 0, .16);
}

.sidebar-brand-mark img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.sidebar-brand-text {
    min-width: 0;
}

.sidebar-brand-name {
    display: block;
    color: #fff;
    font-family: "DM Serif Display", serif;
    font-size: 25px;
    letter-spacing: .5px;
    line-height: 1.2;
}

.sidebar-brand-sub {
    display: block;
    margin-top: 6px;
    color: var(--gold);
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 2.4px;
    text-transform: uppercase;
}

.sidebar-user {
    padding: 20px 30px 22px;
    border-bottom: 1px solid rgba(255, 255, 255, .06);
}

.sidebar-user-role {
    color: var(--gold);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 4px;
    text-transform: uppercase;
}

.sidebar-user-name {
    margin-top: 6px;
    color: rgba(255, 255, 255, .85);
    font-size: 20px;
    font-weight: 500;
}

.sidebar-logout-form {
    margin: 16px 0 0;
}

.sidebar-logout {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 38px;
    padding: 8px 12px 8px 10px;
    border: 1px solid rgba(255, 255, 255, .14);
    border-radius: 4px;
    background: transparent;
    color: rgba(255, 255, 255, .76);
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    transition: background .15s, border-color .15s, color .15s;
}

.sidebar-logout .nav-icon {
    width: 20px;
    font-size: 16px;
}

.sidebar-logout:hover {
    background: rgba(255, 255, 255, .08);
    border-color: rgba(200, 152, 14, .45);
    color: #fff;
}

.sidebar-nav {
    flex: 1;
    padding: 28px 0;
    overflow-y: auto;
}

.nav-section-label {
    padding: 20px 30px 9px;
    color: rgba(255, 255, 255, .25);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 7px;
    text-transform: uppercase;
}

.nav-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 18px;
    min-height: 53px;
    padding: 13px 30px;
    border-left: 5px solid transparent;
    color: rgba(255, 255, 255, .58);
    cursor: pointer;
    font-size: 20px;
    font-weight: 500;
    text-decoration: none;
    transition: background .15s, color .15s, border-color .15s;
}

.nav-item:hover {
    background: rgba(255, 255, 255, .06);
    color: #fff;
}

.nav-item.active {
    background: rgba(200, 152, 14, .12);
    border-left-color: var(--gold);
    color: #fff;
}

.nav-icon {
    width: 31px;
    font-size: 21px;
    text-align: center;
}

.sidebar-footer {
    padding: 26px 30px;
    border-top: 1px solid rgba(255, 255, 255, .06);
    color: rgba(255, 255, 255, .3);
    font-size: 15px;
    letter-spacing: .5px;
}

.mobile-nav-toggle {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 130;
    width: 48px;
    height: 48px;
    border: 0;
    border-radius: 4px;
    background: var(--navy);
    color: #fff;
    box-shadow: 0 4px 16px rgba(15, 30, 48, .2);
}

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

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    min-height: 98px;
    padding: 18px 48px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 8px rgba(0, 0, 0, .06);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.topbar-title {
    color: var(--navy);
    font-family: "DM Serif Display", serif;
    font-size: 30px;
    line-height: 1.1;
}

.topbar-sub {
    margin-top: 6px;
    color: var(--muted);
    font-size: 17px;
}

.topbar-actions,
.toolbar {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.page {
    padding: 78px 48px;
}

.page-band {
    margin-bottom: 34px;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 30px;
    margin-bottom: 34px;
}

.kpi-card {
    position: relative;
    overflow: hidden;
    min-height: 136px;
    padding: 30px 34px;
    background: #fff;
    border-left: 5px solid var(--navy);
    border-radius: 4px;
    box-shadow: 0 1px 8px rgba(0, 0, 0, .06);
}

.kpi-card::after {
    content: "";
    position: absolute;
    top: -10px;
    right: -10px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(28, 58, 107, .04);
}

.kpi-card.gold-border {
    border-left-color: var(--gold);
}

.kpi-card.teal-border {
    border-left-color: var(--teal);
}

.kpi-card.red-border {
    border-left-color: var(--red);
}

.kpi-label {
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.kpi-value {
    margin: 8px 0;
    color: var(--navy);
    font-family: "DM Serif Display", serif;
    font-size: 36px;
    font-weight: 700;
    line-height: 1.1;
}

.kpi-change {
    color: var(--green);
    font-size: 15px;
    font-weight: 500;
}

.kpi-change.down {
    color: var(--red);
}

.two-col,
.three-col {
    display: grid;
    gap: 30px;
    margin-bottom: 34px;
}

.two-col {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.three-col {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.card,
.table-wrap {
    background: #fff;
    border-radius: 4px;
    box-shadow: 0 1px 8px rgba(0, 0, 0, .06);
}

.card {
    padding: 31px 33px;
}

.card-header,
.table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 22px;
}

.card-header {
    margin-bottom: 24px;
}

.card-title,
.table-title {
    color: var(--navy);
    font-size: 22px;
    font-weight: 700;
    line-height: 1.18;
}

.card-sub,
.table-subtitle {
    margin-top: 5px;
    color: var(--muted);
    font-size: 17px;
}

.table-wrap {
    overflow: hidden;
    margin-bottom: 34px;
}

.table-header {
    min-height: 99px;
    padding: 25px 32px;
    border-bottom: 1px solid var(--border);
}

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

table {
    width: 100%;
    border-collapse: collapse;
}

thead tr {
    background: var(--navy2);
}

thead th {
    padding: 16px 22px;
    color: rgba(255, 255, 255, .72);
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 4px;
    text-align: left;
    text-transform: uppercase;
    white-space: nowrap;
}

tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background .1s;
}

tbody tr:hover {
    background: var(--bg);
}

tbody td {
    padding: 18px 22px;
    color: var(--text);
    font-size: 16px;
    vertical-align: middle;
}

.td-mono,
.mono {
    font-family: "DM Mono", monospace;
    font-size: 15px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    min-height: 43px;
    padding: 10px 20px;
    border: 0;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
    transition: background .15s, border-color .15s, color .15s, opacity .15s;
}

.btn:disabled {
    cursor: not-allowed;
    opacity: .55;
}

.btn-primary {
    background: var(--navy);
    color: #fff;
}

.btn-primary:hover {
    background: var(--navy3);
}

.btn-gold {
    background: var(--gold);
    color: #fff;
}

.btn-gold:hover {
    background: var(--gold2);
    color: var(--navy2);
}

.btn-ghost {
    background: transparent;
    border: 1.5px solid var(--border);
    color: var(--navy);
}

.btn-ghost:hover {
    background: var(--bg);
    border-color: var(--navy);
}

.btn-danger {
    background: var(--red);
    color: #fff;
}

.btn-teal {
    background: var(--teal);
    color: #fff;
}

.btn-sm {
    min-height: 43px;
    padding: 10px 18px;
    font-size: 16px;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 3px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .5px;
    text-transform: uppercase;
    white-space: nowrap;
}

.badge-active,
.badge-paid,
.badge-verified,
.badge-approved,
.badge-complete,
.badge-disbursed,
.badge-ready {
    background: rgba(30, 132, 73, .1);
    color: var(--green);
}

.badge-pending,
.badge-submitted,
.badge-partial,
.badge-in-progress,
.badge-watch,
.badge-held,
.badge-incomplete {
    background: rgba(230, 126, 34, .12);
    color: var(--orange);
}

.badge-closed,
.badge-cancelled,
.badge-archived,
.badge-waived {
    background: rgba(106, 122, 138, .12);
    color: var(--muted);
}

.badge-overdue,
.badge-rejected,
.badge-loss,
.badge-written-off {
    background: rgba(192, 57, 43, .1);
    color: var(--red);
}

.badge-new,
.badge-draft,
.badge-returned {
    background: rgba(28, 58, 107, .1);
    color: var(--navy);
}

.badge-gold {
    background: rgba(200, 152, 14, .12);
    color: var(--gold);
}

.search-box {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 8px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
}

.search-box input {
    width: min(220px, 45vw);
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text);
    font-size: 16px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 22px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group.full {
    grid-column: 1 / -1;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 1.5px;
    text-transform: uppercase;
}

.required {
    color: var(--red);
}

.form-control {
    width: 100%;
    min-height: 46px;
    padding: 11px 14px;
    border: 1.5px solid var(--border);
    border-radius: 4px;
    outline: 0;
    background: #fff;
    color: var(--text);
    font-size: 16px;
    transition: border-color .15s, box-shadow .15s;
}

.form-control:focus {
    border-color: var(--navy);
    box-shadow: 0 0 0 3px rgba(28, 58, 107, .08);
}

textarea.form-control {
    min-height: 112px;
    resize: vertical;
}

.form-hint {
    margin-top: 6px;
    color: var(--muted);
    font-size: 14px;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(15, 30, 48, .6);
    backdrop-filter: blur(2px);
}

.modal-overlay.open {
    display: flex;
}

.modal {
    width: min(90vw, 860px);
    max-height: 88vh;
    overflow: auto;
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}

.modal-header {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 22px;
    padding: 26px 30px 20px;
    background: #fff;
    border-bottom: 1px solid var(--border);
}

.modal-title {
    color: var(--navy);
    font-size: 22px;
    font-weight: 700;
}

.modal-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 50%;
    background: var(--bg);
    color: var(--muted);
    cursor: pointer;
}

.modal-body {
    padding: 26px 30px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 16px;
    padding: 20px 30px;
    border-top: 1px solid var(--border);
}

.steps {
    display: flex;
    align-items: center;
    gap: 0;
    margin-bottom: 34px;
}

.step {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.step-num {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--border);
    color: var(--muted);
    font-size: 16px;
    font-weight: 700;
}

.step.done .step-num {
    background: var(--teal);
    color: #fff;
}

.step.active .step-num {
    background: var(--navy);
    color: #fff;
}

.step-label {
    color: var(--muted);
    font-size: 15px;
    font-weight: 600;
}

.step.active .step-label {
    color: var(--navy);
}

.step.done .step-label {
    color: var(--teal);
}

.step-line {
    flex: 1;
    height: 3px;
    background: var(--border);
}

.step-line.done {
    background: var(--teal);
}

.timeline {
    position: relative;
    padding-left: 32px;
}

.timeline::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 9px;
    width: 2px;
    background: var(--border);
}

.timeline-item {
    position: relative;
    margin-bottom: 22px;
}

.timeline-dot {
    position: absolute;
    top: 3px;
    left: -32px;
    width: 18px;
    height: 18px;
    border: 2px solid #fff;
    border-radius: 50%;
    background: var(--navy);
    box-shadow: 0 0 0 2px var(--navy);
}

.timeline-dot.gold {
    background: var(--gold);
    box-shadow: 0 0 0 2px var(--gold);
}

.timeline-dot.red {
    background: var(--red);
    box-shadow: 0 0 0 2px var(--red);
}

.timeline-dot.teal {
    background: var(--teal);
    box-shadow: 0 0 0 2px var(--teal);
}

.timeline-date {
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .8px;
}

.timeline-text {
    margin-top: 4px;
    color: var(--text);
    font-size: 16px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    gap: 22px;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--bg2);
    font-size: 16px;
}

.detail-row:last-child {
    border-bottom: 0;
}

.detail-key {
    color: var(--muted);
    font-weight: 500;
}

.detail-val {
    color: var(--text);
    font-weight: 600;
    text-align: right;
}

.gold {
    color: var(--gold);
}

.green {
    color: var(--green);
}

.red {
    color: var(--red);
}

.navy {
    color: var(--navy);
}

.alert {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 20px;
    border-radius: 4px;
    margin-bottom: 22px;
    font-size: 16px;
}

.alert-warning {
    background: rgba(230, 126, 34, .1);
    border-left: 4px solid var(--orange);
    color: #7A4A10;
}

.alert-danger {
    background: rgba(192, 57, 43, .08);
    border-left: 4px solid var(--red);
    color: #7A1A10;
}

.alert-success {
    background: rgba(30, 132, 73, .08);
    border-left: 4px solid var(--green);
    color: #0E5226;
}

.alert-info {
    background: rgba(28, 58, 107, .08);
    border-left: 4px solid var(--navy);
    color: var(--navy);
}

.par-bar {
    height: 10px;
    margin-top: 9px;
    overflow: hidden;
    background: var(--bg2);
    border-radius: 4px;
}

.par-fill {
    height: 100%;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--green), var(--gold), var(--red));
    transition: width .4s ease;
}

.chart-bar-wrap {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    height: 128px;
}

.chart-bar-col {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.chart-bar {
    width: 100%;
    min-height: 2px;
    border-radius: 3px 3px 0 0;
    background: var(--navy);
    opacity: .8;
}

.chart-label {
    color: var(--muted);
    font-size: 13px;
}

.tabs {
    display: flex;
    gap: 0;
    margin-bottom: 28px;
    border-bottom: 2px solid var(--border);
    overflow-x: auto;
}

.tab {
    padding: 14px 24px;
    margin-bottom: -2px;
    border-bottom: 2px solid transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    white-space: nowrap;
}

.tab.active {
    border-bottom-color: var(--gold);
    color: var(--navy);
}

.toast-root {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 300;
    display: grid;
    gap: 12px;
}

.toast {
    min-width: 300px;
    max-width: min(420px, 90vw);
    padding: 16px 18px;
    border-left: 4px solid var(--navy);
    border-radius: 4px;
    background: #fff;
    box-shadow: 0 12px 30px rgba(15, 30, 48, .18);
    font-size: 15px;
}

.toast.success {
    border-left-color: var(--green);
}

.toast.error {
    border-left-color: var(--red);
}

.text-right {
    text-align: right;
}

.text-center {
    text-align: center;
}

.mt-16 {
    margin-top: 16px;
}

.mb-16 {
    margin-bottom: 16px;
}

::-webkit-scrollbar {
    width: 5px;
    height: 6px;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

@media (max-width: 1180px) {
    .kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .three-col {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 860px) {
    .mobile-nav-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .sidebar {
        width: min(var(--sidebar-w), 88vw);
        transform: translateX(-105%);
        transition: transform .2s ease;
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    body.sidebar-open::after {
        content: "";
        position: fixed;
        inset: 0;
        z-index: 90;
        background: rgba(15, 30, 48, .45);
    }

    .main {
        margin-left: 0;
    }

    .topbar {
        min-height: auto;
        padding: 16px 18px 16px 78px;
        align-items: flex-start;
        flex-direction: column;
    }

    .page {
        padding: 24px 18px;
    }

    .two-col,
    .three-col,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .steps {
        align-items: flex-start;
        flex-direction: column;
        gap: 10px;
    }

    .step-line {
        display: none;
    }
}

@media (max-width: 560px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .card,
    .kpi-card {
        padding: 20px;
    }

    .table-header,
    .card-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .modal {
        width: 100vw;
        max-height: 92vh;
    }

    .modal-overlay {
        padding: 0;
        align-items: flex-end;
    }
}

@media print {
    .sidebar,
    .mobile-nav-toggle,
    .topbar-actions,
    .btn,
    .toast-root {
        display: none !important;
    }

    .main {
        margin-left: 0;
    }

    .topbar,
    .card,
    .table-wrap {
        box-shadow: none;
    }
}
