/* ==========================================================================
   Lapidare — design system
   ========================================================================== */
:root {
  --bg: #0e0d0b;
  --bg-2: #121110;
  --surface: #171613;
  --surface-2: #1d1b18;
  --surface-3: #25221e;
  --line: #2b2823;
  --line-2: #38342d;
  --text: #ede7dc;
  --text-2: #c7bfb2;
  --muted: #8f877a;
  --gold: #c8a46a;
  --gold-2: #e2c595;
  --gold-soft: rgba(200, 164, 106, 0.12);
  --gold-line: rgba(200, 164, 106, 0.35);
  --success: #7dbb93;
  --success-soft: rgba(125, 187, 147, 0.12);
  --danger: #df7f72;
  --danger-soft: rgba(223, 127, 114, 0.12);
  --info: #86a8d6;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.7);
  --font-display: 'Cormorant Garamond', 'Times New Roman', serif;
  --font-ui: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --sidebar: 248px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--gold); color: #1a1712; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 10px; border: 2px solid var(--bg); }

.serif { font-family: var(--font-display); }
.muted { color: var(--muted); }
.gold { color: var(--gold); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.eyebrow {
  font-size: 10.5px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--gold); font-weight: 500;
}

/* ------------------------------------------------------------------ shell */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  background: linear-gradient(180deg, #13120f 0%, #0f0e0c 100%);
  border-right: 1px solid var(--line); padding: 26px 16px 18px;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 10px 26px; }
