:root {
    --ink: #17243a;
    --muted: #6c778b;
    --line: #e3e8ef;
    --canvas: #f4f7fa;
    --paper: #ffffff;
    --navy: #10233f;
    --navy-soft: #193554;
    --teal: #0b8f88;
    --teal-dark: #08746f;
    --teal-pale: #e7f7f5;
    --orange: #e58b2a;
    --orange-pale: #fff3df;
    --red: #c84e59;
    --red-pale: #fdecee;
    --green: #2f8a61;
    --green-pale: #eaf6ef;
    --blue-pale: #eaf1fb;
    --sidebar-width: 248px;
    --radius: 14px;
    --shadow: 0 10px 30px rgba(23, 36, 58, 0.07);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
    color: var(--ink);
    font-family: Inter, "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, sans-serif;
    background: var(--canvas);
}

a { color: inherit; }

.btn {
    --bs-btn-border-radius: 9px;
    font-weight: 650;
}

.btn-primary {
    --bs-btn-bg: var(--teal);
    --bs-btn-border-color: var(--teal);
    --bs-btn-hover-bg: var(--teal-dark);
    --bs-btn-hover-border-color: var(--teal-dark);
    --bs-btn-active-bg: var(--teal-dark);
    --bs-btn-active-border-color: var(--teal-dark);
}

.form-control, .form-select {
    border-color: #d6dde7;
    border-radius: 9px;
    min-height: 43px;
}

.form-control:focus, .form-select:focus {
    border-color: rgba(11, 143, 136, 0.8);
    box-shadow: 0 0 0 0.2rem rgba(11, 143, 136, 0.12);
}

.form-label { font-weight: 650; color: #344157; }

.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-width);
    padding: 28px 18px 22px;
    flex-direction: column;
    color: white;
    background:
        radial-gradient(circle at 10% 85%, rgba(11, 143, 136, 0.27), transparent 32%),
        linear-gradient(155deg, #10233f 0%, #0b1b31 100%);
    z-index: 1030;
}

.brand-lockup {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    color: white;
    text-decoration: none;
}

.brand-lockup strong {
    display: block;
    font-size: 1.05rem;
    letter-spacing: 0.12em;
    line-height: 1.05;
}

.brand-lockup small {
    display: block;
    margin-top: 4px;
    font-size: 0.58rem;
    letter-spacing: 0.22em;
    opacity: 0.62;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 39px;
    height: 39px;
    color: white;
    background: var(--teal);
    border-radius: 11px 5px 11px 5px;
    font-weight: 850;
    font-size: 1.28rem;
    box-shadow: 0 8px 20px rgba(11, 143, 136, 0.25);
}

.sidebar-caption {
    margin: 38px 10px 12px;
    color: rgba(255,255,255,.42);
    font-size: .7rem;
    letter-spacing: .16em;
}

.sidebar-nav { display: grid; gap: 6px; }

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    color: rgba(255,255,255,.72);
    border-radius: 10px;
    text-decoration: none;
    font-size: .92rem;
    transition: .18s ease;
}

.sidebar-link:hover { color: white; background: rgba(255,255,255,.07); }
.sidebar-link.active { color: white; background: rgba(11, 143, 136, .25); }

.nav-glyph {
    display: grid;
    place-items: center;
    min-width: 34px;
    height: 27px;
    padding: 0 6px;
    border: 1px solid rgba(255,255,255,.16);
    border-radius: 7px;
    font-size: .66rem;
    font-weight: 750;
}

.sidebar-link.active .nav-glyph { background: var(--teal); border-color: var(--teal); }
.sidebar-foot { margin-top: auto; padding: 0 10px; }

.app-mobile-nav { color: white; background: var(--navy); }
.app-mobile-nav .offcanvas-header { border-bottom: 1px solid rgba(255,255,255,.1); }

.app-shell { min-height: 100vh; margin-left: var(--sidebar-width); }

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    display: flex;
    align-items: center;
    min-height: 82px;
    padding: 14px 34px;
    background: rgba(255,255,255,.93);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--line);
}

.app-topbar h1 { margin: 1px 0 0; font-size: 1.3rem; font-weight: 760; }
.topbar-eyebrow { color: var(--teal); font-size: .65rem; font-weight: 800; letter-spacing: .18em; }

.topbar-user { display: flex; align-items: center; gap: 10px; }
.topbar-user strong { display: block; font-size: .86rem; }
.topbar-user small { display: block; color: var(--muted); font-size: .7rem; }

