:root {
  --bg: #f6f4ef;
  --panel: #fffdf8;
  --ink: #342d27;
  --muted: #74695d;
  --line: #e2d8ca;
  --primary: #76543a;
  --primary-dark: #4a3528;
  --accent: #52745b;
  --danger: #b83232;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Microsoft YaHei", sans-serif; color: var(--ink); background: var(--bg); }
button, input, select, textarea { font: inherit; }

.customer-body { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.tablet-shell { width: min(1120px, 100%); min-height: 680px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; box-shadow: 0 18px 50px rgba(42, 35, 28, .12); display: flex; flex-direction: column; }
.kiosk-body { padding: 0; background: #171412; }
.kiosk-shell { width: 100%; min-height: 100vh; background: var(--panel); display: flex; flex-direction: column; }
.app-topbar, .workspace-top { height: 72px; padding: 0 28px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); background: #fff; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; color: var(--primary); }
.brand-mark { width: 36px; height: 36px; border-radius: 8px; background: var(--accent); color: white; display: grid; place-items: center; }
.step-dots span { display: inline-block; width: 10px; height: 10px; border-radius: 999px; background: var(--line); margin-left: 8px; }
.step-dots .active { width: 30px; background: var(--primary); }
.screen { display: none; flex: 1; padding: 36px; }
.screen.active { display: block; }
.kiosk-shell .screen { padding: 0; }
.intro-grid, .capture-layout, .result-layout, .history-layout { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(280px, .7fr); gap: 32px; align-items: center; height: 100%; }
h1 { font-size: 34px; line-height: 1.2; margin: 0 0 16px; color: var(--primary-dark); }
h2 { margin: 0 0 14px; }
p { color: var(--muted); line-height: 1.7; }
.guide-panel, .tea-card, .photo-input, .stats-strip > div, .chart-list > div { background: #fdf8f0; border: 1px solid var(--line); border-radius: 8px; padding: 18px; }
.guide-panel { display: grid; gap: 14px; }
.check-line { display: block; margin: 14px 0; color: var(--ink); }
.inline-form { display: flex; gap: 12px; margin: 20px 0; }
.inline-form input, .dialog-form input, .dialog-form select, .dialog-form textarea { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 9px 10px; background: white; }
.primary-action, .secondary-action, .row-action { border: 0; border-radius: 7px; padding: 11px 18px; cursor: pointer; text-decoration: none; display: inline-block; text-align: center; }
.primary-action { background: var(--primary); color: white; }
.secondary-action { background: white; color: var(--primary); border: 1px solid var(--line); }
.row-action { background: #eee5da; color: var(--primary-dark); padding: 7px 10px; }
.photo-preview { margin-top: 12px; height: 320px; border: 2px dashed var(--line); border-radius: 8px; display: grid; place-items: center; color: var(--muted); overflow: hidden; background: #faf5ed; }
.photo-preview img { width: 100%; height: 100%; object-fit: cover; }
.capture-actions ul { color: var(--muted); line-height: 2; padding-left: 20px; }
.camera-tools { display: grid; gap: 10px; margin: 14px 0; }
.camera-tools video { width: 100%; aspect-ratio: 16 / 9; background: #241f1a; border-radius: 8px; object-fit: cover; }
.camera-stage { min-height: calc(100vh - 34px); display: grid; grid-template-rows: auto minmax(0, 1fr) auto; background: #171412; color: white; }
.camera-header { min-height: 72px; padding: 0 28px; display: flex; align-items: center; justify-content: space-between; background: rgba(0,0,0,.72); }
.camera-header .brand { color: white; }
.camera-header #cameraState { color: #e6d8c6; }
.live-frame { position: relative; min-height: 0; background: #080706; display: grid; place-items: center; overflow: hidden; }
.live-frame video { width: 100%; height: 100%; object-fit: cover; }
.camera-empty { position: absolute; inset: 0; display: grid; place-items: center; color: #e7dccf; background: #171412; }
.capture-panel { padding: 18px 28px 22px; background: rgba(0,0,0,.78); display: grid; gap: 12px; justify-items: center; }
.capture-main { width: min(520px, 100%); min-height: 64px; font-size: 24px; font-weight: 800; }
.capture-main:disabled { opacity: .65; cursor: wait; }
.agreement-lines { width: min(720px, 100%); display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; color: #eadfD0; font-size: 14px; }
.agreement-lines input { transform: translateY(1px); }
.button-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.loading-block { height: 520px; display: grid; place-items: center; align-content: center; gap: 20px; }
.ai-loading { min-height: calc(100vh - 34px); display: grid; place-items: center; align-content: center; gap: 18px; background: var(--panel); text-align: center; padding: 24px; }
.ai-loading h1 { margin: 0; }
.spinner { width: 54px; height: 54px; border: 5px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.badge { color: var(--accent); font-weight: 700; margin-bottom: 8px; }
#resultConstitution { font-size: 44px; color: var(--primary); }
.confidence { margin: 22px 0; }
.confidence div { height: 12px; background: #eadfD0; border-radius: 999px; overflow: hidden; margin-top: 8px; }
.confidence i { display: block; height: 100%; background: var(--accent); }
.result-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.result-grid div { border: 1px solid var(--line); border-radius: 8px; padding: 14px; }
.result-grid span, .tea-card span, .stats-strip span { display: block; color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.disclaimer { font-size: 13px; }
.result-page { min-height: calc(100vh - 34px); padding: 24px 36px 36px; display: grid; grid-template-rows: auto auto 1fr auto; gap: 22px; background: var(--panel); }
.result-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.countdown { color: var(--primary); font-weight: 700; }
.countdown span { font-size: 28px; }
.result-hero { text-align: center; max-width: 820px; margin: 0 auto; }
.result-hero h1 { font-size: 56px; margin: 4px 0 10px; color: var(--primary); }
.result-grid-wide { width: min(960px, 100%); margin: 0 auto; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.result-grid-wide strong { font-size: 18px; color: var(--primary-dark); }
.result-page .disclaimer { max-width: 960px; margin: 0 auto; text-align: center; }
.history-list { display: grid; gap: 10px; max-height: 500px; overflow: auto; }
.history-item { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(160px, .8fr) auto; gap: 10px; align-items: center; background: white; border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.history-item span { color: var(--muted); font-size: 13px; }
#statusLine, .toast { min-height: 34px; padding: 8px 28px; color: var(--danger); }

.admin-body { min-height: 100vh; display: flex; }
.sidebar { width: 230px; background: #2d261f; color: #e8ded0; padding: 20px 12px; display: flex; flex-direction: column; gap: 8px; }
.sidebar-title { font-weight: 800; padding: 10px 12px 22px; }
.nav { color: #d7cab8; background: transparent; border: 0; text-align: left; text-decoration: none; padding: 11px 12px; border-radius: 7px; cursor: pointer; }
.nav.active, .nav:hover { background: rgba(255,255,255,.08); color: white; }
.workspace { flex: 1; min-width: 0; }
.workspace-top h1 { font-size: 24px; margin: 0; }
.stats-strip { display: grid; grid-template-columns: repeat(5, minmax(120px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stats-strip strong { font-size: 28px; }
.panel { display: none; padding: 24px; }
.panel.active { display: block; }
.data-table { width: 100%; border-collapse: collapse; background: white; border: 1px solid var(--line); }
.data-table th, .data-table td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; font-size: 14px; }
.data-table th { background: #f7f1e9; color: var(--muted); }
.chart-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.toolbar { display: flex; gap: 14px; align-items: center; margin-bottom: 16px; }
.toolbar input, .toolbar select, .login-panel input, .login-panel select { border: 1px solid var(--line); border-radius: 6px; padding: 9px 10px; background: white; }
.login-panel { max-width: 420px; display: grid; gap: 14px; background: white; border: 1px solid var(--line); border-radius: 8px; padding: 22px; }
dialog { border: 0; border-radius: 10px; width: min(620px, calc(100% - 40px)); padding: 0; box-shadow: 0 18px 60px rgba(0,0,0,.25); }
.dialog-form { padding: 24px; display: grid; gap: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

@media (max-width: 860px) {
  .intro-grid, .capture-layout, .result-layout, .history-layout, .split { grid-template-columns: 1fr; }
  .customer-body { padding: 0; }
  .tablet-shell { min-height: 100vh; border-radius: 0; }
  .camera-header { padding: 0 16px; }
  .camera-header .brand span:last-child { display: none; }
  .capture-panel { padding: 14px 16px 18px; }
  .capture-main { min-height: 58px; font-size: 21px; }
  .agreement-lines { display: grid; justify-content: stretch; gap: 8px; }
  .result-page { padding: 16px; }
  .result-top { align-items: flex-start; }
  .result-hero h1 { font-size: 42px; }
  .result-grid-wide { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-body { display: block; }
  .sidebar { width: 100%; flex-direction: row; overflow-x: auto; }
  .stats-strip { grid-template-columns: repeat(2, 1fr); }
}
