:root {
    color-scheme: light;
    --background: #f4f7f6;
    --surface: #fff;
    --surface-subtle: #f7faf9;
    --ink: #18302a;
    --text: #2a413b;
    --muted: #536b64;
    --line: #dce6e2;
    --accent: #08785e;
    --accent-hover: #065e4a;
    --accent-light: #e6f5ef;
    --amber: #83500c;
    --amber-light: #fff1dc;
    --red: #a12b2c;
    --red-light: #fae9e8;
    --blue: #1b558b;
    --blue-light: #e9f3ff;
    --radius: 12px;
    font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", "Noto Sans SC", system-ui, sans-serif;
    background: var(--background);
    color: var(--ink);
    text-rendering: optimizeLegibility;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 280px; font-size: 14px; line-height: 1.55; }
a { color: var(--accent); text-decoration-thickness: .09em; text-underline-offset: .22em; }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: 3px solid #14735b; outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
h1 { font-weight: 690; font-size: clamp(1.6rem, 3.2vw, 2.1rem); line-height: 1.3; letter-spacing: -.024em; }
h2 { font-weight: 670; font-size: 1.09rem; line-height: 1.4; }
h3 { font-weight: 650; font-size: .96rem; line-height: 1.45; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
:disabled { cursor: not-allowed; }
fieldset { padding: 0; margin: 0; border: 0; min-width: 0; }
label { font-weight: 600; }
code, .mono { font-family: "SFMono-Regular", "Cascadia Mono", "IBM Plex Mono", monospace; font-size: .91em; font-variant-numeric: tabular-nums; }
small { font-size: .82rem; }
[hidden] { display: none !important; }

.skip-link { position: absolute; top: 12px; left: 12px; transform: translateY(-200%); z-index: 4; padding: 10px 16px; background: var(--surface); color: var(--ink); border-radius: 6px; }
.skip-link:focus { transform: none; }
.app-shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 100vh; }
.sidebar { display: flex; flex-direction: column; gap: 34px; position: sticky; top: 0; height: 100vh; padding: 31px 17px 20px; background: #13382f; color: #f1fbf7; }
.brand { display: inline-flex; align-items: center; gap: 10px; align-self: flex-start; padding: 0 9px; color: inherit; font-weight: 700; font-size: .96rem; line-height: 1.25; text-decoration: none; white-space: nowrap; }
.brand:hover { color: inherit; }
.brand-mark { display: grid; width: 34px; height: 34px; flex: 0 0 auto; place-items: center; border-radius: 9px; background: #d8f3e9; color: #176a54; }
.brand-mark::before { content: ""; width: 15px; height: 10px; border: 2px solid currentColor; border-top: 0; border-right: 0; transform: translateY(-2px) rotate(-45deg); }
.sidebar :focus-visible { outline-color: #bce8d9; }
.sidebar-nav { display: grid; gap: 6px; }
.sidebar-nav a, .sidebar-logout { display: block; width: 100%; padding: 10px 12px; border: 0; border-radius: 8px; background: none; color: #d2e7df; text-align: left; font-weight: 600; text-decoration: none; }
.sidebar-nav a:hover, .sidebar-logout:hover { background: #204a3e; color: #fff; }
.sidebar-nav a[aria-current="page"] { background: #286052; color: #fff; }
.sidebar-footer { margin-top: auto; }
.main { width: 100%; max-width: 1520px; margin-inline: auto; padding: 35px clamp(18px, 3.3vw, 55px) 48px; min-width: 0; }
.page-header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 14px 24px; margin-bottom: 22px; }
.page-header p { margin-top: 6px; }
.page-header-actions, .action-group { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.card { min-width: 0; margin-bottom: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.card-body { padding: clamp(14px, 2.4vw, 22px); }
.card-header { display: flex; justify-content: space-between; flex-wrap: wrap; align-items: center; gap: 12px; padding: 14px clamp(14px, 2.4vw, 22px); border-bottom: 1px solid var(--line); }
.card-header p { margin-top: 3px; }
.muted { color: var(--muted); }
.subtle { color: var(--muted); font-size: .82rem; }
.money { white-space: nowrap; font-variant-numeric: tabular-nums; }
.money-strong { font-weight: 650; }
.wrap-id { overflow-wrap: anywhere; }
.mass-action { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; padding: clamp(14px, 2.4vw, 22px); border-color: #c5e3d7; background: #edf8f4; }
.mass-action p { margin-top: 4px; }
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.metric { display: grid; gap: 2px; padding: 13px clamp(13px, 2.2vw, 22px); }
.metric + .metric { border-left: 1px solid var(--line); }
.metric dt { font-size: .82rem; font-weight: 600; color: var(--muted); }
.metric dd { margin: 0; font-weight: 670; font-variant-numeric: tabular-nums; font-size: 1.3rem; }
.metric dd .unit { font-size: .81rem; color: var(--muted); font-weight: 500; }
.notice { margin-bottom: 13px; padding: 10px 13px; border: 1px solid #d7e5ec; border-radius: 8px; background: #eff6fa; color: #2a4a5d; overflow-wrap: anywhere; }
.notice.success { color: #126448; background: var(--accent-light); border-color: #cae7dc; }
.notice.warning { color: var(--amber); background: var(--amber-light); border-color: #eddbbf; }
.notice.error { color: var(--red); background: var(--red-light); border-color: #f0cecb; }
.notice:last-child { margin-bottom: 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; width: fit-content; min-height: 38px; padding: 7px 12px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--ink); font-weight: 650; line-height: 1.35; white-space: nowrap; text-align: center; text-decoration: none; }
.btn:hover { color: var(--ink); }
.btn-primary { color: #fff; background: var(--accent); border-color: var(--accent); }
.btn-primary:hover { color: #fff; background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-secondary { border-color: #c9dad3; background: var(--surface); }
.btn-secondary:hover { background: var(--accent-light); border-color: #abcfc1; }
.btn-quiet { color: var(--muted); }
.btn-quiet:hover { color: var(--accent-hover); background: var(--accent-light); }
.btn:disabled { opacity: .45; }
.btn:disabled:hover { filter: none; }
.btn-primary:disabled:hover { background: var(--accent); color: #fff; }
.btn-secondary:disabled:hover { border-color: #c9dad3; background: var(--surface); }
.inline-form { margin: 0; }
.inline-field { display: flex; align-items: center; gap: 8px; }
.inline-field label { color: var(--muted); font-size: .85rem; }
.field { display: grid; gap: 5px; min-width: 0; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
.stack { display: grid; gap: 14px; }
.field-note { color: var(--muted); font-size: .82rem; }
input:not([type="checkbox"], [type="hidden"]), select, textarea { display: block; width: 100%; min-width: 0; min-height: 38px; padding: 7px 9px; border: 1px solid #c0d2cb; border-radius: 7px; background: var(--surface); color: var(--ink); line-height: 1.4; }
input::placeholder, textarea::placeholder { color: #63766f; }
select { padding-right: 25px; }
input[type="checkbox"] { width: 16px; height: 16px; margin: 0; vertical-align: middle; accent-color: var(--accent); cursor: pointer; }
textarea { resize: vertical; }
.secret { font-family: "SFMono-Regular", "Cascadia Mono", "IBM Plex Mono", monospace; font-size: .83rem; }
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 12px; }
.filters .search-field { width: min(100%, 260px); }
.filters .state-field { min-width: 120px; }

.table-scroll { width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; text-align: left; }
.data-table th, .data-table td { padding: 11px 14px; vertical-align: top; border-bottom: 1px solid var(--line); }
.data-table thead th { background: var(--surface-subtle); color: var(--muted); font-size: .79rem; font-weight: 650; white-space: nowrap; }
.data-table tbody tr:hover { background: #fcfefd; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table .check-cell { width: 43px; padding-right: 2px; text-align: center; }
.data-table .nowrap { white-space: nowrap; }
.data-table .message-cell { min-width: 170px; overflow-wrap: anywhere; }
.complaint-table { min-width: 760px; }
.complaint-table .order-cell { max-width: 275px; min-width: 148px; }
.preview-table, .batch-table, .item-table { min-width: 550px; }
.merchant-table { min-width: 520px; }
.cell-lines { display: grid; gap: 4px; }
.compact-details { margin-top: 4px; }
.compact-details summary { cursor: pointer; color: var(--accent-hover); font-size: .82rem; }
.compact-details p { max-width: 100%; min-width: 0; margin-top: 5px; overflow-wrap: anywhere; white-space: pre-wrap; }
.refund-results { display: grid; gap: 8px; margin-top: 6px; }
.refund-results > div + div { border-top: 1px solid var(--line); padding-top: 6px; }
.tag { display: inline-flex; align-items: center; max-width: 100%; padding: 1px 8px; border-radius: 5px; background: #edf2ef; color: #405a50; font-size: .8rem; font-weight: 650; white-space: nowrap; }
.tag-success { background: var(--accent-light); color: #146047; }
.tag-warning { background: var(--amber-light); color: var(--amber); }
.tag-error { background: var(--red-light); color: var(--red); }
.tag-info { background: var(--blue-light); color: var(--blue); }
.table-footer, .selection-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 9px 14px; padding: 11px clamp(14px, 2.4vw, 22px); }
.table-footer { border-top: 1px solid var(--line); }
.selection-bar { border-bottom: 1px solid var(--line); }
.selection-count { font-weight: 600; }
.pagination { display: flex; align-items: center; gap: 6px; }
.pagination .btn { min-height: 32px; padding: 5px 9px; }
.empty { padding: clamp(24px, 4vw, 50px) 18px; text-align: center; }
.empty p { margin: 4px 0 14px; color: var(--muted); }
.empty p:last-child { margin-bottom: 0; }
.review-messages { padding: 12px clamp(14px, 2.4vw, 22px); white-space: pre-wrap; overflow-wrap: anywhere; }
.review-summary { display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center; }
.review-summary strong { margin-left: 3px; }
.batch-counts { display: flex; flex-wrap: wrap; gap: 3px 9px; }
dialog { width: min(470px, calc(100% - 26px)); padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); box-shadow: 0 14px 44px #18302a2b; }
dialog::backdrop { background: #132c26a6; }
dialog .action-group { justify-content: flex-end; }
.login-page { display: grid; min-height: 100vh; place-items: center; padding: 20px; background: #eaf4ef; }
.login-card { width: min(100%, 400px); padding: clamp(20px, 5vw, 36px); border: 1px solid #cfdfd8; border-radius: 16px; background: var(--surface); box-shadow: 0 12px 40px #244a3c0a; }
.login-card .brand { padding: 0; margin-bottom: 20px; color: var(--ink); }
.login-card h1 { margin-bottom: 15px; font-size: 1.5rem; }
.login-card .btn { width: 100%; }

@media (max-width: 800px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 10px 14px; padding: 11px 13px; }
    .brand { align-self: auto; padding: 0; }
    .brand-mark { width: 31px; height: 31px; }
    .sidebar-nav { display: flex; flex-wrap: wrap; gap: 4px; }
    .sidebar-nav a, .sidebar-logout { padding: 6px 8px; }
    .sidebar-footer { margin: 0 0 0 auto; }
    .main { padding-top: 20px; }
}
@media (max-width: 490px) {
    .field-grid { grid-template-columns: 1fr; }
    .sidebar-nav { width: 100%; order: 2; }
    .main { padding-inline: 10px; }
    .page-header { margin-bottom: 15px; }
    .card { margin-bottom: 12px; }
    .metric { padding-inline: 9px; }
    .mass-action .btn { width: 100%; }
}

.metrics:has(.metric:only-child) { grid-template-columns: 1fr; }