.brand svg { width: 34px; height: 34px; flex: none; }
.brand-name { font-family: var(--font-display); font-size: 26px; font-weight: 600; letter-spacing: 0.04em; line-height: 1; }
.brand-sub { font-size: 9.5px; letter-spacing: 0.26em; color: var(--muted); text-transform: uppercase; margin-top: 4px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase; color: #5f594f; padding: 18px 12px 8px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  color: var(--text-2); font-weight: 500; transition: background .15s, color .15s;
}
.nav a svg { width: 18px; height: 18px; opacity: .75; flex: none; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--gold-soft); color: var(--gold-2); box-shadow: inset 2px 0 0 var(--gold); }
.nav a.active svg { opacity: 1; }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--line); padding: 14px 8px 0; display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: linear-gradient(135deg, var(--gold), #8a6c3f); color: #17140f; font-weight: 600; font-size: 13px;
}
.sidebar-foot .who { min-width: 0; flex: 1; }
.sidebar-foot .who b { display: block; font-weight: 500; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-foot .who span { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }

.main { min-width: 0; }
.topbar { display: none; }
.page { padding: 34px 40px 60px; max-width: 1480px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 28px; flex-wrap: wrap; }
.page-head h1 { font-family: var(--font-display); font-weight: 600; font-size: 40px; line-height: 1.05; margin: 6px 0 0; letter-spacing: 0.01em; }
.page-head p { margin: 6px 0 0; color: var(--muted); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ------------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line-2);
  background: var(--surface-2); color: var(--text); font-weight: 500; cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s, opacity .15s; white-space: nowrap;
}
.btn:hover { background: var(--surface-3); border-color: #4a443a; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn svg { width: 17px; height: 17px; }
.btn-primary {
  background: linear-gradient(180deg, #d4b27a, #b8924f); border-color: #caa66a; color: #1a1610;
  box-shadow: 0 8px 22px -10px rgba(200, 164, 106, .7), inset 0 1px 0 rgba(255,255,255,.25);
}
.btn-primary:hover { background: linear-gradient(180deg, #dcbb85, #c09a57); border-color: #d6b27a; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--line); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: rgba(223,127,114,.4); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn-icon { width: 40px; padding: 0; }
.btn-sm.btn-icon { width: 32px; }
.btn-block { width: 100%; }

/* ------------------------------------------------------------------ cards / panels */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.panel-head h2, .panel-head h3 { margin: 0; font-family: var(--font-display); font-size: 22px; font-weight: 600; }
.panel-body { padding: 22px; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 22px; }
.kpi {
  position: relative; overflow: hidden; padding: 20px 22px; border-radius: var(--radius);
  background: radial-gradient(120% 140% at 100% 0%, rgba(200,164,106,.10), transparent 55%), var(--surface);
  border: 1px solid var(--line);
}
.kpi .label { font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
.kpi .value { font-family: var(--font-display); font-size: 34px; font-weight: 600; line-height: 1.1; margin-top: 10px; }
.kpi .sub { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.kpi .sub b { color: var(--success); font-weight: 500; }
.kpi svg.deco { position: absolute; right: 16px; top: 16px; width: 22px; height: 22px; color: var(--gold); opacity: .8; }

.grid-2 { display: grid; grid-template-columns: 1.5fr 1fr; gap: 18px; }
.grid-2-eq { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.stack { display: flex; flex-direction: column; gap: 18px; }

/* ------------------------------------------------------------------ forms */
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field > label, .label-sm { font-size: 11.5px; letter-spacing: .06em; color: var(--muted); font-weight: 500; }
.input, select.input, textarea.input {
  width: 100%; height: 42px; padding: 0 13px; border-radius: 10px; border: 1px solid var(--line-2);
  background: var(--bg-2); color: var(--text); outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea.input { height: auto; min-height: 84px; padding: 11px 13px; resize: vertical; }
.input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
.input[readonly] { background: transparent; border-style: dashed; color: var(--text-2); }
.input-group { display: flex; align-items: stretch; }
.input-group .input { border-radius: 10px 0 0 10px; }
.input-group .addon {
  display: grid; place-items: center; padding: 0 12px; border: 1px solid var(--line-2); border-left: 0;
  border-radius: 0 10px 10px 0; background: var(--surface-2); color: var(--muted); font-size: 13px;
}
.input-group .addon.pre { order: -1; border-left: 1px solid var(--line-2); border-right: 0; border-radius: 10px 0 0 10px; }
.input-group .addon.pre + .input { border-radius: 0 10px 10px 0; }
.input-group select.addon { appearance: none; cursor: pointer; padding: 0 12px; }
.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.col-12 { grid-column: span 12; } .col-8 { grid-column: span 8; } .col-6 { grid-column: span 6; }
.col-4 { grid-column: span 4; } .col-3 { grid-column: span 3; } .col-2 { grid-column: span 2; }
.search { position: relative; }
.search svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); }
.search .input { padding-left: 38px; }
.hint { font-size: 12px; color: var(--muted); }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 20px; }
.toolbar .search { flex: 1; min-width: 220px; max-width: 420px; }
.toolbar select.input { width: auto; min-width: 160px; }
.seg { display: inline-flex; padding: 3px; border-radius: 11px; background: var(--bg-2); border: 1px solid var(--line-2); }
.seg button {
  border: 0; background: transparent; color: var(--muted); height: 34px; padding: 0 14px; border-radius: 8px; cursor: pointer; font-weight: 500;
}
.seg button.on { background: var(--surface-3); color: var(--text); box-shadow: 0 1px 0 rgba(255,255,255,.04) inset; }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { display: none; }
.switch .track { width: 38px; height: 22px; border-radius: 22px; background: var(--surface-3); border: 1px solid var(--line-2); position: relative; transition: background .15s; }
.switch .track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--text-2); transition: transform .15s, background .15s; }
.switch input:checked + .track { background: var(--gold-soft); border-color: var(--gold-line); }
.switch input:checked + .track::after { transform: translateX(16px); background: var(--gold); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 13px; border-radius: 20px;
  border: 1px solid var(--line-2); background: var(--bg-2); color: var(--text-2); cursor: pointer; font-size: 13px;
}
.chip.on { border-color: var(--gold-line); background: var(--gold-soft); color: var(--gold-2); }
.chip small { color: var(--muted); }

/* ------------------------------------------------------------------ badges */
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 20px;
  font-size: 11px; font-weight: 500; letter-spacing: .03em; border: 1px solid transparent; white-space: nowrap;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { color: var(--success); background: var(--success-soft); border-color: rgba(125,187,147,.25); }
.badge.sold { color: var(--danger); background: var(--danger-soft); border-color: rgba(223,127,114,.25); }
.badge.draft { color: var(--gold-2); background: var(--gold-soft); border-color: var(--gold-line); }
.badge.done { color: var(--info); background: rgba(134,168,214,.12); border-color: rgba(134,168,214,.25); }

/* ------------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted);
  font-weight: 500; padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td { padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr.click { cursor: pointer; transition: background .12s; }
.table tbody tr.click:hover { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table th.num { text-align: right; }
.thumb { width: 44px; height: 44px; border-radius: 9px; object-fit: cover; background: var(--surface-3); flex: none; }
.cell-prod { display: flex; align-items: center; gap: 12px; min-width: 0; }
.cell-prod b { font-weight: 500; display: block; }
.code { font-family: ui-monospace, 'SF Mono', Consolas, monospace; font-size: 11.5px; color: var(--gold); letter-spacing: .04em; }

/* ------------------------------------------------------------------ product grid */
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; }
.pcard {
  position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; cursor: pointer; transition: transform .2s, border-color .2s, box-shadow .2s;
}
.pcard:hover { transform: translateY(-3px); border-color: var(--gold-line); box-shadow: var(--shadow); }
.pcard .ph { aspect-ratio: 1 / 1; background: var(--surface-2); position: relative; overflow: hidden; }
.pcard .ph img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s; }
.pcard:hover .ph img { transform: scale(1.04); }
.pcard .ph .badge { position: absolute; top: 12px; right: 12px; backdrop-filter: blur(8px); background: rgba(14,13,11,.72); }
.pcard .ph .code-tag {
  position: absolute; top: 12px; left: 12px; padding: 3px 9px; border-radius: 20px; background: rgba(14,13,11,.72);
  backdrop-filter: blur(8px); font-family: ui-monospace, Consolas, monospace; font-size: 11px; color: var(--gold-2); letter-spacing: .05em;
}
.pcard .info { padding: 14px 16px 16px; }
.pcard .cat { font-size: 10px; letter-spacing: .18em; text-transform: uppercase; color: var(--gold); }
.pcard h4 { font-family: var(--font-display); font-size: 20px; font-weight: 600; margin: 4px 0 10px; line-height: 1.15;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 46px; }
.pcard .row { display: flex; justify-content: space-between; align-items: flex-end; gap: 8px; }
.pcard .price { font-family: var(--font-display); font-size: 24px; font-weight: 700; color: var(--text); line-height: 1; }
.pcard .meta { font-size: 12px; color: var(--muted); }
.pcard.sold .ph img { filter: grayscale(.7) brightness(.6); }
.pcard .sel {
  position: absolute; left: 12px; bottom: 12px; width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center;
  background: rgba(14,13,11,.75); border: 1px solid var(--line-2); color: transparent;
}
.pcard.selected { border-color: var(--gold); }
.pcard.selected .sel { background: var(--gold); border-color: var(--gold); color: #1a1610; }

.gem-ph { width: 100%; height: 100%; display: grid; place-items: center; background:
  radial-gradient(80% 80% at 50% 40%, #232019, #141310); color: var(--gold); }
.gem-ph svg { width: 34%; height: 34%; opacity: .55; }

/* ------------------------------------------------------------------ empty / loading */
.empty { text-align: center; padding: 70px 20px; color: var(--muted); }
.empty svg { width: 54px; height: 54px; color: var(--gold); opacity: .6; margin-bottom: 14px; }
.empty h3 { font-family: var(--font-display); font-size: 26px; color: var(--text); margin: 0 0 6px; font-weight: 600; }
.empty p { margin: 0 0 20px; }
.loading { display: grid; place-items: center; padding: 80px; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--gold); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ modal */
.modal-back {
  position: fixed; inset: 0; background: rgba(6,5,4,.72); backdrop-filter: blur(6px); z-index: 100;
  display: grid; place-items: center; padding: 20px; animation: fade .18s;
}
.modal {
  width: min(640px, 100%); max-height: calc(100vh - 40px); overflow: auto; background: var(--surface);
  border: 1px solid var(--line-2); border-radius: 18px; box-shadow: 0 40px 100px -30px #000; animation: pop .22s cubic-bezier(.2,.9,.3,1.2);
}
.modal.wide { width: min(980px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.modal-head h3 { margin: 0; font-family: var(--font-display); font-size: 26px; font-weight: 600; }
.modal-body { padding: 24px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: var(--surface); }
.modal-foot .spacer { flex: 1; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } }

/* ------------------------------------------------------------------ toasts */
#toasts { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  min-width: 260px; max-width: 380px; padding: 13px 16px; border-radius: 12px; background: var(--surface-3); border: 1px solid var(--line-2);
  box-shadow: var(--shadow); display: flex; gap: 10px; align-items: flex-start; animation: pop .25s;
}
.toast::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--gold); margin-top: 6px; flex: none; }
.toast.ok::before { background: var(--success); }
.toast.err::before { background: var(--danger); }

/* ------------------------------------------------------------------ photo picker */
.photo-drop {
  position: relative; aspect-ratio: 1/1; border-radius: var(--radius); border: 1px dashed var(--line-2); background: var(--bg-2);
  overflow: hidden; display: grid; place-items: center; cursor: pointer; transition: border-color .15s;
}
.photo-drop:hover { border-color: var(--gold); }
.photo-drop img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.photo-drop .ph-empty { text-align: center; color: var(--muted); padding: 20px; }
.photo-drop .ph-empty svg { width: 34px; height: 34px; color: var(--gold); margin: 0 auto 8px; }
.photo-drop .ph-actions { position: absolute; bottom: 10px; left: 10px; right: 10px; display: flex; gap: 8px; justify-content: center; }
.photo-drop .ph-actions .btn { background: rgba(14,13,11,.8); backdrop-filter: blur(6px); }
.ai-state { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); margin-top: 10px; }
.ai-state .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.ai-state.ok .dot { background: var(--success); }
.ai-state.busy .dot { background: var(--gold); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

/* ------------------------------------------------------------------ price calculator */
.calc { border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-2); padding: 18px; }
.calc-row { display: flex; justify-content: space-between; padding: 7px 0; color: var(--text-2); }
.calc-row b { font-weight: 500; color: var(--text); font-variant-numeric: tabular-nums; }
.calc-row.total { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 12px; }
.calc-row.total b { font-family: var(--font-display); font-size: 26px; font-weight: 700; color: var(--gold-2); }
.profit-pos { color: var(--success) !important; }
.profit-neg { color: var(--danger) !important; }

/* ------------------------------------------------------------------ purchase editor */
.items-table td { padding: 10px 8px; vertical-align: top; }
.items-table th { padding: 10px 8px; }
.items-table .input { height: 38px; padding: 0 10px; font-size: 13px; }
.items-table .input-group .addon { padding: 0 8px; font-size: 12px; }
.item-photo {
  width: 52px; height: 52px; border-radius: 10px; border: 1px dashed var(--line-2); background: var(--bg-2); cursor: pointer;
  display: grid; place-items: center; overflow: hidden; position: relative; color: var(--gold);
}
.item-photo img { width: 100%; height: 100%; object-fit: cover; }
.item-photo svg { width: 20px; height: 20px; }
.item-photo .emb { position: absolute; right: 3px; bottom: 3px; width: 8px; height: 8px; border-radius: 50%; background: var(--success); border: 1.5px solid var(--bg); }
.computed { font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 13px; line-height: 1.35; padding-top: 2px; }
.computed small { display: block; color: var(--muted); font-size: 11px; }
.share-bar { height: 4px; border-radius: 4px; background: var(--surface-3); margin-top: 6px; overflow: hidden; width: 70px; }
.share-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold-2)); }
.summary-sticky { position: sticky; top: 20px; }

