:root {
    color-scheme: light;
    --navy-950: #101d2b;
    --navy-900: #17283a;
    --navy-800: #20384f;
    --gold-500: #c69a45;
    --gold-100: #f7efdf;
    --slate-700: #344454;
    --slate-500: #687786;
    --slate-300: #cfd7df;
    --slate-100: #edf1f4;
    --surface: #ffffff;
    --background: #f4f6f8;
    --success: #2f7d54;
    font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-width: 320px;
    color: var(--slate-700);
    background: var(--background);
}

button,
input,
select,
textarea {
    font: inherit;
}

.app-shell {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    padding: 24px 16px;
    color: #fff;
    background: var(--navy-950);
}

.brand,
.login-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand {
    padding: 0 8px 24px;
    border-bottom: 1px solid rgb(255 255 255 / 12%);
}

.brand-mark {
    display: inline-grid;
    flex: 0 0 auto;
    width: 46px;
    height: 46px;
    place-items: center;
    border-radius: 12px;
    color: var(--navy-950);
    background: var(--gold-500);
    font-weight: 700;
}

.brand-mark.large {
    width: 58px;
    height: 58px;
    border-radius: 16px;
}

.brand strong,
.brand small {
    display: block;
}

.brand strong {
    font-size: 15px;
}

.brand small {
    margin-top: 4px;
    color: #aeb9c5;
    font-size: 11px;
}

.sidebar-nav {
    display: grid;
    gap: 3px;
    margin-top: 20px;
}

.sidebar-nav a {
    padding: 10px 14px;
    border-radius: 7px;
    color: #c8d1da;
    font-size: 14px;
    text-decoration: none;
}

.sidebar-nav a:hover,
.sidebar-nav a:focus-visible,
.sidebar-nav a.active {
    color: #fff;
    background: var(--navy-800);
}

.sidebar-nav a.active {
    border-left: 3px solid var(--gold-500);
}

.workspace {
    min-width: 0;
}

.topbar {
    display: flex;
    min-height: 72px;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 12px 32px;
    border-bottom: 1px solid var(--slate-300);
    background: var(--surface);
}

.topbar-label,
.topbar-subtitle {
    display: block;
}

.topbar-label {
    color: var(--navy-900);
    font-weight: 700;
}

.topbar-subtitle {
    margin-top: 3px;
    color: var(--slate-500);
    font-size: 12px;
}

.account-area {
    display: flex;
    align-items: center;
    gap: 14px;
    color: var(--slate-500);
    font-size: 14px;
}

.account-area form {
    margin: 0;
}

.logout-button {
    padding: 7px 12px;
    border: 1px solid var(--slate-300);
    border-radius: 6px;
    color: var(--slate-700);
    background: #fff;
    cursor: pointer;
}

.logout-button:hover,
.logout-button:focus-visible {
    border-color: var(--navy-800);
}

.main-content {
    padding: 38px 40px;
}

.app-footer {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-top: 42px;
    padding-top: 18px;
    border-top: 1px solid var(--slate-300);
    color: var(--slate-500);
    font-size: 12px;
}

.app-footer a,
.breadcrumb a {
    color: #315f88;
    text-decoration: none;
}

.breadcrumb {
    display: flex;
    gap: 8px;
    margin-bottom: 18px;
    color: var(--slate-500);
    font-size: 13px;
}

.setup-panel {
    margin: 22px 0;
}

.checklist-grid,
.import-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.check-item {
    display: grid;
    gap: 5px;
    padding: 12px;
    border-radius: 7px;
    background: var(--slate-100);
}

