/* Albor Studio v2 — minimalista: una tipografía (la del sistema), neutros cálidos y un solo acento (vino). */
:root {
  --bg: #FAFAF8; --card: #FFFFFF; --soft: #F1F0EC; --line: #ECEBE6; --line-strong: #DAD8D1;
  --fg: #1C1C1A; --muted: #8A8985; --accent: #7A0000; --on-accent: #FFFFFF;
  --pend: #A8620A; --bad: #A6392E;
  --shadow: 0 20px 50px rgba(30, 25, 15, .16);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --nav-h: 60px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111110; --card: #1B1B1A; --soft: #232322; --line: #2A2A28; --line-strong: #3A3A37;
    --fg: #F2F1ED; --muted: #8E8D88; --accent: #C4504A; --on-accent: #FFFFFF;
    --pend: #E0A44A; --bad: #E0857A;
    --shadow: 0 20px 50px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden], .oculto { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 400 16px/1.45 var(--font); overscroll-behavior-y: none; -webkit-font-smoothing: antialiased; }
body.con-hoja { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; text-align: inherit; touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3, p, ul { margin: 0; padding: 0; }
ul { list-style: none; }
em { font-style: normal; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; display: block; }
/* El monograma se tiñe con el color de acento. */
.mg { display: inline-block; flex: none; background: var(--accent); -webkit-mask: url(icons/logo.png) center / contain no-repeat; mask: url(icons/logo.png) center / contain no-repeat; }

/* ---------- estructura ---------- */
#app { max-width: 720px; margin: 0 auto; padding: 0 18px calc(var(--nav-h) + env(safe-area-inset-bottom) + 32px); }
#top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 9px; margin: 0 -18px; padding: calc(env(safe-area-inset-top) + 12px) 18px 10px; background: var(--bg); }
#top .mg { width: 22px; height: 24px; }
#top strong { font-size: 15px; font-weight: 600; letter-spacing: -.01em; flex: 1; }
#sync { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
#sync[data-st="ok"] { display: none; }
#sync[data-st="pend"], #sync[data-st="off"] { color: var(--pend); }
#sync[data-st="error"], #sync[data-st="sesion"] { color: var(--bad); }
.ico { width: 40px; height: 40px; margin-right: -4px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); }
.ico svg { width: 20px; height: 20px; }

#nav { position: fixed; z-index: 6; left: 0; right: 0; bottom: 0; display: flex; background: var(--bg); border-top: 1px solid var(--line); padding: 0 6px env(safe-area-inset-bottom); }
#nav button { flex: 1; height: var(--nav-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; color: var(--muted); }
#nav button[aria-current="page"] { color: var(--accent); }

#comp { display: flex; gap: 8px; align-items: flex-end; margin: 0 0 2px; }
#comp textarea { flex: 1; resize: none; min-height: 48px; padding: 12px 15px; border-radius: 14px; border: 1px solid transparent; background: var(--soft); }
#comp textarea:focus { border-color: var(--line-strong); outline: none; background: var(--card); }
#comp textarea::placeholder { color: var(--muted); }
#comp button { width: 48px; height: 48px; border-radius: 14px; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; flex: none; }

@media (min-width: 760px) {
  #app { padding-bottom: 60px; }
  #nav { position: sticky; top: 58px; left: auto; right: auto; bottom: auto; margin: 0 -18px 10px; padding: 0 12px; border-top: 0; border-bottom: 1px solid var(--line); gap: 4px; }
  #nav button { flex: none; flex-direction: row; gap: 8px; height: 46px; padding: 0 14px; font-size: 14px; }
  #nav svg { width: 18px; height: 18px; }
  #toast { bottom: 24px; }
}

/* ---------- piezas ---------- */
.titulo { font-size: 28px; font-weight: 650; letter-spacing: -.02em; line-height: 1.2; margin-top: 10px; }
.resumen { font-size: 15.5px; color: var(--muted); margin: 3px 0 14px; }
.resumen b { font-weight: 550; color: var(--fg); }
.resumen b.pend { color: var(--pend); }
.sec { margin-top: 24px; }
.sec > header { display: flex; align-items: baseline; gap: 10px; padding: 0 4px 8px; }
.sec h2 { font-size: 13.5px; font-weight: 400; color: var(--muted); flex: 1; }
.sec-x { font-size: 13.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.vacio { padding: 14px 16px; color: var(--muted); font-size: 14.5px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; }
.rows + .vacio, .sheet-c .vacio { margin-top: 8px; }
.lnk { color: var(--fg); font-size: 13.5px; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-strong); min-height: 32px; }
.sub-h { font-size: 13.5px; font-weight: 400; color: var(--muted); margin: 22px 4px 8px; }

