/* Colores base. Los de marca (--accent, --bg, --surface, --text, --muted, --font…) se reemplazan al
   cargar con los de public/marca.js (ver aplicarMarca en js/marca-aplicar.js); estos valores solo se ven un instante. */
:root {
  --c-income: #199e70;
  --c-purchases: #d95926;
  --c-taxes: #3987e5;
  --ink: #f2f4f7;
  --grid: #22252a;
  --axis: #3a3e45;
  --muted-ink: #8a9099;
  --bg: #070b08;
  --surface: #101512;
  --surface-2: #161d18;
  --text: #f2f5f3;
  --muted: #a9b4ad;
  --accent: #17b959;
  --accent-light: #57ea91;
  --on-accent: #050806;
  --line: color-mix(in srgb, var(--accent) 14%, transparent);
  --ok: #6fbf8b;
  --danger: #e0705c;
  /* Advertencia (stock bajo, fiado, por vencer): color de estado, no de marca. */
  --warn: #f0b43c;
  --dim: #6b7079;
  --tooltip-bg: #1a1d21;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --sidebar-w: 236px;
}

* { box-sizing: border-box; }
html { color-scheme: dark; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent-light); outline-offset: 2px; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: 0.01em; }
h1 { font-size: 24px; }
h3 { font-size: 15px; }
h4 { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; margin: 18px 0 8px; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.late { color: var(--danger); font-weight: 600; }
.link { color: var(--accent-light); font-size: 13px; }
.link:hover { text-decoration: underline; }

/* Botones */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 10px;
  padding: 9px 14px;
  transition: border-color 0.15s, background-color 0.15s;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 700; }
.btn-primary:hover { background: var(--accent-light); border-color: var(--accent-light); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); }
.btn-small { padding: 5px 10px; font-size: 13px; }
.btn-icon { padding: 6px 8px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.4; cursor: default; }
.btn[disabled]:hover { border-color: var(--line); }

/* Formularios */
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input, select, textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 11px;
}
textarea { min-height: 84px; resize: vertical; }
.field { margin-bottom: 14px; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; min-width: 0; }
.error { color: var(--danger); font-size: 14px; min-height: 20px; margin: 4px 0 10px; }

/* Marca */
.brand { display: flex; flex-direction: column; }
.brand strong { font-size: 20px; letter-spacing: 0.14em; color: var(--accent-light); }
.brand span { color: var(--muted); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; }
.brand-logo { display: block; width: 150px; max-width: 100%; height: auto; margin-bottom: 6px; }
.login-card .brand-logo { width: 210px; margin: 0 auto 8px; }
.mobilebar .brand-logo { width: auto; height: 30px; margin: 0; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px 24px;
}
.login-card .brand { margin-bottom: 22px; align-items: center; }
.login-card .brand strong { font-size: 22px; }

/* Pantalla de carga (arranque, login, y al cambiar de contraseña obligatoria) */
.boot-loading { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.boot-mark { display: flex; flex-direction: column; align-items: center; margin-bottom: 26px; }
.boot-mark strong { font-size: 26px; letter-spacing: 0.16em; color: var(--accent-light); }
.boot-mark span { color: var(--muted); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; margin-top: 4px; }
.spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
.boot-hint { margin: 16px 0 0; color: var(--muted); font-size: 13px; letter-spacing: 0.03em; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2.4s; }
}

/* Estructura con barra lateral */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px 14px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}
.sidebar .brand { padding: 0 8px 16px; border-bottom: 1px solid var(--line); }

/* Con más secciones el menú puede ser más alto que la pantalla: se desplaza solo, sin tapar la marca ni el pie.
   El scrollbar es delgado y del color de la marca en vez del gris del sistema. */
.nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1 1 auto;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--accent) 30%, transparent) transparent;
}
.nav::-webkit-scrollbar { width: 6px; }
.nav::-webkit-scrollbar-track { background: transparent; }
.nav::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--accent) 28%, transparent); border-radius: 999px; }
.nav::-webkit-scrollbar-thumb:hover { background: color-mix(in srgb, var(--accent) 45%, transparent); }

/* Cada grupo es un <details>: se puede plegar y recuerda si lo dejaste cerrado (localStorage). */
.nav-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.nav > .nav-group:first-of-type { margin-top: 0; padding-top: 2px; border-top: 0; }
.nav-group-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted-ink);
  padding: 2px 12px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.nav-group-label::-webkit-details-marker { display: none; }
