/* ========== Variables y temas ========== */
:root {
  font-family: "Segoe UI", system-ui, Arial, sans-serif;
  font-synthesis: none;
  --bg: #f1f4f3;
  --card: #ffffff;
  --text: #242a30;
  --muted: #7b848c;
  --border: #e1e6e9;
  --input: #fafbfc;
  --head: #fafbfb;
  --hover: #f5faf7;
  --track: #edf0f2;
  --shadow: 0 2px 8px rgba(20, 30, 40, .05);

  --accent: #3f7d62;
  --accent-hover: #306350;
  --accent-soft: #e4f1ea;
  --on-soft: #306350;
  --blue: #3b6fb6;
  --blue-soft: #e2ecf8;
  --warn: #c98a12;
  --warn-soft: #fbf0d7;
  --warn-text: #8a5d05;
  --danger: #c0483d;
  --danger-soft: #f8e1de;

  --dark: #1c262e;
  --dark-2: #2b3944;
}

[data-theme="dark"] {
  --bg: #0f161b;
  --card: #18222a;
  --text: #e6ecef;
  --muted: #8e9aa3;
  --border: #29343c;
  --input: #1f2a32;
  --head: #1d2830;
  --hover: #1e2a32;
  --track: #26323a;
  --shadow: 0 2px 10px rgba(0, 0, 0, .35);

  --accent: #3f9a78;
  --accent-hover: #4aae88;
  --accent-soft: #1f3a2f;
  --on-soft: #8fe0b8;
  --blue: #7fa8e6;
  --blue-soft: #1d2c44;
  --warn-soft: #3a2f12;
  --warn-text: #e6b04a;
  --danger: #ef8a80;
  --danger-soft: #3d1f1c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  transition: background .3s, color .3s;
}

button, input, select { font: inherit; }
button { cursor: pointer; }

