:root {
    color-scheme: light;
    --bg: #f6f7f9;
    --panel: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --line: #d8dee7;
    --primary: #0f766e;
    --primary-ink: #ffffff;
    --danger: #b42318;
    --warning: #a15c07;
    --success: #117a45;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: Arial, "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 220px;
    background: #ffffff;
    border-right: 1px solid var(--line);
    padding: 22px 16px;
}
.brand { font-weight: 700; font-size: 20px; margin-bottom: 22px; }
.sidebar nav { display: grid; gap: 6px; }
.sidebar a {
    color: var(--text);
    padding: 10px 12px;
    border-radius: 6px;
}
.sidebar a:hover { background: #eef7f5; text-decoration: none; }

.main { flex: 1; padding: 26px; min-width: 0; }
.page-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 18px;
}
h1, h2 { margin: 0; line-height: 1.25; }
h1 { font-size: 26px; }
h2 { font-size: 17px; margin-bottom: 14px; }
p { color: var(--muted); margin: 6px 0 0; }

.panel, .metric {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
    margin-bottom: 16px;
}
.section-title { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}
.metric { margin: 0; }
.metric span { display: block; color: var(--muted); margin-bottom: 8px; }
.metric strong { font-size: 22px; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    cursor: pointer;
    font: inherit;
    white-space: nowrap;
}
.btn:hover { text-decoration: none; background: #f9fafb; }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn.danger { background: #fff5f5; color: var(--danger); border-color: #f0b8b4; }
.actions, .filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }

table { width: 100%; border-collapse: collapse; }
th, td {
    text-align: left;
    padding: 11px 10px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}
th { color: var(--muted); font-size: 12px; font-weight: 700; }
small { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 28px; }

