/* Botillería · sistema de diseño */
:root {
  color-scheme: light;
  --bg: #f4f4f3; --surface: #ffffff; --surface-2: #f8f8f7; --ink: #111113; --ink-2: #44444a; --muted: #85858c;
  --line: #e6e6e3; --brand: #111113; --brand-2: #2b2b30; --brand-soft: #efefed; --on-brand: #ffffff;
  --side: #0b0b0c; --side-ink: #e6e6e8; --side-muted: #8b8b92; --side-active: #1f1f23;
  --ok: #167a4a; --ok-soft: #e3f4ea; --warn: #b54708; --warn-soft: #fdf0e3; --bad: #c2302e; --bad-soft: #fde8e7;
  --t-iva: #6b7280; --t-iaba10: #0e8a7e; --t-iaba18: #d9731a; --t-ila205: #7c4dcc; --t-ila315: #b42347;
  --field: #ffffff; --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.05);
  --r: 14px;
}
/* Tema oscuro: solo si se activa a mano con <html data-theme="dark">. Por defecto, siempre claro. */
:root[data-theme="dark"] {
  --bg: #0e0e10; --surface: #18181b; --surface-2: #1f1f23; --ink: #f4f4f5; --ink-2: #cacad0; --muted: #8f8f97;
  --line: #2a2a2f; --brand: #f4f4f5; --brand-2: #ffffff; --brand-soft: #26262b; --on-brand: #0b0b0c;
  --side: #000000; --side-ink: #e6e6e8; --side-muted: #85858c; --side-active: #1c1c20;
  --ok: #5fd39a; --ok-soft: #173326; --warn: #f0a35e; --warn-soft: #3a2614; --bad: #ff8a85; --bad-soft: #3d1a1a;
  --t-iva: #a1a7b3; --t-iaba10: #4fd1c1; --t-iaba18: #f5a35c; --t-ila205: #b394f2; --t-ila315: #f07a99;
  --field: #262124; --shadow: none;
  }
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
       -webkit-font-smoothing: antialiased; }
a { color: var(--brand); }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2;
        stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }

/* ---------- Estructura ---------- */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); padding: 20px 14px; position: sticky; top: 0; height: 100vh; align-self: start;
        display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 20px; font-weight: 700; font-size: 17px; color: #fff; }
.brand .logo { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
               background: #0b0b0c; border: 1px solid rgba(255,255,255,.14); }
.brand .logo svg { width: 24px; height: 24px; }
.brand small { display: block; font-weight: 500; font-size: 12px; color: var(--side-muted); }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--side-ink);
         text-decoration: none; font-weight: 500; }
