/* Cuentas Claras: tablero claro y simple. Barra superior, catálogo de tarjetas y pantallas por módulo. Solo tema claro. */
:root {
  --bg: #f4f7f6; --panel: #ffffff; --panel-2: #edf2f0; --line: #d9e3e0;
  --ink: #17231f; --muted: #566762; --accent: #0b6e73; --accent-ink: #ffffff; --accent-soft: #dcefef;
  --in: #16764a; --in-soft: #dff2e7; --out: #b23a30; --out-soft: #f9e4e1; --tax: #8a5a00; --tax-soft: #f7ecd3;
  --draft: #5b4bb0; --draft-soft: #e9e5f8;
  --sans: "Schibsted Grotesk", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", "Cascadia Mono", Consolas, monospace;
  --r: 8px; color-scheme: light;
}
* { box-sizing: border-box }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 15px/1.5 var(--sans) }
button, input, select, textarea { font: inherit; color: inherit }
h1, h2, h3 { margin: 0; text-wrap: balance; line-height: 1.2 }
h1 { font-size: 1.6rem; font-weight: 700 } h2 { font-size: 1.05rem; font-weight: 600 }
p { margin: 0 } a { color: var(--accent) }
[hidden] { display: none !important }
.cargando { padding: 40px 16px; text-align: center; color: var(--muted) }

/* Barra superior */
.shell-bar { background: var(--accent); color: var(--accent-ink); position: sticky; top: 0; z-index: 5 }
.shell-bar .in-bar { max-width: 1320px; margin: 0 auto; padding: 10px 16px; display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center }
.marca { color: inherit; text-decoration: none; font-weight: 700; font-size: 1.1rem; margin-right: auto }
.shell-bar .quien { font-size: .85rem; opacity: .9 }
.btn-bar { border: 1px solid rgba(255,255,255,.55); background: transparent; color: inherit; border-radius: var(--r); padding: 5px 12px; cursor: pointer; text-decoration: none; font-size: .9rem }
.btn-bar:hover { background: rgba(255,255,255,.16) }
.contenido { max-width: 1320px; margin: 0 auto; padding: 20px 16px 48px; display: grid; gap: 20px; align-content: start }
.contenido > * { min-width: 0 }

/* Estructura */
.head { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: end }
.head p, .hint { color: var(--muted) } .hint { font-size: .82rem }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center }
.periodo { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; padding: 10px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r) }
.periodo label { display: grid; gap: 2px }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; min-width: 0 }
.stack { display: grid; gap: 12px } .gap-s { gap: 4px }
.frase { font-size: 1.1rem; background: var(--accent-soft); border-radius: var(--r); padding: 14px 16px }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px }
.label { font-size: .78rem; color: var(--muted); letter-spacing: .02em }
.big { font: 500 1.5rem/1.2 var(--mono); font-variant-numeric: tabular-nums; overflow-wrap: anywhere }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px }
.kpi { padding: 14px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); min-width: 0; display: grid; gap: 4px }
.kpi .big { font-size: 1.15rem }
.in { color: var(--in) } .out { color: var(--out) } .tax { color: var(--tax) }

/* Catálogo de tarjetas */
.grupo { display: grid; gap: 10px }
.grupo > h2 { font-size: .85rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600 }
.tiles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px }
.grupo-cab { display: flex; align-items: baseline; gap: 10px } .grupo-cab h2 { font-size: .95rem; font-weight: 600 } .grupo-cab span { font-size: .75rem; color: var(--muted) }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--panel); border: 1px solid var(--line); border-radius: 12px }
.stats > div { padding: 12px 16px; display: grid; gap: 2px; border-left: 1px solid var(--line); min-width: 0 } .stats > div:first-child { border-left: 0 }
.stats strong { font: 500 1.15rem/1.2 var(--mono); font-variant-numeric: tabular-nums; overflow-wrap: anywhere } .stats span { font-size: .78rem; color: var(--muted) }
.tile-pie { display: flex; justify-content: space-between; border-top: 1px solid var(--line); padding-top: 8px; margin-top: 4px; font-size: .78rem; font-weight: 600; color: var(--accent) }
@media (max-width: 1180px) { .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)) } }
@media (max-width: 860px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)) } .stats > div:nth-child(3) { border-left: 0 } .stats > div:nth-child(n+3) { border-top: 1px solid var(--line) } }
.tile { display: grid; grid-template-rows: auto auto 1fr auto auto; gap: 6px; min-height: 176px; padding: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; color: var(--ink); text-decoration: none; transition: box-shadow .15s, transform .15s, border-color .15s }
a.tile:hover { box-shadow: 0 4px 14px rgba(23,35,31,.12); transform: translateY(-2px); border-color: var(--accent) }
.tile-top { display: flex; justify-content: space-between; align-items: center; gap: 8px }
.tile-ico { width: 40px; height: 40px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center }
.tile-ico svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round }
.tile h3 { font-size: 1.05rem }
.tile-desc { font-size: .85rem; color: var(--muted) }
.tile-live { align-self: end; display: grid; gap: 2px; min-height: 44px }
.tile-valor { font: 500 1.2rem/1.2 var(--mono); font-variant-numeric: tabular-nums; overflow-wrap: anywhere }
.tile-nota { font-size: .78rem; color: var(--muted) }
.tile.pronto { background: var(--panel-2); border-style: dashed; color: var(--muted) }
.tile.pronto .tile-ico { background: var(--line); color: var(--muted) }
.insignia { font-size: .72rem; padding: 2px 8px; border-radius: 99px; background: var(--tax-soft); color: var(--tax); font-weight: 600; white-space: nowrap }