/* ========== Sidebar ========== */
.sidebar {
  width: 245px;
  position: fixed;
  inset: 0 auto 0 0;
  background: linear-gradient(180deg, var(--dark), #121a20);
  color: white;
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
}

.brand { display: flex; align-items: center; gap: 12px; }

.logo {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: linear-gradient(135deg, #4f9a78, #2f6b53);
  font-weight: 800; font-size: 20px;
  box-shadow: 0 4px 12px rgba(63, 125, 98, .45);
}

.sidebar h2 { font-size: 19px; margin: 0; letter-spacing: 1px; }
.subtitle, .sidebar-footer { color: #9fb0ba; font-size: 12px; margin: 2px 0 0; }

.nav-label {
  margin: 34px 0 8px 14px;
  font-size: 10px; letter-spacing: 1.6px; color: #6f818d; font-weight: 700;
}

nav { display: grid; gap: 6px; }

.nav-btn {
  display: flex; align-items: center; gap: 12px;
  text-align: left;
  border: 0;
  padding: 12px 14px;
  border-radius: 8px;
  background: transparent;
  color: #cdd6dc;
  transition: background .2s, transform .2s;
}

.nav-btn span { width: 18px; text-align: center; opacity: .8; }
.nav-btn:hover { background: var(--dark-2); transform: translateX(2px); }
.nav-btn.active {
  background: var(--dark-2);
  color: white;
  box-shadow: inset 3px 0 0 #5fb58f;
}

.side-card {
  margin-top: auto;
  margin-bottom: 36px;
  padding: 16px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .08);
}
.side-card p { margin: 0 0 6px; font-size: 12px; color: #9fb0ba; }
.side-card strong { font-size: 20px; }
.side-card small { display: block; margin-top: 6px; color: #8296a3; font-size: 11px; }

.sidebar-footer { position: absolute; bottom: 20px; }

/* ========== Layout ========== */
main { margin-left: 245px; padding: 35px; max-width: 1600px; }

header, .section-heading, .table-heading {
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
}

header { margin-bottom: 28px; }

h1 { margin: 4px 0 2px; font-size: 29px; }
h2, h3 { margin-top: 0; }
h3 { font-size: 16px; }

.eyebrow {
  color: var(--accent);
  font-size: 11px; font-weight: 700; letter-spacing: 1.5px; margin: 0;
}

.today { margin: 0; color: var(--muted); font-size: 13px; text-transform: capitalize; }

.header-actions { display: flex; align-items: center; gap: 12px; }

.icon-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 16px;
  transition: transform .3s, background .2s;
}
.icon-btn:hover { transform: rotate(20deg); background: var(--accent-soft); }

.status {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  padding: 9px 14px;
  border-radius: 20px;
}

.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #3fb27f;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(63, 178, 127, .6); }
  70% { box-shadow: 0 0 0 7px rgba(63, 178, 127, 0); }
  100% { box-shadow: 0 0 0 0 rgba(63, 178, 127, 0); }
}

.view { animation: fade .35s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.hidden { display: none !important; }
.muted { color: var(--muted); line-height: 1.6; }

.app-footer {
  margin-top: 30px; padding-top: 18px;
  border-top: 1px solid var(--border);
  text-align: center; font-size: 12px; color: var(--muted);
}

/* ========== Bienvenida ========== */
.welcome {
  display: flex; justify-content: space-between; align-items: center; gap: 24px;
  padding: 34px;
  border-radius: 16px;
  color: white;
  background:
    radial-gradient(circle at 85% 20%, rgba(143, 224, 184, .25), transparent 45%),
    linear-gradient(120deg, #1b362c 0%, #3f7d62 100%);
  box-shadow: 0 10px 28px rgba(48, 99, 80, .28);
}

.welcome .eyebrow { color: #b6e3cd; }
.welcome h2 { font-size: clamp(24px, 3vw, 36px); max-width: 540px; margin: 8px 0 12px; }
.welcome-text p:not(.eyebrow) { color: #d8ece2; line-height: 1.6; margin: 0; }
.welcome .primary { background: white; color: #2f6b53; margin-top: 18px; }
.welcome .primary:hover { background: #eaf6f0; }

.health { text-align: center; flex: none; }
.health p { margin: 12px 0 2px; font-weight: 600; font-size: 14px; }
.health small { color: #b6e3cd; font-size: 12px; }

.ring {
  --p: 0;
  width: 112px; height: 112px;
  margin: 0 auto;
  border-radius: 50%;
  display: grid; place-items: center;
  background: conic-gradient(#8fe0b8 calc(var(--p) * 1%), rgba(255, 255, 255, .18) 0);
  position: relative;
  transition: background .6s;
}
.ring::before {
  content: "";
  position: absolute; inset: 11px;
  border-radius: 50%;
  background: #24493b;
}
.ring span { position: relative; font-size: 24px; font-weight: 700; }

/* ========== Botones ========== */
.primary {
  border: 0;
  background: var(--accent);
  color: white;
  padding: 11px 18px;
  border-radius: 8px;
  margin-top: 10px;
  font-weight: 600;
  transition: background .2s, transform .1s, box-shadow .2s;
}
.primary:hover { background: var(--accent-hover); box-shadow: 0 4px 12px rgba(63, 125, 98, .3); }
.primary:active { transform: scale(.98); }

.ghost {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: background .2s, border-color .2s;
}
.ghost:hover { background: var(--accent-soft); border-color: var(--accent); }

/* ========== Tarjetas ========== */
.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin: 20px 0;
}

.stat-card, .panel, .mini {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px;
  box-shadow: var(--shadow);
  transition: background .3s, border-color .3s;
}

.stat-card {
  display: flex; align-items: center; gap: 16px;
  position: relative; overflow: hidden;
  transition: transform .2s, box-shadow .2s;
}
.stat-card::after {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--c);
}
.stat-card:hover { transform: translateY(-3px); box-shadow: 0 10px 22px rgba(20, 30, 40, .12); }

.stat-icon {
  flex: none; width: 48px; height: 48px;
  display: grid; place-items: center;
  border-radius: 12px; font-size: 22px;
  background: color-mix(in srgb, var(--c) 16%, transparent);
}

.stat-card p { font-size: 13px; color: var(--muted); margin: 0 0 4px; }
.stat-card strong { font-size: 24px; }

.c1 { --c: #3f7d62; } .c2 { --c: #3b6fb6; } .c3 { --c: #7a5cb0; }
.c4 { --c: #2f9aa8; } .c5 { --c: #3fa35a; } .c6 { --c: #c98a12; }

.panel { margin-bottom: 20px; }
.two-cols { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; margin-bottom: 4px; }

/* ========== Gráfico ========== */
.chart-box { position: relative; margin-top: 6px; }
#sales-chart { width: 100%; height: auto; display: block; }
#sales-chart .grid { stroke: var(--border); stroke-dasharray: 3 4; }
#sales-chart .axis { fill: var(--muted); font-size: 11px; }
#sales-chart rect {
  transform-box: fill-box; transform-origin: bottom;
  animation: grow .7s cubic-bezier(.2, .8, .2, 1) both;
}
.bar-compra { fill: var(--blue); }
.bar-venta { fill: var(--accent); }
@keyframes grow { from { transform: scaleY(0); } to { transform: scaleY(1); } }

.chart-empty {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  margin: 0; color: var(--muted); font-size: 13px;
  background: color-mix(in srgb, var(--card) 70%, transparent);
}

.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.sw.compra { background: var(--blue); }
.sw.venta { background: var(--accent); }

/* ========== Ranking ========== */
.ranking { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 14px; }
.ranking li { display: grid; grid-template-columns: 30px 1fr auto; gap: 4px 12px; align-items: center; font-size: 13px; }
.rank-n {
  grid-row: span 2;
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--on-soft); font-weight: 700;
}
.ranking li:first-child .rank-n { background: #f3d27a; color: #6b4a00; }
.ranking small { color: var(--muted); }
.mini-track { grid-column: 2 / 4; height: 6px; border-radius: 6px; background: var(--track); overflow: hidden; }
.mini-fill { height: 100%; background: var(--accent); border-radius: 6px; transition: width .8s cubic-bezier(.2, .8, .2, 1); }

/* ========== Barras de existencias ========== */
.bars { display: grid; gap: 14px; margin-top: 14px; }
.bar-top { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 5px; }
.bar-track { height: 10px; background: var(--track); border-radius: 10px; overflow: hidden; }
.bar-fill {
  height: 100%; border-radius: 10px;
  background: linear-gradient(90deg, #5fb58f, #3f7d62);
  transition: width .8s cubic-bezier(.2, .8, .2, 1);
}
.bar-fill.low { background: linear-gradient(90deg, #e6b04a, #c98a12); }
.bar-fill.out { background: var(--danger); }

/* ========== Actividad ========== */
.activity { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 14px; }
.activity li { display: flex; gap: 12px; align-items: center; font-size: 13px; }
.ico {
  flex: none; width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700;
}
.ico.compra { background: var(--blue-soft); color: var(--blue); }
.ico.venta { background: var(--accent-soft); color: var(--on-soft); }
.activity small { display: block; color: var(--muted); margin-top: 2px; }

/* ========== Formularios ========== */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}
.form-grid label { display: grid; gap: 8px; font-size: 13px; font-weight: 600; align-content: start; }

input, select {
  width: 100%;
  min-height: 43px;
  padding: 10px 12px;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--input);
  transition: border-color .2s, box-shadow .2s, background .2s;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
.form-actions { grid-column: 1 / -1; }

/* ========== Barra de herramientas y filtros ========== */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 6px 0 16px; }
.toolbar input[type="search"] { flex: 1 1 240px; width: auto; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--border);
  background: transparent; color: var(--muted);
  padding: 8px 14px; border-radius: 20px;
  font-size: 12px; font-weight: 600;
  transition: all .2s;
}
.chip:hover { border-color: var(--accent); color: var(--text); }
.chip.active { background: var(--accent); border-color: var(--accent); color: white; }

/* ========== Resumen de movimientos ========== */
.mini-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.mini { padding: 18px 22px; border-left: 4px solid var(--c); }
.mini p { margin: 0 0 4px; font-size: 12px; color: var(--muted); }
.mini strong { font-size: 21px; }
.c-blue { --c: #3b6fb6; } .c-green { --c: #3f7d62; } .c-teal { --c: #2f9aa8; }

/* ========== Tablas ========== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: 13px; }
th, td { border-bottom: 1px solid var(--border); padding: 14px 10px; white-space: nowrap; }
th {
  color: var(--muted); font-weight: 600;
  font-size: 11px; text-transform: uppercase; letter-spacing: .6px;
  background: var(--head);
}
tbody tr { transition: background .15s; }
tbody tr:hover { background: var(--hover); }
tbody tr { animation: fade .3s ease both; }

.pill {
  font-size: 12px; font-weight: 600;
  background: var(--accent-soft); color: var(--on-soft);
  padding: 5px 12px; border-radius: 20px;
}

.badge { font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 20px; }
.badge.ok, .badge.venta { background: var(--accent-soft); color: var(--on-soft); }
.badge.compra { background: var(--blue-soft); color: var(--blue); }
.badge.low { background: var(--warn-soft); color: var(--warn-text); }
.badge.out { background: var(--danger-soft); color: var(--danger); }

.prod-cell { display: flex; align-items: center; gap: 10px; }
.avatar {
  flex: none; width: 30px; height: 30px; border-radius: 8px;
  display: grid; place-items: center;
  color: white; font-weight: 700; font-size: 13px;
}

.stock-cell { display: flex; align-items: center; gap: 10px; min-width: 130px; }
.stock-cell b { min-width: 28px; }
.stock-cell .bar-track { flex: 1; height: 6px; }

.empty {
  text-align: center; color: var(--muted);
  padding: 30px 10px 10px; margin: 0;
}

/* ========== Avisos ========== */
.toasts { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 10px; z-index: 50; }
.toast {
  background: var(--dark); color: white;
  padding: 13px 18px; border-radius: 10px;
  border-left: 4px solid #5fb58f;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
  animation: slide .3s ease;
  max-width: 340px; font-size: 14px;
}
.toast.error { border-left-color: #e0645a; }
@keyframes slide { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: none; } }

/* ========== Responsive ========== */
@media (max-width: 1100px) {
  .two-cols { grid-template-columns: 1fr; }
}

@media (max-width: 850px) {
  .sidebar { position: static; width: 100%; }
  .sidebar-footer, .side-card, .nav-label { display: none; }
  nav { display: flex; margin-top: 20px; flex-wrap: wrap; }
  main { margin-left: 0; padding: 20px; }
  .stats, .mini-stats { grid-template-columns: 1fr 1fr; }
  .welcome { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 560px) {
  .form-grid, .stats, .mini-stats { grid-template-columns: 1fr; }
  header { align-items: flex-start; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}


/* ========== Acciones y diálogo de confirmación ========== */
.btn-delete {
  border: 1px solid var(--danger);
  background: transparent;
  color: var(--danger);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  transition: background .2s, color .2s;
}
.btn-delete:hover { background: var(--danger); color: white; }
.btn-delete.locked {
  border-color: var(--border);
  color: var(--muted);
  opacity: .7;
  cursor: not-allowed;
}
.btn-delete.locked:hover { background: transparent; color: var(--muted); }

.danger {
  border: 0;
  background: var(--danger);
  color: white;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
}
[data-theme="dark"] .danger { color: #1a0f0e; }
.danger:hover { filter: brightness(1.1); }

.dialog {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  width: min(420px, 92vw);
  background: var(--card);
  color: var(--text);
  box-shadow: 0 20px 50px rgba(0, 0, 0, .35);
  text-align: center;
}
.dialog::backdrop { background: rgba(10, 16, 20, .55); backdrop-filter: blur(2px); }
.dialog[open] { animation: fade .25s ease; }
.dialog-icon {
  width: 56px; height: 56px; margin: 0 auto 12px;
  display: grid; place-items: center;
  border-radius: 50%; font-size: 26px;
  background: var(--danger-soft);
}
.dialog h3 { margin-bottom: 8px; font-size: 18px; }
.dialog p { margin: 0 0 22px; }
.dialog-actions { display: flex; justify-content: center; gap: 12px; }


/* Columna de acciones siempre visible (fija al borde derecho) */
#product-table td:last-child,
th.col-actions {
  position: sticky;
  right: 0;
  z-index: 1;
  box-shadow: -8px 0 8px -8px rgba(0, 0, 0, .18);
}
#product-table td:last-child { background: var(--card); }
th.col-actions { background: var(--head); }
#product-table tr:hover td:last-child { background: var(--hover); }


/* ========== Kardex por producto ========== */
.toolbar select { flex: 1 1 280px; width: auto; }
.mini-stats.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.c-warn { --c: #c98a12; }
.note { font-size: 12px; margin: 14px 0 0; }

.kardex-table th, .kardex-table td { padding: 11px 10px; }
.kardex-table thead th { text-align: center; }
.kardex-table th.grp { font-size: 12px; color: var(--text); }
.kardex-table .sep { border-left: 2px solid var(--border); }
.kardex-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.kardex-table td.dim { color: var(--muted); text-align: center; }
.kardex-table td:nth-child(3), .kardex-table td:nth-child(6), .kardex-table td:nth-child(9) {
  border-left: 2px solid var(--border);
}
.k-inicial td { font-style: italic; background: var(--head); }
.k-compra td:nth-child(n+3):nth-child(-n+5) { background: color-mix(in srgb, var(--blue-soft) 55%, transparent); }
.k-venta td:nth-child(n+6):nth-child(-n+8) { background: color-mix(in srgb, var(--accent-soft) 70%, transparent); }
.kardex-table td:nth-child(n+9) { font-weight: 600; }

.pill.warn { background: var(--warn-soft); color: var(--warn-text); }

.actions-cell { display: flex; gap: 8px; }
.btn-kardex {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  transition: background .2s, border-color .2s;
}
.btn-kardex:hover { background: var(--accent-soft); border-color: var(--accent); }

.print-head { display: none; }

@media (max-width: 1100px) {
  .mini-stats.four { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .mini-stats.four { grid-template-columns: 1fr; }
}

/* ========== Impresión (kardex en papel) ========== */
@media print {
  :root, [data-theme="dark"] {
    --bg: #fff; --card: #fff; --text: #000; --border: #bbb; --muted: #444;
    --head: #eee; --input: #fff; --hover: #fff;
    --accent-soft: #eee; --blue-soft: #eee; --warn-soft: #eee;
    --on-soft: #000; --blue: #000; --warn-text: #000;
  }
  .sidebar, header, .toasts, .app-footer, .no-print, dialog { display: none !important; }
  main { margin: 0; padding: 0; max-width: none; }
  body { background: #fff; color: #000; }
  .panel, .mini { box-shadow: none; border: 1px solid #bbb; break-inside: avoid; }
  .print-head { display: block; margin-bottom: 14px; }
  .print-head h2 { margin: 0 0 6px; }
  .print-head p { margin: 2px 0; }
  .table-wrap { overflow: visible; }
  th, td { padding: 6px 5px; font-size: 11px; white-space: normal; }
  .k-compra td, .k-venta td, .k-inicial td { background: #fff !important; }
  * { animation: none !important; }
}


/* ========== Devoluciones y ajustes ========== */
.form-grid .full { grid-column: 1 / -1; }
.hint {
  margin: 0; font-size: 12px; line-height: 1.5;
  color: var(--muted); background: var(--head);
  border-radius: 8px; padding: 10px 12px;
}
.form-grid input:disabled { opacity: .55; cursor: not-allowed; }

.badge.dev-venta { background: var(--warn-soft); color: var(--warn-text); }
.badge.dev-compra {
  background: color-mix(in srgb, #7a5cb0 18%, transparent);
  color: color-mix(in srgb, #7a5cb0 70%, var(--text));
}
.badge.ajuste {
  background: color-mix(in srgb, #2f9aa8 18%, transparent);
  color: color-mix(in srgb, #2f9aa8 70%, var(--text));
}
.badge.ajuste-out { background: var(--danger-soft); color: var(--danger); }

.ico.dev-venta { background: var(--warn-soft); color: var(--warn-text); }
.ico.dev-compra {
  background: color-mix(in srgb, #7a5cb0 18%, transparent);
  color: color-mix(in srgb, #7a5cb0 70%, var(--text));
}
.ico.ajuste {
  background: color-mix(in srgb, #2f9aa8 18%, transparent);
  color: color-mix(in srgb, #2f9aa8 70%, var(--text));
}
.ico.ajuste-out { background: var(--danger-soft); color: var(--danger); }


/* ========================================================================
   Íconos SVG
   ======================================================================== */
.ic {
  width: 1.15em; height: 1.15em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -0.2em;
}

.nav-btn .ic { width: 18px; height: 18px; opacity: .85; }
.icon-btn { display: inline-grid; place-items: center; }
.icon-btn .ic { width: 18px; height: 18px; }

.primary, .ghost, .btn-delete, .btn-kardex, .pill {
  display: inline-flex; align-items: center; gap: 8px;
}
.primary .ic, .ghost .ic { width: 17px; height: 17px; }
.btn-delete .ic, .btn-kardex .ic { width: 14px; height: 14px; }
.pill { gap: 6px; }
.pill .ic { width: 14px; height: 14px; }

.stat-icon .ic { width: 24px; height: 24px; color: var(--c); }
.ico .ic { width: 16px; height: 16px; }
.dialog-icon .ic { width: 26px; height: 26px; color: var(--danger); }

.toast { display: flex; align-items: center; gap: 10px; }
.toast .ic { width: 18px; height: 18px; color: #5fb58f; }
.toast.error .ic { color: #e0645a; }

/* Estado vacío con ícono (sin emoji) */
.empty::before {
  content: "";
  display: block;
  width: 46px; height: 46px;
  margin: 0 auto 12px;
  background: var(--muted);
  opacity: .45;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='22 12 16 12 14 15 10 15 8 12 2 12'/%3E%3Cpath d='M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='22 12 16 12 14 15 10 15 8 12 2 12'/%3E%3Cpath d='M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z'/%3E%3C/svg%3E") center / contain no-repeat;
  font-size: 0;
}

/* ========================================================================
   Formularios
   ======================================================================== */
.form-card {
  position: relative;
  overflow: hidden;
  padding: 26px 28px 28px;
  gap: 22px 22px;
}
.form-card::before {
  content: "";
  position: absolute; left: 0; right: 0; top: 0; height: 4px;
  background: linear-gradient(90deg, #5fb58f, var(--accent), #2f9aa8);
}

.form-head {
  display: flex; align-items: center; gap: 14px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.form-head h3 { margin: 0 0 2px; font-size: 17px; }
.form-head p { margin: 0; font-size: 13px; line-height: 1.4; }
.form-badge {
  flex: none; width: 46px; height: 46px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--on-soft);
}
.form-badge .ic { width: 22px; height: 22px; }

.field { gap: 7px; align-content: start; }
.field-label { font-size: 12.5px; font-weight: 700; letter-spacing: .2px; }
.req { color: var(--danger); margin-left: 2px; }
.field-help { font-size: 11.5px; font-weight: 500; color: var(--muted); }

.input-wrap { position: relative; display: block; }
.input-wrap > .ic {
  position: absolute; left: 14px; top: 50%;
  width: 17px; height: 17px;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
  transition: color .2s;
}
.input-wrap > .ic.chev { left: auto; right: 14px; width: 16px; height: 16px; }
.input-wrap .prefix {
  position: absolute; left: 14px; top: 50%;
  transform: translateY(-50%);
  font-size: 12px; font-weight: 800;
  color: var(--muted);
  pointer-events: none;
}
.input-wrap:focus-within > .ic,
.input-wrap:focus-within .prefix { color: var(--accent); }

.input-wrap input,
.input-wrap select {
  width: 100%;
  min-height: 46px;
  padding: 11px 14px 11px 42px;
  font-size: 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--input);
}
.input-wrap input::placeholder { color: var(--muted); opacity: .7; }
.input-wrap input:hover:not(:disabled),
.input-wrap select:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.input-wrap input:focus,
.input-wrap select:focus {
  border-color: var(--accent);
  background: var(--card);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent);
}
.input-wrap select { appearance: none; -webkit-appearance: none; padding-right: 40px; cursor: pointer; }
.input-wrap select option { color: #1e293b; background: #fff; }

/* Validación visual: solo cuando ya se escribió algo */
.input-wrap input:not(:placeholder-shown):invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger) 14%, transparent);
}
.input-wrap input:disabled { background: var(--head); opacity: .6; cursor: not-allowed; }

/* El buscador y el selector de las barras de herramientas */
.toolbar .input-wrap.search { flex: 1 1 260px; }
.toolbar .input-wrap.select { flex: 1 1 300px; }
.toolbar .input-wrap input[type="search"],
.toolbar .input-wrap select { width: 100%; }
.input-wrap input[type="search"]::-webkit-search-cancel-button { cursor: pointer; }

/* Aviso informativo del formulario de movimientos */
.hint {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px;
  border-radius: 10px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  color: var(--on-soft);
  font-size: 12.5px; line-height: 1.5;
}
.hint .ic { width: 16px; height: 16px; margin-top: 1px; }

/* Botones de acción del formulario */
.form-card .form-actions {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  padding-top: 6px;
}
.form-card .primary { margin-top: 0; padding: 12px 22px; font-size: 14px; }
.form-card .ghost { padding: 12px 18px; }

.ghost:disabled, .primary:disabled { opacity: .55; cursor: not-allowed; }
.primary:focus-visible, .ghost:focus-visible, .chip:focus-visible, .nav-btn:focus-visible,
.btn-delete:focus-visible, .btn-kardex:focus-visible, .icon-btn:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: 2px;
}

@media (max-width: 560px) {
  .form-card { padding: 20px 18px 22px; }
  .form-card .form-actions .primary { flex: 1 1 100%; justify-content: center; }
  .form-card .form-actions .ghost { flex: 1 1 100%; justify-content: center; }
}


/* ========== Logo de la marca ========== */
.logo {
  background: none;
  box-shadow: none;
  border-radius: 0;
  display: block;
  filter: drop-shadow(0 4px 10px rgba(63, 125, 98, .45));
}
.logo svg { display: block; width: 100%; height: 100%; }