/* ──────────────────────────────────────────────────────────────────────
   Circuit Analyzer — SaaS dashboard theme (inspired by ProSale ref).
   Built on top of Bootstrap 5 with heavy overrides.
   ────────────────────────────────────────────────────────────────────── */

:root {
  --bg:        #f3f5f9;
  --surface:   #ffffff;
  --card:      #ffffff;
  --tint:      #f7f9fc;
  --border:    #e6eaf1;
  --border-2:  #eef1f6;

  --text:      #0f172a;
  --text-2:    #334155;
  --muted:     #64748b;
  --muted-2:   #94a3b8;

  --primary:        #2f80ed;
  --primary-soft:   #e9f1ff;
  --primary-ink:    #1d4ed8;

  --teal:           #10b981;
  --teal-soft:      #d1fae5;
  --teal-ink:       #065f46;

  --amber:          #f59e0b;
  --amber-soft:     #fef3c7;
  --amber-ink:      #92400e;

  --violet:         #8b5cf6;
  --violet-soft:    #ede9fe;
  --violet-ink:     #5b21b6;

  --danger:         #ef4444;
  --danger-soft:    #fee2e2;
  --danger-ink:     #991b1b;

  --radius:    16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --shadow:    0 1px 3px rgba(15,23,42,0.04), 0 4px 12px rgba(15,23,42,0.04);
  --shadow-md: 0 4px 12px rgba(15,23,42,0.06), 0 8px 24px rgba(15,23,42,0.05);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-ink); }

/* ── app shell ──────────────────────────────────────────────────────── */

.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

/* ── sidebar ────────────────────────────────────────────────────────── */

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 16px;
  border-bottom: 1px solid var(--border-2);
}
.brand-mark {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--teal), #0891b2);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  box-shadow: 0 4px 12px -2px rgba(16,185,129,0.4);
  flex-shrink: 0;
}
.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  min-width: 0;
}
.brand-name {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.015em;
  color: var(--text);
}
.brand-tagline {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 1px;
}

.nav-section { display: flex; flex-direction: column; gap: 2px; }
.nav-section-title {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-2);
  padding: 6px 10px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-weight: 500;
  font-size: 13.5px;
  transition: background .15s, color .15s;
}
.nav-item i { font-size: 16px; opacity: 0.85; }
.nav-item:hover { background: var(--tint); color: var(--text); }
.nav-item.active {
  background: var(--teal-soft);
  color: var(--teal-ink);
}
.nav-item.active i { color: var(--teal); opacity: 1; }

