/* =========================================================
   Warm Studio / Architectural Design System
   Zero external CDN · Zero OS Emoji · 4-Tier Responsive
   ========================================================= */

:root {
  --bg: #F6F5F1;
  --surface: #FFFFFF;
  --surface-subtle: #FAF9F6;
  --surface-warm: #EFECE5;
  --border: #E6E3DB;
  --border-strong: #D4CFC4;

  --ink: #1C1917;
  --ink-2: #44403C;
  --ink-muted: #78716C;
  --ink-faint: #A8A29E;

  --accent: #9A6B4C;
  --accent-hover: #83583C;
  --accent-soft: #F5ECE5;
  --accent-bd: #DFC7B6;

  --sage-bg: #EBF4EE;
  --sage-fg: #215B3A;
  --sage-bd: #C4E0CD;

  --ochre-bg: #FDF6E7;
  --ochre-fg: #8F5B14;
  --ochre-bd: #F0D9A8;

  --slate-bg: #EEF2F5;
  --slate-fg: #344C64;
  --slate-bd: #CFD9E3;

  --danger-bg: #FDF1F1;
  --danger-fg: #A12D2D;
  --danger-bd: #F2C9C9;

  --radius: 14px;
  --radius-md: 11px;
  --radius-sm: 9px;
  --shadow-card: 0 1px 2px rgba(28, 25, 23, 0.03), 0 6px 20px rgba(28, 25, 23, 0.035);
  --shadow-hover: 0 2px 6px rgba(28, 25, 23, 0.045), 0 12px 28px rgba(154, 107, 76, 0.09);
  --shadow-float: 0 14px 36px rgba(28, 25, 23, 0.16);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "PingFang SC", "HarmonyOS Sans SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.num { font-variant-numeric: tabular-nums; }
.mono { font-family: "Cascadia Mono", "JetBrains Mono", Consolas, "Microsoft YaHei", monospace; }
.muted { color: var(--ink-muted); font-size: 12.5px; }
.hidden { display: none !important; }

/* ==================== LOGIN VIEW ==================== */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 18% 18%, rgba(154, 107, 76, 0.09), transparent 42%),
    radial-gradient(circle at 82% 80%, rgba(28, 25, 23, 0.05), transparent 45%),
    linear-gradient(to right, rgba(28, 25, 23, 0.025) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(28, 25, 23, 0.025) 1px, transparent 1px);
  background-size: auto, auto, 36px 36px, 36px 36px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 36px 32px 30px;
  box-shadow: 0 18px 50px rgba(28, 25, 23, 0.08);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.login-kicker {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--accent);
  margin-bottom: 2px;
}

.login-card h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.login-sub {
  margin: 0 0 24px;
  font-size: 13px;
  color: var(--ink-muted);
}

.form-error {
  min-height: 18px;
  font-size: 12.5px;
  color: var(--danger-fg);
  margin-bottom: 10px;
}

.login-foot {
  margin: 18px 0 0;
  text-align: center;
  font-size: 12px;
  color: var(--ink-muted);
}

/* ==================== NAVBAR ==================== */
.navbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: 60px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.nav-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
  color: var(--ink);
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--ink);
  color: #FAF9F6;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-mark-lg {
  width: 44px;
  height: 44px;
  border-radius: 12px;
}

.brand-title-short { display: none; }

.brand-sub {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  margin-left: 2px;
  padding-left: 10px;
  border-left: 1px solid var(--border);
}

.nav-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg);
  padding: 4px;
  border-radius: 11px;
  border: 1px solid var(--border);
  min-width: 0;
}

.nav-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 14px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.nav-tab:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.65);
}

.nav-tab.active {
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(28, 25, 23, 0.08);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 11px 4px 5px;
  border-radius: 99px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--ink-2);
  font-weight: 500;
  white-space: nowrap;
}

.avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #FFFFFF;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
}

.mobile-bnav { display: none; }

/* ==================== CONTAINER & HEADERS ==================== */
.container {
  max-width: 1380px;
  margin: 0 auto;
  padding: 24px 28px 64px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px 20px;
  margin-bottom: 20px;
}

.page-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.page-sub {
  margin: 3px 0 0;
  font-size: 13px;
  color: var(--ink-muted);
}

