/* ============ Blend Admin · estilos ============ */
:root {
  --black: #000000;
  --ink: #2C2A2B;
  --ink-2: #5E595B;
  --muted: #8A8486;
  --beige: #E5DACA;
  --beige-2: #F3EEE6;
  --beige-3: #FAF7F2;
  --line: #E6E0D6;
  --white: #FFFFFF;
  --c-ing: #8A4518;   /* serie ingresos (validada) */
  --c-egr: #B98A3A;   /* serie egresos (validada)  */
  --ok: #2F7D4F;   --ok-bg: #E7F3EC;
  --warn: #9A6B00; --warn-bg: #FBF1D9;
  --bad: #B3362B;  --bad-bg: #FBE9E7;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 6px 24px rgba(44,42,43,.06);
  --font: "Poppins", system-ui, sans-serif;
  --font-title: "Montserrat", "Poppins", sans-serif;
  --sidebar: 236px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); color: var(--ink); background: var(--beige-3); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--font-title); margin: 0; letter-spacing: -.01em; }
a { color: inherit; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ---------- iconos ---------- */
i[data-i] { display: inline-flex; width: 18px; height: 18px; flex: none; }
i[data-i] svg { width: 100%; height: 100%; }

/* ---------- botones ---------- */
.btn { font: 500 13px/1 var(--font); border-radius: 10px; padding: 11px 16px; border: 1px solid transparent; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; justify-content: center; transition: background .15s, border-color .15s, transform .05s; white-space: nowrap; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--black); color: var(--white); }
.btn-primary:hover { background: var(--ink); }
.btn-secondary { background: var(--white); color: var(--ink); border-color: var(--line); }
.btn-secondary:hover { border-color: var(--ink-2); }
.btn-danger { background: var(--white); color: var(--bad); border-color: #EBC7C3; }
.btn-danger:hover { background: var(--bad-bg); }
.btn-ghost-dark { background: transparent; color: var(--beige); border-color: #4a4648; }
.btn-ghost-dark:hover { border-color: var(--beige); }
.btn-sm { padding: 7px 11px; font-size: 12px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn-wa { background: #E8F5EC; color: #1E6B3A; border-color: #CBE7D4; }
.btn-wa:hover { background: #D7EEDF; }
.icon-btn { background: none; border: 0; padding: 8px; border-radius: 8px; cursor: pointer; color: inherit; display: inline-flex; }
.icon-btn:hover { background: var(--beige-2); }
.link { background: none; border: 0; padding: 0; color: inherit; text-decoration: underline; cursor: pointer; font: inherit; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art { background: var(--black); color: var(--beige); display: flex; flex-direction: column; justify-content: flex-end; padding: 56px; position: relative; overflow: hidden; }
.login-art::before { content: ""; position: absolute; width: 520px; height: 520px; border-radius: 50%; border: 1px solid #3a3637; top: -120px; right: -160px; }
.login-art::after { content: ""; position: absolute; width: 320px; height: 320px; border-radius: 50%; background: radial-gradient(circle, #2C2A2B 0%, transparent 70%); top: 80px; right: 40px; }
.login-brand { font-family: var(--font-title); font-weight: 700; font-size: 72px; letter-spacing: .28em; color: var(--white); position: relative; z-index: 1; }
.login-art p { font-size: 18px; font-weight: 300; margin: 8px 0 0; position: relative; z-index: 1; }
.login-card { align-self: center; justify-self: center; width: min(400px, 100% - 32px); display: flex; flex-direction: column; gap: 14px; padding: 24px 0; }
.login-logo { font-family: var(--font-title); font-weight: 700; letter-spacing: .24em; font-size: 18px; }
.login-logo span, .brand span { font-family: var(--font); font-weight: 300; letter-spacing: .05em; font-size: .7em; color: var(--muted); margin-left: 4px; }
.login-card h1 { font-size: 26px; margin-top: 18px; }
.login-card .muted { margin: -6px 0 6px; }
.form-error { color: var(--bad); min-height: 1em; margin: 0; font-size: 13px; }
.demo-hint { background: var(--beige-2); border-radius: 10px; padding: 10px 12px; font-size: 12px; color: var(--ink-2); margin: 0; }

/* ---------- formularios ---------- */
label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 500; color: var(--ink-2); }
input, select, textarea { font: 400 14px/1.4 var(--font); color: var(--ink); background: var(--white); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; outline: none; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(229,218,202,.7); }
textarea { resize: vertical; min-height: 64px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.field-row { display: flex; gap: 12px; align-items: end; }
.check { flex-direction: row; align-items: center; gap: 10px; font-size: 13px; color: var(--ink); font-weight: 500; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--black); margin: 0; }
.seg { display: inline-flex; background: var(--beige-2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; font: 500 12px var(--font); padding: 7px 12px; border-radius: 8px; cursor: pointer; color: var(--ink-2); }
.seg button.on { background: var(--white); color: var(--black); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 0; display: flex; flex-direction: column; gap: 12px; }
legend { font: 600 12px var(--font-title); padding: 0 6px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); }

/* ---------- layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar); background: var(--black); color: var(--beige); position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; padding: 22px 14px; z-index: 40; transition: transform .2s; }
.brand { font-family: var(--font-title); font-weight: 700; letter-spacing: .24em; color: var(--white); font-size: 18px; padding: 4px 10px 22px; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; text-decoration: none; color: #CFC6BA; font-weight: 400; }
.nav a:hover { background: #1b1a1a; color: var(--white); }
.nav a.on { background: var(--beige); color: var(--black); font-weight: 500; }
.sidebar-foot { border-top: 1px solid #2a2828; padding-top: 14px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.me { display: flex; flex-direction: column; min-width: 0; }
.me span { color: var(--white); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me small { color: var(--muted); font-size: 11px; text-transform: capitalize; }
.main { flex: 1; margin-left: var(--sidebar); min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(250,247,242,.92); backdrop-filter: blur(8px); display: flex; align-items: center; gap: 12px; padding: 18px 32px; border-bottom: 1px solid var(--line); }
.topbar h1 { font-size: 22px; flex: 1; }
.topbar-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.menu-btn { display: none; }
.view { padding: 24px 32px 64px; outline: none; max-width: 1360px; }
.demo-banner { background: var(--beige); color: var(--ink); font-size: 12px; padding: 8px 32px; display: flex; gap: 10px; align-items: center; }
.scrim { display: none; }

/* ---------- tarjetas ---------- */
.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px 0; }
.card-h h2 { font-size: 15px; }
.card-b { padding: 16px 18px 18px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.kpi { padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.kpi .k-label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.kpi .k-value { font-family: var(--font-title); font-weight: 700; font-size: 24px; color: var(--black); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .k-sub { font-size: 12px; color: var(--ink-2); }
.kpi.dark { background: var(--black); border-color: var(--black); }
.kpi.dark .k-label { color: #b5aca0; } .kpi.dark .k-value { color: var(--white); } .kpi.dark .k-sub { color: var(--beige); }
.delta-up { color: var(--ok); } .delta-down { color: var(--bad); }
.kpi.dark .delta-up { color: #8fd3aa; } .kpi.dark .delta-down { color: #f3a49b; }

.dash-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 14px; }
.dash-3 { grid-template-columns: 1fr 1fr 1fr; }
.dash-1-2 { grid-template-columns: 1fr 2fr; align-items: start; }
.chart-box { position: relative; height: 280px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--ink-2); flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend b { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend b.line { height: 2px; width: 14px; border-radius: 1px; }

/* barras horizontales simples */
.hbars { display: flex; flex-direction: column; gap: 10px; }
.hbar { display: grid; grid-template-columns: minmax(90px, 38%) 1fr auto; gap: 10px; align-items: center; font-size: 12.5px; }
.hbar .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .track { height: 8px; background: var(--beige-2); border-radius: 4px; overflow: hidden; }
.hbar .fill { height: 100%; background: var(--c-ing); border-radius: 4px; }
.hbar .val { color: var(--ink-2); font-variant-numeric: tabular-nums; min-width: 40px; text-align: right; }

/* periodo */
.period { display: flex; align-items: center; gap: 6px; background: var(--white); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.period .lbl { font-weight: 500; font-size: 13px; min-width: 128px; text-align: center; text-transform: capitalize; }

/* ---------- tablas ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
.t th { text-align: left; font-weight: 500; font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--beige-3); }
.t td { padding: 11px 14px; border-bottom: 1px solid #F0EBE3; vertical-align: middle; }
.t tbody tr:hover { background: #FCFAF7; }
.t tbody tr.click { cursor: pointer; }
.t tr.anulada td { color: var(--muted); text-decoration: line-through; }
.t td.actions { white-space: nowrap; text-align: right; }
.t tfoot td { font-weight: 600; border-top: 1px solid var(--line); border-bottom: 0; }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty b { display: block; color: var(--ink); font-family: var(--font-title); font-size: 15px; margin-bottom: 4px; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 500; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.b-ok { background: var(--ok-bg); color: var(--ok); }
.b-warn { background: var(--warn-bg); color: var(--warn); }
.b-bad { background: var(--bad-bg); color: var(--bad); }
.b-neutral { background: var(--beige-2); color: var(--ink-2); }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.toolbar input[type=search] { max-width: 260px; }
.toolbar select { width: auto; }
.summary { display: flex; gap: 22px; flex-wrap: wrap; padding: 12px 18px; font-size: 12.5px; color: var(--ink-2); border-bottom: 1px solid var(--line); background: var(--beige-3); }
.summary b { color: var(--black); font-variant-numeric: tabular-nums; }

/* stock */
.stock-bar { height: 6px; background: var(--beige-2); border-radius: 3px; overflow: hidden; width: 120px; }
.stock-bar > div { height: 100%; background: var(--ink); }
.stock-bar.low > div { background: var(--bad); }

/* ---------- modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.42); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 5vh 16px; overflow-y: auto; animation: fade .15s; }
.modal { background: var(--white); border-radius: 16px; width: min(560px, 100%); box-shadow: 0 20px 60px rgba(0,0,0,.25); animation: pop .18s; }
.modal.wide { width: min(820px, 100%); }
.modal-h { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-h h2 { font-size: 17px; }
.modal-b { padding: 20px 22px; display: flex; flex-direction: column; gap: 14px; }
.modal-f { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; background: var(--beige-3); border-radius: 0 0 16px 16px; }
@keyframes fade { from { opacity: 0 } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98) } }

.items { display: flex; flex-direction: column; gap: 8px; }
.item-row { display: grid; grid-template-columns: 1fr 96px 70px 120px 34px; gap: 8px; align-items: center; }
.item-row select, .item-row input { padding: 9px 10px; }
.totals { background: var(--beige-3); border-radius: var(--radius); padding: 12px 14px; display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; font-size: 13px; }
.totals .big { font-family: var(--font-title); font-weight: 700; font-size: 17px; color: var(--black); }
.suggest { position: relative; }
.suggest-list { position: absolute; left: 0; right: 0; top: 100%; background: var(--white); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); z-index: 5; margin-top: 4px; max-height: 220px; overflow-y: auto; }
.suggest-list button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 9px 12px; font: 13px var(--font); cursor: pointer; }
.suggest-list button:hover { background: var(--beige-2); }
.chip { display: inline-flex; align-items: center; gap: 8px; background: var(--beige-2); border-radius: 10px; padding: 8px 12px; font-size: 13px; }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 18px; font-size: 13px; }
.detail-grid dt { color: var(--muted); font-size: 12px; }
.detail-grid dd { margin: 0 0 6px; }

/* ---------- toasts ---------- */
.toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: var(--black); color: var(--white); padding: 12px 16px; border-radius: 10px; font-size: 13px; box-shadow: var(--shadow); animation: pop .2s; max-width: 360px; }
.toast.err { background: var(--bad); }

.alert { border-radius: 10px; padding: 10px 12px; font-size: 12.5px; display: flex; gap: 8px; align-items: flex-start; }
.alert-warn { background: var(--warn-bg); color: #6d4c00; }
.alert-info { background: var(--beige-2); color: var(--ink-2); }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .dash-grid, .dash-3, .dash-1-2 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .login { grid-template-columns: 1fr; }
  .login-art { padding: 32px 24px; min-height: 180px; }
  .login-brand { font-size: 44px; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; }
  .scrim.open { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 30; }
  .main { margin-left: 0; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 12px 16px; flex-wrap: wrap; }
  .topbar h1 { font-size: 18px; }
  .topbar-actions { width: 100%; justify-content: flex-start; }
  .view { padding: 16px 16px 64px; }
  .demo-banner { padding: 8px 16px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .item-row { grid-template-columns: 1fr 1fr; }
  .item-row .del { justify-self: end; }
  .kpi .k-value { font-size: 20px; }
  .toolbar input[type=search] { max-width: none; flex: 1 1 100%; }
  .modal-bg { padding: 0; }
  .modal { border-radius: 0; min-height: 100vh; }
  .modal-f { border-radius: 0; position: sticky; bottom: 0; }
  .hide-m { display: none; }
}
@media (max-width: 480px) {
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 12px; }
  .kpi .k-value { font-size: 17px; }
}

/* ---------- ajustes ---------- */
.btn svg, .icon-btn svg { width: 16px; height: 16px; flex: none; }
.icon-btn svg { width: 18px; height: 18px; }
.alert svg { width: 16px; height: 16px; flex: none; margin-top: 1px; }
.t th.right, .t td.right { text-align: right; }
.t td.num, .t td.right { white-space: nowrap; }
.t td .muted, .t td small { white-space: nowrap; }
.dash-grid > *, .kpis > * { min-width: 0; }
a.btn { text-decoration: none; }
.card .t { min-width: 100%; }
.card-h { flex-wrap: wrap; }
.card-h .legend { flex-wrap: nowrap; }

/* ---------- importar datos ---------- */
.imp-tipos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.imp-tipo { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; cursor: pointer; color: var(--ink-2); font-weight: 400; font-size: 12.5px; transition: border-color .15s, background .15s; position: relative; }
.imp-tipo:hover { border-color: var(--ink-2); }
.imp-tipo.on { border-color: var(--black); background: var(--beige-3); box-shadow: inset 0 0 0 1px var(--black); }
.imp-tipo input { position: absolute; opacity: 0; pointer-events: none; }
.imp-tipo b { font-family: var(--font-title); font-size: 15px; color: var(--black); }
.imp-tipo .link { align-self: flex-start; margin-top: 6px; font-size: 12px; color: var(--c-ing); }
.imp-tipo:has(input:focus-visible) { outline: 2px solid var(--black); outline-offset: 2px; }
.drop { border: 1.5px dashed #CDBFA9; border-radius: var(--radius); background: var(--beige-3); padding: 34px 16px; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; cursor: pointer; color: var(--ink); font-weight: 400; font-size: 13px; transition: background .15s, border-color .15s; }
.drop:hover, .drop.over { background: var(--beige-2); border-color: var(--ink-2); }
.drop b { font-size: 14px; font-weight: 500; }
.drop-ic { width: 44px; height: 44px; border-radius: 50%; background: var(--white); border: 1px solid var(--line); display: inline-flex; align-items: center; justify-content: center; color: var(--ink); flex: none; }
.drop-ic svg { width: 20px; height: 20px; }
.drop-ic.ok { background: var(--ok-bg); border-color: transparent; color: var(--ok); }
.chip svg { width: 16px; height: 16px; }
.map-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 20px; }
.map-row { display: grid; grid-template-columns: minmax(130px, 40%) 1fr; align-items: center; gap: 10px; font-size: 13px; color: var(--ink); font-weight: 400; padding: 4px 0; }
.map-row > span { display: flex; flex-direction: column; }
.map-row small { font-size: 11px; line-height: 1.3; }
.map-row select { padding: 8px 10px; font-size: 13px; color: var(--muted); }
.map-row.set select { color: var(--ink); border-color: #CDBFA9; }
.req { color: var(--bad); font-weight: 600; }
.imp-opts { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.imp-opts small { margin: -4px 0 4px 28px; font-size: 12px; }
.imp-msg { font-size: 12px; color: var(--ink-2); min-width: 220px; }
.imp-foot { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 14px 18px; border-top: 1px solid var(--line); background: var(--beige-3); border-radius: 0 0 var(--radius) var(--radius); }
.imp-done { display: flex; align-items: center; gap: 16px; padding: 20px; flex-wrap: wrap; }
.imp-done h2 { font-size: 17px; }
.imp-done p { margin: 2px 0 0; color: var(--ink-2); }
@media (max-width: 860px) {
  .imp-tipos, .map-grid { grid-template-columns: 1fr; }
  .map-row { grid-template-columns: 1fr; gap: 4px; }
}

label.inline-l { flex-direction: row; align-items: center; gap: 8px; font-size: 13px; color: var(--ink); font-weight: 400; flex-wrap: wrap; }
label.inline-l select { width: auto; }

.olvido { align-self: flex-start; font-size: 12.5px; color: var(--ink-2); margin-top: -6px; }
.me-pass { color: var(--muted); font-size: 11px; text-align: left; margin-top: 2px; }
.me-pass:hover { color: var(--beige); }
