:root {
  --bg: #f5f7f9;
  --surface: #ffffff;
  --surface-subtle: #f9fafb;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-muted: #475569;
  --text-faint: #64748b;
  --primary: #0f766e;
  --primary-hover: #0d5f59;
  --primary-soft: #ecfdf5;
  --green: #059669;
  --green-bg: #ecfdf5;
  --green-border: #a7f3d0;
  --amber: #b45309;
  --amber-bg: #fffbeb;
  --amber-border: #fde68a;
  --red: #dc2626;
  --red-bg: #fef2f2;
  --red-border: #fecaca;
  --blue: #1d4ed8;
  --blue-bg: #eff6ff;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

.muted { color: var(--text-faint); font-size: 12px; }
.hidden { display: none !important; }

/* Topbar */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #0f766e, #115e59);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
}
.brand-name { font-size: 17px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.badge-proto {
  font-size: 11px;
  font-weight: 600;
  background: #f1f5f9;
  color: #334155;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
}
.brand-sub { font-size: 12px; color: var(--text-faint); }

.topbar-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.offline-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--green-bg);
  border: 1px solid var(--green-border);
  color: #065f46;
  font-size: 12px;
  font-weight: 600;
}
.offline-pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.2);
}

.lang-switch {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}
.lang-btn {
  border: none;
  background: transparent;
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}
.lang-btn.active {
  background: var(--text);
  color: #fff;
}

/* Main container */
.container {
  max-width: 1280px;
  margin: 20px auto 48px;
  padding: 0 24px;
}