.check-item.passed { color: #226342; background: #e4f4ea; }
.check-item.pending { color: #855c12; background: #fff1ce; }
.check-item small { font-size: 11px; }
.import-card { padding: 20px; }
.import-card h2 { margin-top: 0; color: var(--navy-900); font-size: 18px; }
.import-card p { min-height: 42px; color: var(--slate-500); }

.health-overall {
    min-width: 100px;
    padding: 14px 18px;
    border-radius: 8px;
    text-align: center;
    font-size: 20px;
    font-weight: 800;
}

.health-overall.pass, .health-pass { color: #226342; background: #e4f4ea; }
.health-overall.warn, .health-warn { color: #855c12; background: #fff1ce; }
.health-overall.fail, .health-fail { color: #8c3030; background: #fff1f1; }

.error-page {
    max-width: 680px;
    margin: 8vh auto;
    text-align: center;
}

.error-code { color: var(--gold-500); font-size: 64px; font-weight: 800; }
.error-page h1 { color: var(--navy-900); }
.error-page p { margin-bottom: 26px; color: var(--slate-500); }

.page-heading .eyebrow {
    color: var(--gold-500);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .08em;
}

.page-heading h1 {
    margin: 10px 0 8px;
    color: var(--navy-900);
    font-size: clamp(26px, 3vw, 36px);
}

.page-heading p {
    margin: 0;
    color: var(--slate-500);
}

.status-card {
    display: flex;
    max-width: 760px;
    align-items: flex-start;
    gap: 16px;
    margin-top: 36px;
    padding: 24px;
    border: 1px solid var(--slate-300);
    border-radius: 10px;
    background: var(--surface);
    box-shadow: 0 8px 24px rgb(16 29 43 / 5%);
}

.status-indicator {
    flex: 0 0 auto;
    width: 12px;
    height: 12px;
    margin-top: 6px;
    border: 3px solid #d9eee2;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 0 4px #eff8f3;
}

.status-card h2 {
    margin: 0;
    color: var(--navy-900);
    font-size: 19px;
}

.status-card p {
    margin: 8px 0 0;
    color: var(--slate-500);
    line-height: 1.7;
}

.login-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
    background: linear-gradient(145deg, var(--navy-950), var(--navy-800));
}

.login-card {
    width: min(100%, 460px);
    padding: 36px;
    border-top: 4px solid var(--gold-500);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: 0 24px 70px rgb(0 0 0 / 25%);
}

.login-brand h1 {
    margin: 0;
    color: var(--navy-900);
    font-size: 20px;
}

.login-brand p {
    margin: 5px 0 0;
    color: var(--slate-500);
    font-size: 13px;
}

.login-form {
    display: grid;
    gap: 18px;
    margin-top: 30px;
}

.form-field {
    display: grid;
    gap: 7px;
}

.form-field label {
    color: var(--navy-900);
    font-size: 14px;
    font-weight: 600;
}

.form-field input {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid var(--slate-300);
    border-radius: 6px;
    color: var(--navy-900);
    background: #fff;
}

.form-field input:focus {
    border-color: var(--gold-500);
    outline: 3px solid var(--gold-100);
}

.primary-button {
    margin-top: 4px;
    padding: 12px 18px;
    border: 0;
    border-radius: 6px;
    color: #fff;
    background: var(--navy-900);
    cursor: pointer;
    font-weight: 700;
}

.primary-button:hover,
.primary-button:focus-visible {
    background: var(--navy-800);
}

.form-error {
    margin-top: 22px;
    padding: 10px 12px;
    border-left: 3px solid #b33a3a;
    color: #862e2e;
    background: #fff1f1;
    font-size: 14px;
}

.message-stack {
    display: grid;
    gap: 8px;
    margin-bottom: 20px;
}

.message {
    padding: 11px 14px;
    border-left: 3px solid var(--success);
    border-radius: 4px;
    color: #245f42;
    background: #edf8f1;
}

.page-title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 26px;
}

.page-heading.compact h1 {
    margin-top: 7px;
    font-size: 29px;
}

.primary-button,
.secondary-button,
.danger-button {
    display: inline-flex;
    min-height: 40px;
    align-items: center;
    justify-content: center;
    padding: 9px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 700;
    text-decoration: none;
}

.button-link {
    margin-top: 0;
}

.secondary-button {
    border: 1px solid var(--slate-300);
    color: var(--navy-900);
    background: #fff;
}

.secondary-button:hover,
.secondary-button:focus-visible {
    border-color: var(--navy-800);
}

.danger-button {
    border: 1px solid #d5a4a4;
    color: #8c3030;
    background: #fff7f7;
}

.filter-bar {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    margin-bottom: 18px;
    padding: 17px;
    border: 1px solid var(--slate-300);
    border-radius: 8px;
    background: var(--surface);
}

.filter-field {
    display: grid;
    min-width: 150px;
    gap: 6px;
}

.filter-field.grow {
    flex: 1;
    min-width: 240px;
}

.filter-field label {
    color: var(--slate-500);
    font-size: 12px;
    font-weight: 700;
}

.filter-field input,
.filter-field select,
.data-form input:not([type="checkbox"]),
.data-form select,
.data-form textarea {
    width: 100%;
    padding: 10px 11px;
    border: 1px solid var(--slate-300);
    border-radius: 6px;
    color: var(--navy-900);
    background: #fff;
}

.filter-field input:focus,
.filter-field select:focus,
.data-form input:focus,
.data-form select:focus,
.data-form textarea:focus {
    border-color: var(--gold-500);
    outline: 3px solid var(--gold-100);
}

.text-button {
    padding: 10px 4px;
    color: var(--slate-500);
    text-decoration: none;
}

.table-card,
.card,
.detail-card {
    border: 1px solid var(--slate-300);
    border-radius: 9px;
    background: var(--surface);
    box-shadow: 0 5px 18px rgb(16 29 43 / 4%);
}

.table-scroll {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    white-space: nowrap;
}

th,
td {
    padding: 13px 14px;
    border-bottom: 1px solid var(--slate-100);
    text-align: left;
}

th {
    color: var(--slate-500);
    background: #f9fafb;
    font-size: 12px;
    letter-spacing: .02em;
}

td {
    color: var(--slate-700);
    font-size: 13px;
}

tbody tr:last-child td {
    border-bottom: 0;
}

tbody tr:hover {
    background: #fbfcfd;
}

.numeric {
    text-align: right;
}

.code {
    color: var(--navy-900);
    font-family: Consolas, "Courier New", monospace;
    font-weight: 700;
}

.status-badge {
    display: inline-flex;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.status-badge.active {
    color: #226342;
    background: #e4f4ea;
}

.status-badge.inactive {
    color: #6e7378;
    background: #eceff1;
}

.status-badge.voided {
    color: #8c3030;
    background: #fff1f1;
}

.status-badge.draft,
.status-badge.cancelled,
.status-badge.out {
    color: #6e7378;
    background: #eceff1;
}

.status-badge.pending,
.status-badge.partially_received,
.status-badge.low {
    color: #855c12;
    background: #fff1ce;
}

.status-badge.completed {
    color: #226342;
    background: #e4f4ea;
}

.actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.actions a,
.link-button {
    border: 0;
    color: #315f88;
    background: none;
    cursor: pointer;
    font-size: 13px;
    text-decoration: none;
}

.actions form,
.detail-actions form {
    display: inline-flex;
    margin: 0;
}

.link-button.danger {
    padding: 0;
    color: #983d3d;
}

.empty-state {
    padding: 50px 20px;
    color: var(--slate-500);
    text-align: center;
}

.empty-state a {
    display: block;
    margin-top: 9px;
    color: #315f88;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 16px;
    padding: 13px 16px;
    border-top: 1px solid var(--slate-100);
    color: var(--slate-500);
    font-size: 13px;
}

.pagination a {
    color: #315f88;
    text-decoration: none;
}

.pagination .disabled {
    color: #adb5bc;
}

.data-form {
    max-width: 980px;
    padding: 26px;
}

.data-form.wide-form {
    max-width: none;
}

.section-title {
    margin: 30px 0 14px;
    color: var(--navy-900);
    font-size: 18px;
}

.section-card {
    margin-top: 22px;
}

.validation-card {
    border-top: 4px solid var(--slate-300);
}

.validation-card.passed { border-top-color: var(--success); }
.validation-card.warning,
.validation-card.blocked { border-top-color: #b56b21; }
.validation-card.failed { border-top-color: #b33a3a; }

.validation-badge {
    display: inline-flex;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
}

.validation-badge.passed,
.validation-badge.row-valid {
    color: #226342;
    background: #e4f4ea;
}

.validation-badge.warning,
.validation-badge.blocked,
.validation-badge.row-warning,
.validation-badge.row-pending {
    color: #855c12;
    background: #fff1ce;
}

.validation-badge.failed,
.validation-badge.row-error {
    color: #8c3030;
    background: #fff1f1;
}

.validation-badge.row-ignored {
    color: #6e7378;
    background: #eceff1;
}

.validation-guidance,
.validation-callout {
    margin: 18px 24px 0;
    padding: 13px 15px;
    border-left: 3px solid var(--slate-300);
    background: #f7f9fa;
    line-height: 1.7;
}

.validation-callout.pending,
.validation-callout.blocked {
    border-left-color: #b56b21;
    background: #fff8e8;
}

.validation-subsection {
    margin: 0 24px 22px;
    padding-top: 18px;
    border-top: 1px solid var(--slate-100);
}

.validation-subsection h3 {
    margin: 0 0 12px;
    color: var(--navy-900);
    font-size: 16px;
}

.compact-grid {
    padding: 0;
}

.candidate-list ul,
.issue-list {
    margin: 10px 0 0;
    padding-left: 22px;
}

.candidate-list li,
.issue-item {
    margin: 7px 0;
    line-height: 1.6;
}

.issue-item.error strong { color: #a83c3c; }
.issue-item.warning strong { color: #855c12; }
.issue-field {
    margin-left: 8px;
    color: var(--slate-500);
    font-family: Consolas, "Courier New", monospace;
    font-size: 12px;
}

.resolution-counts {
    color: var(--slate-500);
}

.formset-table input:not([type="checkbox"]),
.formset-table select {
    min-width: 115px;
    padding: 8px;
    border: 1px solid var(--slate-300);
    border-radius: 5px;
}

.formset-table select {
    min-width: 190px;
}

.audit-note {
    margin-top: 18px;
    padding: 14px 16px;
    border-left: 3px solid var(--gold-500);
    background: var(--gold-100);
    color: var(--navy-900);
}

.multi-filter {
    flex-wrap: wrap;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px 24px;
}

.form-grid .full-width {
    grid-column: 1 / -1;
}

.required-mark,
.field-error {
    color: #a83c3c;
}

.field-error,
.help-text {
    font-size: 12px;
}

.checkbox-field {
    align-content: start;
}

.checkbox-field input {
    width: 18px;
    height: 18px;
    accent-color: var(--gold-500);
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 26px;
    padding-top: 20px;
    border-top: 1px solid var(--slate-100);
}

.detail-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 9px;
}

.profit-nav {
    max-width: 620px;
}

.profit-metrics {
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.metric-card.featured {
    border-color: var(--gold-500);
    background: var(--gold-100);
}

.two-column {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 22px;
}

.detail-card {
    max-width: 1060px;
}

.detail-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--slate-100);
}

.detail-card-header h2 {
    margin: 0;
    color: var(--navy-900);
    font-size: 18px;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 0;
    padding: 8px 24px 24px;
    column-gap: 42px;
}

.detail-grid > div {
    padding: 17px 0;
    border-bottom: 1px solid var(--slate-100);
}

.detail-grid .full-width {
    grid-column: 1 / -1;
}

.detail-grid dt {
    margin-bottom: 7px;
    color: var(--slate-500);
    font-size: 12px;
}

.detail-grid dd {
    margin: 0;
    color: var(--navy-900);
    line-height: 1.65;
}

.pre-line {
    white-space: pre-line;
}

.sha-value {
    overflow-wrap: anywhere;
    user-select: all;
}

.document-detail .page-heading h1,
.document-detail .page-heading p,
.document-detail .detail-grid dd {
    min-width: 0;
    overflow-wrap: anywhere;
}

.dashboard-heading,
.panel-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.kpi-card,
.panel,
.report-card {
    border: 1px solid var(--slate-300);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: 0 4px 16px rgb(16 29 43 / 5%);
}

.kpi-card {
    min-height: 132px;
    padding: 19px;
    border-top: 3px solid var(--navy-800);
}

.kpi-card.accent { border-top-color: var(--gold-500); }
.kpi-card.warning { border-top-color: #b56b21; }
.kpi-card span,
.kpi-card small,
.panel td small {
    display: block;
}
.kpi-card span { color: var(--slate-500); font-size: 13px; }
.kpi-card strong { display: block; margin: 11px 0 8px; color: var(--navy-950); font-size: 25px; }
.kpi-card small { color: var(--slate-500); font-size: 11px; line-height: 1.5; }

.dashboard-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 18px;
}

.panel { min-width: 0; padding: 20px; }
.panel-heading { margin-bottom: 14px; }
.panel-heading h2 { margin: 3px 0 0; color: var(--navy-900); font-size: 18px; }
.panel-heading a { color: #866315; font-size: 13px; }
.table-scroll { overflow-x: auto; }
.trend-chart { display: block; width: 100%; height: 190px; overflow: visible; }
.chart-axis { stroke: var(--slate-300); stroke-width: 1; }
.sales-line,
.profit-line { fill: none; stroke-linejoin: round; stroke-linecap: round; stroke-width: 4; }
.sales-line { stroke: var(--gold-500); }
.profit-line { stroke: var(--success); }
.month-labels { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 2px; }
.month-labels span { overflow: hidden; color: var(--slate-500); font-size: 9px; text-align: center; writing-mode: vertical-rl; }

.report-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(245px, 1fr));
    gap: 16px;
}
.report-card { padding: 22px; }
.report-card h2 { margin-top: 0; color: var(--navy-900); font-size: 18px; }
.report-card p { min-height: 44px; color: var(--slate-500); line-height: 1.55; }

.activity-list { display: grid; gap: 0; }
.activity-item { display: grid; grid-template-columns: 74px 1fr; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--slate-100); }
.activity-item:last-child { border-bottom: 0; }
.activity-time { color: var(--slate-500); font-size: 12px; }
.activity-item strong { color: var(--navy-900); font-size: 13px; }
.activity-item p { margin: 4px 0; font-size: 13px; }
.activity-item small { color: var(--slate-500); }
.status-pill.danger { color: #8a2f22; background: #fbe9e6; }
.empty-state { padding: 28px !important; color: var(--slate-500); text-align: center; }

@media (max-width: 1050px) {
    .dashboard-row { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        padding-bottom: 12px;
    }

    .sidebar-nav {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .topbar,
    .main-content {
        padding-right: 20px;
        padding-left: 20px;
    }

    .topbar {
        align-items: flex-start;
    }

    .account-area {
        flex-direction: column;
        align-items: flex-end;
        gap: 6px;
    }

    .page-title-row,
    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-field,
    .filter-field.grow {
        min-width: 0;
    }

    .form-grid,
    .detail-grid {
        grid-template-columns: 1fr;
    }

    .detail-grid .full-width,
    .form-grid .full-width {
        grid-column: auto;
    }

    .detail-actions {
        justify-content: flex-start;
    }

    .two-column {
        grid-template-columns: 1fr;
    }

    .dashboard-heading,
    .panel-heading {
        flex-direction: column;
    }
}
