:root {
  color-scheme: light;
  --page: #f3f5f7;
  --surface: #ffffff;
  --surface-muted: #f8f9fb;
  --text: #1f2329;
  --secondary: #646a73;
  --border: #dfe3e8;
  --primary: #1668dc;
  --primary-hover: #0958d9;
  --success: #237b4b;
  --danger: #c9363e;
  --chart-teal: #16837b;
  --chart-amber: #a76b12;
  font-family: Inter, "Microsoft YaHei", system-ui, sans-serif;
  background: var(--page);
  color: var(--text);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
.shell { width: min(1680px, calc(100% - 32px)); margin: 24px auto 64px; }
header { margin-bottom: 28px; max-width: 900px; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: 28px; letter-spacing: 0; }
h2 { margin-bottom: 12px; font-size: 18px; }
.eyebrow { color: var(--secondary); font-size: 13px; letter-spacing: 0; }
.intro, .hint, .section-heading p { color: var(--secondary); line-height: 1.6; }
.hint.error { color: var(--danger); }
.card { margin: 16px 0; padding: 24px; border: 0; border-top: 1px solid var(--border); border-radius: 0; background: var(--surface); }
form { display: grid; gap: 14px; max-width: 460px; }
.inline-form { display: flex; max-width: none; align-items: end; gap: 12px; }
label { display: grid; gap: 7px; color: var(--text); font-size: 14px; }
input, select { width: 100%; min-height: 42px; padding: 9px 11px; color: inherit; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-muted); font: inherit; transition: border-color 120ms ease, opacity 120ms ease; }
.inline-form label { width: 120px; }
.setting-form, .trace-controls { margin: 16px 0; }
.setting-form label, .trace-controls label { width: min(240px, 100%); }
button { min-height: 42px; padding: 9px 15px; border: 0; border-radius: 6px; background: var(--primary); color: #ffffff; font: inherit; font-weight: 600; cursor: pointer; transition: filter 120ms ease, opacity 120ms ease, background-color 120ms ease; }
button:hover { background-color: var(--primary-hover); }
button.quiet:hover { background-color: #edf3fa; border-color: #b7c9e1; }
button.danger:hover { background-color: #aa2630; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
a { color: var(--primary); }
button:disabled { cursor: default; opacity: .45; filter: none; }
button.quiet { border: 1px solid var(--border); background: transparent; color: var(--text); }
.toolbar, .section-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.toolbar { margin: 0 4px 4px; color: var(--secondary); }
.view-tabs { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0 8px; }
.section-heading p { margin-bottom: 0; font-size: 13px; }
.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.metric { display: grid; gap: 7px; min-height: 96px; padding: 16px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-muted); }
.metric span { color: var(--secondary); font-size: 13px; }
.metric strong { white-space: pre-line; font-size: 18px; line-height: 1.45; }
.pre-review-windows { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.pre-review-window { min-width: 0; padding: 16px 0; border-top: 1px solid var(--border); background: transparent; }
.pre-review-window h3, .pre-review-window h4 { margin: 0 0 10px; }
.pre-review-window h4 { color: var(--secondary); font-size: 13px; }
.metric-grid.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.metric-grid.compact .metric { min-height: 76px; padding: 12px; }
.pre-review-counts { margin-top: 16px; }
.pre-review-counts summary { padding: 10px 4px; color: var(--secondary); font-size: 13px; font-weight: 600; cursor: pointer; border-bottom: 1px solid var(--border); transition: color 120ms, background-color 120ms; }
.pre-review-counts summary:hover { color: var(--primary); background: var(--surface-muted); }
.pre-review-counts summary::marker { color: var(--primary); }
.pre-review-counts[open] summary { margin-bottom: 10px; color: var(--text); }
.pre-review-counts ul { display: grid; gap: 6px; margin: 0; padding-left: 20px; color: var(--text); }
.codes { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 10px; }
.code { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px; border-radius: 6px; background: var(--surface-muted); border: 1px solid var(--border); font-family: ui-monospace, Consolas, monospace; }
.code button { min-height: 32px; padding: 5px 9px; font-size: 13px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; min-width: 760px; border-collapse: collapse; font-size: 14px; }
th, td { padding: 12px 8px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
th { color: var(--secondary); font-weight: 600; background: var(--surface-muted); }
tbody tr:hover { background: #f0f5fb; }
.price-table { min-width: 980px; }
.price-table td:nth-child(2) { white-space: pre-line; }
.price-table input { min-width: 110px; }
.analytics-users { min-width: 1680px; }
.analytics-users th:first-child, .analytics-users td:first-child { position: sticky; left: 0; width: 42px; min-width: 42px; background: var(--surface); z-index: 1; }
.analytics-users th:nth-child(2), .analytics-users td:nth-child(2) { position: sticky; left: 42px; min-width: 220px; background: var(--surface); z-index: 1; }
.analytics-users th:first-child, .analytics-users th:nth-child(2) { z-index: 2; }
.analytics-users th:nth-child(8), .analytics-users td:nth-child(8) { width: 112px; max-width: 112px; }
.analytics-users th:nth-child(9), .analytics-users td:nth-child(9) { min-width: 330px; white-space: normal; }
.analytics-users th:last-child, .analytics-users td:last-child { min-width: 230px; }
.account-cell { display: flex; align-items: center; gap: 9px; }
.account-cell .account-name { overflow: hidden; text-overflow: ellipsis; }
.operation-bar { display: flex; align-items: center; gap: 14px; margin: 16px 0 8px; }
.operation-bar .hint { margin: 0; }
.operation-results { display: grid; gap: 4px; margin-bottom: 8px; }
.operation-results p { margin: 0; color: var(--secondary); font-size: 13px; }
.operation-results .success { color: var(--success); }
.operation-results .error { color: var(--danger); }
.account-selector, .trace-content-checkbox { width: 18px; height: 18px; min-height: 18px; padding: 0; accent-color: var(--primary); }
.trace-controls .trace-content-toggle { display: flex; width: auto; min-height: 42px; align-items: center; gap: 8px; }
.row-actions { display: flex; gap: 6px; }
.filter-form { max-width: none; grid-template-columns: repeat(5, minmax(130px, 1fr)); align-items: end; margin-bottom: 16px; }
.trace-filters { display: grid; grid-template-columns: repeat(3, minmax(140px, 1fr)); gap: 12px; margin: 14px 0; }
.model-config { display: grid; grid-template-columns: repeat(3, minmax(180px, 1fr)); gap: 12px; margin-top: 16px; padding: 16px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-muted); }
.model-config h3 { grid-column: 1 / -1; margin: 0; font-size: 15px; }
.log-stream { display: grid; align-content: start; gap: 8px; min-height: 460px; max-height: calc(100vh - 290px); overflow: auto; padding: 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-muted); color: var(--text); }
.log-entry { border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.log-entry[open] { border-color: var(--primary); }
.log-entry summary { padding: 12px; cursor: pointer; }
.log-entry summary::marker { color: var(--primary); }
.log-summary { display: inline-grid; width: calc(100% - 24px); grid-template-columns: minmax(150px, 1.2fr) minmax(130px, 1fr) minmax(130px, 1fr) minmax(90px, .7fr) minmax(75px, .5fr); gap: 12px; vertical-align: middle; }
.log-summary > span { display: grid; min-width: 0; gap: 3px; }
.log-summary small { color: var(--secondary); font-size: 11px; }
.log-summary span span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.log-summary.trace-summary { grid-template-columns: minmax(150px, 1fr) minmax(120px, .8fr) minmax(75px, .45fr) minmax(100px, .65fr) minmax(220px, 2fr); }
.log-detail { position: relative; border-top: 1px solid var(--border); background: var(--surface-muted); }
.log-detail-actions { display: flex; justify-content: flex-end; gap: 6px; padding: 10px 10px 0; }
.log-detail pre { border-top: 0; }
.log-entry pre { max-height: 52vh; margin: 0; overflow: auto; padding: 14px; border-top: 1px solid var(--border); background: var(--surface-muted); white-space: pre-wrap; word-break: break-word; font: 12px/1.55 ui-monospace, Consolas, monospace; }
.log-empty { margin: auto; padding: 40px 16px; color: var(--secondary); text-align: center; }
.log-pagination { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 14px; color: var(--secondary); }
dialog { width: min(1100px, calc(100% - 24px)); max-height: 88vh; color: inherit; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); padding: 22px; }
dialog::backdrop { background: #1f232966; }
dialog pre { max-height: 58vh; overflow: auto; padding: 14px; white-space: pre-wrap; word-break: break-word; border-radius: 6px; background: var(--surface-muted); }
.dialog-actions { display: flex; justify-content: end; gap: 10px; }
.user-detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; margin: 14px 0; }
.detail-section { min-width: 0; padding: 20px 0; border-top: 1px solid var(--border); }
.detail-toolbar, .pagination { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.pagination button, #refresh-user-detail { width: 42px; height: 42px; padding: 0; }
#user-detail-view { padding: 24px; background: var(--surface); animation: reveal-admin-view 140ms ease-out; }
#user-detail-view .dialog-actions { flex-wrap: wrap; justify-content: flex-start; margin-top: 24px; }
#detail-title { overflow-wrap: anywhere; }
@keyframes reveal-admin-view { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) { #user-detail-view { animation: none; } }
.detail-section h3 { margin: 0 0 12px; font-size: 15px; }
.detail-fields { display: grid; gap: 9px; }
.detail-field { display: grid; grid-template-columns: minmax(110px, .45fr) minmax(0, 1fr); gap: 12px; align-items: start; }
.detail-field span { color: var(--secondary); font-size: 13px; }
.detail-field strong { min-width: 0; overflow-wrap: anywhere; font-size: 13px; font-weight: 600; line-height: 1.55; }
.detail-list-section { grid-column: span 2; }
.sensitive-content-panel { margin: 16px 0; }
.message-audit-stream { display: grid; gap: 10px; max-height: 420px; overflow: auto; }
.message-audit-item { padding: 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); }
.message-audit-item .message-audit-meta { margin-bottom: 8px; color: var(--secondary); font-size: 12px; }
.message-audit-item pre { max-height: none; margin: 0; padding: 10px; }
.audit-table { min-width: 1500px; }
.audit-table td:nth-child(6) { min-width: 220px; max-width: 360px; white-space: normal; }
.audit-table details { min-width: 200px; }
.audit-table summary { color: var(--primary); cursor: pointer; }
.audit-table pre { max-width: 520px; max-height: 320px; overflow: auto; padding: 10px; white-space: pre-wrap; word-break: break-word; background: var(--surface-muted); }
button.danger { background: var(--danger); color: white; }
button.small { min-height: 32px; padding: 5px 9px; font-size: 12px; }
.status { display: inline-block; padding: 4px 8px; border-radius: 999px; font-size: 12px; }
.status.active { color: var(--success); background: #edf8f1; }
.status.used { color: var(--primary); background: #eaf3ff; }
.status.expired { color: var(--danger); background: #fff1f0; }
#notice { min-height: 24px; margin: 18px 4px; color: var(--success); }
#notice.error { color: var(--danger); }
@media (max-width: 900px) { .pre-review-windows { grid-template-columns: 1fr; } }
@media (max-width: 700px) { .shell { width: min(100% - 20px, 1680px); margin-top: 28px; } .card { padding: 16px; border-radius: 0; } .inline-form { align-items: stretch; flex-direction: column; } .inline-form label { width: 100%; } .section-heading { align-items: flex-start; flex-direction: column; } .filter-form, .model-config, .metric-grid.compact, .trace-filters, .user-detail-grid { grid-template-columns: 1fr; } .detail-list-section { grid-column: auto; } .detail-field { grid-template-columns: 1fr; gap: 3px; } .operation-bar { align-items: stretch; flex-direction: column; } .row-actions { min-width: 280px; } .analytics-users th:nth-child(2), .analytics-users td:nth-child(2) { position: static; } .log-stream { min-height: 360px; } .log-summary, .log-summary.trace-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); } .log-summary > span:first-child { grid-column: 1 / -1; } }
/* Date-range reporting stays unframed beside the existing admin sections. */
.overview-section { padding: 24px; min-width: 0; background: var(--surface); border-bottom: 1px solid var(--border); }
.overview-filter { display: flex; max-width: none; align-items: end; flex-wrap: wrap; gap: 12px; }
.overview-section .metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.overview-section .metric { min-height: 84px; border-radius: 8px; }
.overview-filter label { width: 185px; max-width: 100%; }
.overview-filter button { min-width: 76px; }
.overview-chart-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-top: 24px; }
.overview-chart-heading label { width: 230px; max-width: 65%; }
#overview-chart { display: block; width: 100%; height: 260px; }
.overview-daily-section { padding: 12px 0; }
.overview-daily-section summary { cursor: pointer; padding: 8px 0; }
.overview-daily-section .table-scroll { overflow-x: auto; max-width: 100%; }
.overview-daily-section table { min-width: 1040px; }
.client-cell { white-space: pre-line; min-width: 150px; }
@media (max-width: 600px) {
  h1 { font-size: 24px; }
  .overview-section, #user-detail-view { padding: 16px; }
  .overview-filter label { flex: 1 1 140px; }
  .overview-chart-heading { align-items: end; }
  .overview-section .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .overview-section .metric-value { overflow-wrap: anywhere; }
}