.rows { background: var(--card); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.rows + .rows { margin-top: 8px; }
.rows > li { display: flex; align-items: center; gap: 10px; padding: 0 12px 0 14px; border-top: 1px solid var(--line); }
.rows > li:first-child { border-top: 0; }
.rows > li.mas { padding: 0; }
.rows > li.mas button { flex: 1; min-height: 46px; text-align: center; font-size: 13.5px; color: var(--muted); }
.row-b { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 12px 0; min-height: 60px; }
.row-m { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-m b { font-size: 15.5px; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-m small { color: var(--muted); font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-m small:empty { display: none; }
.amt { font-size: 15.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.amt.warn, td.warn { color: var(--pend); }
.row.cancel .row-m b, .row.cancel .amt { color: var(--muted); text-decoration: line-through; }
.row.tarea.hecha .row-m b { color: var(--muted); text-decoration: line-through; }

.chip { flex: none; min-height: 36px; padding: 0 14px; border-radius: 18px; background: var(--soft); font-size: 13.5px; font-weight: 550; white-space: nowrap; position: relative; }
.chip::before { content: ""; position: absolute; inset: -6px 0; }
.chip.go, .chip.pay { background: var(--accent); color: var(--on-accent); }
.check { flex: none; width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--line-strong); position: relative; }
.check::before { content: ""; position: absolute; inset: -10px; }
.check[aria-pressed="true"] { background: var(--fg); border-color: var(--fg); }
.check[aria-pressed="true"]::after { content: "✓"; position: absolute; inset: 0; text-align: center; line-height: 21px; font-size: 13px; color: var(--bg); }

.kpis { display: grid; gap: 8px; margin-top: 12px; }
.k3 { grid-template-columns: repeat(3, 1fr); }
.k4 { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 620px) { .k4 { grid-template-columns: repeat(4, 1fr); } }
.kpi { background: var(--soft); border-radius: 14px; padding: 12px 13px; display: flex; flex-direction: column; min-width: 0; }
.kpi span { font-size: 13px; color: var(--muted); }
.kpi b { font-size: 23px; font-weight: 650; letter-spacing: -.02em; line-height: 1.25; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi b em { font-size: 14px; font-weight: 400; letter-spacing: 0; color: var(--muted); }
.kpi small { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi.warn b { color: var(--pend); }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 46px; padding: 0 18px; border-radius: 12px; background: var(--soft); font-size: 15px; font-weight: 550; white-space: nowrap; cursor: pointer; }
.btn.gold { background: var(--accent); color: var(--on-accent); }
.btn.peligro { background: none; color: var(--bad); padding: 0 6px; }
.btn.add { width: 100%; margin-top: 8px; background: none; border: 1px dashed var(--line-strong); color: var(--muted); font-weight: 400; }
.btn:disabled { opacity: .5; }
.acciones { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.barra { display: flex; gap: 8px; margin-top: 12px; }
.barra input { flex: 1; min-width: 0; background: var(--soft); border-color: transparent; }
#cl-list { margin-top: 12px; }

.mes-sw { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
.mes-sw span { font-size: 28px; font-weight: 650; letter-spacing: -.02em; flex: 1; }
.mes-sw button { width: 42px; height: 42px; border-radius: 50%; background: var(--soft); text-align: center; font-size: 20px; line-height: 1; color: var(--muted); }
.mes-sw .hoy { width: auto; padding: 0 14px; font-size: 13.5px; border-radius: 21px; color: var(--fg); }

/* ---------- calendario ---------- */
.cal { margin-top: 14px; }
.cal-h, .cal-g { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-h span { text-align: center; font-size: 12px; color: var(--muted); padding-bottom: 6px; }
.dia { aspect-ratio: 1 / 1; max-height: 60px; width: 100%; border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 15px; font-variant-numeric: tabular-nums; }
.dia.es-hoy { color: var(--accent); font-weight: 650; }
.dia.sel { background: var(--fg); color: var(--bg); }
.pts { display: flex; gap: 3px; height: 5px; }
.dot { flex: none; width: 5px; height: 5px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.prog { background: none; box-shadow: inset 0 0 0 1px var(--muted); }
.dot.debe { background: var(--pend); }
.dot.cancel { opacity: .35; }
.dia.sel .dot.ok { background: var(--bg); }
.dia.sel .dot.prog { box-shadow: inset 0 0 0 1px var(--bg); }
.ley { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 10px 4px 0; font-size: 12.5px; color: var(--muted); }
.ley span { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- números ---------- */
.charts { display: grid; gap: 24px; margin-top: 26px; }
@media (min-width: 720px) { .charts { grid-template-columns: 1fr 1fr; } }
.chart h3 { font-size: 13.5px; color: var(--muted); font-weight: 400; margin: 0 4px 8px; }
.bar { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px; padding: 5px 4px; font-size: 13.5px; color: var(--muted); }
.bar b { font-weight: 400; font-variant-numeric: tabular-nums; min-width: 52px; text-align: right; }
.bar.act, .bar.act b { color: var(--fg); font-weight: 550; }
.bar-t { position: relative; height: 8px; border-radius: 4px; background: var(--soft); overflow: hidden; }
.bar-t i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 4px; background: var(--line-strong); }
.bar-t i.b2 { background: var(--muted); }
.bar.act .bar-t i.b2 { background: var(--accent); }
.tbl-w { overflow-x: auto; border-radius: 16px; }
.tbl { width: 100%; font-size: 14.5px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; border-spacing: 0; border-collapse: separate; overflow: hidden; }
.tbl th { font-size: 12.5px; color: var(--muted); font-weight: 400; }
.tbl th, .tbl td { padding: 11px 12px 11px 4px; text-align: right; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl thead th { border-top: 0; }
.tbl th:first-child, .tbl td:first-child { text-align: left; padding-left: 14px; white-space: normal; }
.tbl .lnk { font-size: inherit; text-decoration: none; font-weight: 550; }

/* ---------- formularios y hojas ---------- */
input, select, textarea { width: 100%; min-height: 48px; padding: 11px 13px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--card); font-size: 16px; }
textarea { resize: vertical; line-height: 1.4; }
/* iOS: los campos de fecha y hora ignoran el ancho y se montan sobre el campo de al lado. */
input[type="date"], input[type="time"] { -webkit-appearance: none; appearance: none; display: block; min-width: 0; max-width: 100%; text-align: left; }
input::-webkit-date-and-time-value { text-align: left; margin: 0; }
select { min-width: 0; max-width: 100%; text-overflow: ellipsis; }
input[type="checkbox"] { width: 22px; min-height: 22px; height: 22px; padding: 0; accent-color: var(--accent); }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 12px; }
.form + .form { margin-top: 12px; }
.fld { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.fld > span { font-size: 13px; color: var(--muted); }
.full { grid-column: 1 / -1; }
@media (max-width: 360px) { .form { grid-template-columns: 1fr; } }
@media (max-width: 380px) {
  #app { padding-left: 14px; padding-right: 14px; }
  #top { margin: 0 -14px; padding-left: 14px; padding-right: 14px; }
  .tbl { font-size: 13.5px; }
  .tbl th, .tbl td { padding-right: 8px; }
  .tbl th:first-child, .tbl td:first-child { padding-left: 12px; }
  .kpi b { font-size: 20px; }
  .titulo, .mes-sw span { font-size: 25px; }
}
.fld.chk { flex-direction: row; align-items: center; gap: 10px; }
.fld.chk > span { font-size: 15px; color: var(--fg); }
.seg { display: flex; gap: 2px; padding: 3px; background: var(--soft); border-radius: 12px; }
.seg button { flex: 1; min-height: 40px; text-align: center; font-size: 14px; color: var(--muted); border-radius: 9px; }
.seg button[aria-pressed="true"] { background: var(--card); color: var(--fg); font-weight: 550; box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.sheet-c > .seg { margin-bottom: 14px; }
.tarjeta { padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: var(--card); }
.nota-dup { font-size: 13px; color: var(--pend); }
.orig { margin-top: 14px; font-size: 13.5px; color: var(--muted); }
.err { margin-top: 12px; color: var(--bad); font-size: 14px; }
.caja { padding: 16px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; margin-bottom: 10px; }
.caja b { font-weight: 550; }
.caja p { color: var(--muted); font-size: 14px; margin-top: 4px; }
.caja .peq { font-size: 13px; }
.caja .fld { margin-top: 12px; }
.pasos { margin: 8px 0 0; padding-left: 20px; color: var(--muted); font-size: 14px; }
.pasos li { margin: 2px 0; }
.aviso-err { color: var(--bad); }
.intro { color: var(--muted); font-size: 15px; margin: -2px 0 16px; }
.peq-nota { color: var(--muted); font-size: 13.5px; margin-top: 12px; }
.row.tarde .row-m small { color: var(--pend); }
.amt.dias { color: var(--muted); font-size: 14px; }
.row.tarde .amt.dias { color: var(--pend); }
.pend { color: var(--pend); }
.cols .sec:first-child { margin-top: 20px; }
.cols .row-m small { white-space: normal; }
@media (min-width: 900px) { #app { max-width: 1080px; } .cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; align-items: start; } .cols .sec { margin-top: 20px; } }
.av-form { margin-top: 12px; }
.av-form .fld.chk { margin-top: 4px; }
#q-res { margin-top: 6px; }
#q-res .sub-h:first-child { margin-top: 14px; }
.informe { font-family: ui-monospace, Menlo, monospace; font-size: 13px; }

#sheet-bg { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, .4); display: flex; align-items: flex-end; justify-content: center; }
#sheet { width: 100%; max-width: 540px; max-height: 92dvh; display: flex; flex-direction: column; background: var(--bg); border-radius: 22px 22px 0 0; box-shadow: var(--shadow); }
#sheet > header { display: flex; align-items: center; padding: 18px 10px 8px 20px; }
#sheet > header h2 { flex: 1; font-size: 20px; font-weight: 650; letter-spacing: -.01em; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.x { width: 44px; height: 44px; font-size: 24px; text-align: center; color: var(--muted); }
.sheet-c { padding: 6px 20px 20px; overflow-y: auto; overscroll-behavior: contain; }
#sheet > footer { display: flex; gap: 8px; align-items: center; padding: 12px 20px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.sp { flex: 1; }
@media (min-width: 620px) { #sheet-bg { align-items: center; } #sheet { border-radius: 22px; max-height: 86dvh; } }

#toast { position: fixed; z-index: 30; left: 14px; right: 14px; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 12px); max-width: 480px; margin: 0 auto; display: flex; align-items: center; gap: 6px; padding: 8px 8px 8px 16px; min-height: 52px; border-radius: 14px; background: var(--fg); color: var(--bg); box-shadow: var(--shadow); font-size: 14.5px; }
#toast span { flex: 1; }
#toast button { min-height: 36px; padding: 0 12px; border-radius: 10px; font-weight: 550; font-size: 13.5px; background: color-mix(in srgb, var(--bg) 16%, transparent); white-space: nowrap; }

/* ---------- entrada ---------- */
#gate { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 28px calc(32px + env(safe-area-inset-bottom)); text-align: center; }
#gate .mg { width: 64px; height: 70px; margin-bottom: 16px; }
#gate h1 { font-size: 24px; font-weight: 650; letter-spacing: -.02em; }
#g-sub { color: var(--muted); margin: 2px 0 28px; font-size: 14.5px; }
#gate form { width: 100%; max-width: 320px; display: flex; flex-direction: column; gap: 10px; }
#gate input { background: var(--soft); border-color: transparent; }
#gate input:focus { border-color: var(--line-strong); background: var(--card); outline: none; }
#gate .fld { text-align: left; }
#gate .btn { margin-top: 4px; }
.g-nota { font-size: 13px; color: var(--muted); text-align: left; margin: -2px 2px 0; }
.g-cambio { margin-top: 16px; }
#g-msg { min-height: 44px; max-width: 320px; margin-top: 14px; font-size: 14px; color: var(--bad); }

@media (prefers-reduced-motion: no-preference) {
  #sheet { animation: sube .2s ease-out; }
  .bar-t i { transition: width .35s ease-out; }
  @keyframes sube { from { transform: translateY(28px); } }
}
