/* ===== Design Tokens ===== */
:root {
  color-scheme: light;
  --bg: #f5f4f0;
  --surface: #ffffff;
  --surface-hover: #f9fafb;
  --brand: #2d3a7a;
  --brand-light: #e8eaf6;
  --brand-muted: #c5cae9;
  --accent: #3f51b5;
  --accent-dark: #303f9f;
  --success: #0d9488;
  --success-light: #ccfbf1;
  --warm: #d97706;
  --warm-light: #fffbeb;
  --danger: #dc2626;
  --danger-light: #fef2f2;
  --text: #18181b;
  --text-secondary: #52525b;
  --muted: #71717a;
  --placeholder: #a1a1aa;
  --border: #e4e4e7;
  --border-light: #f4f4f5;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.04);
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.06), 0 2px 4px -2px rgba(0,0,0,.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.06), 0 4px 6px -4px rgba(0,0,0,.05);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,.06), 0 8px 10px -6px rgba(0,0,0,.04);
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

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

button, input, select, textarea { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }

/* ===== Layout ===== */
.app-shell { max-width: 1200px; margin: 0 auto; padding: 0 20px 40px; }

/* ===== Header ===== */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 20px 0 16px; flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 10px; }

.brand-mark {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.brand-text h1 { font-size: 20px; font-weight: 700; letter-spacing: -.3px; }
.brand-text span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1.5px; font-weight: 500; }

.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-group { display: flex; gap: 6px; }
.btn-group + .btn-group::before {
  content: ''; display: block; width: 1px; background: var(--border);
  margin: 0 2px; align-self: stretch;
}

.lang-toggle {
  width: 44px; justify-content: center; padding: 0;
  font-weight: 600; font-size: 12px; letter-spacing: 0.5px;
  border-color: var(--brand-muted); background: var(--brand-light);
  color: var(--brand); margin-right: 6px;
}
.lang-toggle:hover {
  background: var(--brand-muted); border-color: var(--accent);
}

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 14px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface);
  color: var(--text-secondary); font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all .15s; white-space: nowrap;
}
.btn:hover { background: var(--surface-hover); border-color: #d4d4d8; }
.btn:active { transform: scale(.98); }
.btn.primary { border-color: var(--accent); background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--brand-light); }
.btn-icon {
  width: 36px; height: 36px; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--muted); font-size: 20px;
  cursor: pointer; display: grid; place-items: center;
}
.btn-icon:hover { background: var(--surface-hover); color: var(--text); }

.btn-ghost-sm {
  height: 28px; padding: 0 10px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface);
  color: var(--text-secondary); font-size: 12px; cursor: pointer;
}
.btn-ghost-sm:hover { background: var(--surface-hover); }
.btn-ghost-sm.danger { color: var(--danger); border-color: var(--danger-light); }
.btn-ghost-sm.danger:hover { background: var(--danger-light); }

/* ===== Hero Card ===== */
.hero-card {
  position: relative; margin-bottom: 14px;
  padding: 28px 32px; border-radius: var(--radius-lg);
  background: linear-gradient(135deg, #1e2040, #2d3270, #1a1c33);
  color: #fff; overflow: hidden; box-shadow: var(--shadow-xl);
}
.hero-card::before {
  content: ''; position: absolute; top: -60px; right: -60px;
  width: 280px; height: 280px; border-radius: 50%;
  background: rgba(255,255,255,.03); pointer-events: none;
}
.hero-card::after {
  content: ''; position: absolute; bottom: -40px; left: 30%;
  width: 200px; height: 200px; border-radius: 50%;
  background: rgba(255,255,255,.02); pointer-events: none;
}
.hero-label { position: relative; z-index: 1; font-size: 14px; color: rgba(255,255,255,.6); font-weight: 500; margin-bottom: 4px; }
.hero-price { position: relative; z-index: 1; font-size: clamp(40px, 6vw, 64px); font-weight: 800; letter-spacing: -1.5px; line-height: 1; margin-bottom: 8px; }
.hero-meta { position: relative; z-index: 1; display: flex; gap: 20px; flex-wrap: wrap; font-size: 13px; color: rgba(255,255,255,.55); }
.hero-meta strong { color: rgba(255,255,255,.85); font-weight: 600; }

/* ===== Stats Row ===== */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 16px; }
.stat-card {
  padding: 16px 18px; border-radius: var(--radius); background: var(--surface);
  border: 1px solid var(--border); box-shadow: var(--shadow-sm); transition: box-shadow .15s;
}
.stat-card:hover { box-shadow: var(--shadow); }
.stat-card .stat-label { display: block; font-size: 12px; color: var(--muted); font-weight: 500; margin-bottom: 4px; }
.stat-card .stat-value { display: block; font-size: clamp(18px, 2.5vw, 24px); font-weight: 700; letter-spacing: -.3px; }
.stat-card.accent { border-color: var(--brand-muted); background: var(--brand-light); }
.stat-card.accent .stat-value { color: var(--brand); }