.sidebar-promo {
  margin-top: auto;
  background: linear-gradient(160deg, #0f172a, #1e293b);
  color: white;
  border-radius: var(--radius);
  padding: 18px 16px;
  text-align: center;
}
.promo-icon {
  width: 40px;
  height: 40px;
  margin: 0 auto 10px;
  border-radius: 50%;
  background: rgba(245,158,11,0.18);
  color: var(--amber);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}
.promo-title {
  font-size: 13px;
  font-weight: 700;
  margin: 0 0 4px;
}
.promo-text {
  font-size: 11.5px;
  color: rgba(255,255,255,0.65);
  margin: 0 0 12px;
  line-height: 1.5;
}
.btn-promo {
  background: var(--amber);
  color: #1f1300;
  border: 0;
  font-weight: 700;
  font-size: 12px;
  padding: 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: block;
}
.btn-promo:hover { background: #fbbf24; color: #1f1300; }

/* ── main ───────────────────────────────────────────────────────────── */

.main {
  padding: 24px 28px 32px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 4px;
}
.page-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.page-sub {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.key-field {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 4px 4px 14px;
  width: 340px;
  transition: border-color .15s, box-shadow .15s;
}
.key-field:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.key-field i { color: var(--muted-2); margin-right: 8px; }
.key-field input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 13px;
  font-family: inherit;
  padding: 6px 0;
  color: var(--text);
}
.key-field input::placeholder { color: var(--muted-2); }
.btn-key {
  background: var(--text);
  color: white;
  border: 0;
  border-radius: 999px;
  padding: 7px 14px;
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
}
.btn-key:hover { background: #1e293b; }

/* ── chips ──────────────────────────────────────────────────────────── */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.chip i { font-size: 12px; }
.chip-muted    { background: var(--tint);       color: var(--muted);    border: 1px solid var(--border); }
.chip-success  { background: var(--teal-soft);  color: var(--teal-ink); }
.chip-danger   { background: var(--danger-soft);color: var(--danger-ink); }
.chip-warning  { background: var(--amber-soft); color: var(--amber-ink); }
.chip-primary  { background: var(--primary-soft); color: var(--primary-ink); }

/* status pill state overrides */
#status[data-state="working"] { background: var(--amber-soft); color: var(--amber-ink); border-color: transparent; }
#status[data-state="ok"]      { background: var(--teal-soft);  color: var(--teal-ink); border-color: transparent; }
#status[data-state="err"]     { background: var(--danger-soft);color: var(--danger-ink); border-color: transparent; }

/* ── stat cards ─────────────────────────────────────────────────────── */

.stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
@media (max-width: 1200px) { .stat-row { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 700px)  { .stat-row { grid-template-columns: 1fr; } }

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: var(--shadow);
  transition: transform .15s, box-shadow .15s;
}
.stat-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.stat-head {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.stat-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.stat-icon-blue   { background: var(--primary-soft); color: var(--primary-ink); }
.stat-icon-green  { background: var(--teal-soft);    color: var(--teal-ink); }
.stat-icon-amber  { background: var(--amber-soft);   color: var(--amber-ink); }
.stat-icon-violet { background: var(--violet-soft);  color: var(--violet-ink); }
.stat-label {
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0.02em;
}
.stat-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
  margin-top: 2px;
}

/* ── workspace row ──────────────────────────────────────────────────── */

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: 14px;
}
@media (max-width: 1100px) { .workspace { grid-template-columns: 1fr; } }

/* ── panels ─────────────────────────────────────────────────────────── */

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-2);
}
.panel-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
.panel-sub {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}
.panel-body { padding: 18px 20px; }
.panel-body.p-0 { padding: 0; }

.field-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field-label { font-size: 12px; color: var(--text-2); font-weight: 500; }

.select-input {
  appearance: none;
  background: var(--tint) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 12px center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 32px 10px 12px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text);
  outline: 0;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.select-input:focus,
.select-input:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.or-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 12px;
  color: var(--muted-2);
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.or-divider::before, .or-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-2);
}

.upload-zone {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--tint);
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.upload-zone:hover,
.upload-zone.drag {
  background: var(--primary-soft);
  border-color: var(--primary);
}
.upload-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: white;
  border: 1px solid var(--border);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}
.upload-title { font-weight: 600; font-size: 13px; color: var(--text); }
.upload-sub { font-size: 11.5px; color: var(--muted); }

.preview-wrap {
  margin-top: 14px;
  background: var(--tint);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  min-height: 220px;
  max-height: 320px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.preview-wrap img { max-width: 100%; max-height: 320px; display: block; }
.preview-empty {
  color: var(--muted-2);
  font-size: 13px;
  text-align: center;
  padding: 40px 20px;
}
.preview-empty i { font-size: 28px; display: block; margin-bottom: 8px; opacity: 0.6; }

.path-label {
  margin-top: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--muted);
  word-break: break-all;
}

.action-row {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}
.action-row .btn { flex: 1; }

/* ── buttons (custom; not Bootstrap) ────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  transition: background .15s, border-color .15s, color .15s, transform .08s;
  user-select: none;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn i { font-size: 15px; }

.btn-cta {
  background: var(--text);
  color: white;
  font-size: 14px;
  padding: 11px;
  box-shadow: 0 4px 12px -2px rgba(15,23,42,0.3);
}
.btn-cta:hover:not(:disabled) { background: #1e293b; }

.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--tint);
  border-color: var(--muted-2);
}

.cta-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── breakdown panel ────────────────────────────────────────────────── */

.breakdown-body { max-height: 640px; overflow-y: auto; }

