/* ============================================================================
   Stockia — app styles. Built on Nodo J foundations + dashboard kit.
   Adds inventory/sales-specific components: status pills, category chips,
   stock meters, filter toolbars, donut/area charts, product drawer, order
   cards, and the client portal.
   ========================================================================== */

/* ---- brand / sidebar logo override (Stockia) ---- */
.side-logo .word { font-family: var(--font-display); font-weight: 600; font-size: 19px; letter-spacing: -.03em; color: #fff; }
.side-logo .word b { color: var(--accent); font-weight: 600; }
.side-logo .tag { display: block; font-family: var(--font-mono); font-size: 8.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--slate-500); margin-top: 3px; line-height: 1.4; white-space: normal; }

/* keep sidebar scrollable on short screens */
.side { overflow-y: auto; }
.side::-webkit-scrollbar { width: 7px; }
.side::-webkit-scrollbar-thumb { background: rgba(255,255,255,.08); border-radius: 9px; }
.nav-item { user-select: none; }

/* ---- semantic badge extension ---- */
.b-red { background: var(--danger-bg); color: #9b1c1c; } .b-red .d { background: var(--danger); }
.b-blue { background: #e7f0f8; color: #2b5878; } .b-blue .d { background: #6aa7c9; }
.badge.solid { padding: 4px 10px; }

/* ---- danger button ---- */
.btn-ghost { background: transparent; color: var(--fg2); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-2); color: var(--fg1); border-color: var(--line-strong); }
.btn-danger { background: var(--danger-bg); color: #9b1c1c; border-color: transparent; }
.btn-danger:hover { background: #f7d3d3; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #128a3e; }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---- page subnav / segmented control ---- */
.seg { display: inline-flex; background: var(--slate-100); border: 1px solid var(--line); border-radius: var(--r-md); padding: 3px; gap: 2px; }
.seg button { font-family: var(--font-sans); font-weight: 600; font-size: 13px; color: var(--fg2); background: transparent;
  border: none; border-radius: 7px; padding: 7px 14px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; transition: all var(--dur-fast) var(--ease); }
.seg button svg { width: 15px; height: 15px; }
.seg button:hover { color: var(--fg1); }
.seg button.on { background: var(--surface); color: var(--fg1); box-shadow: var(--shadow-sm); }

/* ---- filter toolbar ---- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.toolbar .grow { flex: 1; }
.select-field { position: relative; display: inline-flex; align-items: center; }
.select-field select { appearance: none; font-family: var(--font-sans); font-size: 13.5px; font-weight: 500; color: var(--fg1);
  padding: 8px 30px 8px 12px; border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface); cursor: pointer; transition: all var(--dur-fast); }
.select-field select:hover { border-color: var(--slate-400); }
.select-field select:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.select-field .chev { position: absolute; right: 9px; pointer-events: none; width: 15px; height: 15px; color: var(--fg3); }
.select-field .lead { position: absolute; left: 11px; pointer-events: none; width: 15px; height: 15px; color: var(--fg3); }
.select-field.has-lead select { padding-left: 32px; }
.field-label { font-family: var(--font-mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--fg3); margin-right: 2px; }

.searchbox { position: relative; display: flex; align-items: center; min-width: 200px; }
.searchbox svg { position: absolute; left: 11px; width: 16px; height: 16px; color: var(--fg3); }
.searchbox input { width: 100%; font-family: var(--font-sans); font-size: 14px; padding: 8px 12px 8px 34px;
  border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface); outline: none; transition: all var(--dur-fast); }
.searchbox input:focus { border-color: var(--accent); box-shadow: var(--ring); }

/* ---- KPI stat with icon tile + spark ---- */
.stat { position: relative; display: flex; flex-direction: column; gap: 0; transition: border-color var(--dur), box-shadow var(--dur); }
.stat:hover { border-color: var(--line-strong); box-shadow: var(--shadow-md); }
.stat-top { display: flex; align-items: flex-start; justify-content: space-between; }
.stat-ic { width: 38px; height: 38px; border-radius: var(--r-md); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-ic svg { width: 19px; height: 19px; }
.stat .lbl { font-size: 13px; color: var(--fg2); font-weight: 500; padding-right: 8px; }
.stat .val { font-family: var(--font-display); font-weight: 600; font-size: 30px; letter-spacing: -.02em; margin-top: 4px; color: var(--fg1); line-height: 1; }
.stat .sub2 { font-size: 12.5px; color: var(--fg3); margin-top: 7px; }
.stat .chg.flat { color: var(--fg3); }

/* tile color helpers (icon tiles, category dots) */
.tile-teal { background: var(--accent-50); color: var(--accent-ink); }
.tile-green { background: var(--success-bg); color: #0c5a2c; }
.tile-amber { background: var(--warning-bg); color: #8a4d05; }
.tile-red { background: var(--danger-bg); color: #9b1c1c; }
.tile-slate { background: var(--slate-100); color: var(--slate-700); }
.tile-blue { background: #e7f0f8; color: #2b5878; }

/* ---- stock meter ---- */
.stock-cell { display: flex; flex-direction: column; gap: 6px; min-width: 132px; }
.stock-top { display: flex; align-items: baseline; gap: 6px; }
.stock-top b { font-family: var(--font-display); font-weight: 600; font-size: 15px; }
.stock-top span { font-family: var(--font-mono); font-size: 11.5px; color: var(--fg3); }
.meter { height: 6px; background: var(--slate-200); border-radius: 999px; overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 999px; transition: width var(--dur-slow) var(--ease); }
.meter > i.ok { background: var(--success); }
.meter > i.low { background: var(--warning); }
.meter > i.out { background: var(--danger); }

/* category chip */
.cat-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--fg2); white-space: nowrap; }
.cat-chip .dot { width: 8px; height: 8px; border-radius: 3px; flex-shrink: 0; }

/* product icon tile in table */
.p-ic { width: 34px; height: 34px; border-radius: 9px; display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 600; font-size: 14px; color: #fff; flex-shrink: 0; }
.cell-name .sub { font-family: var(--font-mono); font-size: 11.5px; color: var(--fg3); font-weight: 400; margin-top: 1px; }
.cell-name .col { display: flex; flex-direction: column; min-width: 0; max-width: 260px; }
.cell-name .col > span:first-child { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* margin pill — escala de rentabilidad: >50 verde oscuro · 40-50 verde claro · 31-39 naranja · <=30 rojo */
.margin { font-family: var(--font-display); font-weight: 600; font-size: 14.5px; }
.margin.vgood { color: #0a7c45; }   /* verde oscuro (>50%) */
.margin.good { color: #16a34a; }    /* verde claro (40-50%) */
.margin.mid { color: #f59e0b; }     /* naranja (31-39%) */
.margin.bad { color: #ef4444; }     /* rojo (<=30%) */

/* expiry tag */
.exp-tag { display: inline-flex; align-items: center; gap: 5px; font-family: var(--font-mono); font-size: 11.5px; font-weight: 500; }
.exp-tag svg { width: 13px; height: 13px; }
.exp-tag.soon { color: var(--warning); }
.exp-tag.crit { color: var(--danger); }
.exp-tag.ok { color: var(--fg3); }

/* row actions */
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.mini-btn { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; transition: all var(--dur-fast); }
.mini-btn:hover { background: var(--surface-2); border-color: var(--line-strong); color: var(--accent-ink); }
.mini-btn svg { width: 15px; height: 15px; color: var(--fg2); }
.mini-btn:hover svg { color: var(--accent-ink); }

/* ---- FIX: SVG icons inside buttons must not intercept pointer events.
   Lucide replaces <i data-lucide> with <svg>; the SVG's default pointer-events
   can swallow clicks before they reach the button's React onClick handler. ---- */
button svg, button i[data-lucide] { pointer-events: none; }

/* table tweaks */
.table td.tight { padding-top: 11px; padding-bottom: 11px; }
.table .num { font-family: var(--font-display); font-weight: 600; }
tr.rowflash { animation: rowflash 1.4s var(--ease); }
@keyframes rowflash { 0% { background: var(--accent-50); } 100% { background: transparent; } }

/* ---- charts ---- */
/* Grid/flex children default to min-width:auto, which lets a Chart.js canvas
   force the column wider than its track and overflow the page at 100% zoom.
   Allowing them to shrink (min-width:0) + capping the canvas fixes overflow. */
.grid-2 > *, .grid-3 > *, .two-col > *, .stats > * { min-width: 0; }
.panel { min-width: 0; }
.panel canvas { max-width: 100% !important; }
.chart-wrap { padding: 18px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; padding: 0 18px 16px; }
.legend .it { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--fg2); }
.legend .sw { width: 11px; height: 11px; border-radius: 3px; }

/* grouped bars */
.gchart { display: flex; align-items: flex-end; gap: 14px; height: 230px; padding: 8px 4px 0; }
.gcol { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 9px; height: 100%; justify-content: flex-end; min-width: 0; }
.gcol .pair { display: flex; align-items: flex-end; gap: 4px; width: 100%; height: 100%; justify-content: center; }
.gcol .gb { width: 16px; border-radius: 5px 5px 0 0; transition: height var(--dur-slow) var(--ease); position: relative; }
.gcol .gb:hover { filter: brightness(1.06); }
.gcol .x { font-family: var(--font-mono); font-size: 11px; color: var(--fg3); }

/* donut */
.donut-row { display: flex; align-items: center; gap: 26px; padding: 20px 18px; flex-wrap: wrap; }
.donut { position: relative; width: 168px; height: 168px; flex-shrink: 0; }
.donut .center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.donut .center b { font-family: var(--font-display); font-weight: 600; font-size: 26px; letter-spacing: -.02em; }
.donut .center span { font-size: 11.5px; color: var(--fg3); }
.donut-legend { display: flex; flex-direction: column; gap: 11px; flex: 1; min-width: 180px; }
.donut-legend .it { display: flex; align-items: center; gap: 10px; font-size: 13.5px; }
.donut-legend .sw { width: 11px; height: 11px; border-radius: 3px; flex-shrink: 0; }
.donut-legend .it .nm { color: var(--fg1); font-weight: 500; }
.donut-legend .it .vl { margin-left: auto; font-family: var(--font-display); font-weight: 600; color: var(--fg1); }
.donut-legend .it .pc { font-family: var(--font-mono); font-size: 12px; color: var(--fg3); width: 40px; text-align: right; }

/* horizontal ranked bars */
.rank { display: flex; flex-direction: column; gap: 13px; padding: 18px; }
.rank .it { display: grid; grid-template-columns: 1fr; gap: 6px; }
.rank .it .top { display: flex; align-items: center; gap: 9px; font-size: 13.5px; }
.rank .it .top .nm { font-weight: 500; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank .it .top .vl { margin-left: auto; font-family: var(--font-display); font-weight: 600; flex-shrink: 0; }
.rank .bar { height: 8px; background: var(--slate-100); border-radius: 999px; overflow: hidden; }
.rank .bar > i { display: block; height: 100%; border-radius: 999px; transition: width var(--dur-slow) var(--ease); }

/* area / sparkline svg */
.spark { width: 100%; display: block; }

/* ---- alerts feed ---- */
.feed { display: flex; flex-direction: column; }
.feed .row { display: flex; gap: 12px; padding: 13px 18px; border-bottom: 1px solid var(--line); align-items: flex-start; }
.feed .row:last-child { border-bottom: none; }
.feed .ic { width: 32px; height: 32px; border-radius: 9px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.feed .ic svg { width: 16px; height: 16px; }
.feed .ftxt { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.feed .row .t { font-size: 13.5px; color: var(--fg1); line-height: 1.4; }
.feed .row .t b { font-weight: 600; }
.feed .row .time { font-size: 12px; color: var(--fg3); margin-top: 2px; font-family: var(--font-mono); }
.feed .row .right { margin-left: auto; }

/* ---- two/three column grids ---- */
.grid-2 { display: grid; grid-template-columns: 1.5fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.stats.cols-4 { grid-template-columns: repeat(4, 1fr); }

/* ---- order cards ---- */
.orders { display: flex; flex-direction: column; gap: 0; }
.order-card { padding: 16px 18px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: center; transition: background var(--dur-fast); cursor: pointer; }
.order-card:last-child { border-bottom: none; }
.order-card:hover { background: var(--slate-50); }
.order-card .who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.order-card .av { width: 40px; height: 40px; border-radius: 11px; display: flex; align-items: center; justify-content: center; font-family: var(--font-display); font-weight: 600; font-size: 15px; color: #fff; flex-shrink: 0; }
.order-card .who .nm { font-weight: 600; font-size: 14.5px; }
.order-card .who .meta { font-size: 12.5px; color: var(--fg3); margin-top: 2px; }
.order-card .items { font-size: 13px; color: var(--fg2); }
.order-card .items .pill { display: inline-block; background: var(--slate-100); border-radius: 6px; padding: 2px 8px; margin: 2px 4px 2px 0; font-size: 12px; }
.order-card .right { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.order-card .total { font-family: var(--font-display); font-weight: 600; font-size: 17px; }
.order-actions { display: flex; gap: 8px; }

/* ---- drawer extensions ---- */
.drawer { width: 460px; }
.drawer-hero { padding: 22px; background: var(--slate-950); color: var(--fg-on-ink); }
.drawer-hero .ttl { font-family: var(--font-display); font-weight: 600; font-size: 20px; letter-spacing: -.02em; }
.drawer-hero .sub { font-family: var(--font-mono); font-size: 12px; color: var(--slate-400); margin-top: 3px; }
.drawer-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.drawer-stats > div { background: var(--surface); padding: 13px; }
.drawer-stats .k { font-size: 11.5px; color: var(--fg3); }
.drawer-stats .v { font-family: var(--font-display); font-weight: 600; font-size: 18px; margin-top: 4px; }
.lots-table { width: 100%; border-collapse: collapse; }
.lots-table th { text-align: left; font-family: var(--font-mono); font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: var(--fg3); font-weight: 500; padding: 8px 0; border-bottom: 1px solid var(--line); }
.lots-table td { padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.lots-table tr:last-child td { border-bottom: none; }
.sec-label { font-family: var(--font-mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--fg3); margin: 0 0 10px; }

/* price tier list in drawer */
.tiers { display: flex; flex-direction: column; gap: 0; }
.tier { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.tier:last-child { border-bottom: none; }
.tier .k { color: var(--fg2); display: flex; align-items: center; gap: 8px; }
.tier .v { font-family: var(--font-display); font-weight: 600; }

/* ---- portal ---- */
.portal-wrap { max-width: 1180px; margin: 0 auto; padding: 28px; display: flex; flex-direction: column; gap: 22px; }
.portal-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 22px; background: var(--slate-950);
  border-radius: var(--r-xl); color: var(--fg-on-ink); }
.portal-top .brand { display: flex; align-items: center; gap: 13px; }
.portal-top .brand .nm { font-family: var(--font-display); font-weight: 600; font-size: 18px; }
.portal-top .brand .tg { font-size: 12px; color: var(--slate-400); }
.portal-top .who { text-align: right; font-size: 12.5px; color: var(--slate-300); }
.portal-grid { display: grid; grid-template-columns: 1fr 340px; gap: 22px; align-items: start; }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.pcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; display: flex; flex-direction: column; transition: all var(--dur) var(--ease); }
.pcard:hover { border-color: var(--line-strong); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.pcard .ph { height: 120px; display: flex; align-items: center; justify-content: center; position: relative; }
.pcard .ph .glyph { font-family: var(--font-display); font-weight: 600; font-size: 30px; color: rgba(255,255,255,.92); }
.pcard .ph .stk { position: absolute; top: 10px; right: 10px; }
.pcard .body { padding: 13px 14px 15px; display: flex; flex-direction: column; gap: 5px; flex: 1; }
.pcard .body .cat { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--fg3); }
.pcard .body .nm { font-weight: 600; font-size: 14.5px; line-height: 1.25; }
.pcard .body .price { font-family: var(--font-display); font-weight: 600; font-size: 18px; margin-top: 2px; }
.pcard .body .price small { font-size: 12px; color: var(--fg3); font-weight: 400; font-family: var(--font-sans); }
.pcard .foot { margin-top: auto; display: flex; align-items: center; gap: 8px; padding-top: 10px; }

/* qty stepper */
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line-strong); border-radius: var(--r-md); overflow: hidden; }
.stepper button { width: 32px; height: 32px; background: var(--surface); border: none; cursor: pointer; color: var(--fg2); display: flex; align-items: center; justify-content: center; transition: background var(--dur-fast); }
.stepper button:hover { background: var(--surface-2); color: var(--fg1); }
.stepper input { width: 42px; text-align: center; border: none; border-left: 1px solid var(--line); border-right: 1px solid var(--line);
  font-family: var(--font-display); font-weight: 600; font-size: 14px; outline: none; height: 32px; padding: 0; -moz-appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* cart */
.cart { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); position: sticky; top: 22px; display: flex; flex-direction: column; }
.cart-head { padding: 16px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.cart-head h3 { font-family: var(--font-display); font-weight: 600; font-size: 16px; margin: 0; }
.cart-items { padding: 6px 18px; max-height: 340px; overflow-y: auto; }
.cart-line { display: flex; gap: 11px; padding: 12px 0; border-bottom: 1px solid var(--line); align-items: flex-start; }
.cart-line:last-child { border-bottom: none; }
.cart-line .ci { width: 34px; height: 34px; border-radius: 8px; display: flex; align-items: center; justify-content: center; color: #fff; font-family: var(--font-display); font-weight: 600; font-size: 13px; flex-shrink: 0; }
.cart-line .nm { font-size: 13.5px; font-weight: 600; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cart-line .meta { font-size: 12px; color: var(--fg3); margin-top: 2px; }
.cart-line .lt { margin-left: auto; text-align: right; }
.cart-line .lt .amt { font-family: var(--font-display); font-weight: 600; font-size: 14px; }
.cart-line .rm { background: none; border: none; cursor: pointer; color: var(--fg3); font-size: 11px; margin-top: 3px; padding: 0; }
.cart-line .rm:hover { color: var(--danger); }
.cart-foot { padding: 16px 18px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 12px; }
.cart-foot .line { display: flex; justify-content: space-between; font-size: 13.5px; color: var(--fg2); }
.cart-foot .line.total { font-family: var(--font-display); font-weight: 600; font-size: 20px; color: var(--fg1); }
.cart-empty { padding: 40px 18px; text-align: center; color: var(--fg3); font-size: 13.5px; }
.cart-empty svg { width: 30px; height: 30px; color: var(--slate-300); margin-bottom: 10px; }

/* generic helpers */
.empty-state { padding: 56px 24px; text-align: center; color: var(--fg3); }
.empty-state svg { width: 38px; height: 38px; color: var(--slate-300); margin-bottom: 12px; }
.empty-state h4 { font-family: var(--font-display); font-weight: 600; font-size: 17px; color: var(--fg2); margin: 0 0 6px; }
.muted2 { color: var(--fg3); font-size: 13px; }
.dim { color: var(--fg3); }
.flex { display: flex; }
.between { justify-content: space-between; }
.gap8 { gap: 8px; } .gap12 { gap: 12px; }
.center-y { align-items: center; }
.right-align { text-align: right; }
.wrap-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- product form modal ---- */
.modal-card.wide { max-width: 720px; max-height: 90vh; display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 22px 26px 16px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.modal-head h3 { margin: 0; }
.modal-head .sub { font-size: 13px; color: var(--fg3); margin-top: 3px; }
/* flex:1 + min-height:0 = el área de campos hace scroll INTERNO dentro del modal
   (sin esto, los formularios altos se desbordan y los campos de arriba quedan
   fuera de pantalla, imposibles de tocar/editar). */
.modal-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 22px 26px; }
.modal-foot { flex-shrink: 0; }
/* Modales simples (sin .wide): que nunca superen la pantalla; si son altos, scrollean. */
.modal-card { max-height: 92vh; overflow-y: auto; }
.modal-foot { display: flex; align-items: center; gap: 10px; padding: 16px 26px; border-top: 1px solid var(--line); background: var(--slate-50); border-radius: 0 0 var(--r-xl) var(--r-xl); }
.modal-foot .grow { flex: 1; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.form-grid .span2 { grid-column: span 2; }
.form-sec { font-family: var(--font-mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--fg3); margin: 20px 0 12px; padding-top: 18px; border-top: 1px solid var(--line); }
.form-sec:first-child { margin-top: 0; padding-top: 0; border-top: none; }
.field.tight { margin-bottom: 0; }
.field .hint { font-size: 11.5px; color: var(--fg3); font-weight: 400; }
.field .prefix-wrap { position: relative; display: flex; align-items: center; }
.field .prefix-wrap .pfx { position: absolute; left: 12px; color: var(--fg3); font-size: 14px; pointer-events: none; }
.field .prefix-wrap input { width: 100%; padding-left: 26px; }
.margin-live { font-family: var(--font-display); font-weight: 600; font-size: 13px; }

/* lots editor */
.lots-editor { display: flex; flex-direction: column; gap: 8px; }
.lot-row { display: grid; grid-template-columns: 1fr 1.3fr auto; gap: 10px; align-items: center; }
.lot-row input { font-family: var(--font-sans); font-size: 14px; padding: 9px 11px; border: 1px solid var(--line-strong); border-radius: var(--r-md); outline: none; background: var(--surface); transition: all var(--dur-fast); }
.lot-row input:focus { border-color: var(--accent); box-shadow: var(--ring); }
.lot-row .del { width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--fg3); }
.lot-row .del:hover { background: var(--danger-bg); color: var(--danger); border-color: transparent; }
.lots-head { display: grid; grid-template-columns: 1fr 1.3fr auto; gap: 10px; font-family: var(--font-mono); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--fg3); padding-right: 46px; }
.lots-head span:last-child { padding-right: 0; }
.lot-total { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; padding-top: 12px; border-top: 1px dashed var(--line); font-size: 13.5px; }
.lot-total b { font-family: var(--font-display); font-weight: 600; font-size: 16px; }
.add-lot { align-self: flex-start; }

/* confirm dialog */
.confirm-card { max-width: 400px; }
.confirm-card .ico { width: 46px; height: 46px; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin-bottom: 14px; }
.confirm-card p { font-size: 14px; color: var(--fg2); line-height: 1.5; margin: 0 0 20px; }

/* ---- data dropdown menu ---- */
.menu-wrap { position: relative; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 8px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); padding: 6px; min-width: 230px; z-index: 70; animation: pop var(--dur) var(--ease-out); }
.menu-item { display: flex; align-items: center; gap: 11px; width: 100%; padding: 9px 11px; border: none; background: transparent; border-radius: var(--r-md);
  font-family: var(--font-sans); font-size: 13.5px; font-weight: 500; color: var(--fg1); cursor: pointer; text-align: left; transition: background var(--dur-fast); }
.menu-item:hover { background: var(--surface-2); }
.menu-item svg { width: 16px; height: 16px; color: var(--fg3); flex-shrink: 0; }
.menu-item .msub { display: block; font-size: 11.5px; color: var(--fg3); font-weight: 400; margin-top: 1px; }
.menu-item.danger { color: var(--danger); } .menu-item.danger svg { color: var(--danger); }
.menu-sep { height: 1px; background: var(--line); margin: 5px 4px; }
.menu-label { font-family: var(--font-mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--fg3); padding: 7px 11px 4px; }

/* save flash on table row */

/* ---- print (Reportes → PDF) ---- */
@media print {
  .side, .topbar, .scrim, .drawer, .modal, .toast, .seg, .page-head .wrap-actions { display: none !important; }
  .app { display: block !important; }
  .main { display: block !important; }
  .content { padding: 0 !important; }
  .panel { break-inside: avoid; box-shadow: none !important; border-color: #ccc !important; }
  .stat { break-inside: avoid; }
  body { background: #fff !important; }
}

/* hide native number spinners in inline edits */
input[type=number]::-webkit-outer-spin-button, input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ---- hamburger button (hidden on desktop) ---- */
.ham-btn {
  display: none;
  width: 38px; height: 38px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--r-md);
  align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--dur-fast);
}
.ham-btn:hover { background: var(--surface-2); border-color: var(--line-strong); }
.ham-btn svg { width: 20px; height: 20px; color: var(--fg2); }

/* scrim behind mobile sidebar */
.side-scrim {
  position: fixed; inset: 0;
  background: rgba(12,15,20,.55);
  z-index: 98;
  animation: fade var(--dur) var(--ease);
}

/* responsive */
@media (max-width: 1100px) {
  .app { grid-template-columns: 1fr; }
  /* sidebar slides in as an overlay instead of display:none */
  .side {
    position: fixed !important;
    left: 0; top: 0;
    width: 268px;
    height: 100dvh;
    z-index: 99;
    transform: translateX(-270px);
    transition: transform 0.26s ease;
    box-shadow: var(--shadow-xl);
  }
  .side.open { transform: translateX(0); }
  .ham-btn { display: flex; }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .stats.cols-4 { grid-template-columns: repeat(2, 1fr); }
  .portal-grid { grid-template-columns: 1fr; }
  /* tables scroll horizontally on tablet */
  .panel { overflow-x: auto; }
}
/* topbar: keep it from overflowing on tablets/phones */
@media (max-width: 900px) {
  .topbar .crumb { display: none; }       /* redundant with the hamburger/title */
  .topbar .search { min-width: 0; }        /* allow the search to shrink */
}
@media (max-width: 640px) {
  .stats.cols-4 { grid-template-columns: 1fr; }
  .content { padding: 16px; }
  .order-card { grid-template-columns: 1fr; }
  /* drawer goes full-width on phones */
  .drawer { width: 100vw !important; max-width: 100vw !important; }
  /* modals use tighter padding */
  .modal { padding: 12px; }
  /* wide modals (product form) scroll properly */
  .modal-card.wide { max-height: 96dvh; }
  /* two-column form grids collapse to single column */
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span2 { grid-column: span 1; }
  /* compact topbar: drop decorative icon buttons + search, tighten spacing,
     so the hamburger and primary actions always fit phone widths */
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar .icon-btn { display: none; }     /* bell/help are decorative on mobile */
  .topbar .search { display: none; }        /* reclaim width; lists remain browsable */
  .topbar-actions { gap: 8px; margin-left: auto; }
}