.page-head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ==================== CARDS & BUTTONS ==================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow-card);
  margin-bottom: 16px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.card-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 15px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.btn:active:not(:disabled) { transform: translateY(0.5px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-block { width: 100%; height: 42px; font-size: 14px; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 12.5px; border-radius: 8px; }
.btn-xs { height: 27px; padding: 0 9px; font-size: 12px; border-radius: 7px; }

.btn-primary {
  background: var(--ink);
  color: #FAF9F6;
}
.btn-primary:hover:not(:disabled) { background: #2E2925; }

.btn-accent {
  background: var(--accent);
  color: #FFFFFF;
}
.btn-accent:hover:not(:disabled) { background: var(--accent-hover); }

.btn-outline {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--border-strong);
}
.btn-outline:hover:not(:disabled) {
  background: var(--surface-subtle);
  border-color: #B8B2A6;
}

.btn-danger-outline {
  background: var(--surface);
  color: var(--danger-fg);
  border-color: var(--danger-bd);
}
.btn-danger-outline:hover:not(:disabled) {
  background: var(--danger-bg);
}

.icon-btn {
  width: 31px;
  height: 31px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  padding: 0;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.icon-btn:hover:not(:disabled) {
  background: var(--surface-warm);
  color: var(--ink);
}

.icon-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.icon-btn.bordered {
  border-color: var(--border);
  background: var(--surface);
  color: var(--ink-2);
}
.icon-btn.bordered:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: var(--surface-subtle);
  color: var(--ink);
}

.icon-btn.danger-subtle { color: #B45353; }
.icon-btn.danger-subtle:hover:not(:disabled) {
  background: var(--danger-bg);
  border-color: var(--danger-bd);
  color: var(--danger-fg);
}

/* ==================== FORM INPUTS & SEARCH ==================== */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 6px;
}

.input {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-family: inherit;
  background: var(--surface);
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input::placeholder { color: var(--ink-faint); }
.input:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(28, 25, 23, 0.08);
}

textarea.input { resize: vertical; min-height: 64px; line-height: 1.5; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }

.search-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--ink-muted);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.search-field:focus-within {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(28, 25, 23, 0.07);
}
.search-field input {
  border: none;
  outline: none;
  background: transparent;
  width: 100%;
  min-width: 0;
  font-size: 13px;
  font-family: inherit;
  color: var(--ink);
}
.search-field input::placeholder { color: var(--ink-faint); }
.proj-search-field { width: 240px; }

/* Segmented Control */
.seg {
  display: inline-flex;
  background: var(--surface-warm);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
  flex-shrink: 0;
}

.seg-item {
  height: 28px;
  padding: 0 11px;
  border-radius: 7px;
  border: none;
  background: transparent;
  color: var(--ink-muted);
  font-size: 12.5px;
  font-weight: 500;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.seg-item:hover { color: var(--ink); }
.seg-item.active {
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(28, 25, 23, 0.08);
}

/* Dropzone File Input */
.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 18px 16px;
  border: 1.5px dashed var(--border-strong);
  border-radius: 11px;
  background: var(--surface-subtle);
  color: var(--ink-muted);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.dropzone:hover, .dropzone.has-file {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--ink);
}

.dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.dropzone-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  word-break: break-all;
}

.dropzone-hint {
  font-size: 11.5px;
  color: var(--ink-muted);
}

.dropzone-compact {
  padding: 8px 12px;
  min-height: 39px;
  flex-direction: row;
  gap: 6px;
}

.auto-hint {
  margin-top: 6px;
  font-size: 12px;
  color: var(--sage-fg);
  background: var(--sage-bg);
  border: 1px solid var(--sage-bd);
  border-radius: 7px;
  padding: 5px 10px;
}

/* ==================== BADGES & PROGRESS ==================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  border: 1px solid transparent;
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.badge-exact { background: var(--sage-bg); color: var(--sage-fg); border-color: var(--sage-bd); }
.badge-similar { background: var(--ochre-bg); color: var(--ochre-fg); border-color: var(--ochre-bd); }
.badge-manual { background: var(--slate-bg); color: var(--slate-fg); border-color: var(--slate-bd); }
.badge-pending { background: var(--surface-warm); color: var(--ink-2); border-color: var(--border); }
.badge-unmatched { background: var(--danger-bg); color: var(--danger-fg); border-color: var(--danger-bd); }

.job-banner {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-card);
}
.job-banner.done { background: var(--sage-bg); border-color: var(--sage-bd); border-left-color: var(--sage-fg); color: var(--sage-fg); }
.job-banner.error { background: var(--danger-bg); border-color: var(--danger-bd); border-left-color: var(--danger-fg); color: var(--danger-fg); }
.job-banner-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 13px; }
.job-pct { font-weight: 700; }
.progress-track { height: 6px; background: var(--surface-warm); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.progress-fill { height: 100%; background: var(--ink); border-radius: 99px; transition: width 0.3s ease; }
.job-banner.done .progress-fill { background: var(--sage-fg); }
.job-banner.error .progress-fill { background: var(--danger-fg); }

/* ==================== TAB 1: PROJECTS ==================== */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  box-shadow: var(--shadow-card);
}

.stat-lbl { font-size: 12px; color: var(--ink-muted); white-space: nowrap; }
.stat-num { font-size: 19px; font-weight: 700; color: var(--ink); white-space: nowrap; }
.stat-num.quote { color: var(--accent); }
.stat-num.profit { color: var(--sage-fg); }
.stat-pct { font-size: 12px; font-weight: 600; margin-left: 3px; }

.project-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}

.p-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.p-card:hover {
  transform: translateY(-2px);
  border-color: #CEC6B8;
  box-shadow: var(--shadow-hover);
}

