/* te-Gastos — móvil primero. Identidad ThermoEcsa (rojo corporativo), misma familia que te-BIM. */
:root {
    --brand: #9D162E;
    --brand-dark: #7a1024;
    --brand-soft: #fdf2f4;
    --bg: #f8fafc;
    --panel: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --muted: #64748b;
    --ok: #15803d;
    --warn: #b45309;
    --error: #dc2626;
    --radius: 0.8rem;
    --topbar-h: 3.25rem;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
    margin: 0; min-height: 100vh;
    font-family: system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
    background: var(--bg); color: var(--text);
    font-size: 16px;
}
[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; }
input, select { font: inherit; }
svg.ic { width: 1em; height: 1em; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.15em; }

/* ── Login ─────────────────────────────────────────────────────────────── */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; background: var(--brand); }
.login-card { width: 100%; max-width: 380px; background: var(--panel); border-radius: var(--radius); padding: 1.6rem 1.4rem; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.login-logo { font-weight: 800; font-size: 1.4rem; color: var(--brand); text-transform: uppercase; letter-spacing: .03em; }
.login-lead { color: var(--muted); margin: .4rem 0 1.2rem; }
.btn-google { width: 100%; display: flex; align-items: center; justify-content: center; gap: .6rem; padding: .7rem; border: 1px solid var(--border); border-radius: .6rem; background: #fff; font-weight: 600; }
.login-sep { display: flex; align-items: center; gap: .6rem; color: var(--muted); font-size: .8rem; margin: 1rem 0; }
.login-sep::before, .login-sep::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ── Formularios ───────────────────────────────────────────────────────── */
.form label, .campo { display: flex; flex-direction: column; gap: .3rem; font-size: .8rem; font-weight: 600; color: var(--muted); margin-bottom: .9rem; }
.form input, .campo input, .campo select {
    font-size: 1rem; font-weight: 500; color: var(--text);
    padding: .7rem .8rem; border: 1px solid var(--border); border-radius: .6rem; background: #fff; width: 100%;
}
.campo select { appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%; background-size: 5px 5px; background-repeat: no-repeat; }
.form-error { color: var(--error); font-size: .85rem; margin: 0 0 .6rem; }
.form-hint { color: var(--muted); font-size: .8rem; margin: 0 0 .6rem; }
.fila { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.check { flex-direction: row !important; align-items: center; gap: .6rem !important; font-weight: 500; color: var(--text); font-size: .9rem; }
.check input { width: 1.2rem; height: 1.2rem; }

.btn-primary, .btn-ghost { font-size: .9rem; font-weight: 600; padding: .6rem 1rem; border-radius: .6rem; border: 1px solid transparent; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:active { background: var(--brand-dark); }
.btn-primary:disabled { opacity: .6; }
.btn-ghost { background: transparent; color: var(--brand); border-color: var(--brand); }
.btn-full { width: 100%; }
.btn-sm { font-size: .8rem; padding: .4rem .7rem; }
.btn-grande { padding: 1rem; font-size: 1.05rem; }
.btn-link { background: none; border: 0; color: var(--muted); text-decoration: underline; font-size: .85rem; padding: .4rem 0 1rem; display: block; margin: 0 auto; }
.btn-icon { background: none; border: 0; color: #fff; padding: .4rem; border-radius: .5rem; display: inline-flex; font-size: 1.3rem; }
.btn-icon-oscuro { color: var(--text); }

/* ── Cabecera ──────────────────────────────────────────────────────────── */
.app { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
    position: sticky; top: 0; z-index: 5;
    padding-top: var(--safe-top); min-height: calc(var(--topbar-h) + var(--safe-top));
    display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-left: 1rem; padding-right: .6rem;
    background: var(--brand); color: #fff;
}
.topbar-marca { display: flex; align-items: baseline; gap: .6rem; min-width: 0; }
.topbar-title { font-size: 1.05rem; font-weight: 800; text-transform: uppercase; letter-spacing: .02em; }
.topbar-sub { font-size: .78rem; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-user { display: flex; align-items: center; gap: .5rem; }
.chip { font-size: .7rem; font-weight: 700; padding: .15rem .5rem; border-radius: 999px; text-transform: uppercase; letter-spacing: .03em; }
.chip-net { background: #fff; color: var(--warn); }

/* ── Home ──────────────────────────────────────────────────────────────── */
.main { flex: 1; padding: 1rem 1rem calc(1.5rem + var(--safe-bottom)); max-width: 560px; width: 100%; margin: 0 auto; }
.acciones { display: grid; grid-template-columns: 1.4fr 1fr; gap: .8rem; margin: .2rem 0 .4rem; }
.accion {
    display: flex; flex-direction: column; align-items: flex-start; gap: .1rem;
    padding: 1.1rem 1rem; border-radius: var(--radius); border: 1px solid var(--border); background: var(--panel);
    text-align: left; min-height: 7.5rem; box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.accion:active { transform: scale(.985); }
.accion-principal { background: var(--brand); border-color: var(--brand); color: #fff; }
.accion-ico { font-size: 2rem; margin-bottom: .4rem; display: inline-flex; }
.accion-txt { font-size: 1.25rem; font-weight: 800; }
.accion-sub { font-size: .8rem; opacity: .8; }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem; margin-bottom: .9rem; }
.card-viaje { border-color: var(--brand); background: var(--brand-soft); }
.card-viaje-cab { display: flex; align-items: center; gap: .7rem; }
.card-viaje-ico { font-size: 1.5rem; color: var(--brand); display: inline-flex; }
.card-viaje-txt { flex: 1; min-width: 0; }
.card-viaje-tit { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-viaje-sub { font-size: .8rem; color: var(--muted); }
.card-viaje-tot { margin-top: .5rem; font-size: .85rem; color: var(--muted); }
.card-viaje-tot b { color: var(--text); }

.pendientes { background: #fffbeb; border: 1px solid #fcd34d; border-radius: var(--radius); padding: .7rem .9rem; margin: .5rem 0 .9rem; font-size: .85rem; color: var(--warn); }
.pendientes-cab { display: flex; align-items: center; justify-content: space-between; gap: .6rem; }

.lista-sec { margin-top: .6rem; }
.lista-tit { font-size: .8rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: 0 0 .5rem; }
.lista { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.item { display: flex; align-items: center; gap: .8rem; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem .7rem; }
.item-foto { width: 3rem; height: 3rem; border-radius: .5rem; object-fit: cover; background: var(--border); flex-shrink: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: .7rem; font-weight: 700; }
.item-txt { flex: 1; min-width: 0; }
.item-tit { font-weight: 600; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-sub { font-size: .78rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-der { text-align: right; flex-shrink: 0; }
.item-imp { font-weight: 800; font-size: 1rem; }
.estado { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.estado-pendiente { color: var(--warn); }
.estado-registrado { color: var(--ok); }
.estado-cola { color: var(--error); }
.estado-rechazado { color: var(--error); }
.lista-vacio { color: var(--muted); text-align: center; padding: 1.5rem 0; }

/* ── Hojas (pantalla completa) ─────────────────────────────────────────── */
.hoja { position: fixed; inset: 0; z-index: 10; background: var(--bg); display: flex; flex-direction: column; }
.hoja-form { display: flex; flex-direction: column; height: 100%; }
.hoja-cab { padding-top: var(--safe-top); min-height: calc(var(--topbar-h) + var(--safe-top)); display: grid; grid-template-columns: 3rem 1fr 3rem; align-items: center; background: var(--panel); border-bottom: 1px solid var(--border); padding-left: .3rem; }
.hoja-tit { text-align: center; font-weight: 700; }
.hoja-cuerpo { flex: 1; overflow-y: auto; padding: 1rem 1rem 2rem; max-width: 560px; width: 100%; margin: 0 auto; }
.hoja-pie { padding: .8rem 1rem calc(.8rem + var(--safe-bottom)); background: var(--panel); border-top: 1px solid var(--border); }
.hoja-pie .btn-primary { max-width: 560px; margin: 0 auto; display: block; }

.preview { position: relative; background: #0f172a; border-radius: var(--radius); height: 11rem; display: flex; align-items: center; justify-content: center; overflow: hidden; margin-bottom: 1rem; }
.preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.preview-pdf { color: #fff; font-weight: 800; font-size: 1.5rem; letter-spacing: .1em; }
.preview-repetir { position: absolute; right: .5rem; bottom: .5rem; background: rgba(255,255,255,.92); }

.campo-importe { margin-bottom: 1rem; }
.importe-wrap { position: relative; }
.importe-wrap input { font-size: 2rem; font-weight: 800; padding: .6rem 2.4rem .6rem .8rem; text-align: right; }
.importe-eur { position: absolute; right: .9rem; top: 50%; transform: translateY(-50%); font-size: 1.4rem; font-weight: 700; color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: .45rem; }
.chip-tipo { display: inline-flex; align-items: center; gap: .35rem; padding: .5rem .8rem; border-radius: 999px; border: 1px solid var(--border); background: #fff; font-weight: 600; font-size: .9rem; color: var(--text); }
.chip-tipo.activo { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip-tipo svg { font-size: 1.05rem; }

/* ── Toast ─────────────────────────────────────────────────────────────── */
.toast { position: fixed; left: 50%; bottom: calc(1.5rem + var(--safe-bottom)); transform: translateX(-50%); background: #0f172a; color: #fff; padding: .7rem 1.1rem; border-radius: 999px; font-size: .9rem; font-weight: 600; z-index: 20; box-shadow: 0 6px 20px rgba(0,0,0,.25); max-width: 90vw; text-align: center; }
.toast-ok { background: var(--ok); }
.toast-error { background: var(--error); }

.campo-opcional { font-weight: 400; color: var(--muted); font-size: .72rem; }
.item-imp-vacio { color: var(--muted); font-weight: 500; font-size: .8rem; }
.importe-wrap input { font-size: 1.6rem; }