.status {
    display: inline-flex;
    min-width: 78px;
    justify-content: center;
    padding: 4px 8px;
    border-radius: 999px;
    border: 1px solid var(--line);
    font-size: 12px;
}
.status.success { color: var(--success); border-color: #a7d9bd; background: #effaf3; }
.status.failed, .status.rejected { color: var(--danger); border-color: #efb5ae; background: #fff3f1; }
.status.queued, .status.paying, .status.submitted, .status.unknown { color: var(--warning); border-color: #e8c58b; background: #fff9ec; }
.status.done { color: var(--success); border-color: #a7d9bd; background: #effaf3; }
.status.processing { color: var(--warning); border-color: #e8c58b; background: #fff9ec; }

label { display: grid; gap: 6px; color: var(--muted); }
input, select, textarea {
    min-height: 38px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 8px 10px;
    font: inherit;
    color: var(--text);
    background: #fff;
}
textarea {
    width: 100%;
    resize: vertical;
    min-height: 90px;
}
input[readonly], textarea[readonly] {
    background: #f8fafc;
    color: #4b5563;
}
.broadcast-form {
    display: grid;
    gap: 18px;
}
.number-input {
    width: 120px;
}
.small-number {
    width: 72px;
}
.inline-check {
    color: var(--text);
}
.stack-actions {
    display: grid;
    gap: 8px;
    width: 96px;
}
.field-label > span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}
.table-scroll {
    width: 100%;
    overflow-x: auto;
}
.group-metric-grid .metric {
    min-height: 92px;
}
.group-metric-grid .metric strong {
    font-size: 20px;
    line-height: 1.2;
    word-break: break-word;
}
.group-section-head {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: flex-start;
    margin-bottom: 16px;
}
.group-section-head h2 {
    margin-bottom: 4px;
}
.group-broadcast-panel,
.group-config-panel {
    overflow: hidden;
}
.group-broadcast-panel .broadcast-form {
    gap: 14px;
}
.broadcast-content textarea {
    min-height: 108px;
}
.broadcast-actions {
    justify-content: flex-start;
    gap: 14px;
    margin: 4px 0 10px;
}
.group-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
    padding-top: 4px;
}
.group-card {
    min-width: 0;
    min-height: 78px;
    display: grid;
    align-content: start;
    gap: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px 16px;
    background: #f8fafc;
    color: var(--text);
}
.group-card span.group-card-main {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
}
.group-card strong {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.group-card input {
    width: 16px;
    height: 16px;
    min-height: auto;
    margin: 0;
}
.group-card-sub {
    display: block;
    padding-left: 30px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.group-table-wrap {
    border: 1px solid var(--line);
    border-radius: 8px;
}
.group-table {
    min-width: 1390px;
    table-layout: fixed;
}
.group-table th,
.group-table td {
    vertical-align: middle;
    padding: 10px 9px;
}
.group-table th {
    line-height: 1.35;
    white-space: normal;
}
.group-table tbody tr:last-child td {
    border-bottom: 0;
}
.group-table input {
    width: 100%;
    min-height: 36px;
}
.group-col-name { width: 220px; }
.group-col-id { width: 165px; }
.group-col-toggle { width: 105px; }
.group-col-money { width: 160px; }
.group-col-remind { width: 120px; }
.group-col-action { width: 140px; }
.group-name-input {
    font-weight: 600;
}
.group-id {
    display: block;
    max-width: 100%;
    overflow: hidden;
    color: var(--muted);
    font-family: Consolas, "Courier New", monospace;
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.group-toggle {
    width: 100%;
    min-height: 36px;
    justify-content: center;
    color: var(--text);
}
.group-table .number-input {
    width: 100%;
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.group-table .small-number {
    width: 100%;
}
.group-table .quota-readonly {
    color: #374151;
}
.group-actions {
    width: 100%;
    gap: 8px;
}
.group-actions .btn {
    width: 100%;
    min-height: 34px;
    padding: 0 10px;
}
.grid-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(220px, 1fr));
    gap: 14px;
    align-items: end;
}
.grid-form .wide { grid-column: span 2; }
.check { display: flex; align-items: center; gap: 8px; }
.check input { min-height: auto; }
.platform-grid {
    display: grid;
    grid-template-columns: minmax(360px, 1.35fr) minmax(300px, 1fr);
    gap: 16px;
    align-items: start;
}
.platform-grid .panel {
    margin-bottom: 0;
}
.platform-grid .panel:first-child {
    grid-row: span 2;
}
.runtime-settings-form {
    display: grid;
    gap: 16px;
}
.settings-grid {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) minmax(320px, 1fr);
    gap: 22px 32px;
    align-items: start;
}
.settings-grid .wide {
    grid-column: 1 / -1;
}
.setting-switch {
    min-height: 38px;
    align-content: center;
    color: var(--text);
}
.setting-switch input {
    width: 16px;
    height: 16px;
    min-height: auto;
    margin: 0;
}
.export-form {
    display: grid;
    gap: 22px;
}
.export-date-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(220px, 270px));
    gap: 22px;
    align-items: end;
}
.export-actions {
    align-items: center;
}
.export-count {
    margin: 0;
    color: var(--muted);
}
.export-count strong {
    color: var(--primary);
    font-size: 16px;
}
.export-source-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 12px;
}
.export-source-card {
    min-height: 56px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    background: #f8fafc;
    color: var(--text);
}
.export-source-card span {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    gap: 8px;
    align-items: center;
}
.export-source-card input {
    min-height: auto;
    width: 16px;
    height: 16px;
    margin: 0;
}
.export-source-card strong,
.export-source-card small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.export-source-card small {
    padding-left: 26px;
}
.muted-text {
    color: var(--muted);
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(180px, 1fr));
    gap: 14px;
}
.detail-grid div { display: grid; gap: 5px; }
.detail-grid span { color: var(--muted); }
.detail-grid strong { font-weight: 600; word-break: break-word; }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.detail-layout {
    display: grid;
    grid-template-columns: repeat(2, minmax(320px, 1fr));
    gap: 16px;
    align-items: start;
}
pre {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 12px;
    max-height: 420px;
    overflow: auto;
}
.dark-pre {
    margin-top: 14px;
    background: #111827;
    color: #f8fafc;
    border-color: #111827;
}
.table-pre {
    min-width: 220px;
    max-width: 360px;
    max-height: 120px;
    padding: 8px;
    font-size: 12px;
}
.reason-list {
    display: grid;
    gap: 4px;
    margin-top: 8px;
    color: var(--danger);
    font-size: 12px;
    line-height: 1.45;
}
.kv-list {
    display: grid;
    gap: 11px;
}
.kv-list div {
    display: grid;
    grid-template-columns: 170px minmax(0, 1fr);
    gap: 10px;
    align-items: baseline;
}
.kv-list.compact div { grid-template-columns: 90px minmax(0, 1fr); }
.kv-list span {
    color: var(--text);
}
.kv-list strong {
    font-weight: 500;
    word-break: break-word;
}
.kv-table td:first-child {
    width: 38%;
    color: var(--text);
}
.value-pill {
    display: block;
    width: 100%;
    background: #111827;
    color: #f8fafc;
    border-radius: 6px;
    padding: 10px 12px;
    min-height: 38px;
    word-break: break-word;
}
.receipt-preview {
    width: 100%;
    max-height: 860px;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff7fb;
    padding: 14px;
    margin-top: 14px;
}
.receipt-preview img {
    display: block;
    width: 100%;
    height: auto;
    object-fit: contain;
}
code {
    background: #eef2f6;
    padding: 2px 5px;
    border-radius: 4px;
}
.code-list p { color: var(--text); margin: 10px 0; }

.alert {
    padding: 12px 14px;
    border-radius: 6px;
    margin-bottom: 14px;
    border: 1px solid var(--line);
    background: #fff;
}
.alert.error { color: var(--danger); border-color: #efb5ae; background: #fff5f5; }
.alert.success { color: var(--success); border-color: #a7d9bd; background: #effaf3; }
.warning-list { border-color: #e8c58b; background: #fffaf0; }
.warning-list p { color: #6f4200; }

.pagination {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 14px;
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
}
.login-box {
    width: min(420px, 100%);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 26px;
}
.login-box h1 { margin-bottom: 18px; }
.login-box form { display: grid; gap: 14px; }

@media (max-width: 900px) {
    .shell { display: block; }
    .sidebar { width: 100%; border-right: 0; border-bottom: 1px solid var(--line); }
    .sidebar nav { display: flex; flex-wrap: wrap; }
    .main { padding: 18px; }
    .metric-grid, .detail-grid, .split, .grid-form, .detail-layout { grid-template-columns: 1fr; }
    .platform-grid { grid-template-columns: 1fr; }
    .platform-grid .panel:first-child { grid-row: auto; }
    .export-date-grid { grid-template-columns: 1fr; }
    .settings-grid { grid-template-columns: 1fr; }
    .kv-list div, .kv-list.compact div { grid-template-columns: 1fr; }
    .grid-form .wide { grid-column: auto; }
    .page-head { display: grid; }
    table { min-width: 760px; }
    .panel { overflow-x: auto; }
}
