/* Contabilidad Glindent · estilos */
:root {
  --teal: #0e6b6e; --teal-d: #0a4d50; --aqua: #19a7b5; --mint: #dcefee;
  --bg: #f4f6f5; --card: #ffffff; --ink: #142a2c; --soft: #5b6f71; --line: #e3e8e7; --hover: #eef4f3;
  --ok: #1f8a5b; --ok-bg: #e3f4ec; --bad: #c2412d; --bad-bg: #fbe9e5; --warn: #b7791f; --warn-bg: #fdf3df; --info: #2c6db5; --info-bg: #e5effa;
  --shadow: 0 1px 2px rgba(20,42,44,.06), 0 6px 20px rgba(20,42,44,.06);
  --r: 16px; --sans: Inter, system-ui, -apple-system, "Segoe UI", sans-serif; --serif: Fraunces, Georgia, serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1718; --card: #142224; --ink: #e6efee; --soft: #94a9aa; --line: #23393b; --hover: #1a2e30; --mint: #183a3b;
    --ok-bg: #143327; --bad-bg: #3a1c17; --warn-bg: #36290f; --info-bg: #152a40; --shadow: 0 1px 2px rgba(0,0,0,.3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1718; --card: #142224; --ink: #e6efee; --soft: #94a9aa; --line: #23393b; --hover: #1a2e30; --mint: #183a3b;
  --ok-bg: #143327; --bad-bg: #3a1c17; --warn-bg: #36290f; --info-bg: #152a40; --shadow: 0 1px 2px rgba(0,0,0,.3);
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body { font-family: var(--sans); background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
a { color: var(--teal); }
[hidden] { display: none !important; }
svg.i { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--soft); }
.small { font-size: 13px; }
.pos { color: var(--ok); } .neg { color: var(--bad); }

/* ---- Login ---- */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(1200px 600px at 10% -10%, rgba(25,167,181,.25), transparent), linear-gradient(160deg, #0a4d50, #0e6b6e 60%, #128087); }
.login-card { width: min(380px, 100%); background: var(--card); border-radius: 24px; padding: 32px 26px 22px; box-shadow: 0 20px 60px rgba(0,0,0,.25); display: grid; gap: 14px; }
.login-logo { margin: 0 auto; }
:root[data-theme="dark"] .login-logo, :root[data-theme="dark"] .top-logo { filter: invert(1); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .login-logo, :root:not([data-theme="light"]) .top-logo { filter: invert(1); } }
.login h1 { font-family: var(--serif); text-align: center; font-size: 30px; color: var(--teal); line-height: 1; }
.login-sub { text-align: center; color: var(--soft); margin-top: -6px; margin-bottom: 4px; }
.login label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--soft); }
.login-err { color: var(--bad); font-size: 14px; min-height: 1.2em; }
.login-foot { text-align: center; font-size: 12px; color: var(--soft); }

/* ---- Inputs ---- */
input, select, textarea { width: 100%; background: var(--card); border: 1.5px solid var(--line); border-radius: 12px; padding: 11px 12px; font-size: 16px; outline: none; transition: border-color .15s, box-shadow .15s; }
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--aqua); box-shadow: 0 0 0 3px rgba(25,167,181,.18); }
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--teal); }