/* Exchange Rate Indicator */
.exchange-rate-bar {
  text-align: center; padding: 6px 12px; margin-bottom: 12px;
  font-size: 12px; color: var(--muted); font-weight: 500;
  background: var(--brand-light); border-radius: var(--radius-sm);
  border: 1px solid var(--brand-muted); cursor: pointer;
  transition: background .15s;
}
.exchange-rate-bar:hover { background: var(--brand-muted); }

/* ===== Inline action buttons inside breakdown panel ===== */
.breakdown-actions {
  display: flex; gap: 6px; flex-wrap: wrap;
  margin-top: 14px; padding-top: 12px;
  border-top: 1px solid var(--border-light);
}
.breakdown-actions .btn { flex: 1; min-width: 0; justify-content: center; font-size: 12px; height: 34px; padding: 0 6px; }

/* ===== Main Grid ===== */
.main-grid { display: grid; grid-template-columns: 1fr 380px; gap: 16px; align-items: start; }

/* ===== Right Column ===== */
.right-column {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ===== Panel ===== */
.panel {
  padding: 24px; border-radius: var(--radius-lg); background: var(--surface);
  border: 1px solid var(--border); box-shadow: var(--shadow-sm);
}

/* ===== Section Head ===== */
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.section-head h2 { font-size: 17px; font-weight: 700; letter-spacing: -.2px; }
.section-head span { font-size: 12px; color: var(--muted); }
.section-head.compact-top { margin-top: 0; }
.section-divider { margin: 24px 0; border: 0; border-top: 1px solid var(--border-light); }

/* ===== Style Info Layout ===== */
.style-info-layout { display: grid; grid-template-columns: 200px 1fr; gap: 20px; align-items: end; }
.style-info-right {
  display: flex; flex-direction: column;
  align-self: stretch;
}
.style-extra-images {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  width: 50%; /* match 打样色号 column width */
  flex: 1; /* fill remaining vertical space */
  align-items: stretch;
}
.small-image-upload {
  aspect-ratio: auto !important;
  border-width: 1.5px;
}
.small-image-upload span { font-size: 11px; padding: 6px; }

/* ===== Image Upload ===== */
.image-upload {
  position: relative; display: grid; place-items: center;
  aspect-ratio: 3/4; border: 2px dashed var(--border);
  border-radius: var(--radius); background: #fafafa;
  cursor: pointer; overflow: hidden; transition: all .2s;
}
.image-upload:hover { border-color: var(--accent); background: var(--brand-light); }
.image-upload:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(63,81,181,.12); outline: none; }
.image-upload.drag-over {
  border-color: var(--accent); border-style: solid;
  background: var(--brand-light); box-shadow: 0 0 0 4px rgba(63,81,181,.2);
}
.image-upload img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.image-upload span { color: var(--muted); font-size: 13px; text-align: center; padding: 12px; line-height: 1.5; }
.image-upload input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.recognition-status { margin-top: 8px; font-size: 12px; color: var(--muted); line-height: 1.5; }

