:root {
  --bg: #f7f5f2;
  --bg-2: #f1ece7;
  --surface: #ffffff;
  --surface-2: #fbf9f7;
  --ink: #1e1c1b;
  --ink-2: #3d3835;
  --muted: #7a736d;
  --muted-2: #9c948d;
  --line: #e9e3dc;
  --line-strong: #dcd3ca;
  --brand: #a2603f;
  --brand-dark: #7f472c;
  --brand-soft: #f7ebe4;
  --coral: #f0645a;
  --coral-dark: #d94d43;
  --coral-soft: #fff0ee;
  --teal: #18a999;
  --teal-dark: #0e8e80;
  --teal-soft: #e7f8f5;
  --amber: #f0a72f;
  --amber-soft: #fff6e6;
  --danger: #d64545;
  --danger-soft: #fff0f0;
  --ok: #138a63;
  --ok-soft: #e7f8f2;
  --shadow: 0 12px 34px rgba(56, 42, 34, .07), 0 2px 6px rgba(56, 42, 34, .035);
  --shadow-lg: 0 24px 70px rgba(40, 29, 22, .22);
  --radius: 22px;
  --radius-sm: 14px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  background:
    radial-gradient(900px 600px at 8% -5%, #f3e7de 0%, rgba(243, 231, 222, 0) 60%),
    radial-gradient(700px 500px at 100% 10%, #e4f7f2 0%, rgba(228, 247, 242, 0) 55%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand); }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { letter-spacing: -0.025em; line-height: 1.15; }
h1 { font-size: clamp(26px, 3.2vw, 36px); font-weight: 780; }
h2 { font-size: 17px; font-weight: 740; }
h3 { font-size: 16px; font-weight: 720; }
small { font-size: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; line-height: 1.5; }
.pad { padding: 10px 0; }
.profit { color: var(--ok); }
.loss { color: var(--danger); }
.link { text-decoration: none; }
.link:hover { text-decoration: underline; }

.skip-link {
  position: fixed; top: -60px; left: 12px; z-index: 500;
  background: var(--ink); color: white; padding: 10px 14px; border-radius: 10px;
}
.skip-link:focus { top: 12px; }

.app-shell {
  width: 100%; max-width: 1320px; margin: 0 auto; min-height: 100vh; min-height: 100dvh;
  display: grid; grid-template-columns: 264px minmax(0, 1fr);
}
.main-wrap { min-width: 0; }

/* ---------- Sidebar ---------- */
.sidebar {
  position: sticky; top: 0; height: 100dvh;
  display: flex; flex-direction: column; gap: 28px;
  padding: 24px 18px 18px;
  background: linear-gradient(180deg, rgba(255,255,255,.72), rgba(250,249,255,.55));
  border-right: 1px solid var(--line);
  backdrop-filter: blur(18px);
}
.brand {
  display: flex; align-items: center; gap: 12px;
  background: none; border: 0; padding: 4px 6px; text-align: left; border-radius: 14px;
}
.brand:hover { background: rgba(162, 96, 63, .07); }
.brand-mark {
  width: 46px; height: 46px; border-radius: 15px; flex: 0 0 auto;
  display: block; object-fit: cover; padding: 0;
  background: #1f2227;
  box-shadow: 0 8px 20px rgba(31, 34, 39, .28);
}
.brand-mark.small { width: 34px; height: 34px; border-radius: 11px; box-shadow: none; }
.brand-copy { display: flex; flex-direction: column; }
.brand-copy strong { font-size: 15px; letter-spacing: -0.02em; }
.brand-copy small { color: var(--muted); font-size: 11.5px; }

.side-nav { display: flex; flex-direction: column; gap: 6px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  border: 0; background: transparent; color: var(--muted);
  padding: 11px 13px; border-radius: 13px; font-weight: 650; text-align: left;
  transition: background .18s, color .18s, transform .18s;
}
.nav-item svg { width: 20px; height: 20px; flex: 0 0 auto; }
.nav-item:hover { background: rgba(162, 96, 63, .07); color: var(--ink-2); }
.nav-item.active { background: var(--brand-soft); color: var(--brand-dark); }
.nav-item.active svg { stroke-width: 2.1; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; }
.sidebar-sync {
  display: flex; align-items: center; gap: 11px; text-align: left;
  border: 1px solid var(--line); background: var(--surface); border-radius: 16px;
  padding: 12px; box-shadow: var(--shadow);
}
.sidebar-sync:hover { border-color: var(--line-strong); }
.sidebar-sync-icon {
  width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center;
  color: var(--brand); background: var(--brand-soft); flex: 0 0 auto;
}
.sidebar-sync-icon svg { width: 19px; height: 19px; }
.sidebar-sync span:last-child { display: flex; flex-direction: column; min-width: 0; }
.sidebar-sync strong { font-size: 12.5px; }
.sidebar-sync small { color: var(--muted); font-size: 10.5px; }
.sidebar-note { color: var(--muted-2); font-size: 10.5px; text-align: center; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: flex-end; gap: 12px;
  padding: max(10px, env(safe-area-inset-top)) 28px 10px;
  background: rgba(247, 245, 242, .82);
  backdrop-filter: blur(16px);
}
.topbar-brand { display: none; align-items: center; gap: 9px; background: none; border: 0; font-weight: 750; letter-spacing: -0.02em; }
.topbar-actions { display: flex; align-items: center; gap: 9px; }
.user-pill {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 5px 10px 5px 5px; box-shadow: var(--shadow); cursor: pointer;
}
.user-avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: 0 0 auto;
  display: grid; place-items: center; background: var(--brand); color: white;
  font-weight: 800; font-size: 12px;
}
.user-copy { display: flex; flex-direction: column; line-height: 1.05; text-align: left; }
.user-copy strong { font-size: 12px; }
.user-copy small { color: var(--muted); font-size: 9.5px; }
.user-list { display: flex; flex-direction: column; gap: 8px; }
.user-option {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  border: 1px solid var(--line); background: var(--surface-2); border-radius: 14px; padding: 10px 12px;
}
.user-option:hover { border-color: var(--brand); }
.user-option.active { border-color: var(--brand); background: var(--brand-soft); }
.user-option-copy { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.user-option-copy b { font-size: 13px; }
.user-option-copy span { color: var(--muted); font-size: 11px; }
.audit-block { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 12px; }
.audit-block h3 { font-size: 14px; margin-bottom: 4px; }
.audit-list { display: flex; flex-direction: column; }
.audit-row { display: flex; align-items: flex-start; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.audit-row:last-child { border-bottom: 0; }
.audit-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.audit-main b { font-size: 12.5px; }
.audit-main span { color: var(--muted); font-size: 11px; }
.audit-time { color: var(--muted); font-size: 10px; white-space: nowrap; }
.sync-pill {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid transparent; border-radius: 999px;
  padding: 8px 13px; font-size: 12px; font-weight: 680; white-space: nowrap;
  transition: transform .16s, background .16s;
}
.sync-pill:hover { transform: translateY(-1px); }
.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 3px rgba(0,0,0,.05); }
.sync-ok { background: var(--ok-soft); color: var(--ok); border-color: #c8f0e1; }
.sync-warn { background: var(--amber-soft); color: #9a6608; border-color: #ffe3ad; }
.sync-danger { background: var(--danger-soft); color: var(--danger); border-color: #ffd3d3; }
.sync-muted { background: #f1ece7; color: #6b625c; border-color: #e4dcd4; }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 38px; height: 38px; border: 0; border-radius: 11px;
  background: #f3eee9; color: var(--muted); flex: 0 0 auto;
  transition: background .16s, color .16s, transform .16s;
}
.icon-btn:hover { background: var(--brand-soft); color: var(--brand); }
.icon-btn:active { transform: scale(.96); }
.icon-btn svg { width: 19px; height: 19px; }
.topbar-settings { background: var(--surface); box-shadow: var(--shadow); }

/* ---------- View / cards ---------- */
#view {
  display: flex; flex-direction: column; gap: 18px;
  max-width: 1120px; margin: 0 auto; padding: 12px 28px 64px;
  outline: none;
}
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px;
}
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.card-head h2 { margin-bottom: 2px; }
.card-head p { color: var(--muted); font-size: 12.5px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; padding: 4px 2px 2px; }
.page-head h1 { margin: 2px 0 6px; }
.page-head p { color: var(--muted); max-width: 640px; font-size: 13.5px; }
.eyebrow { display: inline-block; font-size: 10.5px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--brand); }

/* ---------- Operación: ingresos vs egresos ---------- */
.ledger { display: grid; gap: 15px; }
.ledger .card-head h2 { margin-bottom: 2px; }
.ledger-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.ledger-item { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ledger-item small { font-size: 10px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.ledger-item b { font-size: clamp(20px, 2.1vw, 26px); font-weight: 800; letter-spacing: -.035em; }
.ledger-item span { font-size: 12px; color: var(--muted); }
.ledger-bars { display: grid; gap: 7px; }
.ledger-bar-row { display: flex; align-items: center; gap: 10px; }
.ledger-bar-label { flex: 0 0 74px; font-size: 11.5px; font-weight: 700; color: var(--ink-2); }
.ledger-bar { flex: 1 1 auto; height: 9px; border-radius: 99px; background: var(--line); overflow: hidden; }
.ledger-bar-fill { display: block; height: 100%; border-radius: 99px; transition: width .3s ease; }
.ledger-bar-fill.profit { background: var(--ok); }
.ledger-bar-fill.loss { background: var(--danger); }
.ledger-foot { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 12px; color: var(--muted); }
.ledger-foot b { color: var(--ink-2); font-weight: 700; }

/* ---------- Action buttons ---------- */
.action-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 13px; }
.action-btn {
  display: flex; align-items: center; gap: 13px; text-align: left;
  border: 0; border-radius: 19px; padding: 15px 16px; color: white;
  box-shadow: 0 12px 28px rgba(32, 24, 80, .16);
  transition: transform .18s, box-shadow .18s, filter .18s;
}
.action-btn:hover { transform: translateY(-2px); box-shadow: 0 16px 34px rgba(32, 24, 80, .22); filter: saturate(1.06); }
.action-btn:active { transform: translateY(0) scale(.99); }
.action-sale { background: linear-gradient(135deg, #f3766c, #e8584e); }
.action-custom { background: linear-gradient(135deg, #bd7d57, #8b4f31); }
.action-product { background: linear-gradient(135deg, #6b625c, #423b36); }
.action-stock { background: linear-gradient(135deg, #26b6a6, #119889); }
.action-icon {
  width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center;
  background: rgba(255,255,255,.17); border: 1px solid rgba(255,255,255,.18); flex: 0 0 auto;
}
.action-icon svg { width: 22px; height: 22px; }
.action-copy { display: flex; flex-direction: column; min-width: 0; }
.action-copy strong { font-size: 15.5px; letter-spacing: -0.015em; }
.action-copy small { font-size: 11.5px; opacity: .8; margin-top: 1px; }
.action-chevron { margin-left: auto; opacity: .7; }
.action-chevron svg { width: 18px; height: 18px; }

/* ---------- KPIs ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; }
.kpi-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpi { display: flex; flex-direction: column; gap: 3px; padding: 17px 18px; min-width: 0; }
.kpi-label { color: var(--muted); font-size: 10.5px; font-weight: 760; letter-spacing: .1em; text-transform: uppercase; }
.kpi-value { font-size: clamp(22px, 2.3vw, 28px); font-weight: 800; letter-spacing: -0.045em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-sub { color: var(--muted); font-size: 11.5px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.kpi-profit .kpi-value { color: var(--teal-dark); }
.kpi-ticket .kpi-value { color: var(--brand-dark); }
.kpi-stock .kpi-value { color: #a56a06; }
.kpi-warn { border-color: #f7dfb3; background: #fffcf4; }

/* ---------- Notices ---------- */
.notice {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 16px; border-radius: 16px;
  background: #fff8e9; border: 1px solid #f6e3b7; color: #6d4b06;
}
.notice .icon { color: #b17408; flex: 0 0 auto; margin-top: 1px; }
.notice b { display: block; font-size: 13px; }
.notice p { font-size: 12.5px; color: #86641e; margin-top: 2px; }
.notice-inline { background: var(--amber-soft); color: #7a560c; padding: 10px 12px; border-radius: 12px; font-size: 12px; }

/* ---------- Filters / forms ---------- */
.filters-card { padding: 17px 20px 20px; }
.filter-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-stack { display: grid; gap: 6px; min-width: 0; }
.field-label { font-size: 11.5px; font-weight: 700; color: var(--ink-2); }
.field-hint { color: var(--muted); font-size: 10.5px; line-height: 1.35; }
.input {
  width: 100%; min-height: 42px; border: 1px solid var(--line-strong); border-radius: 12px;
  background: #fdfbf9; padding: 9px 12px; outline: none;
  transition: border-color .16s, box-shadow .16s, background .16s;
}
.input:hover { border-color: #c8c3dc; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(162, 96, 63, .14); background: white; }
.input::placeholder { color: #aaa6ba; }
textarea.input { min-height: 74px; resize: vertical; }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 17px) 18px, calc(100% - 12px) 18px; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
.input-readonly { background: #f3eee9; color: var(--muted); }
.form { display: flex; flex-direction: column; gap: 15px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-divider { height: 1px; background: var(--line); margin: 2px 0; }
.btn-row { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; }
.switch-line { display: flex; align-items: center; gap: 9px; font-size: 12.5px; }
.switch-line input { accent-color: var(--brand); width: 17px; height: 17px; flex: 0 0 auto; }
.switch-box { border: 1px solid var(--line); background: var(--surface-2); border-radius: 13px; padding: 10px 12px; }
.switch-box span { display: flex; flex-direction: column; }
.switch-box small { color: var(--muted); font-size: 10.5px; }
.search-wrap { position: relative; flex: 1 1 230px; min-width: 200px; }
.search-wrap > .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-input { padding-left: 38px; }

/* ---------- Buttons / chips ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 12px; padding: 10px 15px;
  font-size: 13.5px; font-weight: 700; letter-spacing: -0.01em;
  white-space: nowrap; transition: transform .16s, background .16s, box-shadow .16s, opacity .16s;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(.99); }
.btn:disabled { opacity: .42; cursor: not-allowed; transform: none; }
.btn .icon svg { width: 17px; height: 17px; }
.btn-primary { background: linear-gradient(135deg, var(--brand), #b97853); color: white; box-shadow: 0 8px 20px rgba(162, 96, 63, .24); }
.btn-primary:hover { box-shadow: 0 10px 24px rgba(162, 96, 63, .32); }
.btn-soft { background: var(--brand-soft); color: var(--brand-dark); }
.btn-soft:hover { background: #e5e0ff; }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: #f3eee9; color: var(--ink-2); }
.btn-danger { background: var(--danger); color: white; box-shadow: 0 8px 20px rgba(214, 69, 69, .2); }
.btn-danger:hover { background: #c53b3b; }
.btn-sm { padding: 8px 12px; font-size: 12.5px; border-radius: 10px; }
.btn-xs { padding: 6px 9px; font-size: 11.5px; border-radius: 9px; gap: 5px; }
.btn-xs .icon svg { width: 14px; height: 14px; }
.btn-sm-icon { width: 31px; height: 31px; border-radius: 9px; }
.btn-sm-icon svg { width: 16px; height: 16px; }
.icon { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.icon svg { width: 18px; height: 18px; display: block; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: #f3eee9; color: #6b625c; border-radius: 999px;
  padding: 4px 9px; font-size: 10.5px; font-weight: 750; letter-spacing: .015em;
  white-space: nowrap;
}
.chip-legacy { background: var(--amber-soft); color: #986407; }
.chip-custom { background: var(--brand-soft); color: var(--brand-dark); }
.chip-consignment { background: var(--teal-soft); color: var(--teal-dark); }
.chip-stock-ok { background: var(--teal-soft); color: var(--teal-dark); }
.chip-stock-low { background: var(--amber-soft); color: #996306; }
.chip-stock-out { background: var(--danger-soft); color: var(--danger); }
.tone-ok { color: var(--teal-dark); }
.tone-low { color: #996306; }
.tone-out { color: var(--danger); }
.detail-item .chip-custom { margin-left: 6px; font-weight: 650; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px;
  border-radius: 999px; background: #f3eee9; color: var(--muted); font-size: 10.5px; font-weight: 700;
  white-space: nowrap;
}
.pill .icon svg { width: 13px; height: 13px; }
.pill-local { background: var(--teal-soft); color: var(--teal-dark); }

/* ---------- Charts ---------- */
.dash-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.dash-grid > * { min-width: 0; }
.dash-grid > .span-2 { grid-column: span 2; }
.chart-card { padding-bottom: 16px; }
.chart-box { margin-top: 12px; min-width: 0; }
.chart-svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart-grid { stroke: #ece9f6; stroke-width: 1; }
.chart-axis { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart-x { font-size: 10.5px; }
.bar-revenue, .bar-profit, .donut-segment { transition: opacity .18s; }
.bar-revenue:hover, .bar-profit:hover, .donut-segment:hover { opacity: .78; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 6px; padding-left: 4px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; }
.legend-item i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.donut-svg { width: 100%; max-width: 270px; height: auto; display: block; margin: 2px auto 8px; }
.donut-total { fill: var(--ink); font-size: 22px; font-weight: 800; font-family: var(--font); letter-spacing: -0.04em; }
.donut-sub { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.donut-legend { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.donut-legend-row { display: flex; align-items: center; gap: 8px; font-size: 11.5px; }
.donut-legend-row i { width: 9px; height: 9px; border-radius: 3px; flex: 0 0 auto; }
.donut-legend-label { flex: 1; min-width: 0; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.donut-legend-row b { font-weight: 700; font-size: 11.5px; }
.hbars { display: flex; flex-direction: column; gap: 11px; }
.hbar-row { display: flex; flex-direction: column; gap: 4px; }
.hbar-top { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; }
.hbar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.hbar-value { font-weight: 750; white-space: nowrap; }
.hbar-track { height: 7px; background: #f0eef8; border-radius: 999px; overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 999px; min-width: 2px; }
.hbar-meta { color: var(--muted-2); font-size: 10px; }
.chart-empty {
  display: grid; place-items: center; min-height: 185px;
  border: 1px dashed var(--line-strong); border-radius: 16px;
  color: var(--muted); font-size: 12.5px; text-align: center; padding: 20px;
  background: #fcfbff;
}

/* ---------- Sales list ---------- */
.sale-list { display: flex; flex-direction: column; margin-top: 6px; }
.sale-row {
  display: flex; align-items: center; gap: 13px; width: 100%;
  background: transparent; border: 0; border-bottom: 1px solid var(--line);
  padding: 12px 4px; text-align: left; border-radius: 10px;
  transition: background .16s;
}
.sale-row:last-child { border-bottom: 0; }
.sale-row:hover { background: var(--surface-2); }
.sale-date {
  width: 46px; height: 46px; border-radius: 14px; flex: 0 0 auto;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--brand-soft); color: var(--brand-dark);
}
.sale-date b { font-size: 17px; line-height: 1; font-weight: 800; letter-spacing: -0.04em; }
.sale-date span { font-size: 9px; text-transform: uppercase; font-weight: 750; letter-spacing: .05em; }
.sale-date-legacy { background: var(--amber-soft); color: #9a6608; }
.sale-date-legacy b { font-size: 16px; }
.sale-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sale-title { display: flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 720; min-width: 0; }
.sale-title-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.sale-sub { color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sale-items { display: none; }
.sale-amount { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; flex: 0 0 auto; }
.sale-amount b { font-size: 13.5px; font-weight: 780; white-space: nowrap; }
.sale-amount span { font-size: 10.5px; font-weight: 700; }
.sale-chevron { color: var(--muted-2); }
.sale-chevron svg { width: 16px; height: 16px; }
.sale-list-compact .sale-row { padding: 10px 2px; }
.sale-list-compact .sale-date { width: 40px; height: 40px; border-radius: 12px; }
.load-more { display: flex; justify-content: center; padding-top: 14px; }
.alert-list { display: flex; flex-direction: column; margin-top: 6px; }
.alert-row { display: flex; align-items: center; gap: 10px; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.alert-row:last-child { border-bottom: 0; }
.alert-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.alert-main b { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alert-main span { color: var(--muted); font-size: 10.5px; }

/* ---------- Inventory ---------- */
.toolbar-card { padding: 14px 16px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; }
.toolbar-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.stock-legend { display: inline-flex; align-items: center; gap: 10px; color: var(--muted); font-size: 10.5px; font-weight: 650; }
.legend-item { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; }
.dot.ok { background: var(--teal); }
.dot.low { background: var(--amber); }
.dot.out { background: var(--danger); }
.toolbar .input { min-height: 39px; width: auto; }
.toolbar .search-wrap { flex: 1 1 210px; }
.toolbar .search-input { width: 100%; }
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); gap: 13px; }
.product-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 19px;
  box-shadow: var(--shadow); padding: 16px; display: flex; flex-direction: column; gap: 10px;
  transition: transform .18s, box-shadow .18s, border-color .18s;
}
.product-card:hover { transform: translateY(-2px); box-shadow: 0 16px 38px rgba(36, 29, 84, .1); border-color: #ddd8ee; }
.product-card.stock-card-ok { border-width: 2px; border-color: rgba(24, 169, 153, .5); }
.product-card.stock-card-low { border-width: 2px; border-color: var(--amber); background: linear-gradient(180deg, #fffdf8, #fff9ed); }
.product-card.stock-card-out { border-width: 2px; border-color: var(--danger); background: linear-gradient(180deg, #fffafa, #fff5f5); }
.product-card.stock-card-ok:hover { border-color: var(--teal); }
.product-card.stock-card-low:hover { border-color: var(--amber); }
.product-card.stock-card-out:hover { border-color: var(--danger); }
.product-card.archived { opacity: .62; }
.product-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.stock-badge { padding: 4px 9px; border-radius: 999px; font-size: 10.5px; font-weight: 800; white-space: nowrap; }
.stock-ok { background: var(--teal-soft); color: var(--teal-dark); }
.stock-low { background: var(--amber-soft); color: #996306; }
.stock-out { background: var(--danger-soft); color: var(--danger); }
.product-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 6px; }
.product-title-row h3 { font-size: 15.5px; line-height: 1.25; }
.product-title-row .icon-btn { width: 30px; height: 30px; border-radius: 9px; background: #f5f3fc; }
.product-title-row .icon-btn svg { width: 15px; height: 15px; }
.product-meta { color: var(--muted); font-size: 10.5px; min-height: 15px; }
.price-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 13px; padding: 9px 10px; }
.price-grid div { display: flex; flex-direction: column; min-width: 0; }
.price-grid small { color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .07em; font-weight: 750; }
.price-grid b { font-size: 13px; font-weight: 780; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.price-grid em { color: var(--muted-2); font-size: 9px; font-style: normal; }
.product-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; }
.product-stats { display: flex; flex-direction: column; gap: 1px; color: var(--muted); font-size: 9.5px; min-width: 0; }
.product-stats span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.product-actions { display: flex; align-items: center; gap: 5px; flex: 0 0 auto; }

/* ---------- Settings ---------- */
.settings-card { padding: 19px 20px; }
.settings-form { display: flex; flex-direction: column; gap: 13px; margin-top: 15px; }
.drive-status { background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 12px 13px; display: flex; flex-direction: column; gap: 6px; }
.status-line { display: flex; align-items: flex-start; gap: 9px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex: 0 0 auto; background: var(--muted-2); }
.status-line b { display: block; font-size: 12.5px; }
.status-line small { color: var(--muted); font-size: 10.5px; }
.status-ok .status-dot { background: var(--ok); box-shadow: 0 0 0 3px rgba(19,138,99,.12); }
.status-warn .status-dot { background: var(--amber); box-shadow: 0 0 0 3px rgba(240,167,47,.14); }
.status-danger .status-dot { background: var(--danger); box-shadow: 0 0 0 3px rgba(214,69,69,.12); }
.error-text { color: var(--danger); font-size: 11.5px; background: var(--danger-soft); padding: 7px 9px; border-radius: 9px; }
.help-details { border-top: 1px solid var(--line); padding-top: 10px; }
.help-details summary { cursor: pointer; font-size: 12px; font-weight: 700; color: var(--brand-dark); }
.help-list { margin: 9px 0 6px; padding-left: 19px; color: var(--muted); font-size: 11.5px; display: flex; flex-direction: column; gap: 4px; }
.danger-card { border-color: #f3cccc; background: #fffafa; }
.about-card { display: flex; gap: 14px; align-items: flex-start; }
.about-mark { width: 48px; height: 48px; border-radius: 15px; display: block; object-fit: cover; background: #1f2227; flex: 0 0 auto; }
.about-card p { color: var(--muted); font-size: 12px; margin-top: 4px; }
.install-box { background: var(--brand-soft); border-radius: 14px; padding: 12px 14px; display: flex; flex-direction: column; gap: 5px; }
.install-box b { font-size: 12.5px; color: var(--brand-dark); }
.install-box p { font-size: 11.5px; color: #6b625c; }
.install-box .btn { align-self: flex-start; margin-top: 4px; }

/* ---------- Materia prima ---------- */
.material-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 13px; }
.material-card {
  display: flex; flex-direction: column; gap: 9px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 19px;
  box-shadow: var(--shadow); padding: 16px;
}
.material-card.stock-card-ok { border-width: 2px; border-color: rgba(24, 169, 153, .5); }
.material-card.stock-card-low { border-width: 2px; border-color: var(--amber); background: linear-gradient(180deg, #fffdf8, #fff9ed); }
.material-card.stock-card-out { border-width: 2px; border-color: var(--danger); background: linear-gradient(180deg, #fffafa, #fff5f5); }
.material-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.material-top .stock-badge { margin-left: auto; }
.material-title { display: flex; flex-direction: column; gap: 1px; }
.material-title h3 { font-size: 15px; }
.material-title span { color: var(--muted); font-size: 11.5px; }
.material-meta { color: var(--muted); font-size: 11.5px; line-height: 1.35; }
.material-stats {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 11px;
}
.material-stats div { display: flex; flex-direction: column; min-width: 0; }
.material-stats small { color: var(--muted); font-size: 9px; font-weight: 760; letter-spacing: .05em; text-transform: uppercase; }
.material-stats b { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.material-actions { display: flex; gap: 7px; margin-top: auto; }
.material-actions .btn { flex: 1 1 auto; }
.material-move-list { display: flex; flex-direction: column; margin-top: 4px; }
.material-move-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 9px 0; border-bottom: 1px solid var(--line); }
.material-move-row:last-child { border-bottom: 0; }
.material-move-main { flex: 1 1 180px; min-width: 0; display: flex; flex-direction: column; }
.material-move-main b { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.material-move-main span { color: var(--muted); font-size: 11px; }
.material-move-qty { font-size: 12.5px; white-space: nowrap; }

/* ---------- Contacto / clientes / edición ---------- */
.contact-link { color: var(--brand-dark); font-weight: 700; text-decoration: none; }
.contact-link:hover { text-decoration: underline; }
.dealer-contact { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11.5px; }
.dealer-contact .icon svg { width: 14px; height: 14px; }
.dealer-contact-box {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 11px 12px;
}
.dealer-contact-main { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.dealer-contact-main small { color: var(--muted); font-size: 9px; font-weight: 760; letter-spacing: .06em; text-transform: uppercase; }
.dealer-contact-main b { font-size: 13px; }
.dealer-contact-main span { color: var(--muted); font-size: 11px; }
.customer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; }
.customer-card {
  display: flex; flex-direction: column; gap: 9px;
  border: 1px solid var(--line); border-radius: 16px; background: var(--surface-2); padding: 14px;
}
.customer-card-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.customer-avatar {
  width: 40px; height: 40px; border-radius: 13px; flex: 0 0 auto;
  display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-dark);
  font-weight: 800; font-size: 15px;
}
.customer-card-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.customer-card-title b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.customer-card-title span { color: var(--muted); font-size: 11px; }
.customer-contact { display: flex; align-items: center; gap: 6px; min-height: 18px; color: var(--muted); font-size: 12px; }
.customer-contact .icon svg { width: 14px; height: 14px; }
.customer-notes { color: var(--muted); font-size: 11px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.customer-card-stats {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px;
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 11px;
}
.customer-card-stats div { display: flex; flex-direction: column; min-width: 0; }
.customer-card-stats small { color: var(--muted); font-size: 9px; font-weight: 760; letter-spacing: .05em; text-transform: uppercase; }
.customer-card-stats b { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.customer-card-actions { display: flex; gap: 7px; margin-top: auto; }
.customer-card-actions .btn { flex: 1 1 auto; }
.edit-lines { display: flex; flex-direction: column; gap: 9px; }
.edit-line {
  display: flex; flex-direction: column; gap: 8px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 11px 12px;
}
.edit-line-head { display: flex; flex-direction: column; gap: 2px; }
.edit-line-head b { font-size: 13px; }
.edit-line-head span { color: var(--muted); font-size: 11px; }
.edit-line .form-grid-3 { gap: 8px; }

/* ---------- Empty state ---------- */
.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 7px; padding: 34px 18px; color: var(--muted); }
.empty-icon { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); margin-bottom: 3px; }
.empty-icon svg { width: 25px; height: 25px; }
.empty-state h3 { color: var(--ink-2); font-size: 14.5px; }
.empty-state p { font-size: 12.5px; max-width: 360px; }
.empty-state .btn { margin-top: 7px; }

/* ---------- Modal ---------- */
body.modal-open { overflow: hidden; }
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0; background: rgba(32, 25, 21, .48);
  opacity: 0; transition: opacity .18s ease;
  backdrop-filter: blur(3px);
}
.modal-backdrop.open { opacity: 1; }
.modal {
  width: 100%; max-width: 640px; max-height: 92vh; max-height: 92dvh;
  display: flex; flex-direction: column;
  background: var(--surface); border-radius: 24px 24px 0 0;
  box-shadow: var(--shadow-lg);
  transform: translateY(22px); transition: transform .2s ease;
  overflow: hidden;
}
.modal-backdrop.open .modal { transform: translateY(0); }
.modal-lg { max-width: 880px; }
.modal-sm { max-width: 440px; }
.modal-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 14px;
  padding: 18px 20px 14px; border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fff, #fbf9f7);
}
.modal-title-wrap h2 { font-size: 19px; }
.modal-title-wrap p { color: var(--muted); font-size: 12px; margin-top: 3px; }
.modal-close { width: 34px; height: 34px; }
.modal-body { padding: 18px 20px 22px; overflow: auto; -webkit-overflow-scrolling: touch; }
.modal-foot {
  display: flex; align-items: center; justify-content: flex-end; gap: 9px; flex-wrap: wrap;
  padding: 13px 20px calc(13px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); background: #fff;
}
.confirm-text { color: var(--ink-2); font-size: 14px; }

/* ---------- Sale modal ---------- */
.sale-mode-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; padding: 4px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; }
.sale-mode-tab {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  border: 0; background: transparent; color: var(--muted); border-radius: 10px;
  padding: 9px 10px; font-size: 12.5px; font-weight: 750;
  transition: background .16s, color .16s, box-shadow .16s;
}
.sale-mode-tab .icon svg { width: 16px; height: 16px; }
.sale-mode-tab:hover { color: var(--ink-2); }
.sale-mode-tab.active { background: white; color: var(--brand-dark); box-shadow: 0 2px 9px rgba(56, 42, 34, .09); }
.sale-catalog-block, .sale-custom-block { display: flex; flex-direction: column; gap: 10px; }
.sale-catalog-block[hidden], .sale-custom-block[hidden] { display: none; }
.custom-totals { margin-top: 2px; }
.sale-picker { background: var(--surface-2); border: 1px solid var(--line); border-radius: 16px; padding: 13px; display: flex; flex-direction: column; gap: 9px; }
.sale-price-hint { color: var(--muted); font-size: 10.5px; line-height: 1.45; }
.cart-box { border: 1px dashed var(--line-strong); border-radius: 15px; padding: 6px 12px; min-height: 66px; background: #fdfbf9; }
.cart-empty { display: flex; align-items: center; gap: 9px; padding: 12px 2px; color: var(--muted); font-size: 12px; }
.cart-empty .icon { color: var(--muted-2); }
.cart-line { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.cart-line:last-child { border-bottom: 0; }
.cart-line-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cart-line-main b { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cart-line-main span { color: var(--muted); font-size: 10.5px; }
.cart-line-total { font-size: 12.5px; white-space: nowrap; }
.danger-icon { width: 28px; height: 28px; color: var(--danger); background: var(--danger-soft); }
.danger-icon:hover { background: #ffe0e0; color: var(--danger); }
.danger-icon svg { width: 14px; height: 14px; }
.cart-totals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; background: var(--brand-soft); border-radius: 14px; padding: 11px 13px; }
.cart-totals div { display: flex; flex-direction: column; }
.cart-totals span { color: #8a6a58; font-size: 9.5px; text-transform: uppercase; letter-spacing: .06em; font-weight: 750; }
.cart-totals b { font-size: 14px; }
.stock-preview { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font-size: 12px; color: var(--muted); }
.stock-preview b { color: var(--ink-2); font-size: 12.5px; }

/* ---------- Concesiones ---------- */
.consignment-avatar {
  width: 38px; height: 38px; border-radius: 12px; flex: 0 0 auto;
  display: grid; place-items: center; background: var(--teal-soft); color: var(--teal-dark);
  font-weight: 800; font-size: 15px;
}
.consignment-detail { display: flex; flex-direction: column; gap: 14px; }
.consignment-lines { display: flex; flex-direction: column; gap: 8px; }
.consignment-line {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  border: 2px solid var(--line); border-left-width: 5px; border-radius: 14px; padding: 11px 12px; background: var(--surface-2);
}
.consignment-line.line-ok { border-color: rgba(24, 169, 153, .45); background: #f9fdfc; }
.consignment-line.line-low { border-color: var(--amber); background: #fffaf0; }
.consignment-line.line-out { border-color: var(--danger); background: #fff7f7; }
.consignment-line-main { flex: 1 1 210px; display: flex; flex-direction: column; }
.consignment-line-main b { font-size: 13px; }
.consignment-line-main span { color: var(--muted); font-size: 11px; }
.consignment-line-actions { display: flex; gap: 6px; }

/* ---------- Página de concesiones ---------- */
.dealer-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.dealer-card {
  display: flex; flex-direction: column; gap: 10px;
  border: 2px solid var(--line); border-radius: 16px; padding: 14px; background: var(--surface-2);
}
.dealer-card.dealer-card-ok { border-color: rgba(24, 169, 153, .5); }
.dealer-card.dealer-card-low { border-color: var(--amber); background: linear-gradient(180deg, #fffdf8, #fff9ed); }
.dealer-card.dealer-card-out { border-color: var(--danger); background: linear-gradient(180deg, #fffafa, #fff5f5); }
.dealer-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.card-head-side { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.dealer-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.dealer-title b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dealer-title span { color: var(--muted); font-size: 11px; }
.dealer-stats {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px;
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 11px;
}
.dealer-stats div { display: flex; flex-direction: column; min-width: 0; }
.dealer-stats small { color: var(--muted); font-size: 9px; font-weight: 760; letter-spacing: .05em; text-transform: uppercase; }
.dealer-stats b { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dealer-stats span { color: var(--muted); font-size: 10px; }
.dealer-meta { color: var(--muted); font-size: 11px; }
.dealer-actions { display: flex; gap: 7px; margin-top: auto; }
.dealer-actions .btn { flex: 1 1 auto; }
.pending-product-list { display: flex; flex-direction: column; margin-top: 6px; }
.pending-product-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.pending-product-row:last-child { border-bottom: 0; }
.pending-product-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pending-product-main b { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pending-product-main span { color: var(--muted); font-size: 11px; }
.pending-product-value { display: flex; flex-direction: column; align-items: flex-end; }
.pending-product-value b { font-size: 13px; }
.pending-product-value span { color: var(--muted); font-size: 11px; }

/* ---------- Sale detail ---------- */
.sale-detail { display: flex; flex-direction: column; gap: 14px; }
.sale-detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.sale-detail-head h3 { margin-top: 3px; font-size: 17px; }
.sale-detail-total { text-align: right; display: flex; flex-direction: column; }
.sale-detail-total b { font-size: 22px; letter-spacing: -0.04em; }
.sale-detail-total span { font-size: 11px; font-weight: 700; }
.detail-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 13px; padding: 10px 12px; }
.detail-grid div { display: flex; flex-direction: column; min-width: 0; }
.detail-grid small { color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .07em; font-weight: 750; }
.detail-grid b { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.detail-items { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.detail-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 12px; border-bottom: 1px solid var(--line); }
.detail-item:last-child { border-bottom: 0; }
.detail-item div { display: flex; flex-direction: column; }
.detail-item span { color: var(--muted); font-size: 10.5px; }
.detail-item > b { font-size: 12.5px; white-space: nowrap; }
.detail-note { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.detail-note small { color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .07em; font-weight: 750; }
.detail-note p { font-size: 12px; margin-top: 2px; }

/* ---------- Toast / misc ---------- */
#toast-root { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; width: max-content; max-width: calc(100vw - 30px); }
.toast {
  display: flex; align-items: flex-start; gap: 9px;
  background: #262220; color: white; border-radius: 14px;
  padding: 11px 15px; font-size: 12.5px; line-height: 1.4;
  box-shadow: 0 14px 40px rgba(20, 15, 50, .3);
  opacity: 0; transform: translateY(10px); transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast .icon { color: #e8b79c; margin-top: 1px; }
.toast-success .icon { color: #7ee2c3; }
.toast-error .icon { color: #ff9b9b; }
.toast-error { background: #3d1c27; }
.noscript { margin: 30px auto; max-width: 500px; padding: 20px; background: #fff3f3; color: #8a2222; border-radius: 14px; text-align: center; }

/* ---------- Tabbar (mobile) ---------- */
.tabbar { display: none; }
@media (max-width: 960px) {
  .app-shell { display: block; }
  .sidebar { display: none; }
  .topbar { justify-content: space-between; padding: max(9px, env(safe-area-inset-top)) 16px 9px; }
  .topbar-brand { display: flex; }
  .user-pill .user-copy { display: none; }
  .user-pill { padding: 4px; }
  #view { padding: 8px 16px calc(96px + env(safe-area-inset-bottom)); gap: 14px; }
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    justify-content: space-around; align-items: stretch;
    padding: 7px 8px calc(7px + env(safe-area-inset-bottom));
    background: rgba(255,255,255,.9); border-top: 1px solid var(--line);
    backdrop-filter: blur(18px);
  }
  .tab-item {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    flex: 1; border: 0; background: transparent; color: var(--muted);
    font-size: 9.5px; font-weight: 700; border-radius: 12px; padding: 5px 2px;
    transition: color .16s, background .16s;
  }
  .tab-item svg { width: 22px; height: 22px; }
  .tab-item.active { color: var(--brand-dark); background: var(--brand-soft); }
  .tab-item.active svg { stroke-width: 2.1; }
  .action-grid { grid-template-columns: 1fr; }
  .action-btn { padding: 13px 15px; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .modal-backdrop { padding: 0; }
  #toast-root { bottom: calc(84px + env(safe-area-inset-bottom)); }
}

@media (max-width: 720px) {
  body { font-size: 14.5px; }
  .card { padding: 16px; border-radius: 19px; }
  .page-head { align-items: flex-start; flex-direction: column; gap: 11px; }
  .page-head .btn { align-self: stretch; }
  .page-head .btn-row { width: 100%; }
  .page-head .btn-row .btn { flex: 1 1 0; }
  .consignment-line-actions { width: 100%; }
  .consignment-line-actions .btn { flex: 1 1 0; }
  .customer-grid { grid-template-columns: 1fr; }
  .material-grid { grid-template-columns: 1fr; }
  .dealer-contact-box .btn { width: 100%; }
  .dealer-grid { grid-template-columns: 1fr; }
  .dealer-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card-head-side { width: 100%; justify-content: flex-start; }
  .dash-grid { grid-template-columns: 1fr; }
  .dash-grid > .span-2 { grid-column: auto; }
  .kpi-value { font-size: 23px; }
  .form-grid, .form-grid-3, .form-grid-4 { grid-template-columns: 1fr 1fr; }
  .detail-grid { grid-template-columns: 1fr 1fr; }
  .modal { max-height: 94vh; max-height: 94dvh; }
  .modal-head { padding: 16px 16px 12px; }
  .modal-body { padding: 15px 16px 20px; }
  .modal-foot { padding: 11px 16px calc(11px + env(safe-area-inset-bottom)); }
  .modal-foot .btn { flex: 1 1 auto; }
  .sale-detail-head { flex-direction: column; }
  .sale-detail-total { text-align: left; }
  .sale-amount b { font-size: 12.5px; }
  .sale-sub { max-width: 190px; }
  .chart-axis { font-size: 17px; }
  .chart-x { font-size: 15px; }
  .chart-legend { font-size: 12px; }
  .donut-total { font-size: 24px; }
  .donut-sub { font-size: 12px; }
  .product-grid { grid-template-columns: 1fr 1fr; }
  .product-card { padding: 13px; border-radius: 16px; }
  .price-grid { grid-template-columns: 1fr 1fr; }
  .price-grid div:last-child { display: none; }
  .product-stats { display: none; }
  .product-actions .btn span { display: none; }
  .product-actions .btn { padding: 7px 8px; }
  .sale-list-compact .sale-sub { max-width: 150px; }
}

@media (max-width: 480px) {
  #view { padding-left: 13px; padding-right: 13px; }
  .topbar { padding-left: 13px; padding-right: 13px; }
  .filter-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .form-grid, .form-grid-3, .form-grid-4 { grid-template-columns: 1fr; }
  .kpi-grid, .kpi-grid-3 { gap: 9px; }
  .kpi { padding: 13px 14px; }
  .kpi-value { font-size: 21px; }
  .action-copy small { font-size: 10.5px; }
  .product-grid { grid-template-columns: 1fr; }
  .price-grid div:last-child { display: flex; }
  .sale-sub { max-width: 150px; }
  .cart-totals { grid-template-columns: 1fr 1fr; }
  .cart-totals div:last-child { grid-column: span 2; }
  .sync-pill span { max-width: 92px; overflow: hidden; text-overflow: ellipsis; }
}

@media (min-width: 961px) {
  .topbar { padding-right: 28px; }
  .modal-backdrop { align-items: center; padding: 22px; }
  .modal { border-radius: 24px; max-height: 90vh; }
  .modal-foot { padding-bottom: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

@media (max-width: 420px) {
  .sync-pill span { display: none; }
  .sync-pill { padding: 8px; }
}

@media (max-width: 360px) {
  .tabbar { padding-left: 3px; padding-right: 3px; }
  .tab-item { font-size: 8.5px; padding: 4px 1px; gap: 2px; }
  .tab-item svg { width: 20px; height: 20px; }
}

@media print {
  .sidebar, .topbar, .tabbar, .action-grid, .filters-card, .btn, .icon-btn { display: none !important; }
  .app-shell { display: block; }
  #view { padding: 0; max-width: none; }
  .card { box-shadow: none; border-color: #ddd; }
}