/* Rich category cards grid */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}
.category-card {
  background: var(--tint);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.category-card:hover {
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.cc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.cc-name-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}
.cc-name {
  font-weight: 700;
  font-size: 13.5px;
  color: var(--text);
  letter-spacing: -0.01em;
}
.cc-pct {
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 600;
}
.cc-count {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  font-weight: 700;
  background: var(--primary-soft);
  color: var(--primary-ink);
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.cc-bar {
  height: 4px;
  background: var(--border-2);
  border-radius: 999px;
  overflow: hidden;
}
.cc-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--teal));
  width: 0%;
  transition: width .6s ease;
}
.cc-items {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  max-height: 220px;
  overflow-y: auto;
}
.cc-items li {
  display: grid;
  grid-template-columns: 60px minmax(0, 1fr) minmax(0, auto);
  gap: 8px;
  align-items: baseline;
  padding: 4px 0;
  font-size: 12.5px;
  border-bottom: 1px dashed var(--border-2);
}
.cc-items li:last-child { border-bottom: 0; }
.cc-lbl {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 700;
  color: var(--amber-ink);
  background: var(--amber-soft);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11.5px;
  text-align: center;
}
.cc-val { color: var(--text); font-weight: 500; }
.cc-typ {
  color: var(--muted);
  font-size: 11px;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.breakdown-body .empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}
.breakdown-body .empty i {
  font-size: 32px;
  display: block;
  margin-bottom: 10px;
  opacity: 0.4;
}
.breakdown-body .empty small { color: var(--muted-2); }

.category-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-2);
}
.category-row:first-child { padding-top: 4px; }
.category-row:last-child { border-bottom: 0; }
.cat-info { min-width: 0; }
.cat-info-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.cat-info-name {
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text);
}
.cat-info-count {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
.cat-bar {
  height: 6px;
  background: var(--border-2);
  border-radius: 999px;
  overflow: hidden;
}
.cat-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--teal));
  width: 0%;
  transition: width .6s ease;
}
.cat-pct {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  text-align: right;
  min-width: 44px;
}

/* ── BOM table ──────────────────────────────────────────────────────── */

.bom-panel { margin-bottom: 16px; }
.bom-controls { display: flex; gap: 10px; }
.search-field {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--tint);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  width: 260px;
  transition: border-color .15s, box-shadow .15s;
}
.search-field:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.search-field i { color: var(--muted-2); }
.search-field input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 13px;
  font-family: inherit;
}

.bom-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.bom-table thead th {
  background: var(--tint);
  color: var(--muted);
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  padding: 12px 20px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.bom-table tbody td {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-2);
  color: var(--text-2);
}
.bom-table tbody tr:hover td { background: var(--tint); }
.bom-table tbody tr:last-child td { border-bottom: 0; }
.bom-table .lbl-cell {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--amber-ink);
  font-weight: 600;
}
.bom-table .empty-cell {
  text-align: center;
  color: var(--muted-2);
  padding: 40px 20px;
}
.bom-table .cat-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-ink);
  font-size: 11.5px;
  font-weight: 600;
}

.summary-card {
  margin: 0 20px 20px;
  padding: 14px 16px;
  background: var(--tint);
  border-left: 3px solid var(--teal);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.6;
}
.summary-card strong { color: var(--text); }

/* ── cost analysis loader (prominent banner) ───────────────────────── */