.nav-group-label::after {
  content: '';
  width: 7px;
  height: 7px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.15s;
  flex-shrink: 0;
}
.nav-group[open] > .nav-group-label::after { transform: rotate(45deg); }
.nav-group-label:hover { color: var(--muted); }
.nav-group-label:focus-visible { outline: 2px solid var(--accent-light); outline-offset: 2px; border-radius: 4px; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px 9px 9px;
  border-radius: 9px;
  color: var(--muted);
  border-left: 3px solid transparent;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}
.nav-link svg { opacity: 0.8; transition: opacity 0.15s; flex-shrink: 0; }
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link:hover svg { opacity: 1; }
.nav-link[aria-current='page'] { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent-light); border-left-color: var(--accent); font-weight: 600; }
.nav-link[aria-current='page'] svg { opacity: 1; }

.sidebar-foot { margin-top: auto; padding: 14px 8px 0; border-top: 1px solid var(--line); }
.me { font-size: 14px; margin-bottom: 10px; word-break: break-word; font-weight: 500; }
.sidebar-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.content { padding: 26px 28px 40px; max-width: 1400px; width: 100%; outline: none; }
.mobilebar, .scrim { display: none; }

/* Vistas */
.view-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.head-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  min-width: 0;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }

/* "Hoy": lo que necesita atención, resumido arriba de todo en Inicio */
.today-panel { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--muted-ink); border-radius: 14px; padding: 16px; margin-bottom: 16px; }
.today-panel.warn { border-left-color: var(--warn); }
.today-panel.danger { border-left-color: var(--danger); }
.today-panel.ok { border-left-color: var(--ok); }
.today-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.today-list .pill { margin: 0; font-size: 13px; padding: 5px 12px; text-decoration: none; }
.today-list a.pill:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); }

/* Estadísticas */
.sales-toggle { display: flex; gap: 8px; margin-bottom: 8px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  transition: border-color 0.15s, transform 0.15s;
}
.stat:hover { border-color: var(--accent); transform: translateY(-2px); }
.stat-label { color: var(--muted); font-size: 13px; }
.stat-value { font-size: 34px; line-height: 1.1; color: var(--accent-light); }
.stat.danger .stat-value { color: var(--danger); }
.stat.ok .stat-value { color: var(--ok); }
.stat-hint { font-size: 12.5px; color: var(--muted); }

.bars { display: flex; flex-direction: column; gap: 12px; }
.bar-head { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; margin-bottom: 4px; }
.bar { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width 0.4s; }
.bar-fill.ok { background: var(--ok); }
.bar-fill.danger { background: var(--danger); }
.bar-fill.muted-bar { background: var(--dim); }
.kpi-line { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 13.5px; color: var(--muted); }
.kpi-line strong { color: var(--text); }

.mini-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.mini-list li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid color-mix(in srgb, var(--accent) 10%, transparent); font-size: 14px; }
.mini-list li:last-child { border-bottom: 0; }
.mini-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-list .muted { flex-shrink: 0; font-size: 13px; }

