/* Lenguaje visual tomado de tekfhorm.webflow.io: Space Mono en mayúsculas para etiquetas, Inter 900 para títulos,
   blanco/negro/gris #EAEAEA con azul #0033FF, retícula de líneas de 1 px, glifos [↗] [i] [01] y cruces en las intersecciones. */
:root {
  --ink: #000;
  --paper: #fff;
  --grey: #eaeaea;
  --mid: #333;
  --muted: #555;
  --blue: #0033ff;
  --red: #c00000;
  --green: #00703c;
  --line: 1px solid var(--ink);
  --mono: 'Space Mono', ui-monospace, monospace;
  --sans: 'Inter', Arial, Helvetica, sans-serif;
  --gutter: 16px;
}
* { box-sizing: border-box; border-radius: 0; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 15px/1.45 var(--sans); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--blue); }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.mono, .label, nav a, .btn, th, .chip, label span.t { font-family: var(--mono); font-size: 12px; text-transform: uppercase; letter-spacing: 0; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* --- estructura --- */
.shell { max-width: 1200px; margin: 0 auto; border-left: var(--line); border-right: var(--line); min-height: 100vh; padding-bottom: 80px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px var(--gutter); border-bottom: var(--line); }
.brand { font: 900 26px/1 var(--sans); letter-spacing: -0.02em; }
.brand sup { font: 400 12px var(--mono); }
.topbar .who { display: flex; align-items: center; gap: 16px; font: 12px var(--mono); text-transform: uppercase; }
.linkbtn { background: none; border: 0; padding: 4px 0; font: 12px var(--mono); text-transform: uppercase; cursor: pointer; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.linkbtn:hover { color: var(--blue); }
.linkbtn.danger:hover { color: var(--red); }

nav.tabs { display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: var(--line); }
nav.tabs a { display: block; padding: 14px var(--gutter); color: var(--ink); text-decoration: none; border-right: var(--line); min-height: 48px; }
nav.tabs a:last-child { border-right: 0; }
nav.tabs a:hover { background: var(--grey); }
nav.tabs a[aria-current='page'] { background: var(--ink); color: var(--paper); }
nav.tabs a[aria-current='page'] b { color: #7d98ff; }
nav.tabs b { font-weight: 400; color: var(--blue); margin-right: 6px; }

.pagehead { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: end; padding: 28px var(--gutter) 20px; border-bottom: var(--line); }
.pagehead .eyebrow { font: 12px var(--mono); text-transform: uppercase; margin-bottom: 8px; }
h1 { margin: 0; font: 900 clamp(34px, 6vw, 64px)/0.95 var(--sans); letter-spacing: -0.03em; text-transform: uppercase; }
h2 { margin: 0; font: 900 22px/1.1 var(--sans); letter-spacing: -0.01em; text-transform: uppercase; }
section.block { border-bottom: var(--line); }
.block > header { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px var(--gutter); border-bottom: var(--line); background: var(--grey); }
.block > .body { padding: var(--gutter); }
.note { font: 12px/1.5 var(--mono); text-transform: uppercase; padding: 12px var(--gutter); border-bottom: var(--line); }
.note b { color: var(--blue); font-weight: 400; margin-right: 6px; }

/* --- celdas de datos con cruces de retícula --- */
.cells { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); border-bottom: var(--line); }
.cell { position: relative; padding: 18px var(--gutter) 20px; border-right: var(--line); }
.cell:last-child { border-right: 0; }
.cell::before { content: '+'; position: absolute; top: -9px; right: -5px; font: 700 14px/1 var(--mono); z-index: 1; background: var(--paper); }
.cell:last-child::before { display: none; }
.cell .label { display: block; margin-bottom: 10px; color: var(--muted); }
.cell .value { font: 900 clamp(28px, 4vw, 44px)/1 var(--sans); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.cell .sub { margin-top: 8px; font-size: 13px; color: var(--muted); }
.cell.dark { background: var(--ink); color: var(--paper); }
.cell.dark .label, .cell.dark .sub { color: #cfcfcf; }
.cell.dark::before { background: var(--ink); color: var(--paper); }
.pos { color: var(--green); } .neg { color: var(--red); }

.balance { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center; padding: 22px var(--gutter); background: var(--ink); color: var(--paper); border-bottom: var(--line); }
.balance .label { color: #cfcfcf; display: block; margin-bottom: 8px; }
.balance .big { font: 900 clamp(26px, 4.4vw, 48px)/1.05 var(--sans); letter-spacing: -0.03em; text-transform: uppercase; }
.balance .btn { background: var(--paper); color: var(--ink); border-color: var(--paper); }
.balance .btn:hover { background: var(--blue); color: var(--paper); border-color: var(--blue); }

/* --- botones y formularios --- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 16px; border: var(--line); background: var(--paper); color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--ink); color: var(--paper); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: var(--paper); }
.btn.primary:hover { background: var(--ink); border-color: var(--ink); }
.btn.sm { min-height: 36px; padding: 6px 10px; }
.btn.dangerbtn { border-color: var(--red); color: var(--red); }
.btn.dangerbtn:hover { background: var(--red); color: var(--paper); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field .t { color: var(--ink); }
.field .hint { font-size: 12.5px; color: var(--muted); }
input, select, textarea { width: 100%; min-height: 44px; padding: 10px 12px; border: var(--line); background: var(--paper); font-size: 16px; }
textarea { min-height: 84px; resize: vertical; }
input:hover, select:hover, textarea:hover { background: #f6f6f6; }
input[type='file'] { padding: 8px; font-size: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 14px; }
.err { color: var(--red); font-weight: 600; font-size: 14px; min-height: 1.2em; }

.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; padding: var(--gutter); border-bottom: var(--line); align-items: end; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* --- tablas / listas --- */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; padding: 10px var(--gutter); border-bottom: var(--line); background: var(--grey); font-weight: 400; }
.table td { padding: 12px var(--gutter); border-bottom: 1px solid #bdbdbd; vertical-align: top; }
.table tr:hover td { background: #f7f7f7; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table td .sub { font-size: 12.5px; color: var(--muted); }
.table tfoot td { font-weight: 700; border-top: var(--line); border-bottom: 0; background: var(--grey); }
.actions { display: flex; gap: 12px; justify-content: flex-end; flex-wrap: wrap; }
.chip { display: inline-block; padding: 2px 6px; border: 1px solid var(--ink); margin: 2px 4px 0 0; font-size: 11px; }
.chip.blue { background: var(--blue); border-color: var(--blue); color: #fff; }
.chip.warn { background: var(--ink); color: #fff; }
.chip.late { border-color: var(--red); color: var(--red); }

.cards { display: none; }
.cardrow { padding: 14px var(--gutter); border-bottom: 1px solid #bdbdbd; display: grid; gap: 6px; }
.cardrow .top { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.cardrow .amount { font: 900 20px var(--sans); white-space: nowrap; font-variant-numeric: tabular-nums; }

.subgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.sub-item { padding: var(--gutter); border-right: var(--line); border-bottom: var(--line); display: grid; gap: 10px; align-content: start; }
.sub-item.paused { background: var(--grey); color: var(--muted); }
.sub-item .price { font: 900 28px/1 var(--sans); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }

.bars { display: grid; gap: 12px; }
.bar { display: grid; grid-template-columns: 180px 1fr 100px; gap: 12px; align-items: center; font-size: 14px; }
.bar i { display: block; height: 14px; background: var(--ink); }
.bar .amt { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

.empty { padding: 48px var(--gutter); text-align: left; max-width: 640px; }
.empty h2 { margin-bottom: 10px; }
.empty p { margin: 0 0 16px; }
.empty ol { margin: 0 0 20px; padding-left: 20px; }

/* --- diálogos --- */
dialog { width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 24px); padding: 0; border: var(--line); box-shadow: 8px 8px 0 var(--ink); overflow: auto; background: var(--paper); color: var(--ink); }
dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
dialog form > header { display: flex; justify-content: space-between; align-items: center; padding: 14px var(--gutter); background: var(--ink); color: var(--paper); position: sticky; top: 0; z-index: 2; }
dialog form > header h2 { font-size: 18px; }
dialog header .linkbtn { color: var(--paper); }
dialog .fields { display: grid; gap: 14px; padding: var(--gutter); }
dialog footer { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; padding: var(--gutter); border-top: var(--line); position: sticky; bottom: 0; background: var(--paper); }
.split { border: var(--line); padding: 12px; display: grid; gap: 8px; background: var(--grey); }
.split .preview { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; font-variant-numeric: tabular-nums; }
.split .preview div { background: var(--paper); border: var(--line); padding: 8px 10px; }
.files { display: grid; gap: 6px; }
.files .f { display: flex; justify-content: space-between; align-items: center; gap: 10px; border: var(--line); padding: 8px 10px; font-size: 14px; }
.explain { font-size: 14px; line-height: 1.6; }
.explain code { font-family: var(--mono); background: var(--grey); padding: 1px 5px; }

#toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 12px 18px; font: 12px var(--mono); text-transform: uppercase; display: none; z-index: 50; max-width: calc(100vw - 32px); }
#toast.show { display: block; }
#toast.error { background: var(--red); }

.fab { display: none; }

/* --- acceso --- */
.login { min-height: 100vh; display: grid; place-items: center; padding: var(--gutter); background: var(--grey); }
.login form { width: min(440px, 100%); background: var(--paper); border: var(--line); box-shadow: 8px 8px 0 var(--ink); }
.login .fields { display: grid; gap: 14px; padding: var(--gutter); }
.login .head { padding: 28px var(--gutter) 16px; border-bottom: var(--line); }
.login .head .brand { font-size: 44px; }
.loading { padding: 48px var(--gutter); font: 12px var(--mono); text-transform: uppercase; }

/* --- móvil --- */
@media (max-width: 760px) {
  nav.tabs { grid-template-columns: 1fr 1fr; }
  nav.tabs a:nth-child(2) { border-right: 0; }
  nav.tabs a:nth-child(-n + 2) { border-bottom: var(--line); }
  .pagehead { grid-template-columns: 1fr; }
  .cell { border-right: 0; border-bottom: var(--line); }
  .cell:last-child { border-bottom: 0; }
  .cell::before { display: none; }
  .balance { grid-template-columns: 1fr; }
  .table.responsive { display: none; }
  .cards { display: block; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .bar { grid-template-columns: 1fr 90px; }
  .bar i { grid-column: 1 / -1; grid-row: 2; }
  .sub-item { border-right: 0; }
  .shell { border-left: 0; border-right: 0; }
  .fab { display: flex; position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; min-height: 56px; border: 0; border-top: var(--line); background: var(--blue); color: #fff; font: 700 13px var(--mono); text-transform: uppercase; align-items: center; justify-content: center; cursor: pointer; }
  .toolbar .addbtn { display: none; }
}
@media print { nav, .fab, .actions, .toolbar { display: none !important; } }
@media (prefers-reduced-motion: no-preference) { .btn, nav.tabs a { transition: background-color 0.12s, color 0.12s; } }
@media (max-width: 760px) { .topbar .brand .muted { display: none; } .topbar .who { gap: 10px; } }