.cost-loader {
  position: relative;
  background: linear-gradient(135deg, var(--card), var(--tint));
  border: 1px solid var(--primary);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  padding: 18px 22px 18px 70px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-md), 0 0 0 3px var(--primary-soft);
  display: flex;
  align-items: center;
  gap: 16px;
  animation: fadein .3s ease;
  overflow: hidden;
}
.cl-pulse {
  position: absolute;
  left: 26px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 0 rgba(47,128,237, 0.6);
  animation: pulse 1.4s ease-out infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0  0   rgba(47,128,237, 0.55); }
  70%  { box-shadow: 0 0 0  18px rgba(47,128,237, 0); }
  100% { box-shadow: 0 0 0  0   rgba(47,128,237, 0); }
}
.cl-spinner {
  position: absolute;
  left: 22px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  border: 3px solid var(--primary-soft);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
.cl-text { flex: 1; min-width: 0; }
.cl-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.cl-title::after {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--danger);
  animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
.cl-sub {
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--muted);
}
.cl-sites {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.cl-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--tint);
  color: var(--muted);
  border: 1px solid var(--border);
  transition: all .25s ease;
}
.cl-chip.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  transform: scale(1.06);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.cl-chip.done {
  background: var(--teal-soft);
  color: var(--teal-ink);
  border-color: #99f6e4;
}
.cl-progress {
  height: 4px;
  background: var(--border-2);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 12px;
}
.cl-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--teal));
  animation: cl-fill 35s linear forwards;
}
@keyframes cl-fill {
  0%   { width: 0%; }
  90%  { width: 92%; }
  100% { width: 96%; }
}
.cl-eta {
  margin-top: 8px;
  font-size: 11px;
  color: var(--muted-2);
  font-style: italic;
}

/* ── cost analysis view ─────────────────────────────────────────────── */

.site-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}
.site-card {
  background: var(--tint);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color .15s, box-shadow .15s;
}
.site-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
}
.site-card-best {
  background: linear-gradient(135deg, var(--teal-soft), #ecfeff);
  border-color: var(--teal);
}
.site-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  display: flex;
  align-items: center;
}
.site-total {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
}
.site-delta {
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 600;
}
.site-card-best .site-delta { color: var(--teal-ink); }

.cost-table .min-price {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 700;
  color: var(--teal-ink);
}
.src-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.src-pill {
  display: inline-flex;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--tint);
  color: var(--muted);
  border: 1px solid var(--border);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.src-pill-min {
  background: var(--teal-soft);
  color: var(--teal-ink);
  border-color: #99f6e4;
}
.text-success { color: var(--teal-ink); font-weight: 600; }
.text-muted-strong { color: var(--muted); font-weight: 500; }

/* ── STL view ───────────────────────────────────────────────────────── */

.stl-row {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 18px;
}
@media (max-width: 1100px) { .stl-row { grid-template-columns: 1fr; } }

.stl-left { display: flex; flex-direction: column; }
.stl-right {
  background: var(--tint);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  min-height: 480px;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stl-preview-wrap { width: 100%; }
.stl-preview-img {
  width: 100%;
  height: auto;
  display: block;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: white;
  box-shadow: var(--shadow);
}

/* ── history view ───────────────────────────────────────────────────── */

.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.history-card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s, border-color .15s;
  display: flex;
  flex-direction: column;
}
.history-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}
.hc-thumb {
  width: 100%;
  height: 130px;
  object-fit: cover;
  background: var(--tint);
  border-bottom: 1px solid var(--border-2);
  display: block;
}
.hc-thumb-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted-2);
  font-size: 28px;
}
.hc-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.hc-title {
  font-weight: 700;
  font-size: 13.5px;
  color: var(--text);
  letter-spacing: -0.01em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-clamp: 2;
  overflow: hidden;
}
.hc-meta { display: flex; flex-wrap: wrap; gap: 5px; }
.hc-foot {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  gap: 6px;
}
.hc-file {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1;
}
.hc-when { white-space: nowrap; }
.hc-del {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 0;
  background: rgba(255,255,255,0.92);
  color: var(--danger);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  box-shadow: var(--shadow-sm);
  opacity: 0;
  transition: opacity .15s, background .15s;
}
.history-card:hover .hc-del { opacity: 1; }
.hc-del:hover { background: var(--danger-soft); }

/* ── animations ─────────────────────────────────────────────────────── */

.fadein { animation: fadein .35s ease; }
@keyframes fadein {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── scrollbars ─────────────────────────────────────────────────────── */

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted-2); }

/* ── responsive ─────────────────────────────────────────────────────── */

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; }
  .sidebar-promo { display: none; }
  .nav-section { flex-direction: row; gap: 6px; }
  .nav-section-title { display: none; }
  .topbar { flex-direction: column; align-items: stretch; }
  .key-field { width: 100%; }
}