.mood-strip {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
  padding: 10px 10px 0;
  background: var(--surface-subtle);
  border-bottom: 1px solid #EFECE5;
}

.mood-cell {
  height: 82px;
  background: #FFFFFF;
  border-radius: 8px 8px 0 0;
  border: 1px solid #ECE9E2;
  border-bottom: none;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  overflow: hidden;
}

.mood-cell img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: transform 0.25s ease;
}

.p-card:hover .mood-cell img { transform: scale(1.04); }

.mood-cell-blank {
  background: rgba(255, 255, 255, 0.55);
  border-style: dashed;
}

.mood-more {
  position: absolute;
  right: 16px;
  bottom: 8px;
  background: rgba(28, 25, 23, 0.8);
  color: #FFFFFF;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 99px;
}

.mood-empty {
  height: 92px;
  background: var(--surface-subtle);
  border-bottom: 1px solid #EFECE5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--ink-muted);
  font-size: 12px;
}

.mood-empty-grid { display: flex; gap: 6px; }
.mood-empty-grid div {
  width: 34px;
  height: 24px;
  border-radius: 5px;
  border: 1px dashed var(--border-strong);
  background: rgba(255, 255, 255, 0.65);
}

.p-body {
  padding: 18px 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
}

.p-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.p-title-wrap { min-width: 0; flex: 1; }

.p-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.35;
  letter-spacing: -0.01em;
  word-break: break-word;
}

.p-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 4px;
  font-size: 12.5px;
  color: var(--ink-muted);
  flex-wrap: wrap;
}

.p-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.p-meta-dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--border-strong);
  flex-shrink: 0;
}

.p-del-btn { opacity: 0.6; }
.p-card:hover .p-del-btn { opacity: 1; }

.prog-wrap { display: flex; flex-direction: column; gap: 6px; }
.prog-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-2); font-weight: 500; }
.prog-track { height: 5px; border-radius: 99px; background: var(--surface-warm); overflow: hidden; }
.prog-fill { height: 100%; border-radius: 99px; background: var(--sage-fg); transition: width 0.3s ease; }
.prog-fill.partial { background: var(--accent); }
.prog-fill.zero { background: #C7C2B8; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  background: var(--surface-subtle);
  border: 1px solid #EFECE5;
  border-radius: 10px;
  padding: 11px 10px;
}

.kpi-item { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding: 0 3px; }
.kpi-item + .kpi-item { border-left: 1px solid #E9E6DE; padding-left: 10px; }
.kpi-lbl { font-size: 11px; color: var(--ink-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-val { font-size: 15px; font-weight: 700; color: var(--ink); white-space: nowrap; }
.kpi-val.quote { color: var(--accent); }
.kpi-val.profit { color: var(--sage-fg); }
.kpi-val.zero { color: var(--ink-faint); }

.p-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 12px;
  margin-top: auto;
  border-top: 1px solid #F0EDE7;
}

.p-time { font-size: 12px; color: var(--ink-muted); white-space: nowrap; }

.p-enter {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.p-card:hover .p-enter {
  background: var(--ink);
  color: #FAF9F6;
  border-color: var(--ink);
}

/* Compact Project List View */
.project-table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  overflow-x: auto;
}

.project-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 760px;
}

.project-table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-muted);
  background: var(--surface-subtle);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.project-table td {
  padding: 13px 16px;
  border-bottom: 1px solid #F0EDE7;
  vertical-align: middle;
}

.project-table tbody tr {
  cursor: pointer;
  transition: background 0.12s ease;
}

.project-table tbody tr:hover { background: var(--surface-subtle); }
.project-table tbody tr:last-child td { border-bottom: none; }

.pt-main { display: flex; align-items: center; gap: 12px; }
.pt-thumb {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  border: 1px solid #ECE9E2;
  background: var(--surface-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3px;
  flex-shrink: 0;
  overflow: hidden;
}
.pt-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.pt-title { font-weight: 700; color: var(--ink); }
.pt-sub { font-size: 12px; color: var(--ink-muted); margin-top: 2px; }
.pt-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.tr { text-align: right; }

/* Empty state */
.empty-state {
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 52px 24px;
  text-align: center;
}
.empty-state-icon {
  width: 48px;
  height: 48px;
  border-radius: 13px;
  background: var(--surface-warm);
  color: var(--ink-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}
.empty-state h3 { margin: 0 0 6px; font-size: 16px; color: var(--ink); }
.empty-state p { margin: 0 auto 18px; max-width: 440px; font-size: 13px; color: var(--ink-muted); }

/* ==================== TAB 2: WORKBENCH ==================== */
.wb-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 16px;
  box-shadow: var(--shadow-card);
  margin-bottom: 14px;
}

.wb-bar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex-wrap: wrap;
}

.wb-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex-wrap: wrap;
}