/* ===== Cost Split (2:8 price:remark) ===== */
.cost-split-label { gap: 6px; }
.cost-split-row { display: flex; gap: 8px; width: 100%; }
.cost-price-input { flex: 2; min-width: 60px; }
.cost-remark-input { flex: 8; min-width: 80px; }

/* ===== Form Fields ===== */
.field-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
label { display: flex; flex-direction: column; gap: 5px; }
label .label-text { font-size: 13px; font-weight: 500; color: var(--text-secondary); }
label .label-hint { font-size: 11px; color: var(--muted); font-weight: 400; }

input[type="text"],
input[type="number"],
input[type="date"],
select {
  width: 100%; height: 42px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); font-size: 14px; transition: all .15s;
}
input:focus, select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(63,81,181,.1); outline: none;
}
input::placeholder { color: var(--placeholder); }
input[type="number"] { -moz-appearance: textfield; font-variant-numeric: tabular-nums; }
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ===== Fabric Cards ===== */
.fabric-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); margin-bottom: 10px; overflow: hidden;
  transition: box-shadow .15s;
}
.fabric-card:hover { box-shadow: var(--shadow); }

.fabric-card-header {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; background: #fafafa; border-bottom: 1px solid var(--border-light);
}
.fabric-card-index { font-size: 13px; font-weight: 600; color: var(--brand); white-space: nowrap; }
.fabric-type-select {
  width: 90px; height: 34px; padding: 0 8px; font-size: 13px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: #fff; flex-shrink: 0;
}
.fabric-name-input { flex: 1; min-width: 120px; height: 34px; }
.fabric-delete-btn {
  width: 30px; height: 30px; border: 1px solid transparent; border-radius: var(--radius-sm);
  background: transparent; color: var(--muted); font-size: 18px;
  cursor: pointer; display: grid; place-items: center; flex-shrink: 0; transition: all .15s;
}
.fabric-delete-btn:hover { background: var(--danger-light); color: var(--danger); border-color: var(--danger-light); }

.fabric-inputs {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; padding: 12px;
}

/* ===== Size Toggle ===== */
.size-toggle-label {
  display: flex !important; flex-direction: row !important;
  align-items: center; gap: 10px;
  margin-top: 14px; padding: 10px 0; cursor: pointer; user-select: none;
}
.size-toggle-label input[type="checkbox"] { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track {
  width: 44px; height: 24px; border-radius: 12px;
  background: #d4d4d8; position: relative; transition: background .2s; flex-shrink: 0;
}
.toggle-track .toggle-thumb {
  position: absolute; top: 2px; left: 2px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: var(--shadow-sm); transition: transform .2s;
}
.size-toggle-label input:checked + .toggle-track { background: var(--accent); }
.size-toggle-label input:checked + .toggle-track .toggle-thumb { transform: translateX(20px); }
.toggle-text { font-size: 14px; font-weight: 500; color: var(--text); }

/* ===== Size Table ===== */
#sizeSection { margin-top: 10px; }
.size-table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -2px; padding-bottom: 4px; }

