:root {
  --ink: #17211d;
  --muted: #6c746f;
  --paper: #f6f4ef;
  --surface: #fffdf8;
  --line: #dedbd2;
  --yellow: #ffd946;
  --yellow-soft: #fff3b8;
  --green: #28624a;
  --green-soft: #dceae2;
  --orange: #e8793a;
  --shadow: 0 20px 55px rgba(39, 48, 42, .08);
  --radius: 22px;
}

* { box-sizing: border-box; }
html, body { width: 100%; min-width: 0; overflow-x: hidden; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 2%, rgba(255,217,70,.18), transparent 23rem),
    var(--paper);
  font-family: "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}
button, input { font: inherit; }
button { color: inherit; }
button, label[for], .dropzone { cursor: pointer; }
button:focus-visible, input:focus-visible, .dropzone:focus-within {
  outline: 3px solid rgba(40,98,74,.35);
  outline-offset: 3px;
}
.shell { width: min(1440px, 100%); min-height: 100vh; margin: 0 auto; }
.topbar {
  height: 86px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  padding: 0 42px;
  border-bottom: 1px solid rgba(23,33,29,.11);
}
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; width: fit-content; }
.brand > span:last-child { display: flex; flex-direction: column; line-height: 1.2; }
.brand b { font-size: 16px; letter-spacing: .03em; }
.brand small { color: var(--muted); font-size: 11px; margin-top: 3px; }
.brand-mark {
  width: 34px; height: 34px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px;
  transform: rotate(-4deg);
}
.brand-mark i { border-radius: 50%; background: var(--yellow); border: 1px solid rgba(23,33,29,.15); }
.brand-mark i:nth-child(2), .brand-mark i:nth-child(4), .brand-mark i:nth-child(8) { background: var(--green); }
.tabs { background: rgba(255,255,255,.55); border: 1px solid var(--line); border-radius: 999px; padding: 4px; display: flex; }
.tab { border: 0; background: transparent; padding: 9px 20px; border-radius: 999px; font-weight: 650; font-size: 14px; }
.tab.active { background: var(--ink); color: white; }
.model-pill { justify-self: end; color: var(--muted); font: 12px/1.2 ui-monospace, monospace; display: flex; align-items: center; gap: 8px; }
.model-pill span { width: 8px; height: 8px; border-radius: 50%; background: #37a66a; box-shadow: 0 0 0 4px rgba(55,166,106,.12); }
.header-actions { justify-self: end; display: flex; align-items: center; gap: 14px; }
.header-actions form { margin: 0; }
.logout-button { width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); display: grid; place-items: center; }
.logout-button:hover { background: var(--green-soft); }
.logout-button svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
main { padding: 52px 42px 80px; }
.view { display: none; }
.view.active { display: block; animation: enter .28s ease-out; }
@keyframes enter { from { opacity: 0; transform: translateY(6px); } }
.page-heading, .import-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 36px; margin-bottom: 42px; }
.eyebrow, .section-label { font: 700 11px/1.2 ui-monospace, monospace; letter-spacing: .14em; text-transform: uppercase; color: var(--green); }
h1 { margin: 8px 0 0; font-size: clamp(38px, 5vw, 68px); line-height: 1.02; letter-spacing: -.055em; font-weight: 780; }
h1 em { color: var(--green); font-style: normal; }
.filters { display: flex; align-items: end; gap: 10px; }
.filters label, .store-field { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 650; }
input { min-height: 44px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); padding: 9px 12px; color: var(--ink); }
.button { min-height: 44px; border-radius: 12px; padding: 10px 17px; border: 1px solid transparent; display: inline-flex; align-items: center; justify-content: center; gap: 9px; font-weight: 750; transition: transform .18s, box-shadow .18s, background .18s; }
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.button svg, .text-action svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.button.primary { background: var(--ink); color: white; box-shadow: 0 8px 20px rgba(23,33,29,.16); }
.button.primary:hover { background: var(--green); }
.button.secondary { background: var(--surface); border-color: var(--line); }
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 14px; }
.kpi { min-height: 152px; padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(255,253,248,.72); display: flex; flex-direction: column; }
.kpi-primary { background: var(--yellow); border-color: #e2bf35; transform: rotate(-.35deg); box-shadow: var(--shadow); }
.kpi span { color: var(--muted); font-weight: 650; font-size: 13px; }
.kpi-primary span { color: rgba(23,33,29,.7); }
.kpi strong { font: 700 clamp(28px, 3vw, 42px)/1.1 ui-monospace, "SFMono-Regular", monospace; letter-spacing: -.055em; margin: auto 0 4px; }
.kpi small { color: var(--muted); font-size: 12px; }
.analysis-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(260px, 1fr); gap: 14px; margin-bottom: 14px; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 10px 35px rgba(39,48,42,.035); }
.hour-panel, .ocr-panel, .records-panel, .review-panel { padding: 24px; }
.panel-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 22px; }
h2 { font-size: 24px; line-height: 1.2; margin: 5px 0 0; letter-spacing: -.03em; }
.legend { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 12px; }
.legend i { width: 9px; height: 9px; border-radius: 2px; margin-left: 8px; }
.legend .spend { background: var(--yellow); border: 1px solid #c7a62b; }
.legend .orders { background: var(--green); }
.hour-film { min-height: 235px; display: flex; align-items: stretch; gap: 7px; overflow-x: auto; padding: 8px 0 3px; }
.hour-cell { min-width: 68px; flex: 1; display: flex; flex-direction: column; gap: 7px; }
.bar-stage { flex: 1; min-height: 160px; position: relative; display: flex; align-items: flex-end; justify-content: center; background: #f3f0e9; border-radius: 10px; overflow: hidden; }
.spend-bar { width: 100%; min-height: 2px; background: var(--yellow); border-top: 1px solid #c6a42b; transition: height .4s ease; }
.order-dots { position: absolute; inset: 8px; display: flex; flex-direction: column-reverse; align-items: center; gap: 3px; pointer-events: none; }
.order-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--green); border: 1px solid rgba(255,255,255,.5); }
.hour-cell strong { text-align: center; font: 600 11px/1.2 ui-monospace, monospace; }
.hour-cell small { text-align: center; color: var(--muted); font: 10px/1.2 ui-monospace, monospace; }
.ocr-panel { display: flex; flex-direction: column; align-items: center; text-align: center; }
.ocr-panel .section-label { align-self: flex-start; }
.accuracy-ring {
  --accuracy: 0;
  width: 138px; height: 138px; border-radius: 50%; margin: 16px 0;
  display: grid; place-items: center;
  background: conic-gradient(var(--green) calc(var(--accuracy) * 1%), var(--green-soft) 0);
  position: relative;
}
.accuracy-ring::after { content: ""; position: absolute; inset: 11px; background: var(--surface); border-radius: 50%; }
.accuracy-ring div { z-index: 1; display: flex; flex-direction: column; }
.accuracy-ring strong { font: 700 28px/1 ui-monospace, monospace; }
.accuracy-ring small { color: var(--muted); font-size: 11px; margin-top: 7px; }
.ocr-panel p { color: var(--muted); font-size: 13px; max-width: 28ch; }
.text-action { margin-top: auto; min-height: 44px; border: 0; background: transparent; color: var(--green); font-weight: 750; display: inline-flex; align-items: center; }
.row-count, .review-note { color: var(--muted); font-size: 12px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th { color: var(--muted); font-size: 11px; letter-spacing: .05em; text-align: left; padding: 12px; border-bottom: 1px solid var(--line); }
td { padding: 14px 12px; border-bottom: 1px solid #ebe8e0; font-size: 14px; }
td.num { font-family: ui-monospace, monospace; }
tbody tr:hover { background: #faf7ee; }
.empty-state { text-align: center; padding: 54px 20px; }
.empty-state h3 { margin: 14px 0 2px; }
.empty-state p { color: var(--muted); margin: 0 0 18px; }
.empty-beads { width: 64px; height: 48px; display: inline-block; background: radial-gradient(circle, var(--yellow) 0 6px, transparent 7px) 0 0/22px 22px; }
.import-heading { align-items: center; }
.import-heading > p { color: var(--muted); max-width: 38ch; font-size: 15px; }
.upload-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 16px; margin-bottom: 22px; }
.dropzone {
  min-height: 280px; padding: 35px; border: 1.5px dashed #9d9d91; border-radius: var(--radius);
  background: rgba(255,253,248,.72); display: flex; flex-direction: column; align-items: center; justify-content: center;
  transition: border .2s, background .2s, transform .2s;
}
.dropzone.dragging { border-color: var(--green); background: var(--green-soft); transform: scale(.997); }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dropzone strong { font-size: 19px; margin: 16px 0 4px; }
.dropzone small { color: var(--muted); }
.upload-icon { width: 62px; height: 62px; display: grid; place-items: center; border-radius: 50%; background: var(--yellow); }
.upload-icon svg { width: 28px; height: 28px; fill: none; stroke: var(--ink); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.file-list { display: grid; gap: 7px; margin: 10px 0; }
.file-item { padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); display: flex; align-items: center; justify-content: space-between; font-size: 13px; }
.file-item small { color: var(--muted); }
.wide { width: 100%; }
.process-card { border-radius: var(--radius); background: var(--ink); color: white; padding: 26px; }
.process-card .section-label { color: var(--yellow); }
.process-card ol { list-style: none; padding: 0; margin: 25px 0 0; display: grid; gap: 25px; }
.process-card li { display: flex; gap: 14px; }
.process-card li b { color: var(--yellow); font: 650 12px/1.5 ui-monospace, monospace; }
.process-card li span { display: flex; flex-direction: column; }
.process-card li strong { font-size: 14px; }
.process-card li small { color: #9eaaa3; margin-top: 4px; }
.store-field { max-width: 360px; margin-bottom: 18px; }
.review-table input { min-width: 105px; width: 100%; }
.review-table td { padding: 6px 4px; }
.review-table .store-input { min-width: 210px; }
.review-table .inferred { background: var(--yellow-soft); border-color: #dfc65c; }
.delete-row { border: 0; background: transparent; min-width: 44px; min-height: 44px; color: #a64232; font-size: 20px; border-radius: 8px; }
.delete-row:hover { background: #fee9e4; }
.review-actions { margin-top: 20px; display: flex; justify-content: space-between; gap: 12px; }
.toast { position: fixed; right: 24px; bottom: 24px; max-width: min(390px, calc(100vw - 48px)); padding: 13px 18px; border-radius: 12px; background: var(--ink); color: white; box-shadow: var(--shadow); opacity: 0; transform: translateY(12px); pointer-events: none; transition: .22s; z-index: 10; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #922f25; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.login-page { min-height: 100vh; overflow-x: hidden; }
.login-shell { min-height: 100vh; padding: 0; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(420px, .85fr); }
.login-art { position: relative; overflow: hidden; display: flex; align-items: flex-end; padding: clamp(35px, 6vw, 86px); background: var(--yellow); }
.big-bead-grid {
  position: absolute; width: 540px; height: 420px; right: -55px; top: -55px;
  display: grid; grid-template-columns: repeat(9, 1fr); gap: 9px; transform: rotate(8deg);
}
.big-bead-grid i { border-radius: 50%; background: rgba(255,255,255,.33); border: 1px solid rgba(23,33,29,.12); }
.big-bead-grid i:nth-child(4n), .big-bead-grid i:nth-child(7n) { background: var(--green); }
.big-bead-grid i:nth-child(11n) { background: var(--orange); }
.login-copy { position: relative; z-index: 1; }
.login-copy .eyebrow { color: rgba(23,33,29,.65); }
.login-copy h1 em { color: var(--ink); text-decoration: underline; text-decoration-thickness: .08em; text-underline-offset: .12em; }
.login-form-wrap { display: grid; place-items: center; padding: 36px; background: var(--surface); }
.login-card { width: min(390px, 100%); }
.login-title { margin: 72px 0 28px; }
.login-title h2 { font-size: 34px; margin-top: 8px; }
.login-title p { color: var(--muted); margin: 7px 0 0; }
.login-card form { display: grid; gap: 8px; }
.login-card form label { margin-top: 9px; color: var(--muted); font-size: 12px; font-weight: 700; }
.login-card form input { width: 100%; min-height: 50px; }
.login-card form .button { margin-top: 16px; min-height: 50px; }
.form-error { color: #a3382b; background: #fee9e4; padding: 10px 12px; border-radius: 9px; font-size: 13px; margin: 5px 0 0; }
.login-footnote { display: block; color: var(--muted); text-align: center; margin-top: 17px; }

@media (max-width: 900px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-art { min-height: 300px; padding: 42px 24px; }
  .login-form-wrap { padding: 42px 24px 70px; }
  .login-title { margin-top: 50px; }
  .shell { width: 100%; max-width: 100%; }
  .topbar { grid-template-columns: minmax(0, 1fr) auto; padding: 0 20px; gap: 12px; }
  .tabs { position: fixed; z-index: 5; bottom: 14px; left: 50%; transform: translateX(-50%); box-shadow: 0 8px 30px rgba(0,0,0,.18); background: var(--surface); }
  .model-pill { display: none; }
  main { padding: 36px 20px 100px; }
  .page-heading, .import-heading { align-items: flex-start; flex-direction: column; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .analysis-grid, .upload-grid { grid-template-columns: minmax(0, 1fr); }
  .filters {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }
  .filters label {
    position: relative;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
  }
  .filters input,
  .filters input[type="date"] {
    display: block;
    width: 100%;
    width: -webkit-fill-available;
    max-width: 100%;
    min-width: 0;
    min-inline-size: 0;
    -webkit-appearance: none;
    appearance: none;
  }
  .filters input[type="date"]::-webkit-date-and-time-value {
    min-width: 0;
    text-align: left;
  }
  .filters input[type="date"]::-webkit-datetime-edit {
    min-width: 0;
    padding: 0;
  }
  .filters .button { grid-column: auto; width: 100%; }
}
@media (max-width: 520px) {
  .login-art { min-height: 230px; }
  .login-copy h1 { font-size: 37px; }
  .big-bead-grid { width: 330px; height: 260px; gap: 6px; }
  .topbar { height: 72px; padding-inline: 14px; }
  .brand-mark { width: 30px; height: 30px; }
  main { padding: 28px 14px 132px; }
  h1 { font-size: 42px; }
  .kpi-grid { gap: 8px; }
  .kpi { min-height: 130px; padding: 17px; border-radius: 17px; }
  .kpi strong { font-size: 27px; }
  .hour-panel, .ocr-panel, .records-panel, .review-panel { padding: 17px; }
  .page-heading, .import-heading { gap: 24px; margin-bottom: 28px; }
  .filters input { width: 100%; min-width: 0; padding-inline: 8px; font-size: 13px; }
  .filters .button { padding-inline: 13px; }
  .panel-heading { margin-bottom: 16px; }
  .legend { gap: 3px; font-size: 11px; }
  .hour-film { min-height: 205px; gap: 5px; }
  .hour-cell { min-width: 0; gap: 5px; }
  .bar-stage { min-height: 135px; }
  .hour-cell small { font-size: 9px; }
  .dropzone { min-height: 230px; padding: 24px 12px; text-align: center; }
  .review-actions { flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}