.user-avatar {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: var(--teal-dark);
    background: var(--teal-pale);
    font-weight: 800;
}

.menu-button { margin-right: 12px; }
.app-content { max-width: 1480px; padding: 34px; margin: 0 auto; }

.page-intro { margin-bottom: 25px; }
.section-kicker { color: var(--teal); font-size: .68rem; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; }
.page-title { margin: 4px 0 7px; font-size: clamp(1.6rem, 3vw, 2.05rem); font-weight: 780; }
.page-lead { color: var(--muted); font-size: .94rem; }
.back-link, .text-link { color: var(--teal-dark); font-weight: 700; text-decoration: none; }
.back-link:hover, .text-link:hover { text-decoration: underline; }

.content-card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-heading, .section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 22px 24px;
}

.card-heading { border-bottom: 1px solid var(--line); }
.card-heading h2, .section-heading h2 { margin: 2px 0 0; font-size: 1.12rem; font-weight: 760; }

.metric-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 14px;
}

.metric-card {
    position: relative;
    min-height: 142px;
    padding: 20px;
    overflow: hidden;
    background: white;
    border: 1px solid var(--line);
    border-radius: 13px;
    box-shadow: 0 7px 22px rgba(23,36,58,.05);
}

.metric-card::after {
    content: "";
    position: absolute;
    right: -23px;
    bottom: -28px;
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: var(--metric-soft, var(--blue-pale));
}

.metric-card span { display: block; color: var(--muted); font-size: .82rem; }
.metric-card strong { display: block; margin: 9px 0 6px; font-size: 2rem; line-height: 1; }
.metric-card small { position: relative; z-index: 1; color: #8a94a4; font-size: .68rem; }
.metric-total { --metric-soft: var(--blue-pale); }
.metric-wait { --metric-soft: var(--orange-pale); }
.metric-export, .metric-transit { --metric-soft: var(--teal-pale); }
.metric-refund { --metric-soft: #f0ebfa; }
.metric-done { --metric-soft: var(--green-pale); }

.filter-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--line);
}

.filter-search { flex: 1 1 320px; max-width: 520px; }