/* ---- Botones ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 18px; border-radius: 999px; font-weight: 600; font-size: 15px; border: 1.5px solid transparent; transition: transform .1s, background .15s; white-space: nowrap; text-decoration: none; }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-d); }
.btn-ghost { border-color: var(--line); background: var(--card); color: var(--ink); }
.btn-ghost:hover { background: var(--hover); }
.btn-danger { background: var(--bad-bg); color: var(--bad); }
.btn-wa { background: #25d366; color: #fff; }
.btn-sm { padding: 7px 12px; font-size: 13.5px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; color: var(--soft); }
.icon-btn:hover { background: var(--hover); color: var(--ink); }

/* ---- Estructura ---- */
.app { display: flex; min-height: 100vh; min-height: 100dvh; }
.side { display: none; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.topbar-l { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar h1 { font-family: var(--serif); font-size: 22px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-r { display: flex; align-items: center; gap: 6px; }
.view { padding: 16px 16px calc(110px + var(--safe-b)); width: 100%; max-width: 1180px; margin: 0 auto; outline: none; }
.offline { background: var(--warn-bg); color: var(--warn); text-align: center; padding: 8px 16px; font-size: 13.5px; font-weight: 600; }

.seg { display: flex; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 2px; }
.seg button { padding: 6px 11px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--soft); white-space: nowrap; }
.seg button.on { background: var(--teal); color: #fff; }

.tabbar { position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(5, 1fr); background: var(--card); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + var(--safe-b)); }
.tabbar a { display: grid; justify-items: center; gap: 2px; padding: 6px 0; font-size: 11px; font-weight: 600; color: var(--soft); text-decoration: none; border-radius: 12px; }
.tabbar a.on { color: var(--teal); }
.tabbar a.on svg { stroke-width: 2.3; }
.fab { position: fixed; z-index: 31; right: 18px; bottom: calc(78px + var(--safe-b)); width: 58px; height: 58px; border-radius: 20px; background: linear-gradient(140deg, var(--aqua), var(--teal)); color: #fff; display: grid; place-items: center; box-shadow: 0 10px 24px rgba(14,107,110,.35); transition: transform .15s; }
.fab:active { transform: scale(.94); }
.fab svg { width: 28px; height: 28px; stroke-width: 2.4; }

@media (min-width: 900px) {
  .side { display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; width: 248px; flex: none; background: linear-gradient(180deg, #0a4d50, #0e6b6e); color: #e8f4f3; padding: 22px 14px; }
  .side-brand { display: flex; align-items: center; gap: 12px; padding: 0 10px 22px; }
  .side-brand b { font-family: var(--serif); font-size: 21px; display: block; line-height: 1.1; }
  .side-brand small { opacity: .7; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
  .side-nav { display: grid; gap: 3px; flex: 1; overflow-y: auto; align-content: start; }
  .side-nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; color: inherit; text-decoration: none; font-weight: 500; opacity: .85; }
  .side-nav a:hover { background: rgba(255,255,255,.08); opacity: 1; }
  .side-nav a.on { background: rgba(255,255,255,.16); opacity: 1; font-weight: 600; }
  .side-nav .sep { height: 1px; background: rgba(255,255,255,.12); margin: 8px 10px; }
  .side-user { border-top: 1px solid rgba(255,255,255,.14); padding: 14px 10px 0; font-size: 13px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
  .side-user button { color: inherit; opacity: .8; }
  .tabbar, .top-logo, .mob-more { display: none !important; }
  .fab { bottom: 28px; right: 28px; }
  .view { padding: 24px 28px 60px; }
  .topbar { padding: 14px 28px; }
  .topbar h1 { font-size: 26px; }
}

/* ---- Tarjetas y rejillas ---- */
.card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); border: 1px solid var(--line); padding: 16px; }
.card + .card, .card + .grid, .grid + .card, .grid + .grid, .bar + .card, .bar + .grid, .bar + .list, .card + .h2, .grid + .h2, .list + .h2, .h2 + .card { margin-top: 14px; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-h h3, .h2 { font-family: var(--serif); font-size: 18px; font-weight: 600; }
.h2 { margin: 22px 0 10px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.grid { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
.grid > * { min-width: 0; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 700px) { .g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .gm2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 699px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.kpi { position: relative; overflow: hidden; padding: 14px 14px 13px; }
.kpi .lbl { font-size: 12.5px; font-weight: 600; color: var(--soft); display: flex; align-items: center; gap: 6px; }
.kpi .val { font-size: 23px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; white-space: nowrap; }
.kpi .sub { font-size: 12.5px; color: var(--soft); margin-top: 2px; }
.kpi::after { content: ""; position: absolute; right: -18px; top: -18px; width: 70px; height: 70px; border-radius: 50%; background: var(--k, var(--mint)); opacity: .5; }
.kpi.k-in { --k: var(--ok-bg); } .kpi.k-out { --k: var(--bad-bg); } .kpi.k-res { --k: var(--mint); } .kpi.k-due { --k: var(--warn-bg); }
a.kpi { text-decoration: none; color: inherit; }
.hero-kpi { background: linear-gradient(135deg, #0a4d50, #0e6b6e 55%, #19a7b5); color: #fff; border: 0; }
.hero-kpi .lbl, .hero-kpi .sub { color: rgba(255,255,255,.8); }
.hero-kpi::after { background: rgba(255,255,255,.15); opacity: 1; }
.progress { height: 8px; background: rgba(255,255,255,.25); border-radius: 99px; overflow: hidden; margin-top: 10px; }
.progress span { display: block; height: 100%; background: #fff; border-radius: 99px; }
.progress.dark { background: var(--line); } .progress.dark span { background: var(--teal); }

/* ---- Barra de filtros ---- */
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 14px; }
.bar .grow { flex: 1 1 200px; }
.search { position: relative; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--soft); width: 18px; height: 18px; }
.search input { padding-left: 38px; border-radius: 999px; }
.monthnav { display: inline-flex; align-items: center; gap: 2px; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.monthnav b { min-width: 128px; text-align: center; font-size: 14px; }
.monthnav button { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: var(--soft); }
.monthnav button:hover { background: var(--hover); }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); font-size: 13px; font-weight: 600; color: var(--soft); white-space: nowrap; }
.chip.on { background: var(--ink); border-color: var(--ink); color: var(--card); }
select.mini { width: auto; padding: 8px 30px 8px 12px; border-radius: 999px; font-size: 14px; }

/* ---- Listas ---- */
.list { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); border: 1px solid var(--line); overflow: hidden; }
.list + .list { margin-top: 12px; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--line); text-decoration: none; color: inherit; width: 100%; text-align: left; }
.row:first-child { border-top: 0; }
button.row:hover, a.row:hover { background: var(--hover); }
.row .ic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none; background: var(--mint); color: var(--teal); font-weight: 700; font-size: 14px; }
.row .ic.in { background: var(--ok-bg); color: var(--ok); } .row .ic.out { background: var(--bad-bg); color: var(--bad); } .row .ic.ev { background: var(--info-bg); color: var(--info); } .row .ic.wa { background: var(--warn-bg); color: var(--warn); }
.row .mid { flex: 1; min-width: 0; }
.row .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .s { font-size: 13px; color: var(--soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .end { text-align: right; flex: none; }
.row .amt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row.done .t { text-decoration: line-through; color: var(--soft); }
.day-h { display: flex; justify-content: space-between; padding: 9px 14px; background: var(--bg); font-size: 12.5px; font-weight: 700; color: var(--soft); border-top: 1px solid var(--line); }
.day-h:first-child { border-top: 0; }
.empty { text-align: center; padding: 34px 16px; color: var(--soft); }
.empty svg { width: 40px; height: 40px; stroke-width: 1.4; margin-bottom: 8px; color: var(--aqua); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.b-ok { background: var(--ok-bg); color: var(--ok); } .b-bad { background: var(--bad-bg); color: var(--bad); } .b-warn { background: var(--warn-bg); color: var(--warn); } .b-info { background: var(--info-bg); color: var(--info); } .b-mute { background: var(--hover); color: var(--soft); }

/* ---- Tablas (informes) ---- */
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { padding: 9px 6px; border-bottom: 1px solid var(--line); text-align: left; }
.tbl th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--soft); font-weight: 700; }
.tbl td.r, .tbl th.r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl tr.tot td { font-weight: 700; border-bottom: 0; border-top: 2px solid var(--ink); }
.tbl-wrap { overflow-x: auto; }
.hbar { display: grid; gap: 9px; }
.hbar .it { display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; font-size: 13.5px; }
.hbar .track { grid-column: 1 / -1; height: 7px; background: var(--hover); border-radius: 99px; overflow: hidden; }
.hbar .track span { display: block; height: 100%; border-radius: 99px; background: var(--teal); }

/* ---- Gráfico ---- */
.chart { width: 100%; height: auto; display: block; }
.chart .gi { fill: var(--aqua); } .chart .go { fill: #e08b6f; } .chart .gl { stroke: var(--line); } .chart text { fill: var(--soft); font-size: 10px; font-family: var(--sans); }
.chart .cur text { fill: var(--ink); font-weight: 700; }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--soft); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* ---- Calendario ---- */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .wd { text-align: center; font-size: 11.5px; font-weight: 700; color: var(--soft); padding: 4px 0; text-transform: uppercase; }
.cal button { aspect-ratio: 1 / 1; min-height: 40px; border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-weight: 600; font-size: 14px; position: relative; }
.cal button:hover { background: var(--hover); }
.cal button.out { color: var(--soft); opacity: .45; }
.cal button.today { color: var(--teal); box-shadow: inset 0 0 0 2px var(--aqua); }
.cal button.sel { background: var(--teal); color: #fff; box-shadow: none; }
.cal .dots { display: flex; gap: 2px; height: 5px; }
.cal .dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--aqua); }
.cal .dots i.r { background: var(--bad); } .cal .dots i.g { background: var(--ok); } .cal .dots i.y { background: var(--warn); }
.cal button.sel .dots i { background: #fff; }
@media (min-width: 900px) { .agenda-layout { display: grid; grid-template-columns: 1.1fr 1fr; gap: 14px; align-items: start; } .agenda-layout > * + * { margin-top: 0 !important; } }

/* ---- Ficha ---- */
.profile { display: flex; align-items: center; gap: 14px; }
.avatar { width: 54px; height: 54px; border-radius: 18px; background: linear-gradient(140deg, var(--aqua), var(--teal)); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 19px; flex: none; }
.profile h2 { font-family: var(--serif); font-size: 22px; line-height: 1.15; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.plan { display: grid; gap: 6px; margin-top: 10px; }
.plazo { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13.5px; padding: 7px 10px; border-radius: 10px; background: var(--bg); }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--soft); font-weight: 600; font-size: 14px; text-decoration: none; margin-bottom: 12px; }

/* ---- Hoja (modal) ---- */
.sheet-bg { position: fixed; inset: 0; z-index: 50; background: rgba(8,22,23,.45); display: flex; align-items: flex-end; justify-content: center; animation: fade .18s ease; }
.sheet { width: min(560px, 100%); max-height: 92vh; max-height: 92dvh; background: var(--card); border-radius: 22px 22px 0 0; display: flex; flex-direction: column; animation: up .22s cubic-bezier(.2,.8,.2,1); }
.sheet-h { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 10px; border-bottom: 1px solid var(--line); }
.sheet-h h3 { font-family: var(--serif); font-size: 20px; }
.sheet-b { padding: 16px 18px; overflow-y: auto; display: grid; gap: 13px; }
.sheet-f { padding: 12px 18px calc(14px + var(--safe-b)); border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.sheet-f .sp { flex: 1; }
@media (min-width: 700px) { .sheet-bg { align-items: center; } .sheet { border-radius: 22px; } }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.f { display: grid; gap: 6px; }
.f > span { font-size: 13px; font-weight: 600; color: var(--soft); }
.f > span em { color: var(--bad); font-style: normal; }
.f-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.f-check { display: flex; align-items: center; gap: 10px; font-weight: 600; padding: 4px 0; }
.f-hint { font-size: 12.5px; color: var(--soft); }
.calc { background: var(--bg); border-radius: 12px; padding: 10px 12px; font-size: 14px; display: grid; gap: 3px; }
.calc div { display: flex; justify-content: space-between; }
.calc .tot { font-weight: 700; border-top: 1px solid var(--line); padding-top: 5px; margin-top: 3px; }
.money { position: relative; }
.money input { padding-right: 34px; font-variant-numeric: tabular-nums; }
.money::after { content: "€"; position: absolute; right: 13px; top: 50%; transform: translateY(-50%); color: var(--soft); font-weight: 600; }
.combo { position: relative; }
.combo-list { position: absolute; z-index: 5; left: 0; right: 0; top: calc(100% + 4px); background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); max-height: 220px; overflow-y: auto; }
.combo-list button { display: block; width: 100%; text-align: left; padding: 10px 12px; border-top: 1px solid var(--line); }
.combo-list button:first-child { border-top: 0; }
.combo-list button:hover, .combo-list button.act { background: var(--hover); }
.combo-list small { color: var(--soft); margin-left: 6px; }
.combo-sel { display: flex; align-items: center; justify-content: space-between; gap: 8px; border: 1.5px solid var(--aqua); background: var(--mint); border-radius: 12px; padding: 9px 12px; font-weight: 600; }
.photo-prev { max-width: 100%; border-radius: 12px; border: 1px solid var(--line); }
.quick { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.quick button { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 14px; border-radius: 16px; border: 1px solid var(--line); background: var(--bg); font-weight: 600; text-align: left; }
.quick button:hover { border-color: var(--aqua); }
.quick small { font-weight: 400; color: var(--soft); font-size: 12.5px; }

/* ---- Avisos ---- */
.toasts { position: fixed; z-index: 60; left: 50%; transform: translateX(-50%); bottom: calc(150px + var(--safe-b)); display: grid; gap: 8px; width: min(420px, calc(100% - 32px)); pointer-events: none; }
.toast { background: var(--ink); color: var(--card); padding: 12px 16px; border-radius: 14px; font-weight: 600; font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.25); animation: up .2s ease; pointer-events: auto; }
.toast.bad { background: var(--bad); color: #fff; }
@media (min-width: 900px) { .toasts { bottom: 30px; } }

.menu-list .row .ic { background: var(--hover); color: var(--ink); }
.sk { height: 70px; border-radius: var(--r); background: linear-gradient(90deg, var(--card), var(--hover), var(--card)); background-size: 200% 100%; animation: sk 1.2s infinite; }
@keyframes sk { to { background-position: -200% 0; } }
@media print {
  .side, .tabbar, .fab, .topbar-r, .bar, .no-print { display: none !important; }
  body { background: #fff; }
  .view { padding: 0; }
  .card, .list { box-shadow: none; }
}