.connect-card p { margin-bottom: 12px; }
.checks { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.checks li { padding-left: 24px; position: relative; }
.checks li::before { content: '✓'; position: absolute; left: 2px; color: var(--accent); font-weight: 700; }

.toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.toggle button { border: 0; background: transparent; padding: 6px 12px; font-size: 13px; }
.toggle button[aria-pressed='true'] { background: var(--accent); color: var(--on-accent); font-weight: 700; }

.toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar select { width: auto; min-width: 220px; }
.toolbar input { width: 260px; max-width: 100%; }

/* Calendario */
.layout-cal { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(300px, 1fr); gap: 16px; align-items: start; }
.cal-nav { display: flex; align-items: center; gap: 8px; }
.cal-title { font-size: 18px; min-width: 150px; text-align: center; text-transform: capitalize; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-dow { text-align: center; font-size: 12px; color: var(--muted); padding: 4px 0; text-transform: uppercase; letter-spacing: 0.06em; }
.cal-day {
  min-height: 92px;
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 5px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow: hidden;
}
.cal-day:hover { border-color: var(--line); }
.cal-day.other { opacity: 0.4; }
.cal-day.today .cal-num { background: var(--accent); color: var(--on-accent); }
.cal-day.selected { border-color: var(--accent); }
.cal-num { font-size: 12px; font-weight: 700; align-self: flex-start; padding: 1px 6px; border-radius: 999px; }
.chip {
  display: block;
  font-size: 11.5px;
  line-height: 1.25;
  padding: 2px 5px;
  border-radius: 5px;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  border-left: 3px solid var(--accent);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chip.en_curso { background: color-mix(in srgb, var(--accent) 30%, transparent); }
.chip.hecha { background: rgba(111, 191, 139, 0.14); border-left-color: var(--ok); text-decoration: line-through; color: var(--muted); }
.chip.overdue { border-left-color: var(--danger); background: rgba(224, 112, 92, 0.16); }
.more { font-size: 11px; color: var(--muted); }

/* Tareas y contactos (tarjetas) */
.task-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.task, .task-card, .lead {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  padding: 10px 12px;
  min-width: 0;
}
.task { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: start; }
.task.hecha, .task-card.hecha, .lead.ganado { border-left-color: var(--ok); }
.task.overdue, .task-card.overdue { border-left-color: var(--danger); }
.lead.perdido { border-left-color: var(--dim); opacity: 0.8; }
.task.hecha .task-title, .task-card.hecha .task-title { text-decoration: line-through; color: var(--muted); }
.task-title, .lead-name { font-weight: 600; word-break: break-word; }
.task-desc { font-size: 13px; color: var(--muted); margin-top: 4px; word-break: break-word; }
.lead-contact { font-size: 13px; color: var(--muted); word-break: break-word; }
.lead-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; }
.lead-meta strong { color: var(--accent-light); font-size: 14px; }
.badge { font-size: 11.5px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.task-title .badge { margin-left: 8px; vertical-align: middle; }
.task-meta { font-size: 12.5px; color: var(--muted); margin-top: 4px; display: flex; gap: 10px; flex-wrap: wrap; }
.task-actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.task .task-actions { margin-top: 0; }
.empty { color: var(--muted); font-size: 14px; padding: 6px 0; }

/* Tableros */
.board { display: grid; gap: 14px; align-items: start; }
.board-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.board-6 { grid-template-columns: repeat(6, minmax(172px, 1fr)); overflow-x: auto; padding-bottom: 10px; }
.column { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px; min-width: 0; }
.column-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.column-tools { display: flex; align-items: center; gap: 6px; }
.count { font-size: 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 1px 9px; }

/* Ventanas emergentes */
.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.7); display: grid; place-items: center; padding: 16px; z-index: 30; }
.modal { width: 100%; max-width: 460px; max-height: 92vh; overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 22px; }
.modal h2 { margin-bottom: 16px; font-size: 18px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }
.modal-actions .spacer { margin-right: auto; }

@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .board-3 { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .mobilebar {
    display: flex;
    align-items: center;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 10px 14px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
  }
  .sidebar {
    position: fixed;
    z-index: 25;
    left: 0;
    top: 0;
    width: min(280px, 84vw);
    transform: translateX(-102%);
    transition: transform 0.2s ease;
  }
  .sidebar.open { transform: translateX(0); }
  body.menu-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); z-index: 20; }
  .content { padding: 18px 14px 32px; }
  .layout-cal, .grid-2 { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 640px) {
  h1 { font-size: 21px; }
  .cal-day { min-height: 58px; padding: 3px; }
  .chip { font-size: 0; height: 6px; padding: 0; border-left-width: 0; border-radius: 3px; background: var(--accent); }
  .chip.hecha { background: var(--ok); }
  .chip.overdue { background: var(--danger); }
  .cal-title { min-width: 110px; font-size: 16px; }
  .row { flex-direction: column; gap: 0; }
  .stat-value { font-size: 28px; }
  .toolbar select, .toolbar input { width: 100%; min-width: 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* Negocio: secciones, tablas, productos */
.section-title { margin: 22px 0 10px; }
.section-title:first-of-type { margin-top: 0; }
.hint { margin: -6px 0 12px; }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px; margin-bottom: 14px; }
.check input { width: auto; }
.toolbar.tight { margin: 0; }
.toolbar.tight select { min-width: 170px; }
.foot { margin-top: 12px; }
.plus { color: var(--ok); }
.minus { color: var(--danger); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; margin-bottom: 16px; }
.product.inactive { opacity: 0.6; }
.product-tags { margin: -6px 0 8px; }
/* Lo que el cliente debe evitar (lactosa, estimulantes…): resaltado para verlo antes de venderle. */
.avoid { color: var(--warn); font-weight: 600; }
.match .avoid { margin-top: 4px; }
/* Dentro de la grilla de tarjetas no aplica el espacio entre paneles apilados (desalineaba la primera fila). */
.cards > .panel, .cards > .panel + .panel { margin-top: 0; }
.toolbar { align-items: center; }
.stock-number { font-size: 40px; font-weight: 700; line-height: 1.1; color: var(--accent-light); margin-bottom: 4px; }

.pill { font-size: 11.5px; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); margin-left: 8px; }
.pill.danger { color: var(--danger); border-color: var(--danger); }
.pill.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 70%, transparent); }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-weight: 600; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px; border-bottom: 1px solid color-mix(in srgb, var(--accent) 10%, transparent); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table .strong { font-weight: 600; }
.table .notes-cell { max-width: 260px; color: var(--muted); word-break: break-word; }
.table tr.reversed td { opacity: 0.5; text-decoration: line-through; }
.table tr.reversed td:last-child, .table tr.reversed td .pill { text-decoration: none; }

