:root {
  color-scheme: light;
  --bg: #f6f4f1;
  --surface: #fff;
  --surface-warm: #fff3eb;
  --text: #252422;
  --muted: #77716c;
  --border: #e9e3dd;
  --orange: #ef5b22;
  --orange-dark: #c94312;
  --green: #229657;
  --red: #ca4545;
  --shadow: 0 8px 28px rgba(68, 42, 27, .08);
  --control: #fff;
  --control-border: #ddd5cf;
  --track: #e5ded8;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); min-width: 320px; }
button, input, select { font: inherit; }
button { cursor: pointer; }
.app-header { max-width: 1200px; margin: 0 auto; padding: 24px 20px 14px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; color: #fff; background: linear-gradient(145deg, #ff7a3d, var(--orange)); font-weight: 800; box-shadow: 0 7px 16px rgba(239, 91, 34, .24); }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 2px; font-size: 21px; }
.brand p, .muted { color: var(--muted); }
.brand p { margin: 0; font-size: 12px; }
.header-actions { display: flex; align-items: center; justify-content: flex-end; gap: 14px; }
.model-status { color: var(--muted); font-size: 12px; text-align: right; }
.theme-switch { flex: none; display: grid; grid-template-columns: repeat(3, 30px); gap: 2px; padding: 3px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); box-shadow: var(--shadow); }
.theme-switch button { width: 30px; height: 30px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%; color: var(--muted); background: transparent; line-height: 1; transition: color .2s ease, background .2s ease, box-shadow .2s ease; }
.theme-switch button:hover { color: var(--text); }
.theme-switch button.is-active { color: #fff; background: var(--orange); box-shadow: 0 3px 9px rgba(239, 91, 34, .3); }
.theme-switch svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs { max-width: 1200px; margin: 0 auto 18px; padding: 0 20px; display: flex; gap: 6px; }
.tab { flex: 1; min-height: 42px; border: 0; background: transparent; color: var(--muted); border-radius: 11px; }
.tab.is-active { background: var(--surface); color: var(--orange-dark); box-shadow: var(--shadow); font-weight: 700; }
main { max-width: 1200px; margin: 0 auto; padding: 0 20px 64px; }
.page { display: none; }
.page.is-active { display: grid; gap: 14px; }
.current-layout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(340px, .75fr); align-items: stretch; gap: 16px; }
.current-primary, .current-secondary { display: grid; gap: 14px; min-width: 0; }
.current-summary { display: grid; gap: 14px; min-width: 0; }
.current-secondary .setup-panel .field-grid { grid-template-columns: 1fr 1fr; }
.page-heading, .section-heading, .panel-title { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.page-heading h2, .section-heading h2 { font-size: 34px; margin: 0; }
.page-heading h2 small { color: var(--muted); font-size: 16px; font-weight: 500; }
.eyebrow { margin: 0 0 5px; color: var(--orange-dark); text-transform: uppercase; letter-spacing: .08em; font-size: 11px; font-weight: 800; }
.progress-copy { width: min(46%, 300px); color: var(--muted); text-align: right; font-size: 12px; }
.progress { height: 8px; margin-top: 7px; border-radius: 999px; background: var(--track); overflow: hidden; }
.progress span { display: block; width: 0; height: 100%; background: linear-gradient(90deg, #ff8b4f, var(--orange)); transition: width .2s ease; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { min-width: 0; padding: 15px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); box-shadow: 0 3px 16px rgba(68, 42, 27, .04); }
.stat span { color: var(--muted); font-size: 12px; }
.stat strong { display: block; margin-top: 6px; color: var(--orange-dark); font-size: 21px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat-primary { background: var(--surface-warm); border-color: transparent; }
.panel { padding: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 5px 22px rgba(68, 42, 27, .045); }
.setup-panel summary { cursor: pointer; color: var(--muted); font-weight: 650; }
.setup-panel[open] summary { margin-bottom: 14px; }
.field-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; }
input, select { width: 100%; min-height: 42px; padding: 9px 11px; color: var(--text); background: var(--control); border: 1px solid var(--control-border); border-radius: 10px; font-size: 16px; }
input:focus, select:focus, button:focus-visible { outline: 3px solid rgba(239, 91, 34, .22); outline-offset: 2px; }
.panel-title h3 { margin: 0; font-size: 17px; }
.panel-title p { margin: 4px 0 0; }
.score-chip, .confidence { flex: none; padding: 7px 10px; color: var(--orange-dark); background: var(--surface-warm); border-radius: 999px; font-size: 13px; font-weight: 750; }
.task-grid { margin: 16px 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.task-option { min-height: 72px; padding: 10px; display: flex; align-items: center; gap: 9px; border: 1px solid var(--border); border-radius: 11px; color: var(--text); background: var(--control); text-align: left; }
.task-icon { flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--surface-warm); font-size: 18px; line-height: 1; }
.task-copy { min-width: 0; display: grid; gap: 4px; }
.task-copy strong { font-size: 14px; line-height: 1.2; }
.task-copy small { color: var(--muted); font-size: 11px; }
.task-option.is-selected { color: #fff; background: var(--orange); border-color: var(--orange); }
.task-option.is-selected .task-icon { background: rgba(255,255,255,.2); }
.task-option.is-selected .task-copy small { color: rgba(255,255,255,.82); }
.quality-fields { grid-template-columns: 1fr 1fr; margin-bottom: 12px; }
.cost-field { margin-bottom: 12px; }
.decision-block { margin: 14px 0; padding: 13px; border-radius: 12px; background: var(--surface-warm); }
.decision-block p { margin: 4px 0 10px; font-size: 12px; }
.decision-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.decision-option { display: grid; gap: 3px; padding: 10px; border: 1px solid transparent; border-radius: 10px; background: var(--surface); }
.decision-option.is-selected { border-color: var(--orange); }
.decision-option.is-disabled { opacity: .52; }
.decision-option span, .decision-option small { color: var(--muted); font-size: 11px; }
.button { min-height: 44px; padding: 10px 16px; border: 1px solid var(--border); border-radius: 11px; background: var(--control); color: var(--text); font-weight: 700; }
.button:disabled { cursor: not-allowed; opacity: .45; }
.button-primary { color: #fff; background: var(--orange); border-color: var(--orange); }
.button-primary:hover { background: var(--orange-dark); }
.button-success { color: #fff; background: var(--green); border-color: var(--green); }
.button-danger-ghost { color: var(--red); }
.button-block { width: 100%; }
.error { margin: 10px 0 0; color: var(--red); font-size: 13px; }
.range-copy { margin: 14px 0 10px; font-size: 14px; }
.tier-list { display: grid; gap: 8px; }
.tier-row { display: grid; grid-template-columns: 22px 48px 1fr 42px; align-items: center; gap: 8px; font-size: 12px; }
.tier-rank { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; color: var(--orange-dark); background: var(--surface-warm); font-size: 11px; font-weight: 800; }
.tier-track { height: 8px; border-radius: 999px; overflow: hidden; background: var(--track); }
.tier-track span { display: block; height: 100%; background: var(--orange); }
.entry-list, .history-list { display: grid; gap: 8px; }
.entry-list { max-height: 300px; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; padding-right: 5px; }
.entry-list::-webkit-scrollbar { width: 7px; }
.entry-list::-webkit-scrollbar-thumb { border-radius: 999px; background: var(--border); }
.entry-row { display: grid; grid-template-columns: 56px 1fr 64px 80px auto; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.entry-row:last-child { border-bottom: 0; }
.entry-row strong { font-variant-numeric: tabular-nums; }
.icon-button { width: 34px; height: 34px; border: 0; background: transparent; color: var(--red); border-radius: 8px; }
.empty { margin: 8px 0; color: var(--muted); text-align: center; font-size: 13px; }
.cycle-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.history-card { padding: 16px; border-radius: 15px; border: 1px solid var(--border); background: var(--surface); }
.history-top { display: flex; justify-content: space-between; gap: 12px; }
.history-delete { flex: none; height: 34px; display: inline-flex; align-items: center; gap: 5px; padding: 0 10px; border: 1px solid color-mix(in srgb, var(--red) 35%, transparent); border-radius: 9px; color: var(--red); background: color-mix(in srgb, var(--red) 8%, transparent); font-size: 12px; }
.history-delete:hover { background: color-mix(in srgb, var(--red) 14%, transparent); }
.history-delete span { font-size: 17px; line-height: 1; }
.history-metrics { margin-top: 12px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.history-metrics span { display: block; color: var(--muted); font-size: 11px; }
.history-metrics strong { display: block; margin-top: 3px; font-size: 15px; }
.price-grid { margin-top: 14px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.switch { display: inline-flex; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch span { width: 48px; height: 28px; border-radius: 999px; background: #d5cec8; padding: 3px; transition: background .2s; }
.switch span::after { content: ""; display: block; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 4px rgba(0,0,0,.18); }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(20px); }
.text-button { padding: 8px 0 0; border: 0; color: var(--orange-dark); background: transparent; }
.dialog { width: min(92vw, 480px); padding: 24px; border: 0; border-radius: 18px; color: var(--text); background: var(--surface); box-shadow: 0 25px 80px rgba(0,0,0,.25); }
.dialog::backdrop { background: rgba(35, 29, 25, .55); backdrop-filter: blur(3px); }
.dialog h2 { margin-bottom: 12px; }
.dialog p, .dialog li { color: var(--muted); line-height: 1.65; }
.dialog label { margin: 12px 0; }
.dialog-actions { margin-top: 20px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 20; padding: 11px 16px; color: #fff; background: #292724; border-radius: 10px; box-shadow: var(--shadow); font-size: 13px; }
@media (min-width: 901px) {
  .current-primary { height: 100%; max-height: calc(100dvh - 160px); align-self: start; }
  .record-panel { height: 100%; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
  .record-scroll { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-right: 5px; }
  .record-submit { flex: none; margin-top: 12px; }
}
@media (max-width: 680px) {
  .app-header { padding: 18px 14px 12px; }
  .model-status { max-width: 120px; }
  .tabs, main { padding-left: 12px; padding-right: 12px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .field-grid { grid-template-columns: 1fr 1fr; }
  .task-grid { grid-template-columns: repeat(3, 1fr); }
  .price-grid { grid-template-columns: 1fr 1fr; }
  .decision-grid { grid-template-columns: 1fr; }
  .entry-row { grid-template-columns: 48px 1fr 56px auto; }
  .entry-cost-value { display: none; }
  .history-metrics { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 520px) {
  .model-status { display: none; }
}
@media (max-width: 900px) {
  .current-layout { grid-template-columns: 1fr; }
  .current-primary, .current-secondary { display: contents; }
  .current-summary { order: 1; }
  .record-panel { order: 2; }
  .prediction-panel { order: 3; }
  .cycle-actions { order: 4; }
  .entries-panel { order: 5; }
}
@media (max-width: 390px) {
  .task-grid { grid-template-columns: 1fr 1fr; }
  .cycle-actions { grid-template-columns: 1fr; }
  .dialog-actions { grid-template-columns: 1fr; }
}
:root[data-theme="dark"] { color-scheme: dark; --bg: #111315; --surface: #1b1e21; --surface-warm: #2b201b; --text: #f1eee9; --muted: #aaa39d; --border: #333638; --shadow: 0 8px 28px rgba(0,0,0,.22); --control: #17191c; --control-border: #393c3f; --track: #333638; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]), :root[data-theme="system"] { color-scheme: dark; --bg: #111315; --surface: #1b1e21; --surface-warm: #2b201b; --text: #f1eee9; --muted: #aaa39d; --border: #333638; --shadow: 0 8px 28px rgba(0,0,0,.22); --control: #17191c; --control-border: #393c3f; --track: #333638; }
}
