:root {
  /* Paleta azabache / grafito profundo */
  --bg: #0a0c0f;
  --bg-2: #0e1115;
  --surface: #14181d;
  --surface-2: #1b2027;
  --surface-3: #242b33;
  --border: #232a32;
  --border-soft: rgba(255,255,255,.055);
  --text: #e8eaed;          /* blanco roto */
  --text-dim: #8b939d;
  --text-faint: #5c646d;
  --primary: #5b7cfa;
  --primary-dark: #4763e6;
  --primary-glow: rgba(91,124,250,.32);
  /* Semáforo: tonos suaves, no chillones */
  --green: #34d399;
  --amber: #fbbf24;
  --red: #f87171;
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 18px;
  --shadow: 0 18px 50px rgba(0,0,0,.55);
  --shadow-soft: 0 2px 14px rgba(0,0,0,.28);
  --mono: "SF Mono", "JetBrains Mono", "Roboto Mono", ui-monospace, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Scrollbars discretas */
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 10px; border: 3px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #2f3742; }
::-webkit-scrollbar-track { background: transparent; }

#app { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: 244px;
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg-2) 100%);
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { position: relative; display: flex; align-items: center; justify-content: center; gap: 14px; padding: 28px 20px; }
.brand-logo {
  width: 56px; height: 56px; border-radius: 15px; flex-shrink: 0; cursor: pointer;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  box-shadow: 0 8px 22px rgba(91,124,250,.32);
  transition: box-shadow .18s ease, transform .12s ease;
}
.brand-logo:hover { box-shadow: 0 6px 22px rgba(91,124,250,.5); transform: translateY(-1px); }
.brand-logo svg, .brand-logo img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* Cuando hay logo subido: imagen libre, grande pero contenida en el panel (mantiene proporción) */
.brand-logo.has-img { width: auto; height: auto; border-radius: 8px; overflow: visible; box-shadow: none; background: none; }
.brand-logo.has-img img { width: auto; height: auto; max-height: 84px; max-width: 200px; object-fit: contain; }
.brand.has-logo .brand-text { display: none; }
/* Botón sutil de configuración del logo (aparece al pasar el mouse por el brand) */
.brand-logo-btn {
  position: absolute; top: 10px; right: 10px;
  background: none; border: none; color: var(--text-faint);
  cursor: pointer; font-size: 15px; line-height: 1; padding: 6px; border-radius: 8px;
  opacity: 0; transition: opacity .18s ease, background .18s ease, color .18s ease;
}
.brand:hover .brand-logo-btn { opacity: 1; }
.brand-logo-btn:hover { background: var(--surface-2); color: var(--text); }
.brand-text { display: flex; flex-direction: column; align-items: center; line-height: 1.3; text-align: center; }
.brand-text strong { font-size: 19px; font-weight: 800; letter-spacing: -.4px; }
.brand-text span { font-size: 9.5px; color: var(--text-faint); letter-spacing: 2.5px; text-transform: uppercase; margin-top: 3px; }

