:root,
html[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f6f8;
  --bg-2: #ffffff;
  --ink: #1c1f24;
  --muted: #8b919a;
  --line: #e7ebf0;
  --gold: #f5b400;
  --brass: #e2a61a;
  --card: #ffffff;
  --danger: #e15b55;
  --ok: #1f9d55;
  --warn: #d89a00;
  --shadow: 0 10px 28px rgba(28, 31, 36, 0.06);
  --side: #141414;
  --field: #ffffff;
  --sans: "Outfit", "Segoe UI", sans-serif;
  --serif: "Fraunces", Georgia, serif;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101114;
  --bg-2: #17191d;
  --ink: #f4f6f8;
  --muted: #a7adb6;
  --line: #2a2e35;
  --gold: #f5b400;
  --brass: #e2a61a;
  --card: #1c1f24;
  --danger: #ff8d86;
  --ok: #7dcea0;
  --warn: #f5b400;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
  --field: #14161a;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  letter-spacing: 0.01em;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--gold); }

#app { height: 100%; }
.login-screen {
  height: 100dvh;
  overflow: auto;
  scrollbar-width: none;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
}
.login-screen::-webkit-scrollbar { width: 0; height: 0; display: none; }
.login-brand {
  padding: 56px;
  background:
    radial-gradient(1000px 480px at -10% -20%, rgba(224, 193, 122, 0.18), transparent 50%),
    #090909;
  color: #f7f2e8;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.mark {
  width: 54px;
  height: 54px;
  border: 1px solid #e0c17a;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  color: #e0c17a;
  letter-spacing: 0.08em;
}
.login-brand h1 {
  font-family: var(--serif);
  font-weight: 560;
  font-size: 68px;
  line-height: 0.92;
  margin: 24px 0 12px;
}
.login-brand p { max-width: 440px; color: #d9ccb6; line-height: 1.5; }
.login-panel {
  display: grid;
  place-items: center;
  padding: 32px 20px;
  background: var(--bg);
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.login-card { width: min(420px, 100%); padding: 28px; }
.login-card h2 { font-family: var(--serif); font-size: 34px; margin: 0 0 6px; }
.muted { color: var(--muted); }
.hint {
  margin-top: 16px;
  padding: 12px 14px;
  border-left: 3px solid var(--brass);
  background: rgba(198, 161, 91, 0.08);
  color: var(--muted);
  font-size: 13px;
}

.shell { height: 100dvh; display: grid; grid-template-columns: 232px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; background: var(--bg); overflow: hidden; }
.side {
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: none;
  background: #141414;
  color: #f7f7f7;
  padding: 0 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}
.side::-webkit-scrollbar { width: 0; height: 0; display: none; }
.brand-lockup {
  margin: 0 -12px 8px;
  padding: 8px 8px 6px;
  background: #000;
  border-bottom: 3px solid #f5b400;
}
.brand-lockup img { width: 100%; height: auto; display: block; }
.login-logo { width: min(560px, 100%); height: auto; display: block; }
.foot-logo { height: 48px; width: auto; display: block; }
img.logo { display: block; width: 100%; height: auto; margin: 0 auto 6px; background: #000; }
.nav { display: flex; flex-direction: column; gap: 4px; padding-top: 8px; }
.nav button, .icon, .btn, .btn-line { border: 0; border-radius: 12px; }
.nav button, .nav-logout {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  background: transparent;
  color: #f3f3f3;
  padding: 11px 12px;
  border-radius: 12px;
}
.nav button svg, .nav-logout svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; flex: 0 0 auto; }
.nav button.active { background: #f5b400; color: #1a1408; font-weight: 650; }
.nav button:hover:not(.active) { background: rgba(255, 255, 255, 0.06); }
.nav-badge {
  margin-left: auto;
  min-width: 18px;
  height: 18px;
  border-radius: 99px;
  background: #e15b55;
  color: white;
  font-size: 11px;
  display: grid;
  place-items: center;
  padding: 0 5px;
}
.nav-logout { margin-top: auto; color: #f3f3f3; width: 100%; border: 0; background: transparent; font: inherit; cursor: pointer; }
.btn svg, .btn-line svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.side-foot { padding: 8px; color: #b5aa98; font-size: 12px; }
.main { min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 18px 22px 0;
}
.welcome { display: flex; gap: 10px; align-items: center; }
.top h2 { font-size: 28px; margin: 0; font-weight: 700; letter-spacing: -0.03em; }
.top .muted { margin: 2px 0 0; }
.top-actions { display: flex; gap: 8px; align-items: center; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--muted);
  box-shadow: var(--shadow);
}
#view { flex: 1; padding: 16px 22px 28px; display: grid; gap: 16px; align-content: start; min-height: 0; overflow-x: hidden; overflow-y: auto; scrollbar-width: none; }
#view::-webkit-scrollbar { width: 0; height: 0; display: none; }
.app-foot {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  background: #141414;
  color: #f6f1e4;
  padding: 10px 18px;
  font-size: 13px;
}
.live { color: #7dcea0; }
.gold-note { color: #f5b400; }

.kpi-row, .dash-mid, .dash-low, .stats, .split, .dealer-grid { display: grid; gap: 14px; }
.kpi-row, .stats { grid-template-columns: repeat(4, 1fr); }
.dash-mid { grid-template-columns: 270px minmax(0, 1fr) 250px; margin-top: 14px; }
.dash-low, .split { grid-template-columns: 1.35fr 0.8fr; margin-top: 14px; }
.kpi, .panel, .alert-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.kpi { padding: 16px 16px 14px; display: grid; grid-template-columns: minmax(0, 1fr) 46px; grid-template-rows: auto auto auto; gap: 2px 10px; min-height: 112px; align-items: start; }
.kpi span { grid-column: 1; grid-row: 1; }
.kpi strong { grid-column: 1; grid-row: 2; }
.kpi em { grid-column: 1; grid-row: 3; }
.kpi-icon { grid-column: 2; grid-row: 1 / span 3; align-self: start; }
.kpi.warn { background: #fff6f5; border-color: #ffd0cc; }
html[data-theme="dark"] .kpi.warn { background: #2a1c1c; border-color: #5a3030; }
.kpi span { color: var(--muted); font-size: 13px; }
.kpi strong { font-size: 28px; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.kpi em { font-style: normal; color: var(--ok); font-size: 12px; }
.kpi-icon { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: #fff6df; color: #e2a000; }
.kpi-icon svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 1.7; }
.kpi.warn .kpi-icon { background: #ffe8e6; color: #e15b55; }
.alert-card { padding: 14px; margin-bottom: 12px; display: grid; grid-template-columns: 54px minmax(0, 1fr) 32px; gap: 10px; align-items: start; }
.alert-card.low { background: #fff9ec; border-color: #ffe3a3; }
.alert-card.out { background: #fff5f4; border-color: #ffd0cc; }
html[data-theme="dark"] .alert-card.low { background: #2a2416; }
html[data-theme="dark"] .alert-card.out { background: #2a1c1c; }
.alert-card h3 { margin: 0 0 2px; font-size: 14px; }
.alert-card p { margin: 0; color: var(--muted); font-size: 13px; }
.alert-shot, .alert-shot img { width: 54px; height: 54px; border-radius: 12px; object-fit: cover; background: #f3f4f6; display: grid; place-items: center; }
.panel { padding: 18px 20px; }
.panel h3 { margin: 0 0 12px; font-size: 18px; }
.bar-row { display: grid; grid-template-columns: 110px 1fr auto; gap: 8px; align-items: center; margin: 7px 0; font-size: 13px; }
.bar { height: 7px; background: #f3f0e6; border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: #f5b400; }
.chip svg, .mark svg, .icon-btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.mark svg { width: 22px; height: 22px; }
.icon-btn { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line); background: transparent; color: var(--ink); display: inline-grid; place-items: center; padding: 0; }
.icon-btn.danger { color: var(--danger); }
.dot { width: 8px; height: 8px; border-radius: 99px; background: #3dcc78; display: inline-block; margin-right: 6px; }
.panel-head { display: flex; justify-content: space-between; gap: 8px; align-items: center; margin-bottom: 8px; }
.panel-head h3 { margin: 0; }
.panel-head select { padding: 8px 12px; border-radius: 10px; }
.chart { width: 100%; height: 210px; }
.chart text { fill: var(--muted); font-size: 11px; }
.donut-wrap { display: grid; grid-template-columns: 150px 1fr; gap: 8px; align-items: center; }
.donut { width: 150px; height: 150px; }
.legend { display: grid; gap: 8px; font-size: 13px; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 99px; margin-right: 6px; }
.dash-search { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; align-items: center; }
.dash-search input { flex: 1; min-width: 220px; border-radius: 999px; padding: 12px 16px; }
.linkish { background: none; border: 0; color: var(--brass); padding: 0; font-weight: 650; }

.table-wrap { overflow: visible; border: 1px solid var(--line); border-radius: 18px; background: var(--card); box-shadow: var(--shadow); max-width: 100%; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: 15px; overflow-wrap: break-word; }
.table-wrap th:last-child, .table-wrap td:last-child { width: 1%; white-space: nowrap; }
th { font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 650; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: rgba(198, 161, 91, 0.05); }
.empty { text-align: center; color: var(--muted); padding: 28px; }

.toolbar, .filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 14px; box-shadow: var(--shadow); }
.tab-end { margin-left: auto; }
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]),
select,
textarea {
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 16px;
  min-height: 50px;
  outline: none;
}
textarea { width: 100%; min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--brass); }
.grow { flex: 1; min-width: 180px; }
.btn, .btn-line, .icon {
  padding: 12px 16px;
  font-size: 15px;
  background: var(--ink);
  color: var(--bg);
}
html[data-theme="light"] .btn, html[data-theme="light"] .icon { color: #f7f2e8; background: #1b1712; }
.btn.gold, .btn.gold:hover { background: #f5b400; color: #1a1408; }
.btn-line, .icon.line {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn-line.danger { color: var(--danger); }
.icon { padding: 8px 10px; }
.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 99px;
  padding: 3px 8px;
  font-size: 12px;
  border: 1px solid var(--line);
}
.pill.ok, .pill.paid { background: #e8f8ef; color: #1f9d55; border-color: transparent; }
.pill.low, .pill.partial { background: #fff4d6; color: #b8860b; border-color: transparent; }
.pill.out, .pill.credit, .pill.void { background: #ffe8e6; color: #d64545; border-color: transparent; }
.alert-shot { overflow: hidden; }
.alert-shot .no-photo { color: #8b919a; letter-spacing: 0; text-transform: none; font-size: 11px; background: transparent; }

.notice {
  border: 1px solid var(--line);
  border-left: 3px solid var(--brass);
  background: var(--card);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 14px;
}
.notice + .notice { margin-top: -6px; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.three { display: grid; grid-template-columns: 1.3fr 0.8fr; gap: 14px; align-items: start; }
.cart {
  position: sticky;
  top: 16px;
  padding: 16px;
}
.cart h3 { margin-top: 0; }
.line {
  display: grid;
  grid-template-columns: 1fr 70px 90px auto;
  gap: 6px;
  align-items: center;
  margin-bottom: 8px;
}
.line input { width: 100%; padding: 12px 10px; min-height: 46px; font-size: 16px; }
.totals { display: flex; justify-content: space-between; margin: 6px 0; }
.totals.grand { font-size: 20px; font-family: var(--serif); }
.dealer-grid { grid-template-columns: repeat(2, 1fr); }
.dealer {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.dealer h3 { margin: 0; font-family: var(--serif); font-size: 26px; font-weight: 560; }
.menu-btn { display: none; }

.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 30;
}
.modal {
  width: min(1080px, 100%);
  max-height: min(92vh, 960px);
  overflow: auto;
  background: var(--bg-2);
  color: var(--ink);
  border-radius: 18px;
  border: 1px solid var(--line);
  padding: 22px;
}
.modal header, .modal footer { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.modal header .btn-line { flex: 0 0 auto; width: auto; min-height: 38px; padding: 8px 16px; }
.modal h3 { font-family: var(--serif); margin: 0; font-size: 28px; }
.modal form, .stack { display: grid; gap: 14px; }
label.stack span { font-size: 13px; color: var(--muted); letter-spacing: 0.05em; text-transform: uppercase; font-weight: 650; }
#toast {
  position: fixed;
  bottom: 16px;
  right: 16px;
  background: #14120e;
  color: #f7f2e8;
  border: 1px solid #e0c17a;
  padding: 12px 14px;
  border-radius: 12px;
  display: none;
  z-index: 60;
  max-width: 320px;
}
#print-root { display: none; }

.btn-line.on { border-color: var(--brass); color: var(--gold); }
.catalog { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.pcard { background: var(--card); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.pcard-body { padding: 12px; display: grid; gap: 6px; }
.shot { aspect-ratio: 1; width: 100%; border: 0; padding: 0; background: #12110e; display: grid; place-items: center; overflow: hidden; }
.shot img, .thumb img, .mini-shot img, .lib-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.no-photo { color: var(--gold); letter-spacing: 0.12em; text-transform: uppercase; font-size: 12px; }
.thumb { width: 76px; }
.thumb img, .thumb .no-photo { width: 64px; height: 64px; border-radius: 12px; display: grid; place-items: center; background: #12110e; }
.product-layout { display: grid; grid-template-columns: 1fr 280px; gap: 18px; align-items: start; }
.featured { display: grid; gap: 10px; padding: 14px; }
.featured .k { font-size: 13px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); font-weight: 650; }
.file-btn { display: grid; place-items: center; cursor: pointer; text-align: center; }
.file-btn input { display: none; }
.check { display: flex; align-items: center; gap: 10px; font-size: 16px; }
.check input { width: 18px; height: 18px; min-height: 0; }
.settings-grid { display: grid; grid-template-columns: 1.25fr 0.9fr; gap: 16px; align-items: start; }
.card.pad { padding: 22px; }
.settings-grid h3 { font-family: var(--serif); margin: 0; font-size: 28px; font-weight: 560; }
.stat-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.featured .shot { border-radius: 14px; border: 1px solid var(--line); }
.modal.wide { width: min(920px, 100%); }
.drop { border: 1.5px dashed var(--brass); border-radius: 14px; padding: 18px; text-align: center; margin: 8px 0 14px; }
.drop[data-busy="1"] { opacity: 0.55; }
.library-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: 8px; max-height: 360px; overflow: auto; }
.lib-item { padding: 0; border: 2px solid transparent; border-radius: 10px; overflow: hidden; background: #111; aspect-ratio: 1; }
.lib-item:hover { border-color: var(--brass); }
.sale-choice { width: 100%; display: flex; gap: 12px; align-items: center; text-align: left; padding: 10px 12px; border-radius: 14px; background: var(--card); }
.mini-shot { width: 54px; height: 54px; flex: 0 0 54px; border-radius: 12px; overflow: hidden; display: grid; place-items: center; background: #12110e; }
.pick-list { display: grid; gap: 8px; max-height: 340px; overflow: auto; scrollbar-width: none; }
.pick-list::-webkit-scrollbar { width: 0; height: 0; display: none; }
.dealer-line { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }
.dealer-line .btn { white-space: nowrap; }
.search-panel { display: grid; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: var(--bg); }
.plist { width: 100%; min-width: 0; }
.plist .thumb { width: 76px; }
.plist .thumb img, .plist .thumb .no-photo { width: 72px; height: 72px; border-radius: 12px; }
.plist .no-photo { letter-spacing: 0.02em; font-size: 11px; }
.sku-cell, td.num, th.num { white-space: nowrap; }
.act-row { display: flex; gap: 6px; flex-wrap: nowrap; align-items: center; }
.act-row .btn-line { white-space: nowrap; min-height: 42px; padding: 8px 14px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.mini-chip { border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 999px; padding: 8px 14px; min-height: 0; font-size: 14px; }
.mini-chip.on, .mini-chip:hover { border-color: var(--brass); background: #fff6df; }
html[data-theme="dark"] .mini-chip.on, html[data-theme="dark"] .mini-chip:hover { background: #2a2416; }
.cat-card { display: grid; gap: 8px; align-content: start; }
.cat-card h3 { font-family: var(--serif); margin: 0; font-size: 26px; font-weight: 560; }
.period-date { width: 170px; }
.qty-box { width: 150px; flex: 0 0 150px; }
input.line-qty { width: 120px; min-height: 44px; text-align: right; }
input[type="range"] { min-height: 28px; padding: 0; }
.logo-preview { width: 168px; height: 168px; object-fit: cover; border-radius: 18px; background: #111; }
.crop-wrap { display: grid; gap: 12px; justify-items: start; }
.crop-stage { width: min(320px, 100%); height: 320px; overflow: hidden; position: relative; border-radius: 16px; background: #111; touch-action: none; cursor: grab; }
.crop-stage img { position: absolute; left: 0; top: 0; max-width: none; user-select: none; pointer-events: none; }
#library.modal-back { z-index: 45; }

@media (max-width: 980px) {
  .login-screen, .shell, .stats, .kpi-row, .dash-mid, .dash-low, .split, .three, .dealer-grid, .two, .donut-wrap, .settings-grid { grid-template-columns: 1fr; }
  .side, .main { grid-row: 1; }
  .login-brand { padding: 32px 22px; }
  .login-brand h1 { font-size: 48px; }
  .product-layout { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 25; transform: translateX(-105%); width: min(280px, 86vw); }
  .side.open { transform: none; }
  .menu-btn { display: inline-flex; }
  #view, .top { padding-left: 16px; padding-right: 16px; }
  .top, .top-actions, .filters, .toolbar { flex-wrap: wrap; }
  .line { grid-template-columns: 1fr 1fr; }
  .table-wrap table, .table-wrap tbody, .table-wrap tr { display: block; width: 100%; }
  .table-wrap thead { display: none; }
  .table-wrap tr { padding: 12px 14px; border-bottom: 1px solid var(--line); }
  .table-wrap td { display: block; width: auto; white-space: normal; border: 0; padding: 3px 0; text-align: left; }
  .act-row { flex-wrap: wrap; }
  .plist .thumb { width: auto; }
}

@media print {
  body { background: white; color: black; }
  .shell, #modal-root, #toast { display: none !important; }
  #print-root { display: block !important; }
  @page { margin: 12mm; }
}
.sheet { font-family: Georgia, serif; color: black; }
.sheet h1 { font-size: 28px; margin: 0; }
.sheet h2 { font-size: 16px; letter-spacing: 0.14em; text-transform: uppercase; margin: 8px 0 0; }
.sheet table { width: 100%; border-collapse: collapse; margin-top: 12px; }
.sheet th, .sheet td { border-bottom: 1px solid #ccc; padding: 6px 4px; font-size: 13px; }
.rule { border-top: 2px solid #111; margin: 10px 0; }
.receipt { width: 72mm; font-family: "Courier New", monospace; font-size: 12px; color: black; }
.receipt img.logo, .sheet img.logo, .label-card img.logo { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
.sheet img.logo { width: 86mm; }
.label-card img.logo { width: 48mm; }
.receipt h1 { font-size: 16px; text-align: center; margin: 0; }
.receipt p, .receipt div { margin: 2px 0; }
.custom-line { display: grid; grid-template-columns: 1fr 96px 130px auto; gap: 8px; align-items: center; }
.receipt-foot { margin-top: 8px; font-size: 11px; }
.receipt table { width: 100%; }
.receipt td { border: 0; padding: 2px 0; font-size: 12px; }
.label-card { width: 58mm; border: 1px solid black; padding: 8px; font-family: var(--sans); }
.label-card strong { font-family: var(--serif); }
