﻿:root {
    --bg: #f4efe6;
    --surface: rgba(255, 250, 242, 0.9);
    --surface-strong: #fffaf2;
    --line: #d9c8af;
    --text: #2d2418;
    --muted: #76624b;
    --brand: #1f7a5c;
    --brand-dark: #165844;
    --accent: #c96f3b;
    --shadow: 0 20px 50px rgba(45, 36, 24, 0.08);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: radial-gradient(circle at top left, rgba(201, 111, 59, 0.22), transparent 30%), linear-gradient(135deg, #f7f1e7 0%, #efe2cb 100%);
    color: var(--text);
}
body.modal-open { overflow: hidden; }
.shell { min-height: 100vh; display: grid; grid-template-columns: 280px 1fr; }
.sidebar {
    padding: 32px 24px;
    background: rgba(255, 250, 242, 0.98);
    color: var(--text);
    border-right: 1px solid rgba(217, 200, 175, 0.7);
    box-shadow: 8px 0 30px rgba(45, 36, 24, 0.05);
}
.sidebar h1, .page-head h2, .card h3, .login-card h2, .modal-card h3 { margin: 0; }
.subtle, .eyebrow { color: var(--muted); }
.eyebrow { text-transform: uppercase; letter-spacing: 0.12em; font-size: 12px; }
.page-eyebrow, .login-eyebrow { color: var(--muted); }
.nav { display: grid; gap: 10px; margin-top: 36px; }
.nav a {
    color: var(--text);
    text-decoration: none;
    padding: 12px 14px;
    border-radius: 14px;
    background: rgba(31, 122, 92, 0.05);
    border: 1px solid transparent;
}
.nav a.active, .nav a:hover {
    background: rgba(31, 122, 92, 0.12);
    border-color: rgba(31, 122, 92, 0.16);
    color: var(--brand-dark);
}
.user-card {
    display: grid;
    gap: 4px;
    margin-top: 24px;
    padding: 16px;
    border-radius: 18px;
    background: rgba(31, 122, 92, 0.06);
    color: var(--text);
    border: 1px solid rgba(217, 200, 175, 0.65);
}
.content { padding: 28px; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 24px; }
.badge, .flash { padding: 10px 14px; border-radius: 14px; background: rgba(31,122,92,0.12); color: var(--brand-dark); }
.flash { margin-bottom: 20px; }
.grid { display: grid; gap: 18px; margin-bottom: 18px; }
.cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card { background: var(--surface); border: 1px solid rgba(217,200,175,0.6); border-radius: 24px; padding: 22px; box-shadow: var(--shadow); backdrop-filter: blur(12px); }
.accent-card { background: linear-gradient(135deg, rgba(31,122,92,0.15), rgba(201,111,59,0.18)); }
.stat span, .meta-label { display: block; color: var(--muted); margin-bottom: 12px; }
.stat strong { font-size: 32px; }
.helper, .login-copy { color: var(--muted); line-height: 1.6; }
.form { display: grid; gap: 14px; margin-top: 18px; }
.compact-form { margin-top: 12px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 14px; align-items: end; }
.form label, .inline-form label { display: grid; gap: 8px; color: var(--muted); }
input, select, textarea, button { font: inherit; border-radius: 14px; }
input, select, textarea { border: 1px solid var(--line); background: var(--surface-strong); padding: 12px 14px; }
textarea { resize: vertical; }
button { border: none; padding: 12px 16px; background: linear-gradient(135deg, var(--brand) 0%, var(--accent) 100%); color: white; cursor: pointer; }
.ghost-button, .ghost-link { background: rgba(31,122,92,0.12); color: var(--brand-dark); text-decoration: none; display: inline-flex; align-items: center; justify-content: center; padding: 8px 12px; border-radius: 12px; }
.ghost-danger { background: rgba(201,111,59,0.14); color: #9a4d22; }
.status-pill,
.health-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    line-height: 1.4;
    border: 1px solid rgba(217,200,175,0.75);
    white-space: nowrap;
}
.status-pill-active { background: rgba(31,122,92,0.12); color: var(--brand-dark); }
.status-pill-paused { background: rgba(118,98,75,0.12); color: var(--muted); }
.status-pill-rectification { background: rgba(201,111,59,0.16); color: #9a4d22; }
.status-pill-closed { background: rgba(138,54,54,0.14); color: #8a3636; }
.health-pill-ok { background: rgba(31,122,92,0.10); color: var(--brand-dark); }
.health-pill-warning { background: rgba(201,111,59,0.14); color: #9a4d22; }
.health-pill-danger { background: rgba(138,54,54,0.14); color: #8a3636; }
.health-pill-stack { display: flex; flex-wrap: wrap; gap: 6px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; margin-top: 18px; }
th, td { text-align: left; padding: 12px 8px; border-bottom: 1px solid rgba(217,200,175,0.6); vertical-align: top; }
th { color: var(--muted); font-weight: 600; }
.mini-stats { display: grid; gap: 12px; margin-top: 18px; }
.mini-stats div, .payment-summary div { display: flex; justify-content: space-between; gap: 12px; }
.filter-bar { padding: 18px 22px; }
.toolbar-row { display: flex; justify-content: space-between; gap: 16px; align-items: end; flex-wrap: wrap; }
.toolbar-row-secondary { margin-top: 14px; align-items: center; }
.toolbar-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.shipping-view-switch { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar-button { border: none; padding: 12px 16px; background: linear-gradient(135deg, var(--brand) 0%, var(--accent) 100%); color: white; cursor: pointer; border-radius: 14px; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.inline-note { padding: 12px 14px; border-radius: 14px; background: rgba(31,122,92,0.08); color: var(--brand-dark); }
.payment-summary { display: grid; gap: 8px; padding: 14px; border-radius: 16px; background: rgba(201,111,59,0.10); }
.action-stack { display: flex; gap: 8px; flex-wrap: wrap; }
.field-inline { display: flex; gap: 8px; align-items: center; }
.field-inline input { flex: 1; }
.table-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.table-head { display: flex; justify-content: space-between; align-items: start; gap: 16px; }
.logistics-summary { display: grid; gap: 4px; min-width: 170px; }
.logistics-summary strong { font-size: 13px; color: var(--text); }
.logistics-summary span { font-size: 12px; color: var(--muted); line-height: 1.45; }
.order-code-stack { display: grid; gap: 6px; min-width: 130px; }
.order-code-stack .status-pill,
.order-code-stack .health-pill { width: fit-content; }
.sort-link { color: inherit; text-decoration: none; }
.sort-link:hover { color: var(--brand-dark); text-decoration: underline; text-underline-offset: 2px; }
.orders-table-wrap { position: relative; }
.orders-table { min-width: 1600px; }
.orders-table th,
.orders-table td { background: rgba(255, 250, 242, 0.96); }
.order-sticky-col {
    position: sticky;
    z-index: 2;
    box-shadow: 1px 0 0 rgba(217,200,175,0.45);
}
.orders-table thead .order-sticky-col { z-index: 4; }
.order-sticky-col-1 { left: 0; min-width: 44px; }
.order-sticky-col-2 { left: 44px; min-width: 112px; }
.order-sticky-col-3 { left: 156px; min-width: 160px; }
.page-jump-form { gap: 8px; align-items: end; }
.page-jump-form input[type="number"] { width: 88px; }
.tracking-link { color: var(--brand-dark); text-decoration: underline; text-underline-offset: 2px; }
.tracking-hover-card {
    position: fixed;
    z-index: 30;
    width: min(320px, calc(100vw - 24px));
    padding: 14px 16px;
    border-radius: 18px;
    border: 1px solid rgba(217,200,175,0.8);
    background: rgba(255,250,242,0.98);
    box-shadow: 0 20px 40px rgba(0,0,0,0.16);
    display: none;
    pointer-events: auto;
}
.tracking-hover-card.is-visible { display: grid; gap: 6px; }
.tracking-hover-card__title { font-size: 14px; font-weight: 700; color: var(--text); }
.tracking-hover-card__meta,
.tracking-hover-card__line { font-size: 12px; color: var(--muted); line-height: 1.45; }
.tracking-hover-card__event {
    margin-top: 2px;
    padding-top: 8px;
    border-top: 1px solid rgba(217,200,175,0.65);
    font-size: 12px;
    line-height: 1.55;
    color: var(--text);
}
.tracking-preview-card { width: min(760px, 100%); }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(460px, 100%); background: var(--surface); border: 1px solid rgba(217,200,175,0.6); border-radius: 28px; padding: 28px; box-shadow: var(--shadow); }
.modal-backdrop { position: fixed; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(26,24,20,0.48); z-index: 20; }
.modal-card { width: min(640px, 100%); background: #fffaf2; border-radius: 28px; padding: 24px; box-shadow: 0 24px 60px rgba(0,0,0,0.18); }
.modal-backdrop-static { overflow-y: auto; align-items: start; place-items: start center; padding-top: 24px; padding-bottom: 24px; }
.scroll-modal-card { max-height: calc(100vh - 48px); overflow-y: auto; overscroll-behavior: contain; }
.order-modal-card { width: min(1440px, calc(100vw - 40px)); }
.logistics-modal-card { width: min(620px, 100%); }
.finance-ledger-modal-card { width: min(960px, calc(100vw - 40px)); }
.modal-head { display: flex; justify-content: space-between; gap: 16px; align-items: center; }
.modal-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin: 18px 0; }
.ledger-batch-lines { display: grid; gap: 14px; margin-top: 14px; }
.ledger-batch-line {
    padding: 16px;
    border-radius: 18px;
    border: 1px solid rgba(217,200,175,0.72);
    background: rgba(255,255,255,0.72);
}
.ledger-batch-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}
.ledger-batch-actions {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    align-items: center;
}
.remove-ledger-line-button.is-disabled {
    opacity: 0.5;
    pointer-events: none;
}
.timeline-box { padding: 16px; border-radius: 18px; background: rgba(31,122,92,0.08); }
.divider-line { height: 1px; background: rgba(217,200,175,0.8); margin: 18px 0; }
.subheading { margin: 0 0 12px; }
.callback-tools { margin-top: 10px; }
.callback-url-box {
    margin-top: 10px;
    padding: 10px 12px;
    border-radius: 14px;
    background: rgba(31,122,92,0.08);
    border: 1px solid rgba(217,200,175,0.6);
    overflow-x: auto;
}
.callback-url-box code {
    white-space: nowrap;
    color: var(--brand-dark);
    font-family: Consolas, "SFMono-Regular", Menlo, Monaco, monospace;
    font-size: 12px;
}
.diagnostic-pre {
    margin: 14px 0 0;
    padding: 14px;
    border-radius: 16px;
    border: 1px solid rgba(217,200,175,0.7);
    background: rgba(255,255,255,0.72);
    color: var(--text);
    font-size: 12px;
    line-height: 1.55;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
}
@media (max-width: 1180px) { .cols-5, .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 980px) {
    .shell, .cols-5, .cols-4, .cols-2, .modal-grid { grid-template-columns: 1fr; }
    .page-head, .modal-head, .toolbar-row, .table-head { align-items: start; flex-direction: column; }
}
.form-section { margin-top: 20px; padding: 18px; border-radius: 20px; background: rgba(255,255,255,0.45); border: 1px solid rgba(217,200,175,0.55); }
.section-head { margin-bottom: 14px; }
.section-head h4 { margin: 0 0 6px; }
.compact-grid { margin-top: 0; }
.wide-modal-card { width: min(1440px, calc(100vw - 40px)); }
.span-2 { grid-column: span 2; }
.order-modal-card .compact-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.order-modal-card .form-section { margin-top: 14px; }
.order-modal-card .product-picker { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.order-modal-card .product-option-body { min-height: 168px; }
.order-modal-card .span-2 { grid-column: span 3; }
.product-thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 14px; border: 1px solid rgba(217,200,175,0.7); background: rgba(255,255,255,0.7); }
.product-thumb-empty { display: grid; place-items: center; color: var(--muted); font-size: 12px; }
.product-gallery { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin: 18px 0 10px; }
.product-gallery-card { display: grid; gap: 12px; padding: 14px; border-radius: 20px; background: rgba(255,255,255,0.72); border: 1px solid rgba(217,200,175,0.75); }
.product-gallery-media { display: grid; }
.product-gallery-image { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; border-radius: 16px; background: rgba(244,239,230,0.9); }
.product-gallery-image-empty { display: grid; place-items: center; color: var(--muted); border: 1px dashed rgba(217,200,175,0.9); }
.product-gallery-copy { display: grid; gap: 6px; color: var(--muted); }
.product-gallery-copy strong { color: var(--text); }
.product-picker { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 8px; }
.product-option { display: block; cursor: pointer; }
.product-option input { position: absolute; opacity: 0; pointer-events: none; }
.product-option-body { display: grid; gap: 8px; padding: 12px; border-radius: 18px; border: 1px solid rgba(217,200,175,0.75); background: rgba(255,255,255,0.72); min-height: 190px; }
.product-option input:checked + .product-option-body { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(31,122,92,0.18); }
.product-option-image { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; border-radius: 14px; background: rgba(244,239,230,0.9); }
.product-option-image-empty { display: grid; place-items: center; color: var(--muted); border: 1px dashed rgba(217,200,175,0.9); }
.order-product-cell { display: flex; gap: 12px; align-items: center; min-width: 220px; }
.order-product-meta { display: grid; gap: 4px; color: var(--muted); }
.order-product-meta strong { color: var(--text); }
.logistics-product-card { display: grid; grid-template-columns: 120px 1fr; gap: 16px; align-items: center; }
.logistics-product-image { width: 120px; height: 120px; object-fit: cover; border-radius: 18px; background: rgba(244,239,230,0.9); border: 1px solid rgba(217,200,175,0.7); }
.logistics-product-image-empty { display: grid; place-items: center; color: var(--muted); border: 1px dashed rgba(217,200,175,0.9); }
.logistics-product-copy { display: grid; gap: 8px; color: var(--muted); }
.logistics-product-copy strong { color: var(--text); font-size: 18px; }
@media (max-width: 980px) { .span-2, .order-modal-card .span-2 { grid-column: span 1; } }
@media (max-width: 980px) { .product-picker, .product-gallery, .order-modal-card .compact-grid, .order-modal-card .product-picker, .logistics-product-card, .ledger-batch-grid, .ledger-batch-actions { grid-template-columns: 1fr; } }
.trend-table { display: grid; gap: 14px; margin-top: 18px; }
.trend-row {
    display: grid;
    grid-template-columns: 110px 90px repeat(3, minmax(0, 1fr));
    gap: 12px;
    align-items: center;
    padding: 14px 16px;
    border-radius: 18px;
    border: 1px solid rgba(217,200,175,0.7);
    background: rgba(255,255,255,0.65);
}
.trend-month { font-weight: 700; color: var(--text); }
.trend-orders { color: var(--muted); font-size: 13px; }
.trend-metric { display: grid; gap: 8px; }
.trend-metric span { color: var(--muted); font-size: 13px; }
.trend-bar-track {
    height: 10px;
    border-radius: 999px;
    background: rgba(217,200,175,0.45);
    overflow: hidden;
}
.trend-bar-fill {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(135deg, var(--brand) 0%, #49a07e 100%);
}
.trend-bar-fill-secondary { background: linear-gradient(135deg, #c96f3b 0%, #e0a16f 100%); }
.trend-bar-fill-profit { background: linear-gradient(135deg, #4b8f67 0%, #7ab88f 100%); }
.trend-bar-fill-negative { background: linear-gradient(135deg, #8a3636 0%, #b95f5f 100%); }
@media (max-width: 1180px) {
    .trend-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 980px) {
    .trend-row { grid-template-columns: 1fr; }
}
