:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --sidebar: #ffffff;
  --surface: #ffffff;
  --raised: #f8fafc;
  --line: #dce3eb;
  --text: #263447;
  --muted: #5c6b7d;
  --accent: #8b5b32;
  --hover: #edf1f6;
  --primary: #85552e;
  --success: #246b42;
  --danger: #b03630;
  --font: "Segoe UI Variable Text", "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.65 var(--font); -webkit-font-smoothing: antialiased; display: grid; grid-template-columns: 224px minmax(0, 1fr); min-height: 100vh; }
a { color: var(--accent); }
aside { position: sticky; top: 0; height: 100vh; border-right: 1px solid var(--line); padding: 30px 18px 22px; display: flex; flex-direction: column; background: var(--sidebar); }
.brand { display: flex; gap: 11px; align-items: center; text-decoration: none; padding: 0 8px; }
.brand .couple-word { color: var(--text); font-size: 24px; font-weight: 650; letter-spacing: -.4px; }
.couple-logo { display: inline-block; flex: 0 0 auto; width: 32px; height: 32px; background: linear-gradient(135deg, #bc895b, #8b5b32 55%, #a46e3e); mask: url('./couple.svg') center / contain no-repeat; }
.eyebrow { font-size: 12px; font-weight: 500; letter-spacing: .5px; color: var(--muted); margin: 10px 8px 24px; }
nav { display: grid; gap: 6px; margin-top: 12px; }
nav button { position: relative; display: flex; align-items: center; gap: 11px; text-align: left; border: 1px solid transparent; background: transparent; padding: 10px 12px; color: var(--muted); font-size: 14px; }
nav button:hover { color: var(--text); background: var(--raised); }
nav button.active { background: #f6ede3; color: #764721; border-color: #e8d6c1; font-weight: 600; }
nav button.active::before { content: ""; position: absolute; top: 11px; bottom: 11px; left: -1px; width: 3px; border-radius: 3px; background: var(--accent); }
button svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
footer { margin-top: auto; color: var(--muted); font-size: 12px; line-height: 1.9; padding: 18px 8px 0; border-top: 1px solid var(--line); }
main { max-width: 1640px; min-width: 0; padding: 32px clamp(24px, 3vw, 44px) 48px; width: 100%; margin: 0 auto; }
header { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; margin-bottom: 26px; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
header .eyebrow { margin: 0 0 6px; color: var(--accent); font-size: 12px; letter-spacing: .6px; }
header .muted { margin: 7px 0 0; font-size: 14px; }
h1 { font-size: 28px; line-height: 1.4; font-weight: 650; letter-spacing: -.5px; margin: 0; color: var(--text); }
h2 { font-weight: 600; font-size: 17px; line-height: 1.6; margin: 0 0 18px; overflow-wrap: anywhere; }
p { margin-top: 0; }
.muted, small { color: var(--muted); }
small { font-size: 12px; line-height: 1.7; }
button, input, select { font: inherit; border-radius: 7px; border: 1px solid #ccd5e0; color: var(--text); background: var(--surface); padding: 8px 12px; }
button { cursor: pointer; transition: background .15s, border-color .15s; min-height: 38px; line-height: 1.45; }
button:hover { background: var(--hover); border-color: #9eacbd; }
button:disabled { opacity: .55; cursor: default; }
button.primary { color: #ffffff; background: var(--primary); border-color: var(--primary); font-weight: 600; }
button.primary:hover { background: #70441f; border-color: #70441f; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible, a:focus-visible, .table-wrap:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
input, select { width: 100%; min-width: 0; background: #ffffff; min-height: 40px; }
input:hover, select:hover { border-color: #a9b5c5; }
input:focus, select:focus { border-color: var(--accent); }
input[readonly] { background: var(--raised); color: var(--muted); }
input::placeholder { color: #6b7888; }
input[type="checkbox"] { width: 16px; height: 16px; min-height: 0; margin: 0; accent-color: var(--accent); flex-shrink: 0; }
label { display: grid; gap: 7px; font-size: 13px; color: #45566b; margin-bottom: 18px; }
label:has(input[type="checkbox"]) { display: flex; align-items: center; flex-direction: row; gap: 10px; }
.card { min-width: 0; border: 1px solid var(--line); border-radius: 10px; padding: 22px; background: var(--surface); margin-bottom: 22px; box-shadow: 0 2px 7px #23344c04; }
.card > .card { padding: 0; box-shadow: none; border: 0; background: transparent; margin-bottom: 0; }
.narrow { max-width: 520px; }
#login-card { margin: 42px auto 0; padding: 30px 32px; }
#login-card h2 { font-size: 23px; margin-bottom: 6px; }
#login-card .muted { font-size: 14px; margin: 0 0 26px; }
#login-card form > button { width: 100%; margin-top: 5px; min-height: 42px; }
form > button { margin-top: 8px; }
.section-title { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 20px; }
.section-title h2 { margin: 0; font-size: 21px; }
#refresh { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; }
#logout { flex-shrink: 0; font-size: 13px; margin-top: 4px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(230px, 100%), 1fr)); gap: 20px; }
.table-wrap { overflow-x: auto; overscroll-behavior-x: contain; padding: 0; scrollbar-color: #b9c5d4 #f5f7fa; }
table { width: 100%; min-width: 620px; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-size: 12px; color: #4c5d72; font-weight: 600; background: #f5f7fa; white-space: nowrap; }
td, th { padding: 12px 14px; border-bottom: 1px solid #e7ecf2; vertical-align: middle; }
td { line-height: 1.7; font-variant-numeric: tabular-nums; }
td:first-child, th:first-child { padding-left: 18px; min-width: 108px; }
td:last-child, th:last-child { padding-right: 18px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbfd; }
td button { min-height: 32px; padding: 5px 9px; margin: 2px 4px 2px 0; font-size: 12px; white-space: nowrap; }
td .model-actions { gap: 5px; min-width: 210px; }
.pill { display: inline-block; white-space: nowrap; color: var(--success); background: #edf7f0; border: 1px solid #d3e7d9; border-radius: 5px; padding: 3px 8px; font-size: 12px; line-height: 1.4; font-weight: 500; }
.pill.warn, .pill.disabled { color: #8a5b21; background: #fff7e8; border-color: #efdeb8; }
button.danger { color: var(--danger); border-color: #ebcac6; background: #fff8f7; }
button.danger:hover { background: #ffefed; border-color: #d9a5a0; }
#notice { white-space: pre-wrap; overflow-wrap: anywhere; color: #81531e; border: 1px solid #eddaad; background: #fff9eb; border-radius: 8px; padding: 11px 14px; margin: 0 0 22px; }
#notice:empty { display: none; }
.empty { padding: 28px 20px; text-align: center; color: var(--muted); }
details { margin-top: 22px; }
summary { cursor: pointer; color: var(--accent); padding: 10px 0; font-weight: 500; }
[hidden] { display: none !important; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(164px, 100%), 1fr)); gap: 14px; margin-top: 4px; }
.stat { min-width: 0; border: 1px solid #e3e8ef; border-radius: 8px; padding: 16px 18px; background: #f9fbfd; }
.stat-value { font-size: 24px; line-height: 1.5; letter-spacing: -.4px; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; color: #23354b; }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 5px; }
.range-bar, .filter-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; align-items: flex-end; }
.range-bar { width: fit-content; max-width: 100%; background: #edf1f5; border: 1px solid #e0e6ed; border-radius: 8px; padding: 4px; gap: 4px; }
.range-bar button { border-color: transparent; background: transparent; min-height: 32px; padding: 5px 12px; font-size: 13px; }
.range-bar button:hover { background: #e3e9f0; }
.range-bar button.active { background: #ffffff; color: var(--accent); border-color: #e2d8ca; font-weight: 600; box-shadow: 0 1px 3px #2634470a; }
.filter-bar label { margin-bottom: 0; }
.filter-bar input { width: 170px; padding: 8px 10px; font-size: 13px; }
.filter-bar select { width: auto; max-width: 100%; font-size: 13px; }
.record-filters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; padding: 20px; }
.record-filters label { margin: 0; gap: 6px; font-size: 12px; }
.record-filters input, .record-filters select { height: 38px; padding: 6px 9px; font-size: 13px; }
.record-filter-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-top: 2px; }
.record-filter-actions button { min-height: 34px; padding: 5px 13px; margin: 0; font-size: 13px; }
.record-filter-actions .muted { margin-left: auto; font-size: 12px; }
.record-totals { margin: 0 0 20px; }
.record-breakdown { margin: 0 0 20px; padding: 8px 18px; }
.record-breakdown summary { font-size: 13px; }
.record-breakdown > .card { padding: 0; border: 0; background: transparent; box-shadow: none; margin: 0; }
.pager { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 18px; }
.pager button { min-height: 32px; padding: 5px 12px; font-size: 13px; }
.pager span { margin-right: auto; color: var(--muted); font-size: 13px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; margin-bottom: 22px; padding-bottom: 22px; border-bottom: 1px solid #e7ecf2; }
.inline-form:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom: 0; }
.inline-form label { margin-bottom: 0; flex: 1 1 220px; }
.inline-form label:has(input[type="checkbox"]) { flex: 0 0 auto; min-height: 40px; }
.inline-form label input:not([type="checkbox"]) { width: 100%; max-width: 360px; }
.inline-form button { margin-top: 0; }
.model-toolbar { display: flex; justify-content: flex-end; margin-bottom: 18px; }
.model-toolbar button { min-height: 38px; font-size: 13px; }
.model-list { display: grid; gap: 14px; }
.model-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 22px; align-items: start; border: 1px solid var(--line); border-radius: 10px; padding: 20px 22px; background: var(--surface); box-shadow: 0 2px 7px #23344c04; }
.model-row:hover { border-color: #b8c4d3; }
.model-row > div:first-child { min-width: 0; }
.model-row strong { display: block; font-size: 16px; font-weight: 600; margin-bottom: 5px; overflow-wrap: anywhere; }
.model-row small, .model-row .muted { font-size: 12px; line-height: 1.8; overflow-wrap: anywhere; }
.model-row .model-usage { margin-top: 10px; padding-top: 9px; border-top: 1px solid #e7ecf2; color: #425b75; }
.model-actions { display: flex; gap: 7px; align-items: center; flex-wrap: wrap; }
.model-row .model-actions { justify-content: flex-end; max-width: 294px; }
.model-actions button { font-size: 12px; }
#model-editor { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 22px; margin-bottom: 26px; }
#model-editor > h2, #model-editor > fieldset, #model-editor > .model-actions { grid-column: 1 / -1; }
#model-editor > label { display: flex; flex-direction: column; gap: 7px; margin: 0; }
#model-editor > label:has(input[type="checkbox"]) { flex-direction: row; align-items: center; min-height: 44px; padding: 10px 12px; background: #f8fafc; border: 1px solid #e0e6ee; border-radius: 7px; }
#model-editor > .model-actions { padding-top: 8px; border-top: 1px solid #e7ecf2; }
.cap-grid { border: 1px solid var(--line); border-radius: 8px; padding: 14px; margin: 3px 0; min-width: 0; background: #fbfcfe; }
.cap-grid legend { padding: 0 8px; font-size: 13px; color: #45566b; }
.level-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(174px, 1fr)); gap: 4px; }
#model-editor .level-row { display: grid; grid-template-columns: 16px 3em minmax(0, 1fr); align-items: center; gap: 9px; margin: 0; padding: 8px; border-radius: 6px; cursor: pointer; font-size: 13px; }
#model-editor .level-row:hover { background: var(--hover); }
#model-editor .level-row .level-name { color: var(--text); }
#model-editor .level-row .level-code { font: 12px/1.5 Consolas, monospace; color: var(--muted); }
.model-picker { position: relative; display: inline-block; }
.model-picker-toggle { min-width: 132px; text-align: left; }
.model-picker-panel { display: none; position: fixed; z-index: 30; width: 280px; max-width: calc(100vw - 16px); max-height: 320px; overflow: auto; padding: 8px; border: 1px solid #cbd5e1; border-radius: 9px; background: #ffffff; box-shadow: 0 10px 30px #26344720; }
.model-picker.open .model-picker-panel { display: grid; gap: 3px; }
.model-picker .model-picker-row { display: grid; grid-template-columns: 16px minmax(0, 1fr); gap: 10px; align-items: center; margin: 0; padding: 9px 8px; border-radius: 6px; color: var(--text); font-size: 13px; cursor: pointer; }
.model-picker-row > span { min-width: 0; }
.model-picker-row:hover { background: var(--hover); }
.model-picker-row strong { display: block; font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
.model-picker-row small { display: block; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.model-picker-panel .primary { margin-top: 8px; }
.picker-field { margin-bottom: 16px; }
.picker-caption { display: block; margin-bottom: 8px; font-size: 13px; color: var(--muted); }
.allowed-models { display: flex; flex-wrap: wrap; gap: 5px; min-width: 150px; max-width: 300px; }
#content form.card:not(.narrow):not(#model-editor):not(.record-filters) { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 22px; }
#content form.card:not(.narrow):not(#model-editor):not(.record-filters) > h2, #content form.card:not(.narrow):not(#model-editor):not(.record-filters) > button { grid-column: 1 / -1; }
#content form.card:not(.narrow):not(#model-editor):not(.record-filters) > label { margin-bottom: 0; }
.skip-link { position: fixed; z-index: 100; left: 12px; top: -70px; background: #ffffff; border: 1px solid var(--accent); border-radius: 6px; padding: 8px 14px; text-decoration: none; }
.skip-link:focus { top: 12px; }
@media (max-width: 1180px) {
  body { grid-template-columns: 204px minmax(0, 1fr); }
  aside { padding: 28px 14px 22px; }
  main { padding: 28px 26px 40px; }
  .model-row { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .model-row .model-actions { justify-content: flex-start; max-width: none; }
  .record-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  body { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  aside { position: static; height: auto; padding: 18px 22px 14px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 0; }
  .brand .couple-word { font-size: 22px; }
  aside .eyebrow, aside footer { display: none; }
  nav { display: flex; overflow-x: auto; margin-top: 15px; padding-bottom: 2px; gap: 6px; scrollbar-width: thin; }
  nav button { flex: 1 0 auto; padding: 9px 11px; gap: 7px; font-size: 13px; }
  nav button svg { width: 16px; height: 16px; }
  main { padding: 26px 22px 36px; }
  header { gap: 16px; margin-bottom: 22px; padding-bottom: 22px; }
  h1 { font-size: 26px; }
  .card { padding: 20px; }
  .table-wrap { padding: 0; }
  #model-editor { gap: 18px; }
  #login-card { margin-top: 24px; }
}
@media (max-width: 600px) {
  aside { padding: 16px 16px 10px; }
  nav { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); overflow: visible; }
  nav button { min-width: 0; padding: 8px 6px; gap: 5px; }
  main { padding: 22px 16px 30px; }
  header { gap: 12px; flex-wrap: wrap; }
  header .muted { font-size: 13px; }
  h1 { font-size: 25px; }
  .card { padding: 18px; border-radius: 9px; }
  .table-wrap { padding: 0; }
  #login-card { padding: 24px 22px; }
  #model-editor, #content form.card:not(.narrow):not(#model-editor):not(.record-filters) { grid-template-columns: 1fr; }
  .model-row { padding: 18px; }
  .model-row .model-actions { gap: 6px; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 13px 12px; }
  .stat-value { font-size: 21px; }
  .stat-label { font-size: 12px; }
  .range-bar { gap: 2px; padding: 3px; }
  .range-bar button { padding: 5px 9px; font-size: 12px; }
  .record-filters { grid-template-columns: 1fr; }
  .record-filter-actions .muted { width: 100%; margin: 0; }
  .filter-bar input { width: 100%; }
  .inline-form { align-items: stretch; }
  .inline-form label { flex-basis: 100%; }
  .inline-form label input:not([type="checkbox"]) { max-width: none; }
  .inline-form label:has(input[type="checkbox"]) { min-height: 28px; }
}
@media (prefers-reduced-motion: reduce) { button { transition: none; } }