.nav a:hover { background: rgba(255,255,255,.05); }
.nav a[aria-current] { background: var(--side-active); color: #fff; box-shadow: inset 3px 0 0 #ffffff; }
.side .foot { margin-top: auto; padding: 12px; border-top: 1px solid rgba(255,255,255,.08); font-size: 13px; color: var(--side-muted); }
.side .foot button { margin-top: 8px; width: 100%; }
.main { min-width: 0; padding: 28px 32px 48px; max-width: 1240px; width: 100%; }
.top { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 22px; }
.top h1 { margin: 0; font-size: 26px; letter-spacing: -.02em; }
.top p { margin: 4px 0 0; color: var(--muted); }
.bottomnav { display: none; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .main { padding: 18px 16px 96px; }
  .top h1 { font-size: 22px; }
  .bottomnav { display: flex; position: fixed; inset: auto 0 0 0; background: var(--side); z-index: 10;
               padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around; }
  .bottomnav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0;
                 color: var(--side-muted); text-decoration: none; font-size: 11px; font-weight: 600; border-radius: 10px; }
  .bottomnav a[aria-current] { color: #fff; background: var(--side-active); }
}

/* ---------- Componentes ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; box-shadow: var(--shadow); min-width: 0; }
.card + .card, .grid + .card, .card + .grid, .grid + .grid { margin-top: 16px; }
.grid > .card { margin-top: 0; }
.card h2 { margin: 0 0 14px; font-size: 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.card h2 .sub { margin-left: auto; font-weight: 500; font-size: 13px; color: var(--muted); }
.grid { display: grid; gap: 16px; }
.g4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.g2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.g3-1 { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }
@media (max-width: 860px) {
  .g3-1, .g2 { grid-template-columns: 1fr; }
  .card { padding: 16px; } .scroll { margin: 0 -16px; padding: 0 16px; }
  .g4 { grid-template-columns: 1fr 1fr; gap: 12px; }
  .g4 .kpi { flex-direction: column; gap: 8px; }
  .g4 .kpi .ico { width: 36px; height: 36px; }
  .g4 .kpi .val { font-size: 19px; }
  .list .row { flex-wrap: wrap; row-gap: 4px; }
  .list .row .grow { flex-basis: 100%; }
  .card h2 .sub { margin-left: 0; flex-basis: 100%; }
}

.kpi { display: flex; gap: 14px; align-items: flex-start; }
.kpi .ico { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); flex: none; }
.kpi .ico.ok { background: var(--ok-soft); color: var(--ok); } .kpi .ico.warn { background: var(--warn-soft); color: var(--warn); }
.kpi .lbl { color: var(--muted); font-size: 13px; font-weight: 500; }
.kpi .val { font-size: 24px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.2; }
.kpi .note { font-size: 12.5px; color: var(--muted); }

.btn { display: inline-flex; align-items: center; gap: 8px; font: inherit; font-weight: 600; padding: 10px 16px;
       border-radius: 10px; border: 1px solid var(--brand); background: var(--brand); color: var(--on-brand);
       cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--brand-2); border-color: var(--brand-2); }
.btn.ghost { background: transparent; color: var(--brand); border-color: var(--line); }
.btn.ghost:hover { background: var(--brand-soft); }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.side .btn.ghost { color: var(--side-ink); border-color: rgba(255,255,255,.15); }
.side .btn.ghost:hover { background: rgba(255,255,255,.06); }

input, select, textarea { font: inherit; color: var(--ink); background: var(--field); border: 1px solid var(--line);
                          border-radius: 10px; padding: 9px 12px; max-width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 35%, transparent); border-color: var(--brand); }
textarea { width: 100%; min-height: 120px; font-family: ui-monospace, monospace; font-size: 12px; resize: vertical; }
input.num { width: 70px; text-align: right; padding: 6px 8px; }
select.compact { padding: 6px 8px; font-size: 14px; }
label.field { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); }

.scroll { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em;
     padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
.n { text-align: right; font-variant-numeric: tabular-nums; }
td.wrap { white-space: normal; min-width: 180px; }
tfoot td { font-weight: 700; border-top: 2px solid var(--line); border-bottom: 0; }

.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600;
        background: var(--brand-soft); color: var(--brand); white-space: nowrap; }
.chip.ok { background: var(--ok-soft); color: var(--ok); } .chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.muted { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.tax { --c: var(--t-iva); background: color-mix(in srgb, var(--c) 14%, transparent); color: var(--c); }
.tax-iaba10 { --c: var(--t-iaba10); } .tax-iaba18 { --c: var(--t-iaba18); } .tax-ila205 { --c: var(--t-ila205); } .tax-ila315 { --c: var(--t-ila315); }
.dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; background: var(--c, var(--brand)); flex: none; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.filters button { font: inherit; font-size: 13px; font-weight: 600; padding: 6px 12px; border-radius: 99px; cursor: pointer;
                  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); }
.filters button[aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }

.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty .big { width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 12px; display: grid; place-items: center;
              background: var(--brand-soft); color: var(--brand); }
.empty .big svg { width: 26px; height: 26px; }
.empty h3 { margin: 0 0 6px; color: var(--ink); font-size: 16px; }
.empty p { margin: 0 auto 14px; max-width: 420px; }

.alert { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; margin-bottom: 16px; }
.alert.err { background: var(--bad-soft); color: var(--bad); } .alert.good { background: var(--ok-soft); color: var(--ok); }
.alert.info { background: var(--warn-soft); color: var(--warn); }

.list { display: grid; }
.list .row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list .row:last-child { border-bottom: 0; }
.list .row .grow { flex: 1; min-width: 0; }
.list .row .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .row .s { font-size: 12.5px; color: var(--muted); }
.up { color: var(--bad); font-weight: 700; } .down { color: var(--ok); font-weight: 700; }

.bars { display: grid; gap: 10px; }
.bars .b { display: grid; grid-template-columns: minmax(90px, 160px) 1fr auto; gap: 10px; align-items: center; font-size: 13.5px; }
.bars .b .track { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; border: 1px solid var(--line); }
.bars .b .fill { height: 100%; background: var(--c, var(--brand)); border-radius: 99px; }
.bars .b .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stack { display: flex; height: 14px; border-radius: 99px; overflow: hidden; gap: 2px; margin-bottom: 12px; }
.stack span { background: var(--c); }
.legend { display: grid; gap: 8px; font-size: 13.5px; }
.legend div { display: flex; align-items: center; gap: 8px; }
.legend b { margin-left: auto; font-variant-numeric: tabular-nums; }

/* Pasos */
.steps { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.steps .s { display: flex; align-items: center; gap: 8px; padding: 8px 14px 8px 8px; border-radius: 99px; background: var(--surface);
            border: 1px solid var(--line); font-weight: 600; font-size: 14px; color: var(--muted); }
.steps .s b { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2);
              font-size: 12px; border: 1px solid var(--line); }
.steps .s.on { color: var(--ink); border-color: var(--brand); }
.steps .s.on b { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }
.steps .s.done b { background: var(--ok); color: #fff; border-color: var(--ok); }

.drop { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 6px;
        min-height: 230px; border: 2px dashed var(--line); border-radius: var(--r); cursor: pointer; padding: 24px;
        background: var(--surface); transition: border-color .15s, background .15s; }
.drop:hover, .drop.over { border-color: var(--brand); background: var(--brand-soft); }
.drop .big { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
.drop .big svg { width: 26px; height: 26px; }
.option-title { font-weight: 700; font-size: 16px; }
.muted { color: var(--muted); font-size: 13px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 16px; }
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.summary div { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.summary .lbl { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.summary b { display: block; font-size: 19px; font-variant-numeric: tabular-nums; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px;
         background: radial-gradient(1000px 520px at 20% -10%, #26262b 0%, transparent 60%), var(--side); }
.login .card { width: 100%; max-width: 380px; padding: 28px; }
.login .brand { color: var(--ink); padding: 0 0 18px; }
.login .brand small { color: var(--muted); }
.login form { display: grid; gap: 14px; }
.login .btn { justify-content: center; }

.toast { position: fixed; right: 20px; bottom: 20px; z-index: 50; padding: 12px 16px; border-radius: 12px; font-weight: 600;
         background: var(--ink); color: var(--surface); box-shadow: 0 8px 30px rgba(0,0,0,.2); }
@media (max-width: 860px) { .toast { left: 16px; right: 16px; bottom: 84px; } }