/* Mode tabs */
.mode-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}
.mode-tab {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 11px 20px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.mode-tab:hover { border-color: var(--primary); color: var(--text); }
.mode-tab.active {
  background: var(--text);
  border-color: var(--text);
  color: #fff;
  box-shadow: var(--shadow);
}
.tab-num {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: rgba(148, 163, 184, 0.2);
  display: grid;
  place-items: center;
  font-size: 12px;
}
.mode-tab.active .tab-num { background: rgba(255, 255, 255, 0.2); }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.card-head h3 { margin: 0; font-size: 15px; font-weight: 700; }
.card-sub { margin: 3px 0 0; font-size: 12.5px; color: var(--text-faint); }

/* Dropzone */
.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: 10px;
  padding: 28px 20px;
  text-align: center;
  background: var(--surface-subtle);
  transition: all 0.15s ease;
  cursor: pointer;
}
.dropzone.dragover {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.drop-icon { font-size: 32px; margin-bottom: 6px; }
.drop-title { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.drop-sub { font-size: 13px; color: var(--text-muted); max-width: 680px; margin: 0 auto 14px; }

.sample-bar {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.sample-label { font-size: 12.5px; font-weight: 600; color: var(--text-muted); margin-bottom: 10px; }
.sample-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s;
}
.chip:hover { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.chip-warn { border-color: #fcd34d; background: #fffbeb; color: #92400e; }
.chip-warn:hover { border-color: #d97706; background: #fef3c7; color: #78350f; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s;
}
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-secondary:hover { background: #f1f5f9; }
.btn-accent { background: #0f172a; color: #fff; }
.btn-accent:hover { background: #1e293b; }
.btn-ok { background: var(--green-bg); border-color: var(--green-border); color: #065f46; }
.btn-ok.selected, .btn-ok:hover { background: var(--green); color: #fff; border-color: var(--green); }
.btn-no { background: var(--surface); border-color: var(--border-strong); color: var(--text-muted); }
.btn-no.selected, .btn-no:hover { background: var(--red); color: #fff; border-color: var(--red); }

/* Progress */
.progress-row { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.progress-track { height: 8px; background: #e2e8f0; border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--primary); width: 0%; transition: width 0.15s; }

/* Checksum banner */
.checksum-banner {
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.checksum-pass { background: var(--green-bg); border: 1.5px solid var(--green-border); color: #064e3b; }
.checksum-warn { background: var(--amber-bg); border: 1.5px solid var(--amber-border); color: #78350f; }
.checksum-fail { background: var(--red-bg); border: 1.5px solid var(--red-border); color: #7f1d1d; }
.banner-title { font-size: 16px; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.banner-desc { font-size: 13px; margin-top: 3px; opacity: 0.9; }
.banner-meta { display: flex; gap: 8px; flex-wrap: wrap; }
.pill-neutral {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(15, 23, 42, 0.12);
  font-weight: 600;
}

/* KPI grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}
@media (max-width: 900px) { .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 18px;
  box-shadow: var(--shadow);
}
.kpi-label { font-size: 12px; color: var(--text-faint); font-weight: 600; }
.kpi-val { font-size: 22px; font-weight: 800; margin-top: 4px; letter-spacing: -0.5px; }
.kpi-sub { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.val-neg { color: var(--red); }
.val-pos { color: var(--green); }
.val-amber { color: var(--amber); }

/* Action strip */
.action-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 20px;
}
.action-left, .action-right { display: flex; gap: 10px; flex-wrap: wrap; }

/* Tables */
.table-filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.input-sm {
  padding: 6px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  font-size: 12.5px;
  background: var(--surface);
  color: var(--text);
}
.checkbox-inline { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--text-muted); cursor: pointer; }

.table-wrap { width: 100%; overflow-x: auto; }
.scroll-y { max-height: 520px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 12.8px; }
thead th {
  position: sticky;
  top: 0;
  background: #f1f5f9;
  color: #334155;
  text-align: left;
  padding: 9px 10px;
  font-weight: 700;
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
  z-index: 2;
}
tbody td {
  padding: 8px 10px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: top;
}
tbody tr:hover { background: #f8fafc; }
.num { text-align: right; white-space: nowrap; }
.row-modified { background: #fffbeb; }
.tag-star {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
  margin-right: 4px;
}
.tag-room {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 5px;
  background: #f1f5f9;
  color: #334155;
}

/* Diff dual upload */
.demo-banner {
  background: linear-gradient(90deg, #f0fdfa, #eff6ff);
  border: 1px solid #99f6e4;
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.demo-banner-text { display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.demo-banner-btns { display: flex; gap: 8px; flex-wrap: wrap; }

.dual-upload-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 14px;
  align-items: center;
}
@media (max-width: 820px) { .dual-upload-grid { grid-template-columns: 1fr; } .vs-divider { text-align: center; } }
.dropzone-sm { padding: 18px 16px; }
.slot-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 9px;
  border-radius: 999px;
  margin-bottom: 6px;
}
.slot-a { background: #dbeafe; color: #1e40af; }
.slot-b { background: #fee2e2; color: #991b1b; }
.drop-title-sm { font-size: 14px; font-weight: 700; }
.slot-status { font-size: 12.5px; color: var(--text-muted); margin: 6px 0 10px; word-break: break-all; }
.vs-divider {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--text);
  color: #fff;
  font-weight: 800;
  font-size: 12px;
  display: grid;
  place-items: center;
  margin: 0 auto;
}

/* Variance bars */
.variance-bars { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 900px) { .variance-bars { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.vbar-card {
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 12px 14px;
  background: var(--surface-subtle);
}
.vbar-title { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.vbar-val { font-size: 19px; font-weight: 800; margin-top: 3px; }
.vbar-track { height: 6px; background: #e2e8f0; border-radius: 99px; margin-top: 8px; overflow: hidden; }
.vbar-fill { height: 100%; border-radius: 99px; }

/* Calibration workbench */
.calibration-card { border-color: #99f6e4; background: #fcfefe; }
.calib-grid { display: grid; grid-template-columns: 1fr 1.35fr; gap: 16px; }
@media (max-width: 960px) { .calib-grid { grid-template-columns: 1fr; } }
.calib-pane {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
}
.calib-step-hdr {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 13.5px;
}
.step-pill {
  font-size: 11px;
  font-weight: 800;
  background: var(--primary);
  color: #fff;
  padding: 2px 7px;
  border-radius: 5px;
}
.step-pill-amber { background: #d97706; }
.calib-list { display: flex; flex-direction: column; gap: 8px; max-height: 360px; overflow-y: auto; }

.room-pair-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-subtle);
  font-size: 12.5px;
}
.room-pair-row.needs-confirm { border-color: #fcd34d; background: #fffbeb; }
.room-pair-left { flex: 1; min-width: 0; }
.room-pair-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-pair-arrow { color: var(--text-faint); font-weight: 700; }
.room-select {
  max-width: 195px;
  padding: 5px 8px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  font-size: 12px;
  background: #fff;
}

.sub-card {
  border: 1.5px solid #fcd34d;
  background: #fffbeb;
  border-radius: 9px;
  padding: 10px 12px;
  font-size: 12.5px;
}
.sub-card.confirmed { border-color: var(--green-border); background: var(--green-bg); }
.sub-card.separated { border-color: var(--border); background: #f8fafc; opacity: 0.78; }
.sub-compare {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.sub-side { background: rgba(255, 255, 255, 0.85); padding: 7px 9px; border-radius: 6px; border: 1px solid rgba(15,23,42,0.08); }
.sub-side-lbl { font-size: 10.5px; font-weight: 800; text-transform: uppercase; color: var(--text-faint); }
.sub-side-desc { font-weight: 600; margin: 2px 0; }
.sub-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }

/* Sub tabs */
.sub-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; border-bottom: 1px solid var(--border); padding-bottom: 10px; }
.sub-tab {
  border: 1px solid var(--border);
  background: var(--surface-subtle);
  color: var(--text-muted);
  padding: 7px 13px;
  border-radius: 8px;
  font-size: 12.8px;
  font-weight: 600;
  cursor: pointer;
}
.sub-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Footer */
.footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 18px 24px;
  margin-top: 40px;
}
.footer-inner { max-width: 1280px; margin: 0 auto; font-size: 12px; color: var(--text-faint); }
.footer-inner p { margin: 4px 0; }
.footer-inner .legal { font-size: 11px; color: #94a3b8; }

/* Dual-Pricing Painted Door & Preview Gate */
.pricing-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.btn-plan-single {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-plan-single:hover { background: var(--primary-hover); }
.btn-plan-pro {
  background: #0f172a;
  color: #fff;
  border-color: #0f172a;
}
.btn-plan-pro:hover { background: #1e293b; }
.unlock-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: var(--green-bg);
  color: #065f46;
  border: 1px solid var(--green-border);
}

.preview-gate-box {
  margin-top: 12px;
  padding: 18px 20px;
  border-radius: 10px;
  border: 1.5px dashed #0f766e;
  background: linear-gradient(180deg, #f0fdfa 0%, #ffffff 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.preview-gate-copy strong {
  display: block;
  font-size: 14px;
  color: var(--text);
  margin-bottom: 3px;
}
.preview-gate-copy span {
  font-size: 12.5px;
  color: var(--text-muted);
}

/* Early-Access Unlock Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.56);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1000;
}
.modal-backdrop.hidden { display: none; }
.modal-card {
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border-radius: 14px;
  border: 1px solid var(--border);
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
  padding: 22px 24px;
  position: relative;
}
.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  border: none;
  background: transparent;
  font-size: 20px;
  line-height: 1;
  color: var(--text-faint);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}
.modal-close:hover { background: #f1f5f9; color: var(--text); }
.modal-plan-tag {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid #99f6e4;
  margin-bottom: 8px;
}
.modal-card h3 { margin: 0 0 6px; font-size: 17px; color: var(--text); }
.modal-desc { margin: 0 0 14px; font-size: 13px; color: var(--text-muted); line-height: 1.5; }
.modal-field { margin-bottom: 12px; }
.modal-field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 5px;
}
.modal-input {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
}
.modal-input:focus { outline: 2px solid #99f6e4; border-color: var(--primary); }
.modal-err { color: var(--red); font-size: 12px; margin: 4px 0 8px; font-weight: 600; }
.modal-submit { width: 100%; justify-content: center; padding: 11px 16px; font-size: 14px; }
.privacy-note {
  margin-top: 12px;
  padding: 9px 11px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.45;
}
.ext-divider {
  margin: 14px 0;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