.wb-title {
  margin: 0;
  font-size: 16.5px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.wb-customer {
  font-size: 12.5px;
  color: var(--ink-muted);
  padding-left: 10px;
  border-left: 1px solid var(--border);
}
.wb-customer:empty { display: none; }

.wb-bar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.markup-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 3px 0 10px;
  background: var(--surface-subtle);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  font-size: 12px;
  color: var(--ink-muted);
  flex-shrink: 0;
}

.markup-pill label { font-weight: 600; white-space: nowrap; }

.markup-input {
  width: 54px;
  height: 24px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #FFFFFF;
  text-align: center;
  font-weight: 700;
  font-size: 12.5px;
  font-family: inherit;
  color: var(--ink);
  padding: 0 4px;
}
.markup-input:focus { outline: none; border-color: var(--ink); }

.markup-apply {
  height: 24px;
  padding: 0 9px;
  border-radius: 6px;
  border: none;
  background: var(--surface-warm);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  white-space: nowrap;
  cursor: pointer;
}
.markup-apply:hover { background: #E3DFD6; }

/* Export Dropdown */
.dropdown-wrap { position: relative; }

.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  width: 210px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 14px 36px rgba(28, 25, 23, 0.14);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dd-item {
  width: 100%;
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-2);
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
}
.dd-item:hover { background: var(--surface-subtle); color: var(--ink); font-weight: 600; }
.dd-tag { margin-left: auto; font-size: 10.5px; color: var(--ink-muted); font-weight: 500; }
.dd-sep { height: 1px; background: #EFECE5; margin: 4px 6px; }

/* Filter Strip */
.filter-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.filter-pills {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.f-pill {
  height: 30px;
  padding: 0 12px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 500;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
  transition: all 0.14s ease;
}
.f-pill:hover { border-color: var(--border-strong); color: var(--ink); }
.f-pill.active { background: var(--ink); color: #FAF9F6; border-color: var(--ink); font-weight: 600; }
.f-cnt { font-size: 11px; opacity: 0.72; }
.filter-hint { font-size: 12px; color: var(--ink-muted); }

/* Workbench Item Card */
.wb-item-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.wb-item-head {
  background: var(--surface-subtle);
  border-bottom: 1px solid #EFECE5;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.wb-head-left {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
  min-width: 0;
}

.item-idx {
  min-width: 28px;
  height: 25px;
  padding: 0 7px;
  border-radius: 7px;
  background: var(--surface-warm);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.wb-pos-txt {
  font-size: 12px;
  color: var(--ink-muted);
}

.wb-ocr-pill {
  font-size: 11px;
  background: var(--ochre-bg);
  color: var(--ochre-fg);
  border: 1px solid var(--ochre-bd);
  border-radius: 99px;
  padding: 2px 9px;
  font-weight: 600;
}

.wb-head-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.status-select {
  height: 31px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-2);
  font-family: inherit;
  cursor: pointer;
}
.status-select:focus { outline: none; border-color: var(--ink); }

/* Workbench 3-Column Body (>= 1240px) */
.wb-item-body {
  display: grid;
  grid-template-columns: 286px minmax(0, 1fr) 298px;
  gap: 20px;
  padding: 18px;
}

.wb-col-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-muted);
}

.wb-sku-heading {
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 700;
  margin-left: 4px;
}

.img-box {
  width: 100%;
  height: 186px;
  background: var(--surface-subtle);
  border: 1px solid #ECE9E2;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  overflow: hidden;
  cursor: zoom-in;
  position: relative;
}

.img-box img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: transform 0.2s ease;
}
.img-box:hover img { transform: scale(1.03); }
.img-box .empty-img { color: var(--ink-faint); font-size: 12.5px; cursor: default; }

.wb-field { margin-top: 10px; }
.wb-field label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-muted);
  margin-bottom: 4px;
}
.wb-field .input { font-size: 12.5px; padding: 6px 9px; }
.wb-field textarea.input { min-height: 52px; font-size: 13px; }