/* ------------------------------------------------------------------ sale builder */
.sale-layout { display: grid; grid-template-columns: 1fr 400px; gap: 20px; align-items: start; }
.pick-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; max-height: calc(100vh - 290px); overflow: auto; padding: 2px; }
.pick { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; cursor: pointer; transition: border-color .15s; }
.pick:hover { border-color: var(--gold-line); }
.pick.in { border-color: var(--gold); opacity: .55; }
.pick .ph { aspect-ratio: 4/3; }
.pick .ph img { width: 100%; height: 100%; object-fit: cover; }
.pick .t { padding: 10px 12px; }
.pick .t b { display: block; font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pick .t span { font-family: var(--font-display); font-size: 18px; font-weight: 700; }
.cart-item { display: grid; grid-template-columns: 48px 1fr auto; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.cart-item .thumb { width: 48px; height: 48px; }
.cart-item .input { height: 34px; width: 120px; text-align: right; }

/* ------------------------------------------------------------------ chart */
.bars { display: flex; align-items: flex-end; gap: 14px; height: 200px; padding-top: 10px; }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; }
.bars .pair { display: flex; gap: 4px; align-items: flex-end; height: 100%; width: 100%; justify-content: center; }
.bars .bar { width: 38%; max-width: 22px; border-radius: 5px 5px 2px 2px; min-height: 2px; transition: height .6s cubic-bezier(.2,.8,.2,1); }
.bars .bar.s { background: linear-gradient(180deg, var(--gold-2), var(--gold)); }
.bars .bar.p { background: linear-gradient(180deg, #9dd1ae, #5f9d76); }
.bars .lbl { font-size: 11px; color: var(--muted); text-transform: capitalize; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 22px; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .grow b { font-weight: 500; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-row .grow span { font-size: 12px; color: var(--muted); }

.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 22px; }
.quick a {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); transition: border-color .15s, background .15s;
}
.quick a:hover { border-color: var(--gold-line); background: var(--surface-2); }
.quick a .ic { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--gold-soft); color: var(--gold-2); flex: none; }
.quick a .ic svg { width: 18px; height: 18px; }
.quick a b { font-weight: 500; display: block; }
.quick a span { font-size: 12px; color: var(--muted); }

/* ------------------------------------------------------------------ product detail */
.pdetail { display: grid; grid-template-columns: 300px 1fr; gap: 24px; }
.pdetail .kv { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 20px; margin-top: 18px; }
.kv .k { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.kv .v { font-size: 15px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.big-price { font-family: var(--font-display); font-size: 44px; font-weight: 700; color: var(--gold-2); line-height: 1; }

/* ------------------------------------------------------------------ auth */
.auth {
  min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr;
}
.auth-art {
  position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; padding: 48px;
  background: radial-gradient(90% 70% at 30% 30%, rgba(200,164,106,.16), transparent 60%), radial-gradient(60% 60% at 80% 90%, rgba(120,90,160,.12), transparent 60%), #0b0a09;
  border-right: 1px solid var(--line);
}
.auth-art .facets { position: absolute; inset: 0; opacity: .5; }
.auth-art h2 { font-family: var(--font-display); font-size: 58px; font-weight: 500; line-height: 1.02; margin: 0; max-width: 520px; position: relative; }
.auth-art h2 em { color: var(--gold-2); }
.auth-art p { color: var(--text-2); max-width: 440px; position: relative; font-size: 15px; }
.auth-form { display: grid; place-items: center; padding: 40px 24px; }
.auth-card { width: min(400px, 100%); }
.auth-card h1 { font-family: var(--font-display); font-size: 38px; font-weight: 600; margin: 8px 0 6px; }
.auth-card form { display: flex; flex-direction: column; gap: 16px; margin-top: 28px; }
.auth-card .switch-link { text-align: center; margin-top: 18px; color: var(--muted); }
.auth-card .switch-link a { color: var(--gold-2); cursor: pointer; }

/* ------------------------------------------------------------------ scanner */
.scan-page { position: fixed; inset: 0; left: var(--sidebar); background: #000; z-index: 5; overflow: hidden; }
.scan-page video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scan-vignette { position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 32%, rgba(0,0,0,.6) 80%); }
.reticle { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); pointer-events: none; transition: width .3s, height .3s; }
.reticle i { position: absolute; width: 34px; height: 34px; border: 2px solid var(--gold-2); filter: drop-shadow(0 0 6px rgba(226,197,149,.5)); transition: border-color .3s; }
.reticle i:nth-child(1) { left: 0; top: 0; border-right: 0; border-bottom: 0; border-radius: 14px 0 0 0; }
.reticle i:nth-child(2) { right: 0; top: 0; border-left: 0; border-bottom: 0; border-radius: 0 14px 0 0; }
.reticle i:nth-child(3) { left: 0; bottom: 0; border-right: 0; border-top: 0; border-radius: 0 0 0 14px; }
.reticle i:nth-child(4) { right: 0; bottom: 0; border-left: 0; border-top: 0; border-radius: 0 0 14px 0; }
.reticle .sweep { position: absolute; left: 8%; right: 8%; height: 2px; top: 0; background: linear-gradient(90deg, transparent, var(--gold-2), transparent); animation: sweep 2.2s ease-in-out infinite; opacity: .8; }
.reticle.locked i { border-color: var(--success); filter: drop-shadow(0 0 8px rgba(125,187,147,.6)); }
.reticle.locked .sweep { display: none; }
@keyframes sweep { 0%, 100% { top: 6%; } 50% { top: 94%; } }

.price-tag {
  position: absolute; left: 50%; transform: translate(-50%, -100%); min-width: 260px; max-width: min(360px, 90vw);
  background: rgba(16,15,13,.84); backdrop-filter: blur(14px) saturate(1.2); border: 1px solid var(--gold-line);
  border-radius: 16px; padding: 14px 18px 14px; box-shadow: 0 24px 60px -20px #000; opacity: 0; transition: opacity .25s, top .25s;
  pointer-events: auto; cursor: pointer;
}
.price-tag.show { opacity: 1; }
.price-tag::after {
  content: ''; position: absolute; left: 50%; bottom: -8px; width: 14px; height: 14px; transform: translateX(-50%) rotate(45deg);
  background: rgba(16,15,13,.9); border-right: 1px solid var(--gold-line); border-bottom: 1px solid var(--gold-line);
}
.price-tag .pt-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.price-tag .pt-price { font-family: var(--font-display); font-size: 40px; font-weight: 700; color: var(--gold-2); line-height: 1.05; margin: 4px 0 2px; }
.price-tag .pt-name { font-family: var(--font-display); font-size: 19px; font-weight: 600; line-height: 1.2; }
.price-tag .pt-meta { display: flex; gap: 14px; font-size: 12px; color: var(--text-2); margin-top: 8px; flex-wrap: wrap; }
.price-tag .conf { height: 3px; background: rgba(255,255,255,.08); border-radius: 3px; margin-top: 10px; overflow: hidden; }
.price-tag .conf i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--success)); transition: width .3s; }

