/* Televentas · Importadora Universal — hoja de estilos única (sin dependencias externas) */
:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #0b4f8a;
  --primary-600: #093f6f;
  --primary-50: #e8f1fa;
  --accent: #f59e0b;
  --success: #15803d;
  --success-50: #e9f7ee;
  --danger: #b91c1c;
  --danger-50: #fdecec;
  --warn: #b45309;
  --warn-50: #fff6e6;
  --info-50: #eaf3fd;
  --purple: #7c3aed;
  --wa: #1f9d55;
  --sidebar: #0c2340;
  --sidebar-text: #c9d6e6;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .05);
  --shadow-lg: 0 18px 50px rgba(15, 23, 42, .25);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 14px/1.45 var(--font); color: var(--text); background: var(--bg); }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h1 { font-size: 20px; } h2 { font-size: 16px; } h3 { font-size: 14.5px; }
p { margin: 0 0 8px; }
a { color: var(--primary); }
code { font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; }
img { max-width: 100%; }
[hidden] { display: none !important; }
.ic { flex-shrink: 0; vertical-align: middle; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.pad { padding: 12px 14px; }
.grow { flex: 1; }
.right { text-align: right; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack > * { min-width: 0; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between, .between { justify-content: space-between; }
.label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Estructura ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 248px; flex-shrink: 0; background: var(--sidebar); color: var(--sidebar-text); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 60; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 16px; border-bottom: 1px solid rgba(255, 255, 255, .08); }
.brand-logo { width: 42px; height: 42px; border-radius: 10px; background: #fff; padding: 3px; object-fit: contain; flex-shrink: 0; }
.brand-mark { width: 38px; height: 38px; border-radius: 9px; background: linear-gradient(135deg, #f59e0b, #d97706); color: #1f1300;
  font-weight: 800; display: grid; place-items: center; letter-spacing: .02em; flex-shrink: 0; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { color: #fff; font-size: 15px; }
.brand-text small { color: var(--sidebar-text); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav { padding: 10px 8px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: var(--sidebar-text); text-decoration: none; font-weight: 500; }
.nav-item:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav-item.active { background: rgba(245, 158, 11, .16); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.sidebar-foot { padding: 12px 16px; font-size: 11.5px; color: #8ea3bd; border-top: 1px solid rgba(255, 255, 255, .08); }
.sidebar-backdrop { display: none; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 12px; padding: 10px 22px; background: rgba(255, 255, 255, .96);
  border-bottom: 1px solid var(--border); backdrop-filter: blur(6px); min-height: 60px; }
.topbar-title { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.topbar-title h1 { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-date { color: var(--muted); font-size: 12px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.icon-btn { position: relative; width: 38px; height: 38px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface);
  display: grid; place-items: center; cursor: pointer; color: var(--text); }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.menu-toggle { display: none; }
.notif-count { position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger);
  color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.user-btn { display: flex; align-items: center; gap: 8px; border: 1px solid var(--border); background: var(--surface); border-radius: 22px; padding: 3px 12px 3px 3px; cursor: pointer; color: var(--text); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 12.5px; }
.user-meta { display: flex; flex-direction: column; text-align: left; line-height: 1.2; }
.user-meta small { color: var(--muted); font-size: 11.5px; }
.content { padding: 20px 22px 40px; min-width: 0; }

/* ---------- Menús desplegables ---------- */
.dropdown { position: relative; }
.dropdown-menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 230px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; display: none; z-index: 80; }
.dropdown.open .dropdown-menu { display: block; }
.dropdown-wide { width: min(360px, 92vw); }
.dropdown-head { font-weight: 600; padding: 6px 8px 8px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.dropdown-item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; border-radius: 7px; border: 0; background: none; color: var(--text);
  text-decoration: none; font: inherit; cursor: pointer; text-align: left; }
.dropdown-item:hover { background: var(--surface-2); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-menu form { margin: 0; }
.notif-list { max-height: 340px; overflow-y: auto; }
.notif-item { display: flex; gap: 8px; padding: 8px 10px; border-radius: 7px; text-decoration: none; color: var(--text); font-size: 13px; }
.notif-item:hover { background: var(--surface-2); }
.notif-item .dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex-shrink: 0; background: var(--primary); }
.notif-item.warning .dot { background: var(--accent); }
.notif-item.muted .dot { background: var(--border-strong); }

/* ---------- Tarjetas ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.card-body { padding: 16px; }
.card-foot { padding: 12px 16px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.card-foot strong { color: var(--text); }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grid-2 > *, .grid-3 > * { min-width: 0; }

/* ---------- Formularios ---------- */
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > label, .field-label { font-size: 12.5px; font-weight: 600; color: #334155; }
label.req::after, .field-label.req::after { content: " *"; color: var(--danger); }
.hint { font-size: 12px; color: var(--muted); }
.input { width: 100%; height: 36px; padding: 6px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface);
  font: inherit; color: var(--text); }
textarea.input { height: auto; min-height: 72px; resize: vertical; padding: 8px 10px; }
select.input { padding-right: 26px; }
.input:focus { outline: 2px solid rgba(11, 79, 138, .25); border-color: var(--primary); }
.input[readonly] { background: var(--surface-2); }
.input.invalid { border-color: var(--danger); }
.input-icon { position: relative; }
.input-icon .ic { position: absolute; left: 10px; top: 10px; color: var(--muted); }
.input-icon .input { padding-left: 32px; }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 13.5px; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 12px; padding: 12px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.filters .field { width: 150px; }
.filters .field.wide { width: 210px; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 14px; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-all { grid-column: 1 / -1; }
.form-error { color: var(--danger); font-size: 13px; }

/* ---------- Botones ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
  text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn:disabled, .btn.disabled { opacity: .55; cursor: not-allowed; pointer-events: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-600); }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { background: #116a32; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #991616; }
.btn-wa { background: var(--wa); border-color: var(--wa); color: #fff; }
.btn-wa:hover { background: #18834a; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--primary); }
.btn-ghost:hover { background: var(--primary-50); }
.btn-link-danger { color: var(--danger); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-xs { height: 26px; padding: 0 8px; font-size: 12px; }
.btn-lg { height: 44px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.btn-group .btn.active { background: var(--primary-50); border-color: var(--primary); color: var(--primary); z-index: 1; }
.exp-btns { display: inline-flex; gap: 4px; }

/* ---------- Alertas e insignias ---------- */
.alert { display: flex; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid; font-size: 13.5px; }
.alert > div { min-width: 0; }
.alert-info { background: var(--info-50); border-color: #bcd8f5; color: #0b3b66; }
.alert-warn { background: var(--warn-50); border-color: #f5d39c; color: #7a3e04; }
.alert-ok { background: var(--success-50); border-color: #b2e0c2; color: #0f5130; }
.alert-error { background: var(--danger-50); border-color: #f2b8b8; color: #7f1414; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap;
  background: #eef2f7; color: #334155; }
.badge.green { background: #dcf3e4; color: #0f5d2d; }
.badge.red { background: #fbe1e1; color: #8c1616; }
.badge.amber { background: #fdecd6; color: #8a3a06; }
.badge.purple { background: #ede5fd; color: #5521b5; }
.badge.blue { background: #dfeefc; color: #0b4f8a; }
.badge.gray { background: #e8edf3; color: #3e4b5c; }
.badge .sw { width: 8px; height: 8px; border-radius: 50%; }

/* ---------- Pestañas ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); padding: 0 10px; overflow-x: auto; scrollbar-width: thin; }
.card > .tabs { padding: 0 12px; }
.content > .tabs { margin-bottom: 16px; padding: 0; }
.tab { border: 0; background: none; padding: 10px 14px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px; text-decoration: none; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.table th { background: var(--surface-2); font-size: 12px; color: #475569; font-weight: 700; white-space: nowrap; position: sticky; top: 0; }
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable:hover { color: var(--text); }
.table th .arrow { font-size: 10px; margin-left: 3px; color: var(--primary); }
.table td.num, .table th.num { text-align: right; white-space: nowrap; }
.table td.code { white-space: nowrap; font-family: var(--mono); font-size: 12.5px; }
.table td.dt { white-space: nowrap; }
.table td.long { min-width: 180px; max-width: 360px; }
.table tbody tr:hover { background: #f9fbfd; }
.table tbody tr.clickable { cursor: pointer; }
.table tfoot td { font-weight: 700; background: var(--surface-2); }
.table td.actions { white-space: nowrap; text-align: right; }
.table .empty td { text-align: center; color: var(--muted); padding: 26px; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 10px 16px; border-top: 1px solid var(--border); }
.pager .pages { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.loading-row td { color: var(--muted); text-align: center; padding: 26px; }
.applied { padding: 6px 16px; font-size: 12px; color: var(--muted); }

/* ---------- Dashboard ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(175px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); min-width: 0; }
.kpi .k-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.kpi .k-value { font-size: 24px; font-weight: 750; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .k-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi.accent { border-top: 3px solid var(--primary); }
.kpi.ok { border-top: 3px solid var(--success); }
.kpi.bad { border-top: 3px solid var(--danger); }
.kpi.warn { border-top: 3px solid var(--accent); }
.chart-box { position: relative; height: 280px; }
.chart-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 13px; background: rgba(255, 255, 255, .85); }

/* ---------- Catálogo ---------- */
.products { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.product { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; display: flex; flex-direction: column; min-width: 0; }
.product.inactive { opacity: .6; }
.product .ph { aspect-ratio: 4 / 3; background: var(--surface-2); display: grid; place-items: center; border-bottom: 1px solid var(--border); overflow: hidden; }
.product .ph img { width: 100%; height: 100%; object-fit: contain; }
.product .pb { padding: 10px 12px; display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.p-code { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.p-desc { font-weight: 600; font-size: 13.5px; overflow-wrap: anywhere; }
.p-price { font-weight: 750; color: var(--primary); font-size: 15px; margin-top: auto; }
.p-actions { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px 12px; align-items: center; }
.p-actions .input.qty { width: 64px; height: 30px; padding: 4px 6px; }
.thumb { width: 44px; height: 44px; object-fit: contain; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2); }

/* ---------- Llamadas ---------- */
.call-search { position: relative; }
.call-search .input { height: 44px; padding-left: 40px; font-size: 15px; }
.suggest { position: absolute; left: 0; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); max-height: 380px; overflow-y: auto; z-index: 70; }
.suggest-item { display: flex; justify-content: space-between; gap: 10px; padding: 9px 12px; cursor: pointer; border-bottom: 1px solid var(--border); }
.suggest-item:last-child { border-bottom: 0; }
.suggest-item:hover, .suggest-item.active { background: var(--primary-50); }
.suggest-item .s-main { min-width: 0; }
.suggest-item .s-name { font-weight: 600; }
.suggest-item .s-sub { color: var(--muted); font-size: 12.5px; }
.empty-state { text-align: center; color: var(--muted); padding: 38px 16px; }
.empty-state .ic { color: var(--border-strong); margin-bottom: 8px; }
.workspace { display: grid; grid-template-columns: 380px minmax(0, 1fr); gap: 16px; margin-top: 16px; align-items: start; }
.workspace > * { min-width: 0; }
.sticky { position: sticky; top: 76px; }
.cust-card .card-body { display: flex; flex-direction: column; gap: 10px; }
.cust-name { font-size: 17px; font-weight: 750; overflow-wrap: anywhere; }
.dl { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 6px 10px; margin: 0; font-size: 13px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; overflow-wrap: anywhere; }
.customer-data { grid-template-columns: 150px minmax(0, 1fr); font-size: 14.5px; background: #f6f8fb; border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
@media (max-width: 480px) { .customer-data { grid-template-columns: 1fr; gap: 2px; } .customer-data dd { margin-bottom: 6px; } }
.call-panel { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.call-status { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; }
.call-status .pulse { width: 11px; height: 11px; border-radius: 50%; background: var(--border-strong); }
.call-status.active .pulse { background: var(--success); animation: pulse 1.3s infinite; }
.call-status.ringing .pulse { background: var(--accent); animation: pulse 1s infinite; }
.call-status.ended .pulse { background: var(--muted); }
.call-status.failed .pulse { background: var(--danger); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(21, 128, 61, .45); } 70% { box-shadow: 0 0 0 9px rgba(21, 128, 61, 0); } 100% { box-shadow: 0 0 0 0 rgba(21, 128, 61, 0); } }
.timer { font-family: var(--mono); font-size: 18px; font-weight: 700; }
.big-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.btn-call { height: 46px; padding: 0 22px; font-size: 15px; }
.hist-item { border-bottom: 1px solid var(--border); padding: 9px 0; font-size: 13px; }
.hist-item:last-child { border-bottom: 0; }
.hist-item .h-top { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.results-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.result-opt { position: relative; }
.result-opt input { position: absolute; opacity: 0; }
.result-opt span { display: flex; align-items: center; gap: 8px; border: 2px solid var(--border); border-radius: 9px; padding: 10px 12px; cursor: pointer; font-weight: 600; height: 100%; }
.result-opt span::before { content: ""; width: 12px; height: 12px; border-radius: 50%; background: var(--c, #64748b); flex-shrink: 0; }
.result-opt input:checked + span { border-color: var(--c, var(--primary)); background: color-mix(in srgb, var(--c, #0b4f8a) 9%, white); }
.result-opt input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- Pedido ---------- */
.order-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; }
.order-layout > * { min-width: 0; }
.order-results { display: flex; flex-direction: column; gap: 6px; max-height: 52vh; overflow-y: auto; margin-top: 8px; }
.order-prod { display: flex; align-items: center; gap: 10px; border: 1px solid var(--border); border-radius: 8px; padding: 7px 9px; }
.order-prod .op-main { flex: 1; min-width: 0; }
.order-prod .op-desc { font-weight: 600; font-size: 13px; overflow-wrap: anywhere; }
.order-prod .input.qty { width: 64px; height: 30px; padding: 4px 6px; }
.cart { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); display: flex; flex-direction: column; max-height: 62vh; }
.cart-head { padding: 10px 12px; border-bottom: 1px solid var(--border); font-weight: 700; display: flex; justify-content: space-between; gap: 8px; }
.cart-lines { overflow-y: auto; padding: 6px 12px; flex: 1; }
.cart-line { display: grid; grid-template-columns: minmax(0, 1fr) 62px auto; gap: 6px 8px; align-items: center; border-bottom: 1px solid var(--border); padding: 7px 0; font-size: 12.5px; }
.cart-line .input { height: 28px; padding: 3px 5px; }
.cart-line .cl-total { grid-column: 1 / -1; display: flex; justify-content: space-between; color: var(--muted); }
.cart-foot { padding: 10px 12px; border-top: 1px solid var(--border); }
.cart-total { font-size: 18px; font-weight: 800; display: flex; justify-content: space-between; }

/* ---------- Mapa ---------- */
.map-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 16px; align-items: start; }
.map-layout > * { min-width: 0; }
.map-box { height: calc(100vh - 170px); min-height: 460px; border-radius: var(--radius); }
.legend { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.legend span { display: inline-flex; align-items: center; gap: 8px; }
.legend i { width: 12px; height: 12px; border-radius: 50%; display: inline-block; border: 2px solid rgba(0, 0, 0, .15); }
.nc-item { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12.5px; border: 1px solid var(--border); border-radius: 7px; padding: 6px 8px; }
.nc-item > div { min-width: 0; overflow-wrap: anywhere; }
.leaflet-popup-content { font: 13px/1.45 var(--font); margin: 12px 14px; }
.leaflet-popup-content .pop-name { font-weight: 700; font-size: 14px; }
.leaflet-popup-content .pop-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.leaflet-popup-content a.btn { color: var(--text); }
.leaflet-popup-content a.btn-primary, .leaflet-popup-content a.btn-success { color: #fff; }
.map-picker { height: 260px; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.leaflet-container.picking { cursor: crosshair; }

/* ---------- Ventanas modales ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .5); z-index: 1000; display: flex; align-items: flex-start; justify-content: center;
  padding: 5vh 16px; overflow-y: auto; }
.modal { background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-lg); width: min(560px, 100%); display: flex; flex-direction: column; max-width: 100%; }
.modal.lg { width: min(820px, 100%); }
.modal.xl { width: min(1180px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 16.5px; }
.modal-close { border: 0; background: none; font-size: 24px; line-height: 1; cursor: pointer; color: var(--muted); padding: 0 4px; }
.modal-body { padding: 16px 18px; min-width: 0; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 12px 12px; }
body.modal-open { overflow: hidden; }

/* ---------- Notificaciones flotantes ---------- */
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 2000; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: #0f172a; color: #fff; padding: 11px 14px; border-radius: 9px; box-shadow: var(--shadow-lg); font-size: 13.5px; border-left: 4px solid var(--primary);
  animation: tin .18s ease-out; }
.toast.ok { border-left-color: #22c55e; }
.toast.error { border-left-color: #ef4444; }
.toast.warn { border-left-color: var(--accent); }
@keyframes tin { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Ingreso ---------- */
.login-page { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.login-side { background: linear-gradient(160deg, #0c2340, #0b4f8a); color: #dbe7f5; padding: 40px; display: flex; flex-direction: column; justify-content: space-between; gap: 30px; }
.login-side h1 { color: #fff; font-size: 30px; margin-bottom: 10px; }
.login-side p { font-size: 16px; max-width: 420px; }
.login-main { display: grid; place-items: center; padding: 30px 16px; }
.login-card { width: min(420px, 100%); }
.login-card h2 { font-size: 22px; margin-bottom: 4px; }
.login-logo { display: block; width: 190px; height: auto; margin: 0 auto 18px; }

/* ---------- Catálogo público ---------- */
.public-head { background: var(--sidebar); color: #fff; padding: 18px 16px; }
.public-head h1 { font-size: 20px; }
.public-brand { display: flex; align-items: center; gap: 12px; }
.public-logo { width: 44px; height: 44px; border-radius: 10px; background: #fff; padding: 3px; object-fit: contain; flex-shrink: 0; }
.public-wrap { max-width: 1180px; margin: 0 auto; padding: 18px 16px 40px; }

/* ---------- Adaptación a pantallas ---------- */
@media (max-width: 1180px) {
  .workspace { grid-template-columns: 330px minmax(0, 1fr); }
  .order-layout { grid-template-columns: minmax(0, 1fr) 300px; }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 960px) {
  .icon-btn.menu-toggle { display: grid; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 55; }
  .workspace, .order-layout, .map-layout, .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .sticky { position: static; }
  .map-box { height: 60vh; min-height: 340px; }
  .login-page { grid-template-columns: 1fr; }
  .login-side { padding: 24px; }
  .login-side h1 { font-size: 22px; }
  .cart { max-height: none; }
  .order-results { max-height: 40vh; }
}
@media (max-width: 640px) {
  .content { padding: 14px 12px 32px; }
  .topbar { padding: 8px 12px; }
  .user-meta, .topbar-date { display: none; }
  .user-btn { padding: 3px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid .span-2 { grid-column: auto; }
  .filters .field, .filters .field.wide { width: calc(50% - 6px); }
  .filters .field[style*="flex:1"] { width: 100%; }
  .card-head { padding: 10px 12px; }
  .card-body { padding: 12px; }
  .modal-backdrop { padding: 0; }
  .modal, .modal.lg, .modal.xl { border-radius: 0; min-height: 100vh; }
  .btn-call { flex: 1 1 100%; }
  .big-actions .btn { flex: 1 1 calc(50% - 4px); }
  .dl { grid-template-columns: 96px minmax(0, 1fr); }
  .products { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi .k-value { font-size: 20px; }
}
@media print {
  .sidebar, .topbar, .toolbar, .filters, .pager { display: none !important; }
  .content { padding: 0; }
}

/* ---------- Números para marcar (llamadas manuales) ---------- */
.dial { display: flex; flex-wrap: wrap; gap: 10px 26px; }
.dial-num { display: flex; flex-direction: column; gap: 2px; align-items: flex-start; }
.dial-link { font-size: 24px; font-weight: 750; color: var(--text); text-decoration: none; letter-spacing: .02em; }
.dial-link:hover { color: var(--primary); }
@media (max-width: 640px) { .dial-link { font-size: 22px; } }

/* ---------- Pedido desde el catálogo público ---------- */
.cart-bar { position: fixed; left: 0; right: 0; bottom: 16px; display: flex; justify-content: center; z-index: 900; pointer-events: none; padding: 0 16px; }
.cart-bar .btn { pointer-events: auto; box-shadow: var(--shadow-lg); max-width: 100%; white-space: normal; }
.public-wrap { padding-bottom: 90px; }
body.public-page .toasts { top: 16px; bottom: auto; }

/* ---------- Bienvenida del catálogo público ---------- */
.welcome { max-width: 640px; }
.welcome-card { margin-top: 8px; }
.welcome-logo { display: block; width: 170px; height: auto; margin: 0 auto 14px; }
.welcome-title { font-size: 22px; margin-bottom: 8px; color: var(--primary); }
.welcome-text { font-size: 15px; }
.welcome-steps { padding-left: 22px; margin: 14px 0 18px; display: flex; flex-direction: column; gap: 8px; font-size: 14.5px; }
.welcome-form .input { flex: 1; min-width: 0; }
.customer-hello { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; font-size: 15px; }
.input[readonly].prefilled { background: var(--surface-2); color: var(--text); border-style: dashed; }