.wb-factory-split {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.wb-factory-split .img-box { height: 158px; }

.loc-box {
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 11.5px;
  color: var(--ink-2);
  white-space: pre-line;
  line-height: 1.55;
  margin-bottom: 8px;
}

.loc-box-head {
  font-weight: 700;
  color: var(--ink);
  font-family: inherit;
  display: block;
  margin-bottom: 2px;
}

.wb-mat-info {
  font-size: 12px;
  color: var(--ink-muted);
  line-height: 1.55;
  word-break: break-word;
}
.wb-mat-info strong { color: var(--ink-2); }
.wb-mat-remark { color: var(--ochre-fg); margin-top: 4px; }

.wb-unmatched-box {
  padding: 34px 20px;
  text-align: center;
  background: var(--surface-subtle);
  border: 1.5px dashed var(--border-strong);
  border-radius: 10px;
}
.wb-unmatched-box p { margin: 0 0 12px; font-size: 12.5px; color: var(--ink-muted); }

/* Right Pricing Column */
.wb-col-pricing {
  border-left: 1px solid #EFECE5;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
}

.wb-margin-tag {
  font-size: 12px;
  font-weight: 700;
  color: var(--sage-fg);
}

.price-grid {
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
}

.price-box {
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 7px 8px;
}

.price-box.price-sell {
  background: var(--accent-soft);
  border-color: var(--accent-bd);
}

.price-box label {
  display: block;
  font-size: 11px;
  color: var(--ink-muted);
  margin-bottom: 3px;
  white-space: nowrap;
}

.price-box.price-sell label { color: var(--accent); font-weight: 600; }

.price-box input {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: #FFFFFF;
  padding: 4px 6px;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.price-box input:focus { outline: none; border-color: var(--ink); }
.price-box.price-sell input { color: var(--accent); border-color: var(--accent-bd); }

.subtotal-box {
  margin-top: 10px;
  background: var(--surface-subtle);
  border: 1px solid #EFECE5;
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12.5px;
}

.sub-row { display: flex; justify-content: space-between; align-items: center; color: var(--ink-2); }
.sub-row.total { border-top: 1px solid #E6E3DB; padding-top: 6px; margin-top: 2px; font-weight: 600; color: var(--ink); }
.sub-sell { color: var(--accent); }
.sub-profit { color: var(--sage-fg); }

/* AI Candidates Strip */
.cand-strip {
  border-top: 1px solid #EFECE5;
  background: #FAF9F5;
  padding: 11px 18px;
}

.cand-strip-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.cand-list {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 2px 0 4px;
  margin-top: 10px;
}

.cand-chip {
  flex: 0 0 212px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.cand-chip:hover { border-color: var(--accent); }
.cand-chip.selected {
  border-color: var(--sage-fg);
  background: #F6FBF8;
  box-shadow: 0 0 0 1px var(--sage-fg);
}

.cand-thumb {
  width: 58px;
  height: 54px;
  flex-shrink: 0;
  background: var(--surface-subtle);
  border: 1px solid #EFECE5;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  overflow: hidden;
}
.cand-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }

.cand-meta { min-width: 0; flex: 1; font-size: 11.5px; line-height: 1.4; }
.cand-row { display: flex; justify-content: space-between; align-items: baseline; gap: 4px; color: var(--ink); }
.cand-sub { font-size: 10.5px; color: var(--ink-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cand-lvl { font-size: 11px; font-weight: 600; margin-top: 2px; }
.cand-lvl.exact { color: var(--sage-fg); }
.cand-lvl.similar { color: var(--ochre-fg); }

/* Floating Sticky Warm-Charcoal Summary Bar */
.summary-float {
  position: sticky;
  bottom: 14px;
  z-index: 30;
  margin-top: 18px;
  background: rgba(28, 25, 23, 0.96);
  backdrop-filter: blur(10px);
  color: #FAF9F6;
  padding: 13px 22px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  box-shadow: var(--shadow-float);
}

.sum-stats {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.sum-item > span {
  display: block;
  font-size: 11px;
  color: #A8A29E;
  white-space: nowrap;
}

.sum-item > strong {
  font-size: 16.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.sum-sage { color: #86EFAC; }
.sum-gold { color: #FDE68A; }
.sum-div { width: 1px; height: 26px; background: rgba(255, 255, 255, 0.13); }

.sum-actions { display: flex; align-items: center; gap: 8px; }

.btn-dark-ghost {
  height: 33px;
  padding: 0 13px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #FAF9F6;
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  cursor: pointer;
}
.btn-dark-ghost:hover { background: rgba(255, 255, 255, 0.18); }

.btn-dark-accent {
  height: 33px;
  padding: 0 14px;
  border-radius: 8px;
  background: #FAF9F6;
  border: none;
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 700;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  cursor: pointer;
}
.btn-dark-accent:hover { background: #FFFFFF; }

/* ==================== TAB 3: FACTORIES & CATALOG ==================== */
.subtab-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
}

.subtabs {
  display: inline-flex;
  gap: 4px;
  background: var(--surface-warm);
  border: 1px solid var(--border);
  padding: 4px;
  border-radius: 11px;
}

.subtab {
  height: 34px;
  padding: 0 15px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s ease;
}

.subtab:hover { color: var(--ink); }
.subtab.active {
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(28, 25, 23, 0.08);
}

.subtab-cnt {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 99px;
  background: var(--bg);
  color: var(--ink-muted);
  font-weight: 600;
}

.filter-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-card);
}

.catalog-search-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

select.cat-factory-select { width: 196px; flex: 0 0 196px; height: 36px; padding: 0 10px; }
.catalog-search-input { flex: 1 1 220px; min-width: 160px; }

.sheet-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 12px;
}

.pill-prefix { align-self: center; }

.pill {
  padding: 5px 12px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--surface-subtle);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
  transition: all 0.14s ease;
}

.pill:hover { border-color: var(--border-strong); color: var(--ink); background: var(--surface); }
.pill.active {
  background: var(--ink);
  color: #FAF9F6;
  border-color: var(--ink);
  font-weight: 600;
}

.cat-meta-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.cat-mobile-tip { font-size: 12px; color: var(--ink-muted); }

/* SKU Gallery Grid */
.sku-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.sku-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-card);
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.sku-card:hover {
  transform: translateY(-2px);
  border-color: #CEC6B8;
  box-shadow: var(--shadow-hover);
}

.sku-img-wrap {
  position: relative;
  width: 100%;
  height: 176px;
  background: var(--surface-subtle);
  border-bottom: 1px solid #EFECE5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  overflow: hidden;
}

.sku-img-wrap img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: transform 0.25s ease;
}
.sku-card:hover .sku-img-wrap img { transform: scale(1.04); }

.sku-sheet-tag {
  position: absolute;
  left: 10px;
  top: 10px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  color: var(--ink-2);
  font-weight: 500;
  max-width: calc(100% - 20px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sku-img-empty { color: var(--ink-faint); font-size: 12.5px; }

.sku-body {
  padding: 13px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.sku-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.sku-code-wrap {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  flex: 1;
}

.sku-code {
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sku-item-name {
  font-size: 12px;
  color: var(--ink-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sku-price {
  color: var(--sage-fg);
  font-size: 16.5px;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}
.sku-price .yen { font-size: 12px; margin-right: 1px; }

.sku-meta {
  font-size: 11.5px;
  color: var(--ink-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding-bottom: 7px;
  border-bottom: 1px solid #F0EDE7;
}

.sku-material {
  background: var(--surface-subtle);
  border: 1px solid #EFECE5;
  border-radius: 8px;
  padding: 7px 9px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--ink-2);
  white-space: pre-line;
  word-break: break-word;
}

.sku-mat-tag {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 0 6px;
  border-radius: 4px;
  margin-right: 6px;
  vertical-align: 1px;
}

.sku-tiers { display: flex; flex-direction: column; gap: 3px; margin-top: 2px; }
.sku-tier-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 3px 0;
  border-bottom: 1px dashed #EFECE5;
  font-size: 12px;
  line-height: 1.4;
}
.sku-tier-row:last-child { border-bottom: none; }
.sku-tier-spec { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.sku-tier-right { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; flex-shrink: 0; }
.sku-tier-price { font-weight: 700; color: var(--ink); }
.sku-tier-cell {
  font-size: 10px;
  color: var(--ink-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 0 4px;
  border-radius: 4px;
}

.sku-tier-more {
  margin-top: 2px;
  padding: 2px 0;
  border: none;
  background: transparent;
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}
.sku-tier-more:hover { text-decoration: underline; }

.sku-remark {
  background: var(--ochre-bg);
  border: 1px solid var(--ochre-bd);
  color: var(--ochre-fg);
  border-radius: 7px;
  padding: 5px 8px;
  font-size: 11.5px;
  line-height: 1.45;
}

.sku-loc {
  margin-top: auto;
  background: var(--surface-subtle);
  border: 1px solid #ECE9E2;
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 10.5px;
  color: var(--ink-muted);
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Factory Management List */
.factory-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 15px 18px;
  margin-bottom: 10px;
  background: var(--surface-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.factory-item:last-child { margin-bottom: 0; }
.factory-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.factory-name { font-size: 15.5px; font-weight: 700; color: var(--ink); }
.factory-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* Pagination */
.cat-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 22px;
}

.pg-btn {
  min-width: 34px;
  height: 34px;
  padding: 0 11px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: all 0.14s ease;
}
.pg-btn:hover:not(:disabled) { border-color: var(--ink); color: var(--ink); }
.pg-btn.active { background: var(--ink); border-color: var(--ink); color: #FAF9F6; }
.pg-btn:disabled { opacity: 0.42; cursor: not-allowed; }
.pg-ellipsis { padding: 0 4px; color: var(--ink-faint); font-weight: 700; }
.pg-jump { display: inline-flex; align-items: center; gap: 6px; margin-left: 8px; font-size: 12.5px; color: var(--ink-muted); }
.pg-jump input {
  width: 52px;
  height: 32px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  text-align: center;
  font-size: 12.5px;
  font-family: inherit;
  background: var(--surface);
}

/* ==================== TAB 4: SETTINGS ==================== */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  align-items: start;
}

.settings-card { margin-bottom: 0; }

.settings-card-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid #F0EDE7;
}

.settings-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--surface-warm);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.settings-card-head .muted { margin: 3px 0 0; }
.test-ai-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.settings-save-row { display: flex; justify-content: flex-end; margin-top: 6px; }

/* ==================== MODALS, DRAWER & LIGHTBOX ==================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(28, 25, 23, 0.46);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: 0 24px 64px rgba(28, 25, 23, 0.24);
}

.modal-box.wide { max-width: 1060px; }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.modal-title {
  margin: 0;
  font-size: 16.5px;
  font-weight: 700;
  color: var(--ink);
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid #F0EDE7;
}

/* Picker Modal */
.picker-search-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
select.picker-factory-select { width: 180px; flex: 0 0 180px; height: 36px; padding: 0 10px; }
.picker-search-input { flex: 1 1 200px; min-width: 160px; }
.picker-grid {
  max-height: 58vh;
  overflow-y: auto;
  padding: 4px 4px 8px 0;
  grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: 12px;
}
.picker-card { cursor: default; }
.picker-card .sku-img-wrap { height: 142px; cursor: zoom-in; }

/* SKU Detail Drawer (Desktop Modal -> Mobile Bottom Sheet) */
.drawer-sheet {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 20px 22px 24px;
  box-shadow: 0 24px 64px rgba(28, 25, 23, 0.26);
}

.drawer-handle { display: none; }

.drawer-img-stage {
  width: 100%;
  height: 220px;
  background: var(--surface-subtle);
  border: 1px solid #ECE9E2;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  margin: 12px 0 16px;
  cursor: zoom-in;
}
.drawer-img-stage img { max-width: 100%; max-height: 100%; object-fit: contain; }

.drawer-sec-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-muted);
  margin: 14px 0 6px;
}

.drawer-mat-box {
  background: var(--surface-subtle);
  border: 1px solid #EFECE5;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink-2);
  white-space: pre-line;
  word-break: break-word;
}

.drawer-tier-list {
  border: 1px solid #EFECE5;
  border-radius: 10px;
  background: var(--surface-subtle);
  padding: 4px 12px;
}

.drawer-tier-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px dashed #E6E3DB;
  font-size: 13px;
}
.drawer-tier-row:last-child { border-bottom: none; }

.drawer-loc-box {
  margin-top: 14px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 9px;
  padding: 10px 12px;
  font-size: 12px;
  color: var(--ink-2);
  white-space: pre-line;
  line-height: 1.6;
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(18, 16, 14, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 220;
  cursor: zoom-out;
  padding: 24px;
}
.lightbox img {
  max-width: 92vw;
  max-height: 90vh;
  border-radius: 10px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
  background: #FFFFFF;
}
.lightbox-close {
  position: fixed;
  top: 18px;
  right: 20px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.14);
  color: #FFFFFF;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.lightbox-close:hover { background: rgba(255, 255, 255, 0.24); }

/* Toast */
.toast {
  position: fixed;
  top: 74px;
  right: 24px;
  background: var(--ink);
  color: #FAF9F6;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  z-index: 300;
  box-shadow: 0 12px 32px rgba(28, 25, 23, 0.24);
  max-width: calc(100vw - 32px);
}
.toast.ok { background: var(--sage-fg); }
.toast.err { background: var(--danger-fg); }

/* =========================================================
   RESPONSIVE BREAKPOINTS (4 Tiers)
   Tier 1: >= 1440px (Wide desktop — default above)
   Tier 2: 1024px – 1239px (Laptop 125%-150% DPI scaling)
   Tier 3: 768px – 1023px (Split-screen / Tablet)
   Tier 4: < 768px (Mobile Showroom Lookup & Light Edit)
   ========================================================= */

/* Tier 2: Compact Desktop / Laptop DPI Scaling (<= 1239px) */
@media (max-width: 1239px) {
  .brand-sub { display: none; }
  .navbar { padding: 0 20px; }
  .container { padding: 20px 20px 64px; }

  /* Workbench transitions to: Top 2-col Customer vs Factory side-by-side + Bottom Horizontal Pricing Bar! */
  .wb-item-body {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
  }

  .wb-factory-split {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .wb-factory-split .img-box { height: 186px; }

  .wb-col-pricing {
    grid-column: 1 / -1;
    border-left: none;
    padding-left: 0;
    border-top: 1px solid #EFECE5;
    padding-top: 14px;
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
    gap: 12px 18px;
    align-items: start;
  }
  .wb-col-pricing .wb-col-head { grid-column: 1 / -1; margin-bottom: 0; }
  .wb-col-pricing .subtotal-box { margin-top: 0; }
  .wb-col-pricing .wb-field { grid-column: 1 / -1; margin-top: 0; }

  .settings-grid { grid-template-columns: 1fr; }
}

/* Tier 2.5: Medium Laptop / Tablet Grid (<= 1099px) */
@media (max-width: 1099px) {
  .project-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Tier 3: Split-screen Laptop & Tablet (768px – 1023px) */
@media (max-width: 1023px) {
  .brand-title-full { display: none; }
  .brand-title-short { display: inline; }
  .navbar { padding: 0 16px; height: 56px; }
  .nav-tab { padding: 0 11px; font-size: 12.5px; }
  .proj-search-field { width: 200px; }
  .sum-stats { gap: 14px; }
  .sum-div-exact, .sum-item-exact { display: none; }
}

/* Tier 4: Mobile Showroom & Touch (< 768px) */
@media (max-width: 767px) {
  .navbar {
    height: 52px;
    padding: 0 14px;
  }
  .nav-tabs { display: none; }
  .brand-title-full { display: none; }
  .brand-title-short { display: inline; font-size: 15px; }
  .user-pill span:last-child { max-width: 72px; overflow: hidden; text-overflow: ellipsis; }

  /* Mobile Fixed Bottom Navigation */
  .mobile-bnav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    height: calc(58px + env(safe-area-inset-bottom, 0px));
    padding: 4px 8px env(safe-area-inset-bottom, 4px);
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-around;
  }

  .bnav-item {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--ink-muted);
    font-size: 11px;
    font-weight: 500;
    font-family: inherit;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 5px 4px;
    border-radius: 8px;
    cursor: pointer;
  }
  .bnav-item.active {
    color: var(--ink);
    font-weight: 700;
  }

  .container {
    padding: 14px 12px calc(92px + env(safe-area-inset-bottom, 0px));
  }

  .page-head { margin-bottom: 14px; gap: 12px; }
  .page-title { font-size: 19px; }
  .page-head-actions { width: 100%; }
  .proj-search-field { flex: 1; width: auto; min-width: 0; }
  .page-head-actions .btn-primary { width: 100%; }

  .stats-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
  .stat-card { padding: 11px 12px; flex-direction: column; gap: 3px; }
  .stat-num { font-size: 16px; }

  .project-grid { grid-template-columns: 1fr; gap: 14px; }
  .p-body { padding: 14px 15px; gap: 12px; }

  /* Workbench Mobile */
  .wb-bar { padding: 12px; gap: 10px; }
  .wb-bar-left { width: 100%; }
  .wb-bar-actions { width: 100%; }
  .wb-bar-actions .btn-primary { flex: 1; }
  .filter-hint { display: none; }
  .wb-item-head { padding: 10px 12px; }
  .wb-item-body {
    grid-template-columns: 1fr;
    padding: 12px;
    gap: 14px;
  }
  .img-box, .wb-factory-split .img-box { height: 170px; }
  .wb-col-pricing { grid-template-columns: 1fr; gap: 10px; }
  .cand-strip { padding: 10px 12px; }
  .cand-chip { flex: 0 0 185px; }

  /* Compact Floating Summary Bar right above Mobile Bottom Nav */
  #tab-workbench { padding-bottom: 68px; }
  .summary-float {
    bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    padding: 10px 12px;
    border-radius: 12px;
    gap: 8px;
  }
  .sum-stats { gap: 12px; }
  .sum-div, .sum-item-count, .sum-item-exact { display: none; }
  .sum-item > span { font-size: 10px; }
  .sum-item > strong { font-size: 13.5px; }
  .sum-actions .btn-dark-ghost { display: none; }
  .sum-actions .btn-dark-accent { height: 30px; padding: 0 11px; font-size: 12px; }

  /* Catalog Mobile: Clean 2-col Gallery + Tap for Bottom Sheet Drawer */
  .subtab-bar { gap: 8px; }
  .subtab { padding: 0 11px; font-size: 12.5px; }
  .filter-card { padding: 12px; }
  .catalog-search-row { flex-wrap: wrap; gap: 8px; }
  select.cat-factory-select { width: 100%; flex: 1 1 100%; }
  .catalog-search-input { flex: 1 1 0; min-width: 0; }
  .sheet-pills {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }
  .cat-meta-bar { flex-direction: column; align-items: flex-start; gap: 2px; }
  .sku-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .sku-img-wrap { height: 126px; padding: 8px; }
  .sku-sheet-tag { display: none; }
  .sku-body { padding: 9px 10px 10px; gap: 4px; }
  .sku-head { flex-direction: column; gap: 2px; }
  .sku-code { font-size: 13.5px; }
  .sku-item-name { display: none; }
  .sku-price { font-size: 15px; }
  .sku-meta { border-bottom: none; padding-bottom: 0; font-size: 11px; }
  /* Hide dense desktop material/tier/coord clutter inside tiny mobile cards — tapping opens bottom drawer! */
  .sku-card-catalog .sku-material,
  .sku-card-catalog .sku-tiers,
  .sku-card-catalog .sku-remark,
  .sku-card-catalog .sku-loc { display: none; }

  /* True Bottom Sheet Drawer on Mobile */
  .drawer-backdrop {
    align-items: flex-end;
    padding: 0;
  }
  .drawer-sheet {
    max-width: 100%;
    max-height: 85vh;
    border-radius: 20px 20px 0 0;
    padding: 10px 16px calc(20px + env(safe-area-inset-bottom, 0px));
    border-bottom: none;
  }
  .drawer-handle {
    display: block;
    width: 36px;
    height: 4px;
    border-radius: 99px;
    background: var(--border-strong);
    margin: 0 auto 12px;
  }
  .drawer-img-stage { height: 168px; }

  .modal-backdrop:not(.drawer-backdrop) { padding: 12px; }
  .modal-box { padding: 18px 16px; border-radius: 14px; }
  select.picker-factory-select { width: 100%; flex: 1 1 100%; }
  .picker-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .toast { top: auto; bottom: calc(70px + env(safe-area-inset-bottom, 0px)); right: 12px; left: 12px; text-align: center; }
}