.nav { padding: 10px 12px; display: flex; flex-direction: column; gap: 3px; flex: 1; min-height: 0; overflow-y: auto; }
.nav-item {
  position: relative;
  display: flex; align-items: center; gap: 13px;
  background: none; border: none; color: var(--text-dim);
  padding: 11px 14px; border-radius: var(--radius-sm); cursor: pointer;
  font-size: 14px; text-align: left; width: 100%;
  transition: background .18s ease, color .18s ease;
}
.nav-icon { width: 18px; height: 18px; flex-shrink: 0; color: var(--text-faint); opacity: .85; transition: color .18s ease, opacity .18s ease; }
.nav-item:hover .nav-icon { color: var(--text); opacity: 1; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--surface-2); color: #fff; }
.nav-item.active .nav-icon { color: #fff; opacity: 1; }
.nav-item.active::before {
  content: ""; position: absolute; left: 0; top: 9px; bottom: 9px; width: 3px;
  border-radius: 0 4px 4px 0; background: var(--primary); box-shadow: 0 0 12px var(--primary-glow);
}

.sidebar-foot { padding: 16px; flex-shrink: 0; }
.tc-box { background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px 14px; display: flex; flex-direction: column; gap: 3px; }
.tc-box span { font-size: 11px; color: var(--text-dim); }
.tc-box strong { font-size: 18px; color: var(--green); font-family: var(--mono); letter-spacing: -.5px; }
.user-box { display: flex; flex-direction: column; align-items: stretch; gap: 8px; background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 12px; margin-top: 10px; font-size: 12px; color: var(--text-dim); }
.user-box #userBoxNombre { font-weight: 650; color: var(--text); }
.user-box button { background: var(--surface-3); border: 1px solid var(--border-soft); border-radius: var(--radius-sm); color: var(--text-dim); cursor: pointer; font-size: 12px; font-weight: 600; line-height: 1; padding: 7px 10px; transition: .15s; }
.user-box button:hover { color: #fff; background: var(--red); border-color: var(--red); }

/* ---------- Login (Supabase Auth real) ---------- */
.login-screen { position: fixed; inset: 0; background: var(--bg); display: flex; align-items: center; justify-content: center; z-index: 200; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 36px 34px; width: 100%; max-width: 360px; }
.login-brand { font-size: 22px; font-weight: 800; letter-spacing: -.4px; text-align: center; margin-bottom: 4px; }
.login-error { color: var(--red); font-size: 12.5px; margin-top: 10px; text-align: center; }
.login-nota { font-size: 11px; line-height: 1.45; margin-top: 18px; text-align: center; }
.login-nota code { background: var(--surface-2); border-radius: 4px; padding: 1px 5px; font-family: var(--mono); }

/* ---------- Main ---------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 34px;
  position: sticky; top: 0; background: rgba(10,12,15,.72); backdrop-filter: saturate(140%) blur(12px); z-index: 5;
  border-bottom: 1px solid var(--border-soft);
}
.topbar h1 { font-size: 22px; font-weight: 650; letter-spacing: -.3px; }
.topbar-right { display: flex; align-items: center; gap: 18px; }
.topbar-actions { display: flex; gap: 10px; }

.usd-blue-badge {
  display: flex; align-items: center; gap: 7px;
  font-size: 12.5px; color: var(--text-dim); font-family: var(--mono); letter-spacing: -.2px;
  padding: 6px 12px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border-soft);
  white-space: nowrap;
}
.usd-blue-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-dim); flex: none; }
.usd-blue-badge.is-live .usd-blue-dot { background: var(--green); box-shadow: 0 0 0 0 rgba(74,222,128,.55); animation: usdBluePulse 2s ease-out infinite; }
.usd-blue-badge.is-stale .usd-blue-dot { background: var(--amber); }
@keyframes usdBluePulse {
  0%   { box-shadow: 0 0 0 0 rgba(74,222,128,.55); }
  70%  { box-shadow: 0 0 0 6px rgba(74,222,128,0); }
  100% { box-shadow: 0 0 0 0 rgba(74,222,128,0); }
}
.view-container { padding: 34px; max-width: 1320px; width: 100%; }

/* ---------- Resumen fijo del mes (Ventas / Compras / Gastos) ---------- */
.mes-resumen { display: flex; align-items: center; gap: 30px; flex-wrap: wrap; padding: 14px 22px; margin-bottom: 22px; background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius); }
.mes-resumen-mes { font-size: 14px; font-weight: 700; text-transform: capitalize; padding-right: 22px; border-right: 1px solid var(--border-soft); line-height: 1.3; }
.mes-resumen-mes small { display: block; font-size: 10px; font-weight: 400; color: var(--text-dim); text-transform: none; }
.mes-resumen-item { display: flex; flex-direction: column; gap: 3px; }
.mes-resumen-item .mr-label { font-size: 15px; color: var(--text); font-weight: 600; }
.mes-resumen-item .mr-value { font-size: 23px; font-weight: 700; font-family: var(--mono); letter-spacing: -.4px; }
.mes-resumen-item .mr-usd { font-size: 15px; color: var(--text-dim); font-family: var(--mono); }

/* ---------- Desglose rápido (fila expandible debajo de cada operación) ---------- */
.detail-row td { background: var(--surface-2); padding: 16px 20px !important; }
.desglose { display: flex; flex-direction: column; gap: 7px; max-width: 520px; }
.desglose-row { display: flex; justify-content: space-between; gap: 18px; font-size: 13px; }

/* ---------- Buttons ---------- */
.btn {
  border: none; border-radius: var(--radius-sm); padding: 10px 17px; font-size: 14px; font-weight: 550;
  cursor: pointer; display: inline-flex; align-items: center; gap: 7px;
  transition: background .18s ease, box-shadow .2s ease, transform .12s ease, border-color .18s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 3px 14px var(--primary-glow); }
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 6px 22px var(--primary-glow); transform: translateY(-1px); }
.btn-ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--border-soft); }
.btn-ghost:hover { background: var(--surface-3); transform: translateY(-1px); }
.btn-danger { background: transparent; color: var(--red); border: 1px solid rgba(248,113,113,.4); }
.btn-danger:hover { background: var(--red); color: #1a0d0d; border-color: var(--red); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.icon-btn { background: none; border: none; color: var(--text-dim); font-size: 18px; cursor: pointer; padding: 5px 9px; border-radius: 8px; transition: .15s; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ---------- Cards / KPIs ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px,1fr)); gap: 18px; margin-bottom: 30px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius);
  padding: 22px 24px; display: flex; flex-direction: column; gap: 8px;
  box-shadow: var(--shadow-soft);
  transition: transform .18s ease, border-color .18s ease;
}
.kpi:hover { transform: translateY(-3px); border-color: var(--border); }
.kpi .kpi-label { font-size: 17px; font-weight: 750; letter-spacing: -.3px; color: var(--text); display: flex; align-items: center; gap: 8px; }
.kpi .kpi-tag { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; color: var(--text-faint); background: var(--surface-2); border: 1px solid var(--border-soft); border-radius: 999px; padding: 2px 8px; }
.kpi .kpi-value { font-size: 27px; font-weight: 700; font-family: var(--mono); letter-spacing: -1px; }
.kpi .kpi-value-ars { font-size: 16px; font-weight: 600; color: var(--text-dim); font-family: var(--mono); letter-spacing: -.3px; margin-top: -2px; }
.kpi .kpi-sub { font-size: 12px; color: var(--text-dim); }
.kpi .kpi-line { display: flex; flex-direction: column; gap: 1px; margin-top: 9px; }
.kpi .kpi-line .kpi-line-label { font-size: 11px; color: var(--text-dim); }
.kpi .kpi-line .kpi-line-value { font-size: 16px; font-weight: 700; font-family: var(--mono); letter-spacing: -.3px; }
.kpi .kpi-line .kpi-line-value small { font-size: 11px; font-weight: 500; color: var(--text-dim); margin-left: 5px; }
.kpi.green .kpi-value { color: var(--green); }
.kpi.amber .kpi-value { color: var(--amber); }
.kpi.blue .kpi-value { color: var(--primary); }