/* Controles */
.btn { border: 1px solid var(--line); background: var(--panel); border-radius: var(--r); padding: 7px 12px; cursor: pointer; text-decoration: none; color: var(--ink); display: inline-block }
.btn:hover { background: var(--panel-2) } .btn:disabled { opacity: .5; cursor: default }
.btn.main { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600 }
.btn.main:hover { opacity: .9 }
.btn.peligro { color: var(--out); border-color: var(--out-soft) }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--line) }
.tab { border: 0; background: none; padding: 8px 12px; cursor: pointer; border-bottom: 3px solid transparent; color: var(--muted) }
.tab.on { color: var(--accent); border-color: var(--accent); font-weight: 600 }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px }
.shell-bar :focus-visible { outline-color: #fff }
input[type=text], input[type=search], input[type=number], input[type=date], input[type=month], input[type=email], input[type=password], select { border: 1px solid var(--line); background: var(--panel); border-radius: var(--r); padding: 7px 10px; max-width: 100% }
.check { display: flex; gap: 8px; align-items: center }

/* Tablas */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel) }
table { border-collapse: collapse; width: 100%; font-size: .9rem }
th { text-align: left; font-weight: 500; font-size: .78rem; color: var(--muted); background: var(--panel-2); white-space: nowrap }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top }
tbody tr:last-child td { border-bottom: 0 }
tbody tr.click { cursor: pointer } tbody tr.click:hover { background: var(--panel-2) }
th.num, .num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap }
.nowrap { white-space: nowrap }
.pill { display: inline-block; font-size: .74rem; padding: 1px 7px; border-radius: 99px; white-space: nowrap; background: var(--panel-2); color: var(--muted) }
.pill.ingreso, .pill.ok { background: var(--in-soft); color: var(--in) } .pill.egreso, .pill.mal { background: var(--out-soft); color: var(--out) }
.pill.impuesto { background: var(--tax-soft); color: var(--tax) } .pill.borrador { background: var(--draft-soft); color: var(--draft) }
.plan th, .plan td { padding: 6px 8px } .plan td:first-child, .plan th:first-child { position: sticky; left: 0; background: var(--panel); white-space: nowrap } .plan th:first-child { background: var(--panel-2) }
.plan .sub td:first-child { padding-left: 22px; color: var(--muted) } .plan .cat td { background: var(--accent-soft); font-weight: 600 } .plan .total td { background: var(--panel-2); font-weight: 600 } .plan td.vacia { color: var(--muted) } .plan td[data-celda] { cursor: pointer } .plan td[data-celda]:hover { outline: 1px solid var(--accent); outline-offset: -1px }
.hbars { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none }
.hbars li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; font-size: .9rem }
.hbars i { grid-column: 1 / -1; height: 8px; border-radius: 99px; background: var(--panel-2); overflow: hidden; display: block }
.hbars b { display: block; height: 100%; background: var(--accent); border-radius: 99px }
.drop { border: 2px dashed var(--line); border-radius: var(--r); padding: 28px 16px; text-align: center; display: grid; gap: 10px; justify-items: center; background: var(--panel); cursor: pointer }
.drop.over { border-color: var(--accent); background: var(--accent-soft) }
.checks { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none }
.checks li { display: flex; gap: 8px; align-items: baseline; justify-content: space-between; flex-wrap: wrap }
.err { color: var(--out); font-weight: 500 }
.tool { display: inline-block; font: .76rem var(--mono); padding: 1px 6px; border-radius: 4px; background: var(--accent-soft); color: var(--accent); overflow-wrap: anywhere }
.code { font: .84rem var(--mono); background: var(--panel-2); padding: 8px 10px; border-radius: var(--r); overflow-x: auto; white-space: pre }
dialog { border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); color: var(--ink); padding: 18px; width: min(520px, calc(100vw - 24px)); max-height: calc(100vh - 24px); overflow-y: auto }
dialog::backdrop { background: rgba(0, 0, 0, .4) }
.thumb { max-height: 160px; max-width: 100%; border-radius: var(--r); border: 1px solid var(--line) }
.dl { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; margin: 0 } .dl dt { color: var(--muted) } .dl dd { margin: 0; overflow-wrap: anywhere }
.bar-in { fill: var(--in) } .bar-out { fill: var(--out) } .bar-neg { fill: var(--out) }
.tick { fill: var(--muted); font: 11px var(--mono) } .grid-line { stroke: var(--line) } .line { fill: none; stroke: var(--accent); stroke-width: 2.5 } .dot { fill: var(--accent) } .area { fill: var(--accent-soft) }
.aviso { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); max-width: min(560px, calc(100vw - 24px)); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: var(--r); z-index: 20; box-shadow: 0 4px 16px rgba(0,0,0,.3) }
.aviso.mal { background: var(--out) }

/* Ingreso */
.login { max-width: 380px; margin: 12vh auto 0; padding: 0 16px }
.login form { display: grid; gap: 12px }
.login label { display: grid; gap: 2px }

@media (max-width: 860px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr) } .opt { display: none }
}
@media (max-width: 480px) {
  .tiles { grid-template-columns: minmax(0, 1fr) }
  .tile { min-height: 0 }
  h1 { font-size: 1.35rem }
  .shell-bar .quien { display: none }
}