.size-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
.size-table th, .size-table td {
  padding: 8px 10px; text-align: center; border: 1px solid var(--border-light);
  white-space: nowrap;
}
.size-table th {
  background: #f4f4f5; font-weight: 600; color: var(--text-secondary);
  font-size: 13px; position: relative;
}
.size-table td { background: var(--surface); }
.size-table td:first-child, .size-table th:first-child {
  text-align: left; position: sticky; left: 0; z-index: 1;
  background: #fafafa; min-width: 130px; font-weight: 500;
}
.size-table th:first-child { background: #f4f4f5; }
.size-table td input {
  width: 80px; height: 34px; padding: 0 6px; text-align: center;
  font-size: 13px; font-variant-numeric: tabular-nums;
}
.size-fabric-header { font-weight: 500; }
.size-fabric-type { font-size: 11px; color: var(--muted); }
.size-delete-btn {
  display: inline-block; width: 18px; height: 18px; border: 0;
  border-radius: 50%; background: transparent; color: var(--muted);
  font-size: 14px; cursor: pointer; line-height: 1; vertical-align: middle;
  margin-left: 2px;
}
.size-delete-btn:hover { background: var(--danger-light); color: var(--danger); }

/* ===== Online Showroom Entrance ===== */
.showroom-entrance {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: linear-gradient(135deg, #f0f4ff 0%, #e8edf9 100%);
  border: 1px solid #c8d6e5;
}

.showroom-entrance-content {
  display: flex;
  align-items: center;
  gap: 14px;
}

.showroom-icon {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: var(--brand-muted, #e8ecf4);
  color: var(--brand, #3f51b5);
}

.showroom-info h3 {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 4px 0;
  color: var(--text);
}

.showroom-info p {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
}

.showroom-btn {
  width: 100%;
  text-align: center;
  text-decoration: none;
}

/* ===== Breakdown Panel ===== */
.breakdown-panel { position: sticky; top: 16px; }

.style-summary {
  display: grid; grid-template-columns: 72px 1fr; gap: 14px; align-items: start;
  margin-bottom: 18px; padding: 12px; border-radius: var(--radius);
  background: #fafafa; border: 1px solid var(--border-light);
}
.style-thumb {
  display: grid; place-items: center; width: 72px; height: 72px;
  border-radius: var(--radius-sm); border: 1px dashed var(--border);
  background: var(--surface); overflow: hidden; color: var(--muted);
  font-size: 11px; text-align: center;
}
.style-thumb img { width: 100%; height: 100%; object-fit: contain; }
.summary-info { display: flex; flex-direction: column; gap: 2px; }
.summary-info p { font-size: 12px; color: var(--text-secondary); line-height: 1.6; }

.breakdown {
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
.fabric-breakdown-section { margin-bottom: 0; }

.breakdown-item {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; padding: 12px 14px; font-size: 14px;
  background: var(--surface); border-bottom: 1px solid var(--border-light);
}
.breakdown-item:last-child { border-bottom: 0; }
.breakdown-item .bd-label { color: var(--text-secondary); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.breakdown-item .bd-value { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.breakdown-item.subtotal { background: #fafafa; }
.breakdown-item.subtotal .bd-label { font-weight: 600; color: var(--text); }
.breakdown-item.fabric-row .bd-label { font-size: 13px; }
.breakdown-item.quote {
  padding: 14px; background: linear-gradient(135deg, var(--brand), #1e2050);
}
.breakdown-item.quote .bd-label { color: rgba(255,255,255,.8); font-weight: 600; font-size: 15px; }
.breakdown-item.quote .bd-value { color: #fff; font-weight: 800; font-size: 20px; letter-spacing: -.5px; }

.breakdown-subhead {
  font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 8px;
}

/* ===== Fabric Type Badge ===== */
.fabric-type-badge {
  display: inline-block; padding: 1px 6px; border-radius: 4px;
  font-size: 11px; font-weight: 600; line-height: 1.5; text-align: center;
}
.badge-main { background: #e8eaf6; color: #2d3a7a; }
.badge-lining { background: #e0f2fe; color: #0369a1; }
.badge-ribbing { background: #fce7f3; color: #be185d; }
.badge-acc { background: #fef3c7; color: #92400e; }
.badge-other { background: #f4f4f5; color: #52525b; }

.fabric-weight-hint {
  font-size: 11px; color: var(--muted); font-weight: 400; margin-left: 4px;
}

/* ===== Formula Box ===== */
.formula-box {
  margin-top: 16px; padding: 14px 16px; border-radius: var(--radius);
  background: var(--warm-light); border-left: 3px solid var(--warm);
}
.formula-box h3 { font-size: 13px; font-weight: 600; color: #92400e; margin-bottom: 6px; }
.formula-box p { font-size: 12px; color: #a16207; line-height: 1.6; }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 110;
  background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center;
}
.modal-overlay[hidden] { display: none; }

.modal-dialog {
  width: 460px; max-width: 92vw; max-height: 85vh;
  background: var(--surface); border-radius: var(--radius-xl);
  box-shadow: 0 24px 80px rgba(0,0,0,.18); display: flex; flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 14px; border-bottom: 1px solid var(--border-light);
}
.modal-header h2 { font-size: 18px; font-weight: 700; }

.modal-body { padding: 18px 20px; overflow-y: auto; flex: 1; }

.modal-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 20px; border-top: 1px solid var(--border-light);
}

/* Save format radio group */
.save-format-group, .save-size-group {
  border: 0; margin-bottom: 16px;
}
.save-format-group legend, .save-size-group legend {
  font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 10px;
}

.save-radio {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px;
  padding: 10px 12px; margin-bottom: 6px; border: 1px solid var(--border);
  border-radius: var(--radius); cursor: pointer; transition: all .15s;
}
.save-radio:hover { background: var(--surface-hover); }
.save-radio:has(input:checked) {
  border-color: var(--accent); background: var(--brand-light);
}
.save-radio input[type="radio"] { width: 16px; height: 16px; accent-color: var(--accent); flex-shrink: 0; }
.save-radio > span { font-size: 14px; font-weight: 500; color: var(--text); }
.save-radio small { font-size: 11px; color: var(--muted); width: 100%; margin-left: 24px; }

.size-presets { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.size-chip { margin-bottom: 0; }
.size-chip small { margin: 0; width: auto; }
.size-chip:has(input:checked) small { color: var(--accent); }

/* ===== History Drawer ===== */
.history-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.35); display: flex; justify-content: flex-end;
}
.history-overlay[hidden] { display: none; }
.history-drawer {
  width: 420px; max-width: 100vw; height: 100%;
  background: var(--surface); box-shadow: -8px 0 40px rgba(0,0,0,.12);
  display: flex; flex-direction: column; padding: 20px; overflow-y: auto;
}
.drawer-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px;
}
.drawer-header h2 { font-size: 20px; font-weight: 700; }

.history-list { flex: 1; overflow-y: auto; }
.history-empty { color: var(--muted); font-size: 14px; text-align: center; padding: 40px 0; }

.history-item {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 12px 14px; margin-bottom: 8px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); transition: box-shadow .15s; cursor: default;
}
.history-item:hover { box-shadow: var(--shadow); }
.history-item-body { flex: 1; min-width: 0; cursor: pointer; }
.history-item-title { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-item-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.history-item-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ===== Toast ===== */
.toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  padding: 10px 20px; border-radius: 20px; background: rgba(24,24,27,.88);
  color: #fff; font-size: 13px; font-weight: 500; z-index: 200;
  opacity: 0; pointer-events: none; transition: opacity .3s;
  backdrop-filter: blur(8px); white-space: nowrap;
}
.toast.toast-show { opacity: 1; }
.toast-ok { color: #fff; background: rgba(13,148,136,.92); }
.toast-warn { color: #fff; background: rgba(217,119,6,.92); }
.toast-info { color: #fff; background: rgba(45,58,122,.92); }

/* ===== Floating Export Format Menu ===== */
.export-format-menu {
  position: fixed; z-index: 9999;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 4px; min-width: 170px;
}
.export-fmt-btn {
  display: block; width: 100%; text-align: left;
  padding: 10px 14px; border: none; border-radius: 6px;
  background: transparent; font-size: 13px; color: var(--text);
  cursor: pointer; transition: background .12s;
}
.export-fmt-btn:hover { background: var(--surface-hover); }

/* ===== Mobile Quote Bar ===== */
.mobile-quote-bar { display: none; }

/* ===== Login / Auth ===== */
.login-dialog { width: 400px; }
.auth-tabs { display: flex; gap: 0; margin-bottom: 18px; border-bottom: 2px solid var(--border-light); }
.auth-tab {
  flex: 1; padding: 10px 0; border: 0; background: transparent;
  font-size: 14px; font-weight: 500; color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all .15s;
}
.auth-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.auth-tab:hover:not(.active) { color: var(--text-secondary); }

.auth-pane { min-height: 140px; }
.auth-label { margin-bottom: 12px; }
.auth-label span { font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-bottom: 4px; display: block; }
.auth-label input { height: 44px; font-size: 14px; }

.auth-full-btn { width: 100%; height: 44px; justify-content: center; font-size: 14px; margin-top: 4px; }
.auth-error { color: var(--danger); font-size: 12px; margin-top: 8px; min-height: 18px; }
.auth-hint { color: var(--muted); font-size: 11px; margin-top: 6px; text-align: center; }

.auth-wx-hint { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 16px; }
.auth-wx-btn {
  width: 100%; height: 44px; justify-content: center; gap: 8px;
  background: #07C160; color: #fff; border-color: #07C160;
  font-size: 14px; font-weight: 500;
}
.auth-wx-btn:hover { background: #06AD56; border-color: #06AD56; }

/* User menu */
.user-menu { position: relative; }
.user-btn { gap: 6px; }
.user-avatar { font-size: 16px; line-height: 1; }
.user-dropdown {
  position: absolute; top: 100%; right: 0; margin-top: 4px;
  min-width: 140px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-md); overflow: hidden; z-index: 50;
}
.user-dropdown-item {
  display: block; width: 100%; padding: 10px 14px; border: 0;
  background: transparent; font-size: 13px; text-align: left; cursor: pointer;
  color: var(--text-secondary); transition: background .1s;
}
.user-dropdown-item:hover { background: var(--surface-hover); color: var(--danger); }

/* ===== Onboarding Overlay ===== */
.onboard-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(15,18,41,.88); display: flex;
  align-items: center; justify-content: center;
  backdrop-filter: blur(6px);
}
.onboard-overlay[hidden] { display: none; }

.onboard-card {
  width: 420px; max-width: 92vw; max-height: 85vh;
  background: var(--surface); border-radius: var(--radius-xl);
  box-shadow: 0 24px 80px rgba(0,0,0,.24); padding: 32px 28px 24px;
  display: flex; flex-direction: column; align-items: center;
  text-align: center; overflow-y: auto;
}
.onboard-header { margin-bottom: 24px; }
.onboard-logo {
  width: 56px; height: 56px; border-radius: var(--radius);
  background: linear-gradient(135deg, #2d3a7a, #3f51b5);
  color: #fff; font-size: 20px; font-weight: 800;
  display: grid; place-items: center; margin: 0 auto 10px;
  letter-spacing: 1px;
}
.onboard-title { font-size: 20px; font-weight: 700; color: var(--text); margin-bottom: 2px; }
.onboard-sub { font-size: 13px; color: var(--muted); }

.onboard-steps { width: 100%; display: flex; flex-direction: column; gap: 14px; margin-bottom: 24px; }
.onboard-step {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 14px 16px; border-radius: var(--radius);
  background: #fafafa; border: 1px solid var(--border-light);
  text-align: left;
}
.onboard-step-num {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--brand); color: #fff; font-size: 14px; font-weight: 700;
  display: grid; place-items: center; flex-shrink: 0;
}
.onboard-step strong { display: block; font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 3px; }
.onboard-step p { font-size: 12px; color: var(--muted); line-height: 1.5; margin: 0; }

.onboard-start-btn { width: 100%; height: 44px; font-size: 15px; justify-content: center; margin-bottom: 8px; }
.onboard-skip { font-size: 12px; color: var(--muted); cursor: pointer; margin: 0; }
.onboard-skip:hover { color: var(--text); }

/* ===== Responsive: Tablet ===== */
@media (max-width: 960px) {
  .main-grid { grid-template-columns: 1fr; }
  .breakdown-panel { position: static; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .style-info-layout { grid-template-columns: 160px 1fr; }
  .image-upload { aspect-ratio: auto; min-height: 200px; }
  .fabric-inputs { grid-template-columns: repeat(3, 1fr); }
  .history-drawer { width: 380px; }
}

/* ===== Responsive: Mobile ===== */
@media (max-width: 640px) {
  body { padding-bottom: 80px; }
  .app-shell { padding: 0 12px 20px; }

  .topbar { padding: 14px 0 10px; flex-direction: column; align-items: flex-start; gap: 10px; }
  .topbar-actions { width: 100%; display: flex; gap: 6px; flex-wrap: wrap; }
  .btn-group + .btn-group::before { display: none; }
  .btn-group { flex: 1 1 auto; }
  .btn-group .btn { flex: 1; justify-content: center; }
  .btn { justify-content: center; height: 40px; font-size: 12px; padding: 0 8px; }
  .brand-text h1 { font-size: 18px; }

  .hero-card { padding: 22px 20px; border-radius: var(--radius); }
  .hero-price { font-size: 42px; }
  .hero-meta { gap: 12px; font-size: 12px; }

  .stats-row { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat-card { padding: 14px; }
  .stat-card .stat-value { font-size: 20px; }

  .main-grid { gap: 10px; }
  .panel {
    padding: 18px; border-left: 0; border-right: 0; border-radius: 0;
  }

  .style-info-layout { grid-template-columns: 1fr; gap: 14px; }
  .image-upload { aspect-ratio: 1; min-height: auto; }
  .field-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .fabric-inputs { grid-template-columns: 1fr 1fr; gap: 8px; }
  .fabric-card-header { flex-wrap: wrap; }
  .fabric-name-input { min-width: 100px; }

  input[type="text"], input[type="number"], input[type="date"], select { height: 44px; font-size: 16px; }
  label .label-text { font-size: 14px; }

  .size-table td input { width: 70px; height: 36px; font-size: 16px; }
  .size-table td:first-child, .size-table th:first-child { min-width: 110px; }

  .breakdown-item { padding: 11px 12px; font-size: 13px; }
  .breakdown-item.quote .bd-value { font-size: 18px; }

  .history-drawer {
    width: 100%; height: 85vh; border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    position: absolute; bottom: 0; padding: 16px;
  }
  .history-overlay { align-items: flex-end; }

  .mobile-quote-bar {
    display: flex; position: fixed; inset: auto 0 0 0; z-index: 50;
    align-items: center; justify-content: space-between; gap: 12px;
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
    background: rgba(24,24,27,.96); backdrop-filter: blur(12px);
    color: #fff; box-shadow: 0 -4px 24px rgba(0,0,0,.15);
  }
  .mobile-quote-bar .mq-label { font-size: 11px; color: rgba(255,255,255,.6); text-transform: uppercase; letter-spacing: .5px; }
  .mobile-quote-bar .mq-price { font-size: 26px; font-weight: 800; letter-spacing: -.5px; }
  .mobile-quote-bar button {
    height: 42px; padding: 0 20px; border: 0; border-radius: var(--radius-sm);
    background: var(--accent); color: #fff; font-size: 14px; font-weight: 600;
    cursor: pointer; white-space: nowrap;
  }
  .mobile-quote-bar button:active { background: var(--accent-dark); }

  .toast { bottom: 90px; }

  .modal-dialog { margin: auto 12px; max-height: 80vh; border-radius: var(--radius-lg); }
  .save-radio { padding: 12px 10px; }
  .size-presets { grid-template-columns: 1fr 1fr; }
}

/* ===== OCR Auto-Fill Highlight Animation ===== */
@keyframes ocr-highlight {
  0% {
    background-color: #ccfbf1;
    border-color: #0d9488;
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.18);
  }
  60% {
    background-color: #e6fffa;
    border-color: #14b8a6;
    box-shadow: 0 0 0 1px rgba(13, 148, 136, 0.06);
  }
  100% {
    background-color: transparent;
    border-color: var(--border);
    box-shadow: none;
  }
}

input.ocr-filled,
select.ocr-filled {
  animation: ocr-highlight 1.8s ease-out forwards;
}

/* For the fabric card header (lighter background), use a subtler pulse */
.fabric-card-header input.ocr-filled,
.fabric-card-header select.ocr-filled {
  animation-name: ocr-highlight-light;
}

@keyframes ocr-highlight-light {
  0% {
    background-color: rgba(204, 251, 241, 0.35);
    border-color: #5eead4;
  }
  100% {
    background-color: transparent;
    border-color: var(--border);
  }
}