.panel {
  background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius);
  overflow: hidden; margin-bottom: 24px; box-shadow: var(--shadow-soft);
}
.panel-head { padding: 18px 22px; border-bottom: 1px solid var(--border-soft); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.panel-head h3 { font-size: 18px; font-weight: 750; letter-spacing: -.3px; }
.panel-body { padding: 0; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 20px; text-align: left; font-size: 13.5px; }
th { color: var(--text-faint); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .7px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { border-bottom: 1px solid var(--border-soft); }
tbody tr { transition: background .14s ease; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
td.num { font-family: var(--mono); font-size: 13px; letter-spacing: -.3px; }

/* Celda destacada: COSTO FINAL UNIT. USD — lo más importante del prorrateo */
th.cell-final { color: var(--green); }
td.cell-final {
  font-weight: 700;
  font-size: 16px;
  color: var(--green);
  background: rgba(52, 211, 153, .08);
  box-shadow: inset 1px 0 0 rgba(52,211,153,.25), inset -1px 0 0 rgba(52,211,153,.25);
}
tbody tr:hover td.cell-final { background: rgba(52, 211, 153, .14); }
.muted { color: var(--text-dim); }
.empty { padding: 52px; text-align: center; color: var(--text-faint); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; padding: 3px 11px; border-radius: 999px; font-size: 11.5px; font-weight: 600; letter-spacing: .2px; }
.badge-green { background: rgba(52,211,153,.12); color: #6ee7b7; }
.badge-amber { background: rgba(251,191,36,.12); color: #fcd34d; }
.badge-red { background: rgba(248,113,113,.13); color: #fca5a5; }
.badge-blue { background: rgba(91,124,250,.14); color: #a6b8ff; }
.badge-gray { background: var(--surface-2); color: var(--text-dim); }

/* ---------- Presupuesto cancelado: fila descolorida en tono rojo tenue ---------- */
tbody tr.doc-row-cancelado { background: rgba(248,113,113,.04); opacity: .55; }
tbody tr.doc-row-cancelado:hover { background: rgba(248,113,113,.08); }
tbody tr.doc-row-cancelado td { color: var(--text-faint); text-decoration: line-through; text-decoration-color: rgba(248,113,113,.5); }
tbody tr.doc-row-cancelado td .badge { text-decoration: none; }

/* ---------- Semáforo de stock (píldora pastel + dot brillante) ---------- */
.stock-tag {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 12px 4px 10px; border-radius: 999px;
  font-family: var(--mono); font-weight: 600; font-size: 12.5px; letter-spacing: -.2px;
}
.stock-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.stock-tag--verde   { background: rgba(52,211,153,.10);  color: #6ee7b7; }
.stock-tag--verde   .stock-dot { background: var(--green); box-shadow: 0 0 7px 1px rgba(52,211,153,.75); }
.stock-tag--naranja { background: rgba(251,191,36,.11);  color: #fcd34d; }
.stock-tag--naranja .stock-dot { background: var(--amber); box-shadow: 0 0 7px 1px rgba(251,191,36,.8); }
.stock-tag--rojo    { background: rgba(248,113,113,.13);  color: #fca5a5; }
.stock-tag--rojo    .stock-dot { background: var(--red); box-shadow: 0 0 8px 1px rgba(248,113,113,.85); animation: dotPulse 1.8s ease-in-out infinite; }
@keyframes dotPulse { 0%,100% { opacity: 1; } 50% { opacity: .45; } }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12.5px; color: var(--text-dim); }
input, select, textarea {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 12px; color: var(--text); font-size: 14px; font-family: inherit; width: 100%;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
input:hover, select:hover, textarea:hover { border-color: var(--surface-3); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); background: var(--bg); }
textarea { resize: vertical; min-height: 64px; }

.toolbar { display: flex; gap: 10px; margin-bottom: 22px; align-items: center; }
.toolbar input[type=search] { max-width: 340px; }
.spacer { flex: 1; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(4,6,9,.66); backdrop-filter: blur(5px); display: flex;
  align-items: flex-start; justify-content: center; padding: 64px 20px; z-index: 50; overflow-y: auto;
}
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); width: 100%; max-width: 740px; box-shadow: var(--shadow); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--border-soft); }
.modal-head h2 { font-size: 18px; font-weight: 650; letter-spacing: -.2px; }
.modal-body { padding: 24px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }

/* line items in sale form */
.items-table td { padding: 9px; }
.items-table input, .items-table select { padding: 8px 10px; }
.items-table .num input { text-align: right; }
.totals { margin-top: 18px; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.totals .row { display: flex; gap: 26px; font-size: 14px; }
.totals .row.grand { font-size: 18px; font-weight: 700; letter-spacing: -.3px; }
.totals .label { color: var(--text-dim); }

.hidden { display: none !important; }

/* ---------- Selección múltiple + acciones masivas (reutilizable en todas las tablas) ---------- */
.sel-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--surface-2); border: 1px solid var(--border-soft); border-radius: var(--radius-sm); padding: 9px 14px; margin-bottom: 14px; font-size: 13px; }
.sel-bar .sel-count { font-weight: 650; color: var(--text); white-space: nowrap; }
.sel-bar .sel-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.sel-chk { width: 16px; height: 16px; cursor: pointer; }
th.sel-col, td.sel-col { width: 30px; text-align: center; padding-right: 0; }

/* ---------- Panel de Recomendaciones (Inicio): 4 categorías fijas con sus ejemplos adentro ---------- */
.reco-panel { border-color: rgba(251,191,36,.18); }
.reco-panel .panel-head { gap: 10px; }
.reco-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.reco-card { background: var(--surface-2); border: 1px solid var(--border-soft); border-top: 3px solid var(--text-faint); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 12px; transition: transform .15s ease, box-shadow .15s ease; }
.reco-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-soft); }
.reco-card-head { display: flex; align-items: center; gap: 8px; }
.reco-card-icon { font-size: 18px; line-height: 1; }
.reco-card-titulo { font-weight: 750; font-size: 14.5px; letter-spacing: -.2px; flex: 1; }
.reco-card-vacio { font-size: 12.5px; color: var(--text-faint); margin: 0; }
.reco-card-ejemplos { display: flex; flex-direction: column; gap: 10px; }
.reco-ejemplo { padding-top: 9px; border-top: 1px solid var(--border-soft); }
.reco-ejemplo:first-child { padding-top: 0; border-top: none; }
.reco-ejemplo-nombre { font-weight: 650; font-size: 12.5px; }
.reco-ejemplo-detalle { font-size: 12px; color: var(--text-dim); line-height: 1.4; margin-top: 1px; }
.reco-ejemplo-extra { font-size: 11px; color: var(--text-faint); margin-top: 2px; }
.reco-ejemplo-mas { font-size: 11.5px; color: var(--text-faint); font-style: italic; padding-top: 4px; }
.reco-card--margen { border-top-color: var(--red); }
.reco-card--costo { border-top-color: var(--amber); }
.reco-card--stock { border-top-color: var(--primary); }
.reco-card--gasto { border-top-color: #c084fc; }

/* ---------- Encabezado de categoría dentro de una tabla (Catálogo agrupado) ---------- */
tr.cat-section-row td { background: var(--surface-2); color: var(--text); font-size: 12px; font-weight: 750; text-transform: uppercase; letter-spacing: .5px; padding: 9px 14px; border-bottom: 1px solid var(--border); }
tr.cat-section-row:hover { background: var(--surface-2); }

/* ---------- Staging de importación (Revisión Previa) ---------- */
.staging-panel { padding-bottom: 6px; }
.staging-head { flex-wrap: wrap; }
.staging-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.staging-tabs { display: flex; gap: 6px; padding: 14px 22px 0; flex-wrap: wrap; }
.stg-tab { display: flex; align-items: center; gap: 7px; background: var(--surface-2); border: 1px solid var(--border-soft); color: var(--text-dim); font-size: 12.5px; font-weight: 600; padding: 8px 14px; border-radius: 999px; cursor: pointer; transition: .15s; }
.stg-tab:hover { color: var(--text); border-color: var(--border); }
.stg-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.stg-tab .stg-count { background: rgba(255,255,255,.18); border-radius: 999px; padding: 1px 8px; font-size: 11px; font-weight: 700; }
.stg-tab.active .stg-count { background: rgba(255,255,255,.28); }
.staging-table th { font-size: 10.5px; }
.staging-table td { padding-top: 9px; padding-bottom: 9px; font-size: 13px; }
.edit-cell { display: inline-block; min-width: 22px; padding: 3px 6px; border-radius: 6px; cursor: text; border: 1px dashed transparent; }
.edit-cell:hover { border-color: var(--border); background: var(--surface-2); }
.edit-input { width: 100%; min-width: 70px; background: var(--surface-3); border: 1px solid var(--primary); border-radius: 6px; color: var(--text); padding: 4px 7px; font-size: 13px; font-family: inherit; }
.edit-input:focus { outline: none; box-shadow: 0 0 0 2px var(--primary-glow); }

/* ---------- Badge compacto de pertenencia al listado/catálogo ---------- */
.cat-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; }
.cat-badge button { padding: 2px 8px; font-size: 11px; }

/* ---------- Radios / condición de pago ---------- */
.radio-group { display: flex; flex-direction: column; gap: 9px; margin-top: 4px; }
.radio-group label { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 14px; cursor: pointer; padding: 11px 14px; border: 1px solid var(--border-soft); border-radius: var(--radius-sm); transition: .16s; }
.radio-group label:hover { background: var(--surface-2); border-color: var(--border); }
.radio-group input { width: auto; }
.pago-box { background: var(--bg-2); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 18px; margin-top: 12px; }

/* ---------- Sub-tabs ---------- */
.sub-tabs { display: flex; gap: 8px; margin-bottom: 24px; }
.sub-tab { background: var(--surface-2); color: var(--text-dim); border: 1px solid var(--border-soft); padding: 9px 18px; border-radius: var(--radius-sm); cursor: pointer; font-size: 14px; font-weight: 550; transition: .16s; }
.sub-tab:hover { color: var(--text); background: var(--surface-3); }
.sub-tab.active { background: var(--primary); color: #fff; border-color: transparent; box-shadow: 0 3px 14px var(--primary-glow); }

/* ---------- Caja cards ---------- */
.caja-card { background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 20px 22px; display: flex; flex-direction: column; gap: 9px; box-shadow: var(--shadow-soft); transition: transform .18s ease, border-color .18s ease; }
.caja-card:hover { transform: translateY(-3px); border-color: var(--border); }
.caja-card .caja-top { display: flex; align-items: center; gap: 11px; }
.caja-card .caja-icon { font-size: 22px; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; background: var(--surface-2); border-radius: 12px; }
.caja-card .caja-name { font-size: 13px; color: var(--text-dim); }
.caja-card .caja-val { font-size: 24px; font-weight: 700; font-family: var(--mono); letter-spacing: -.8px; }
.caja-card .caja-sub { font-size: 12px; color: var(--text-dim); }

.pos { color: var(--green); }
.neg { color: var(--red); }

/* ---------- Finanzas (ex Cierre de Mes): reporte financiero, distinto del Inicio ---------- */
.fin-panel .panel-head { padding: 22px 26px; }
.fin-panel .panel-head h3 { font-size: 20px; font-weight: 800; letter-spacing: -.4px; }
.fin-pill { font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .5px; color: var(--text-dim); background: var(--surface-2); border: 1px solid var(--border-soft); border-radius: 999px; padding: 5px 12px; white-space: nowrap; }

.fin-cta { text-align: center; padding: 36px 26px; }
.fin-cta .btn { font-size: 16px; font-weight: 650; padding: 16px 36px; }

/* Bloques superiores simétricos: cascada de rentabilidad + egresos del período */
.kpi-grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 18px; margin-bottom: 30px; align-items: start; }
.fl-pct { font-size: 11px; font-weight: 650; color: var(--text-faint); margin-left: 6px; }

/* ---------- Listas verticales del balance (Tesorería / Cuentas Corrientes / Inventario) ---------- */
.fin-list { padding: 6px 26px 22px; }
.fin-list-row { display: flex; justify-content: space-between; align-items: baseline; gap: 24px; padding: 14px 0; border-bottom: 1px solid var(--border-soft); }
.fin-list-row:last-of-type { border-bottom: none; }
.fl-label { font-size: 14.5px; color: var(--text-dim); }
.fl-value { font-family: var(--mono); font-weight: 700; font-size: 17px; letter-spacing: -.3px; text-align: right; white-space: nowrap; }
.fl-value small { display: block; font-weight: 500; font-size: 11.5px; color: var(--text-faint); margin-top: 3px; }
.fin-list-row.fin-list-total { border-top: 2px solid var(--border); border-bottom: none; margin-top: 6px; padding-top: 18px; }
.fin-list-row.fin-list-total .fl-label { color: var(--text); font-weight: 650; }
.fin-list-row.fin-list-total .fl-value { font-size: 21px; }

/* ---------- Filtro de fecha (Ventas, Compras, Gastos, Cuentas Corrientes) ---------- */
.filtro-fecha { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.filtro-fecha select, .filtro-fecha input[type=month], .filtro-fecha input[type=date] { max-width: 168px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  padding: 13px 22px; border-radius: var(--radius); box-shadow: var(--shadow); z-index: 100; font-size: 14px;
}
.toast.ok { border-color: rgba(52,211,153,.5); }
.toast.err { border-color: rgba(248,113,113,.5); }

@media print {
  .sidebar, .topbar, .topbar-actions, .no-print { display: none !important; }
  body, #app { background: #fff; color: #000; }
  .view-container { padding: 0; }
  /* Impresión de remito: ocultar la app/modal y mostrar solo el remito */
  body.printing-remito #app,
  body.printing-remito #modalBackdrop,
  body.printing-remito #toast { display: none !important; }
  body.printing-remito #remitoPrint { display: block !important; }
}

/* ---------- Remito (oculto en pantalla, visible solo al imprimir) ---------- */
#remitoPrint { display: none; color: #000; font-size: 13px; padding: 8px 4px; }
.remito-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid #000; padding-bottom: 10px; margin-bottom: 12px; }
.remito-empresa { font-size: 22px; font-weight: 800; }
.remito-sub { font-size: 13px; color: #444; margin-top: 2px; }
.remito-fecha { text-align: right; font-size: 13px; line-height: 1.5; }
.remito-cliente { margin-bottom: 14px; line-height: 1.6; }
.remito-table { width: 100%; border-collapse: collapse; margin-bottom: 14px; }
.remito-table th, .remito-table td { border: 1px solid #999; padding: 7px 9px; font-size: 12.5px; text-align: left; }
.remito-table th { background: #f0f0f0; text-transform: uppercase; font-size: 11px; letter-spacing: .4px; }
.remito-table .num { text-align: right; }
.remito-totales { margin-left: auto; width: 280px; }
.remito-totales > div { display: flex; justify-content: space-between; padding: 4px 0; }
.remito-totales .grand { border-top: 2px solid #000; font-weight: 800; font-size: 15px; margin-top: 4px; padding-top: 8px; }
.remito-nota { margin-top: 12px; font-size: 12.5px; }
.remito-firma { margin-top: 52px; border-top: 1px solid #000; width: 280px; padding-top: 6px; font-size: 12px; color: #444; }
#remitoPrint .muted { color: #555; }