.scan-top { position: absolute; top: 0; left: 0; right: 0; padding: 18px 20px; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: linear-gradient(180deg, rgba(0,0,0,.65), transparent); }
.scan-top .title { font-family: var(--font-display); font-size: 24px; font-weight: 600; }
.scan-status { font-size: 12.5px; color: var(--text-2); display: flex; align-items: center; gap: 8px; }
.scan-status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); animation: pulse 1.2s infinite; }
.scan-status.ready .dot { background: var(--success); animation: none; }
.scan-bottom { position: absolute; left: 0; right: 0; bottom: 0; padding: 16px 20px 22px; background: linear-gradient(0deg, rgba(0,0,0,.8), transparent); }
.scan-controls { display: flex; justify-content: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.scan-controls .btn { background: rgba(20,19,17,.75); backdrop-filter: blur(10px); border-color: rgba(255,255,255,.12); }
.scan-controls .btn.on { border-color: var(--gold); color: var(--gold-2); }
.candidates { display: flex; gap: 10px; overflow-x: auto; justify-content: center; padding-bottom: 2px; }
.cand { display: flex; align-items: center; gap: 10px; padding: 8px 12px 8px 8px; border-radius: 12px; background: rgba(20,19,17,.78);
  backdrop-filter: blur(10px); border: 1px solid rgba(255,255,255,.1); cursor: pointer; flex: none; min-width: 200px; }
.cand img, .cand .gem-ph { width: 42px; height: 42px; border-radius: 8px; object-fit: cover; flex: none; }
.cand b { display: block; font-size: 13px; font-weight: 500; max-width: 140px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cand span { font-size: 12px; color: var(--muted); }
.scan-msg { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); text-align: center; max-width: 420px; padding: 24px; }
.scan-msg h3 { font-family: var(--font-display); font-size: 28px; margin: 0 0 8px; }
.scan-search { position: absolute; inset: 0; background: var(--bg); overflow: auto; padding: 120px 40px 40px; }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1180px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quick { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-2-eq { grid-template-columns: 1fr; }
  .sale-layout { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; z-index: 60; width: 270px; transform: translateX(-100%); transition: transform .25s; box-shadow: var(--shadow);
  }
  .shell.nav-open .sidebar { transform: none; }
  .shell.nav-open::after { content: ''; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 50; }
  .topbar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: rgba(14,13,11,.9); backdrop-filter: blur(10px); z-index: 40; }
  .topbar .brand-name { font-size: 22px; }
  .page { padding: 22px 16px 50px; }
  .page-head h1 { font-size: 32px; }
  .form-grid > * { grid-column: span 12; }
  .form-grid > .col-3, .form-grid > .col-4, .form-grid > .col-2 { grid-column: span 6; }
  .pdetail { grid-template-columns: 1fr; }
  .auth { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .scan-page { left: 0; top: 0; z-index: 45; }
  .scan-search { padding: 120px 16px 30px; }
  .pgrid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  .pcard h4 { font-size: 17px; min-height: 40px; }
  .pcard .price { font-size: 20px; }
  .kpi .value { font-size: 28px; }
  .modal-back { padding: 0; align-items: end; }
  .modal { border-radius: 18px 18px 0 0; max-height: 94vh; }
}
@media (max-width: 520px) {
  .kpis, .quick { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 16px; }
  .kpi .value { font-size: 24px; }
  .quick a span { display: none; }
}

@media print {
  .sidebar, .topbar, .actions, #toasts { display: none !important; }
  body { background: #fff; color: #000; }
}
.thumb img, .thumb .gem-ph { width: 100%; height: 100%; object-fit: cover; }
.thumb .gem-ph svg { width: 50%; height: 50%; }
.catalog-layout { display: grid; grid-template-columns: 340px 1fr; gap: 18px; align-items: start; }
.kpis.kpis-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1000px) {
  .catalog-layout { grid-template-columns: 1fr; }
  .catalog-layout .summary-sticky { position: static; }
}
@media (max-width: 640px) { .kpis.kpis-3 { grid-template-columns: 1fr; } }
.seg button { display: inline-flex; align-items: center; gap: 7px; }
.seg button svg { width: 16px; height: 16px; flex: none; }
.seg button.on { color: var(--gold-2); background: var(--gold-soft); box-shadow: inset 0 0 0 1px var(--gold-line); }
.items-table .input.input-sub { height: 30px; margin-top: 6px; font-size: 12px; color: var(--text-2); }
.items-table td:nth-child(4) .input { min-width: 52px; }
.items-table .share-bar { width: 96px; margin: 5px 0 4px; }
.items-table .input.input-sub { height: 30px; margin-top: 6px; font-size: 12px; color: var(--text-2); }
.items-table td:nth-child(4) .input { min-width: 52px; }
.items-table .share-bar { width: 96px; margin: 5px 0 4px; }
.items-table .computed b { font-weight: 600; }
.items-table td, .items-table th { padding-left: 6px; padding-right: 6px; }
.items-table td:first-child, .items-table th:first-child { padding-left: 16px; }
.scan-seg { background: rgba(14,13,11,.7); backdrop-filter: blur(10px); }
.scan-controls .switch.btn { gap: 10px; }
.scan-controls .switch .track { transform: scale(.85); }
@media (max-width: 560px) {
  .scan-seg span { display: none; }
  .scan-top .title { font-size: 20px; }
  .scan-controls .btn { height: 36px; padding: 0 12px; font-size: 13px; }
  .price-tag .pt-price { font-size: 32px; }
  .cand { min-width: 170px; }
  .candidates { justify-content: flex-start; }
}
.scan-top { z-index: 4; }
.scan-search { padding-top: 96px; }
.candidates { scrollbar-width: none; }
.candidates::-webkit-scrollbar { display: none; }
.kpi .label { padding-right: 30px; }
.panel-head { flex-wrap: wrap; }
@media (max-width: 520px) {
  .panel-head { padding: 16px; }
  .panel-head h2, .panel-head h3 { font-size: 20px; }
  .kpi svg.deco { width: 18px; height: 18px; right: 12px; top: 12px; }
  .list-row { padding: 12px 16px; }
}
.pcard .ph .badge { top: auto; bottom: 12px; right: 12px; }