.preview { margin: 4px 0 12px; padding: 9px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); font-size: 14px; }
.preview.bad { border-color: var(--danger); color: var(--danger); }

/* Venta con varios productos (carrito) */
.cart { display: flex; flex-direction: column; gap: 10px; }
.cart-line { padding: 10px 12px 6px; border: 1px solid var(--line); border-radius: 10px; background: color-mix(in srgb, var(--surface-2) 50%, transparent); }
.cart-line .field { margin-bottom: 6px; }
.cart-line .row > :first-child { flex: 2; }
.cart-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 4px; }
.cart-note.bad { color: var(--danger); }
.cart-remove[hidden] { display: none; }
.cart-add { margin: 8px 0 14px; }

/* Importar desde Shopify */
.import-rules { margin: 4px 0 14px; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
.import-errors { max-height: 220px; overflow: auto; margin-bottom: 10px; font-size: 13px; }
.import-errors li { padding: 4px 0; }
.pill.ok { color: var(--ok); border-color: var(--ok); }

/* Finanzas: gráfica */
.chart-wrap { position: relative; margin-top: 8px; }
.chart-wrap svg { display: block; max-width: 100%; }
.ch-grid { stroke: var(--grid); stroke-width: 1; }
.ch-axis { stroke: var(--axis); stroke-width: 1; }
.ch-tick { fill: var(--muted-ink); font-size: 11px; font-family: inherit; font-variant-numeric: tabular-nums; }
.ch-bar { transition: opacity 0.15s; }
.ch-line { stroke: var(--ink); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.ch-dot { fill: var(--ink); stroke: var(--surface); stroke-width: 2; }
.ch-label { fill: var(--ink); font-size: 12px; font-weight: 600; paint-order: stroke; stroke: var(--surface); stroke-width: 3px; stroke-linejoin: round; }
.ch-cross { stroke: var(--axis); stroke-width: 1; }
.ch-zone { fill: transparent; cursor: default; outline: none; }
.ch-zone:focus-visible { stroke: var(--accent-light); stroke-width: 2; }
.tooltip { position: absolute; z-index: 6; min-width: 200px; pointer-events: none; background: var(--tooltip-bg); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; font-size: 13px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45); }
.tooltip[hidden] { display: none; }
.tip-title { color: var(--muted); text-transform: capitalize; margin-bottom: 6px; }
.tip-row { display: flex; justify-content: space-between; gap: 14px; padding: 2px 0; }
.tip-row strong { font-variant-numeric: tabular-nums; }
.tip-key { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.tip-total { margin-top: 4px; padding-top: 6px; border-top: 1px solid var(--line); }
.legend { display: flex; gap: 18px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; gap: 8px; }
.key-bar { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.key-bar[data-series='income'] { background: var(--c-income); }
.key-bar[data-series='purchases'] { background: var(--c-purchases); }
.key-bar[data-series='taxes'] { background: var(--c-taxes); }
.key-line { display: inline-block; width: 16px; height: 2px; background: var(--ink); border-radius: 2px; }
.bar-fill.c-purchases { background: var(--c-purchases); }
.bar-fill.c-taxes { background: var(--c-taxes); }
.table-twin { margin-top: 14px; }
.table-twin summary { cursor: pointer; color: var(--accent-light); font-size: 13px; padding: 4px 0; }
.table-twin .table-wrap { margin-top: 8px; }
.fin-list { display: flex; flex-direction: column; gap: 10px; }
.fin-row { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.fin-row strong { font-variant-numeric: tabular-nums; }
.fin-strong span { color: var(--ink); }
.fin-strong strong { font-size: 18px; }
.fin-sub { padding-left: 16px; }
.fin-credit strong { color: var(--warn); }
.fin-subtotal { padding-top: 10px; border-top: 1px dashed var(--line); font-weight: 600; }
.fin-note { margin: 0; }
.plain-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.plain-list li { padding: 8px 0; border-bottom: 1px solid color-mix(in srgb, var(--accent) 10%, transparent); }
.plain-list li:last-child { border-bottom: 0; }
.fin-total { margin-top: 4px; padding-top: 12px; border-top: 1px solid var(--line); font-weight: 600; }
.fin-total strong { font-size: 20px; }

/* Formulario de cliente */
.modal.wide { max-width: 680px; }
.form-section { margin: 20px 0 10px; padding-top: 14px; border-top: 1px solid var(--line); }
.form-section:first-of-type { margin-top: 0; border-top: 0; padding-top: 0; }
.group { border: 0; margin: 0 0 12px; padding: 0; min-width: 0; }
.group legend { font-size: 13px; color: var(--muted); margin-bottom: 8px; padding: 0; }
.choices { display: flex; flex-wrap: wrap; gap: 8px 10px; }
.choice { display: inline-flex; align-items: center; gap: 8px; margin: 0; padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px; color: var(--text); font-size: 14px; cursor: pointer; }
.choice input { width: auto; margin: 0; accent-color: var(--accent); }
.choice:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.choice:has(input:focus-visible) { outline: 2px solid var(--accent-light); outline-offset: 2px; }
.warn-note { color: var(--warn); font-size: 13px; margin: -4px 0 12px; }
.warn-note[hidden], input[hidden] { display: none; }
.group + input { margin-bottom: 12px; }
td .pill { margin-left: 0; margin-top: 4px; display: inline-block; }

/* Aviso de versión nueva */
.update-banner { position: fixed; top: 0; left: 0; right: 0; z-index: 60; display: flex; align-items: center; justify-content: center; gap: 12px; padding: 8px 14px; background: var(--accent); color: var(--on-accent); font-weight: 600; font-size: 14px; }
.update-banner .btn { background: var(--on-accent); color: var(--accent-light); border-color: var(--on-accent); }

/* Deudores / fiado */
.stat.warn .stat-value { color: var(--warn); }
.table .actions-cell { display: table-cell; white-space: normal; min-width: 140px; }
.actions-cell .btn { margin: 0 0 4px 6px; }
a.pill { text-decoration: none; }
a.pill:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.table td.late { color: var(--danger); }
.modal .table-wrap { margin-bottom: 8px; }
.stats.stats-auto { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
@media (max-width: 900px) {
  .stats.stats-auto { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.stats + .panel, .stats + .grid-2 { margin-top: 16px; }

/* Venta rápida */
[hidden] { display: none !important; }
.match { margin: -4px 0 12px; padding: 9px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); font-size: 14px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.match.existing { border-color: var(--ok); }
.match.new { border-color: var(--accent); }
.newcustomer { border-left: 2px solid var(--accent); padding-left: 12px; margin-bottom: 12px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 70; max-width: min(92vw, 560px); padding: 12px 18px; border-radius: 12px; background: var(--surface-2); color: var(--text); border: 1px solid var(--ok); box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5); font-size: 14px; }
.stage-pill.ganado { color: var(--ok); border-color: var(--ok); }
.stage-pill.perdido { color: var(--danger); border-color: var(--danger); }
.stage-pill.nuevo, .stage-pill.contactado, .stage-pill.interesado, .stage-pill.propuesta { color: var(--accent-light); border-color: var(--accent); }

/* ===== Refinamiento visual: menos ruido, más aire ===== */
h1 { font-size: 26px; letter-spacing: 0; }
.view-head { margin-bottom: 22px; }
.view-head .muted { font-size: 14px; margin-top: 2px; }
.section-title { font-size: 12px; letter-spacing: 0.1em; margin: 28px 0 12px; color: var(--muted-ink); }

/* Paneles más livianos */
.panel { border-radius: 12px; padding: 20px; }
.panel-head { margin-bottom: 14px; }
.panel-head h3 { font-size: 15px; }
.grid-2 { align-items: start; gap: 18px; margin-top: 18px; }
.panel + .panel, .stats + .panel, .stats + .grid-2 { margin-top: 18px; }
.column, .task-card, .lead { border-color: var(--line); }
.task-card, .lead { border-left-width: 3px; border-top-color: transparent; border-right-color: transparent; border-bottom-color: transparent; background: var(--surface-2); }

/* Cifras: una sola franja con divisiones finas, números neutros */
.stats, .stats.stats-auto {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.stat { border: 0; border-radius: 0; background: var(--surface); padding: 16px 18px; gap: 3px; }
.stat:hover { border-color: transparent; transform: none; }
a.stat:hover { background: var(--surface-2); }
.stat-label { font-size: 12.5px; letter-spacing: 0.02em; }
.stat-value { font-size: 26px; font-weight: 700; color: var(--text); letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.stat.warn .stat-value { color: var(--warn); }
.stat-hint { font-size: 12px; color: var(--muted-ink); }
@media (max-width: 640px) {
  .stats, .stats.stats-auto { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .stat { padding: 14px; }
  .stat-value { font-size: 22px; }
}

/* Barras más finas y tranquilas */
.bars { gap: 14px; }
.bar { height: 5px; }
.bar-fill { background: color-mix(in srgb, var(--accent) 70%, transparent); }
.bar-fill.ok { background: rgba(111, 191, 139, 0.8); }
.bar-head { font-size: 13.5px; }
.kpi-line { margin-top: 18px; padding-top: 14px; }

/* Botones: el color de acento lleno queda solo para la acción principal de cada pantalla */
.btn { background: transparent; }
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); }
.btn-primary:hover { background: var(--accent-light); }
.btn-outline { border-color: color-mix(in srgb, var(--accent) 50%, transparent); color: var(--accent-light); }
.btn-outline:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); border-color: var(--accent); }
.btn-quiet { border-color: transparent; color: var(--muted); }
.btn-quiet:hover { color: var(--text); background: var(--surface-2); border-color: transparent; }
.btn-danger.btn-quiet { color: var(--danger); }
.toggle button[aria-pressed='true'] { background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--accent-light); }
.pill { margin-left: 0; }

/* Tablas: más aire, líneas casi invisibles */
.table td { padding: 13px 10px; border-bottom: 1px solid color-mix(in srgb, var(--accent) 8%, transparent); }
.table th { border-bottom-color: color-mix(in srgb, var(--accent) 18%, transparent); font-weight: 500; letter-spacing: 0.08em; color: var(--muted-ink); }
.table .actions-cell { display: table-cell; text-align: right; white-space: nowrap; min-width: 0; }
.actions-cell .btn { margin: 0 0 0 4px; }
.cell-stack > * + * { margin-top: 3px; }
.cell-stack .pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.cell-stack .pills .pill { margin: 0; }
td .pill { margin-top: 0; }

/* Línea de cifras dentro de un panel (sin tarjetas dentro de tarjetas) */
.inline-stats { display: flex; flex-wrap: wrap; gap: 8px 36px; }
.inline-stats > div { display: flex; flex-direction: column; gap: 1px; }
.inline-stats span { font-size: 12.5px; color: var(--muted); }
.inline-stats strong { font-size: 20px; font-variant-numeric: tabular-nums; }
.inline-stats .ok { color: var(--ok); }
.inline-stats .warn { color: var(--warn); }
.inline-stats .danger { color: var(--danger); }

/* Explicaciones plegables */
details.panel > summary { cursor: pointer; font-weight: 600; font-size: 14px; color: var(--muted); list-style: none; display: flex; align-items: center; gap: 8px; }
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary::before { content: '▸'; color: var(--accent); transition: transform 0.15s; }
details.panel[open] > summary::before { transform: rotate(90deg); }
details.panel > summary:hover { color: var(--text); }
details.panel[open] > summary { margin-bottom: 14px; }

/* Tarjetas del embudo y de tareas más compactas */
.lead-contact, .task-desc { font-size: 12.5px; }
.lead .task-actions, .task-card .task-actions { flex-wrap: nowrap; align-items: center; gap: 4px; margin-top: 10px; }
.lead-meta { margin-top: 4px; }
.lead-line { font-size: 12px; color: var(--muted-ink); margin-top: 6px; }

/* Tablas → tarjetas en celular (las etiquetas las pone main.js con los encabezados) */
@media (max-width: 720px) {
  .table-wrap { overflow-x: visible; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { padding: 14px 0; border-bottom: 1px solid var(--line); }
  .table tr:last-child { border-bottom: 0; }
  .table td { border: 0; padding: 2px 0; text-align: left !important; white-space: normal !important; }
  .table td:empty { display: none; }
  .table td[data-label]:not(:first-child)::before { content: attr(data-label) ': '; color: var(--muted-ink); font-size: 12px; }
  .table .actions-cell { display: flex; flex-wrap: wrap; justify-content: flex-start; gap: 6px; padding-top: 10px; }
  .table .actions-cell .btn { margin: 0; }
  .panel { padding: 16px; }
}
.team-line { margin: -4px 0 14px; font-size: 14px; }
.team-line .late { font-weight: 600; }
.mini-list .muted.minus, .mini-list .minus { color: var(--danger); }
.stock-number { color: var(--text); font-size: 34px; }
.lead-value { font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.lead-meta { display: none; }
.spacer-left { margin-left: auto; }
.grid-2 > .panel { margin-top: 0; }
.grid-2 + .panel, .stats + .panel { margin-top: 18px; }
.view > .section-title:first-of-type { margin-top: 30px; }
@media (max-width: 720px) {
  .table td:has(.cell-stack)::before { display: none; }
  .table td .cell-stack { display: block; }
}
.tip-note { margin-top: 6px; font-size: 12px; color: var(--muted); }
.table td .pill { margin-left: 6px; }
.cell-stack .pills .pill { margin-left: 0; }
@media (max-width: 720px) {
  .board-6 { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: 82%; scroll-snap-type: x mandatory; gap: 12px; }
  .board-6 > .column { scroll-snap-align: start; }
}

/* Embudo: tarjetas compactas y arrastrables */
.lead { padding: 8px 10px; cursor: grab; }
.lead:active { cursor: grabbing; }
.lead-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 6px; }
.lead-name { font-size: 14px; line-height: 1.3; }
.lead-edit { padding: 1px 6px; font-size: 12px; flex-shrink: 0; margin: -1px -4px 0 0; }
.lead-sub { display: flex; justify-content: space-between; gap: 8px; margin-top: 2px; font-size: 12px; color: var(--muted-ink); }
.lead-sub strong { color: var(--text); font-variant-numeric: tabular-nums; }
.task-list .lead + .lead { margin-top: 0; }
.lead.dragging { opacity: 0.35; }
.column.drop-over { outline: 2px dashed var(--accent); outline-offset: -3px; background: color-mix(in srgb, var(--accent) 6%, transparent); }
.stock-facts { display: flex; flex-wrap: wrap; gap: 10px 24px; margin: 10px 0 4px; padding-top: 10px; border-top: 1px solid var(--line); }
.stock-facts > div { display: flex; flex-direction: column; }
.stock-facts span { font-size: 12px; color: var(--muted-ink); }
.stock-facts strong { font-size: 16px; font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.lead-edit { padding: 3px 5px; margin: -2px -5px 0 0; opacity: 0.55; }
.lead:hover .lead-edit, .lead-edit:focus-visible { opacity: 1; }
.lead { position: relative; }


/* Arrastre con el dedo */
.lead { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.lead-ghost { position: fixed; z-index: 90; pointer-events: none; margin: 0; opacity: 0.92; border-color: var(--accent); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6); transform: rotate(-2deg); }
.board.touch-dragging { scroll-snap-type: none !important; }

/* Pantallas táctiles: botones y casillas cómodos para el dedo */
@media (pointer: coarse) {
  .btn-small { min-height: 40px; padding: 8px 14px; }
  .btn-icon { min-width: 40px; min-height: 40px; }
  .lead-edit { min-width: 36px; min-height: 36px; padding: 8px; margin: -8px -8px 0 0; opacity: 1; }
  .nav-link { padding: 13px 12px; }
  .toggle button { padding: 10px 14px; }
  .choice { padding: 10px 14px; }
  .choice input, .check input { width: 20px; height: 20px; }
  .count { padding: 3px 10px; }
}
/* En celular los campos van a 16 px: así el navegador no hace zoom al tocarlos */
@media (max-width: 720px) {
  input, select, textarea { font-size: 16px; }
}

/* Inicio: stock por producto */
.stock-list { display: flex; flex-direction: column; gap: 18px; }
.stock-line { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-top: 6px; font-size: 12.5px; color: var(--muted-ink); }
.stock-line strong { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

/* Usuarios, contraseña temporal, actividad */
.temp-box { margin: 14px 0; padding: 14px; border: 1px solid var(--accent); border-radius: 12px; background: color-mix(in srgb, var(--accent) 8%, transparent); }
.temp-row { display: flex; gap: 8px; margin: 10px 0 6px; }
.temp-pass { font-family: ui-monospace, Consolas, monospace; font-size: 16px; letter-spacing: 0.04em; }
.logout-all { margin-top: 10px; text-align: center; }
.forced-title { font-size: 20px; margin-bottom: 6px; }
.forced-note { margin-bottom: 16px; font-size: 14px; }
.nowrap { white-space: nowrap; }

/* Destacados de la tienda (js/modals-tienda.js) */
.tienda-lista li { display: flex; align-items: center; gap: 10px; }
.tienda-puesto { width: 22px; flex: none; text-align: center; font-weight: 700; color: var(--accent-light); }
.tienda-thumb { width: 44px; height: 44px; flex: none; border-radius: 8px; background: #fff; object-fit: contain; padding: 3px; }
.tienda-info { display: flex; flex: 1; flex-direction: column; gap: 2px; min-width: 0; }
.tienda-info strong { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; font-weight: 600; line-height: 1.3; }
.tienda-info .pill { align-self: flex-start; }
.tienda-acciones { display: flex; flex: none; gap: 4px; }
.tienda-resultados { max-height: 340px; overflow: auto; margin-top: 10px; }
.modal input[type='search'] { width: 100%; }

/* Tienda en línea (js/views/tienda.js) */
.tienda-seccion { margin-bottom: 16px; }
/* Secciones plegables (acordeón) */
.tienda-seccion > summary { cursor: pointer; list-style: none; margin-bottom: 0; flex-wrap: nowrap; }
.tienda-seccion > summary::-webkit-details-marker { display: none; }
.tienda-seccion[open] > summary { margin-bottom: 14px; }
.tienda-flecha { color: var(--muted); font-size: 18px; transition: transform 0.15s; }
.tienda-seccion:not([open]) .tienda-flecha { transform: rotate(-90deg); }
.tienda-seccion > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 8px; }
.paged > div + div .pager { margin: 12px 0 0; }
.tienda-celda { display: flex; align-items: center; gap: 10px; min-width: 220px; }
.tienda-sugerencia { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; color: var(--muted); }
.tienda-seccion select { max-width: 260px; }
.tienda-historial { margin-top: 12px; }
.tienda-historial summary { cursor: pointer; }
.tienda-historial .plain-list { margin-top: 8px; }
.tienda-anuncio-barra { margin: 4px 0 14px; padding: 10px 14px; border-radius: 10px; background: #000; color: #f2f5f3; border: 1px solid var(--line); text-align: center; font-size: 12.5px; letter-spacing: 0.02em; }
.tienda-anuncio-barra.vacia { color: var(--dim); font-style: italic; }
.tienda-contador { display: flex; align-items: center; gap: 8px; }
.tienda-contador input { flex: 1; }
.tienda-problema { margin-top: 6px; color: var(--danger); max-width: 320px; }
.tienda-productos-pedido { max-width: 280px; }
.tienda-acciones-pedido { white-space: nowrap; }
.tienda-acciones-pedido .btn + .btn { margin-left: 6px; }
#de-other { margin-top: 8px; }
.tienda-codigo { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: 0.04em; }

/* Resumen de la tienda en línea en Inicio (js/views/home.js) */
.web-resumen { margin-top: 18px; }
.web-resumen .toolbar { margin-top: 12px; }
.web-resumen h4 { margin-top: 16px; }

/* Inventario: seleccionar varios productos para eliminarlos (js/views/inventory.js) */
.select-bar { padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.product.selected { border-color: var(--accent); }

/* Inventario: cuántos productos mostrar y páginas */
.cards:has(+ *) { margin-bottom: 12px; }
.pager { justify-content: space-between; }
.pager-size { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.toolbar .pager-size select { min-width: 0; width: auto; }
.pager-nav { display: flex; align-items: center; gap: 10px; }
.pager-page { font-size: 13px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.product-select { margin-bottom: 8px; cursor: pointer; }

/* Aviso del panel de pruebas (staging), ver js/main.js */
.aviso-pruebas { position: sticky; top: 0; z-index: 50; padding: 6px 12px; text-align: center; font-size: 13px; font-weight: 600; background: var(--warn); color: #111; }