.app-table { font-size: .84rem; }
.app-table > :not(caption) > * > * { padding: .9rem 1rem; border-bottom-color: #edf0f4; }
.app-table thead th { color: #748094; background: #fafbfd; font-size: .68rem; font-weight: 800; letter-spacing: .05em; white-space: nowrap; }
.app-table tbody tr:hover { background: #fbfdfd; }
.app-table a.contract-link { color: var(--ink); font-weight: 780; text-decoration: none; }
.app-table a.contract-link:hover { color: var(--teal-dark); }
.table-loading, .table-empty { padding: 44px 18px !important; color: var(--muted) !important; text-align: center; }
.table-footer { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 14px 20px; color: var(--muted); font-size: .8rem; }

.status-badge, .role-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 9px;
    border-radius: 999px;
    font-size: .7rem;
    font-weight: 750;
    white-space: nowrap;
}

.status-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-contract { color: #526078; background: #eef1f5; }
.status-waiting { color: #a45f15; background: var(--orange-pale); }
.status-processing, .status-transit { color: var(--teal-dark); background: var(--teal-pale); }
.status-refund { color: #7153a1; background: #f1ecfa; }
.status-completed { color: var(--green); background: var(--green-pale); }
.status-cancelled { color: var(--red); background: var(--red-pale); }

.role-admin { color: #614699; background: #f1ecfa; }
.role-operations_manager { color: #0b6d66; background: #e3f5f2; }
.role-sales { color: #236a98; background: #eaf3fb; }
.role-logistics { color: #98611e; background: #fff3df; }
.role-finance { color: var(--green); background: var(--green-pale); }

.form-card { max-width: 1040px; margin: 0 auto; }
.form-section { padding: 28px 30px; border-bottom: 1px solid var(--line); }
.form-section-title { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 22px; }
.form-section-title > span { display: grid; place-items: center; width: 34px; height: 34px; color: var(--teal-dark); background: var(--teal-pale); border-radius: 9px; font-size: .72rem; font-weight: 800; }
.form-section-title h3 { margin: 0 0 3px; font-size: 1rem; font-weight: 760; }
.form-section-title p { margin: 0; color: var(--muted); font-size: .78rem; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 20px 0 0; }
.form-card > .form-actions { padding: 20px 30px; background: #fafbfd; border-top: 1px solid var(--line); }

.payment-choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.payment-choice { cursor: pointer; }
.payment-choice input { position: absolute; opacity: 0; pointer-events: none; }
.payment-choice span { display: block; min-height: 92px; padding: 19px; border: 1px solid var(--line); border-radius: 11px; transition: .18s ease; }
.payment-choice strong, .payment-choice small { display: block; }
.payment-choice strong { margin-bottom: 8px; }
.payment-choice small { color: var(--muted); }
.payment-choice input:checked + span { border-color: var(--teal); background: var(--teal-pale); box-shadow: inset 0 0 0 1px var(--teal); }
.payment-choice input:focus-visible + span { outline: 3px solid rgba(11,143,136,.2); }

.order-summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; margin-bottom: 28px; overflow: hidden; background: var(--line); border: 1px solid var(--line); border-radius: 12px; }
.order-summary-grid article { min-height: 93px; padding: 20px; background: white; }
.order-summary-grid span { display: block; margin-bottom: 7px; color: var(--muted); font-size: .72rem; }
.order-summary-grid strong { display: block; font-size: .92rem; }

.section-heading { padding: 0 0 15px; }
.workflow-legend { display: flex; gap: 14px; color: var(--muted); font-size: .7rem; }
.workflow-legend span { display: inline-flex; align-items: center; gap: 5px; }
.workflow-legend i { width: 8px; height: 8px; border-radius: 50%; }
.dot-complete { background: var(--green); }
.dot-available { background: var(--orange); }
.dot-pending { background: #c8d0dc; }

.workflow-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.workflow-card { background: white; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.workflow-card > header { display: flex; align-items: center; gap: 12px; padding: 18px 20px; background: #fafbfd; border-bottom: 1px solid var(--line); }
.workflow-number { display: grid; place-items: center; width: 35px; height: 35px; color: white; background: var(--navy); border-radius: 9px; font-size: .7rem; font-weight: 800; }
.workflow-card h3 { margin: 0; font-size: .95rem; font-weight: 760; }
.workflow-card header p { margin: 2px 0 0; color: var(--muted); font-size: .68rem; }
.workflow-list { padding: 8px 20px 15px; }

.workflow-step { position: relative; display: grid; grid-template-columns: 22px 1fr; gap: 10px; padding: 13px 0; }
.workflow-step:not(:last-child)::before { content: ""; position: absolute; left: 7px; top: 31px; bottom: -9px; width: 1px; background: var(--line); }
.step-dot { position: relative; z-index: 1; width: 15px; height: 15px; margin-top: 3px; border: 3px solid white; border-radius: 50%; box-shadow: 0 0 0 1px #c8d0dc; background: #c8d0dc; }
.workflow-step.completed .step-dot { box-shadow: 0 0 0 1px var(--green); background: var(--green); }
.workflow-step.available .step-dot { box-shadow: 0 0 0 1px var(--orange); background: var(--orange); }
.step-main { min-width: 0; }
.step-title-row { display: flex; justify-content: space-between; gap: 8px; }
.step-title { font-size: .82rem; font-weight: 730; }
.step-state { color: var(--muted); font-size: .65rem; white-space: nowrap; }
.workflow-step.available .step-state { color: #a45f15; font-weight: 750; }
.workflow-step.completed .step-state { color: var(--green); }
.step-meta { margin-top: 4px; color: var(--muted); font-size: .66rem; line-height: 1.45; }
.step-note { margin: 6px 0 0; padding: 6px 8px; color: #566177; background: #f5f7f9; border-radius: 6px; font-size: .68rem; }
.step-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.step-actions .btn { --bs-btn-padding-y: .22rem; --bs-btn-padding-x: .48rem; --bs-btn-font-size: .67rem; }

.save-hint { color: var(--muted); font-size: .72rem; }
.finance-form { padding: 0 24px 24px; }
.finance-block { padding: 22px 0; border-bottom: 1px solid var(--line); }
.finance-block h3 { margin: 0 0 15px; font-size: .9rem; font-weight: 760; }
.finance-form[aria-readonly="true"] input, .finance-form[aria-readonly="true"] select { background: #f7f8fa; pointer-events: none; }
.order-notes { padding: 22px 24px; color: #4f5b70; white-space: pre-wrap; }

.modal-content { border: 0; border-radius: 14px; box-shadow: 0 20px 60px rgba(16,35,63,.2); }
.modal-header, .modal-footer { border-color: var(--line); }

.auth-body { background: #eef3f7; }
.auth-shell { display: grid; grid-template-columns: minmax(380px, 1.15fr) minmax(420px, .85fr); min-height: 100vh; }
.auth-brand-panel { position: relative; display: flex; align-items: center; padding: clamp(40px, 7vw, 100px); overflow: hidden; color: white; background: linear-gradient(145deg, #10233f 0%, #153b55 62%, #0b7c78 140%); }
.auth-brand-panel::before, .auth-brand-panel::after { content: ""; position: absolute; border: 1px solid rgba(255,255,255,.08); border-radius: 50%; }
.auth-brand-panel::before { width: 520px; height: 520px; right: -220px; top: -190px; }
.auth-brand-panel::after { width: 320px; height: 320px; left: -150px; bottom: -120px; }
.auth-brand-content { position: relative; z-index: 1; max-width: 680px; }
.auth-brand { margin-bottom: clamp(65px, 10vh, 120px); }
.auth-kicker { margin-bottom: 16px; color: #83d7d2; font-size: .76rem; font-weight: 800; letter-spacing: .2em; }
.auth-brand-panel h1 { max-width: 650px; font-size: clamp(2.4rem, 5vw, 4.7rem); line-height: 1.13; letter-spacing: -.04em; font-weight: 780; }
.auth-flow-line { display: flex; align-items: center; gap: 10px; margin-top: 52px; color: rgba(255,255,255,.72); font-size: .75rem; }
.auth-flow-line i { width: clamp(22px, 4vw, 65px); height: 1px; background: rgba(255,255,255,.28); }
.auth-form-panel { display: grid; place-items: center; padding: 35px; background: white; }
.auth-card { width: min(100%, 420px); }
.auth-card h2 { margin: 3px 0 8px; font-size: 2rem; font-weight: 780; }
.auth-help { margin: 26px 0 0; color: #929bab; font-size: .72rem; text-align: center; }
.auth-body-compact { display: grid; place-items: center; min-height: 100vh; background: linear-gradient(140deg, #eef3f7, #e5f3f2); }
.password-shell { width: 100%; padding: 25px; }
.password-card { max-width: 480px; margin: 0 auto; padding: 35px; background: white; border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }

.log-table .log-description { min-width: 260px; white-space: normal; }
.change-preview { max-width: 320px; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .66rem; white-space: pre-wrap; word-break: break-word; }

.skeleton-line { display: inline-block; width: 75%; height: 12px; border-radius: 5px; background: linear-gradient(90deg, #edf0f4 25%, #f7f8fa 50%, #edf0f4 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

@media (max-width: 1199.98px) {
    .metric-grid { grid-template-columns: repeat(3, 1fr); }
    .workflow-grid { grid-template-columns: 1fr; }
    .workflow-card { display: grid; grid-template-columns: 220px 1fr; }
    .workflow-card > header { align-items: flex-start; border-right: 1px solid var(--line); border-bottom: 0; }
}

@media (max-width: 991.98px) {
    .app-shell { margin-left: 0; }
    .app-topbar { padding: 13px 20px; }
    .app-content { padding: 25px 20px; }
    .auth-shell { grid-template-columns: 1fr; }
    .auth-brand-panel { display: none; }
    .auth-form-panel { min-height: 100vh; }
}

@media (max-width: 767.98px) {
    .metric-grid { grid-template-columns: repeat(2, 1fr); }
    .metric-card { min-height: 128px; }
    .filter-bar { align-items: stretch; flex-direction: column; }
    .filter-search { flex-basis: auto; max-width: none; }
    .payment-choice-grid, .order-summary-grid { grid-template-columns: 1fr 1fr; }
    .workflow-card { display: block; }
    .workflow-card > header { border-right: 0; border-bottom: 1px solid var(--line); }
    .workflow-legend { display: none; }
    .form-section { padding: 24px 20px; }
    .form-card > .form-actions { padding: 18px 20px; }
}

@media (max-width: 479.98px) {
    .app-content { padding: 22px 14px; }
    .app-topbar { padding-inline: 14px; }
    .app-topbar h1 { font-size: 1.05rem; }
    .metric-grid, .payment-choice-grid, .order-summary-grid { grid-template-columns: 1fr; }
    .metric-card { min-height: 115px; }
    .topbar-user .btn { padding-inline: .45rem; }
    .card-heading { align-items: flex-start; padding: 18px; }
    .table-footer { align-items: flex-start; flex-direction: column; }
}
