/* RoadCash · tema oscuro pensado para usar con una mano y poca luz */
:root {
  --bg: #0a0a0c;
  --card: #141418;
  --card-2: #1b1b21;
  --line: #2a2a32;
  --text: #f4f4f5;
  --muted: #8d8d98;
  --amber: #f59e0b;
  --amber-ink: #1a1203;
  --green: #22c55e;
  --red: #ef4444;
  --radius: 18px;
  --f-head: "Archivo Black", "Arial Black", Impact, "Roboto", system-ui, sans-serif;
  --f-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --f-mono: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, Consolas, "Roboto Mono", monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--text); font-family: var(--f-body); }
body { overflow: hidden; touch-action: manipulation; -webkit-text-size-adjust: 100%; }
button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.h-caps, .tab, .cat-label, .btn, .chip-title, .sec-title {
  font-family: var(--f-head);
  text-transform: uppercase;
  letter-spacing: .09em;
}

/* ---------- estructura ---------- */
#app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: max(env(safe-area-inset-top), 8px) 14px max(env(safe-area-inset-bottom), 8px);
  max-width: 720px;
  margin: 0 auto;
  background: radial-gradient(120% 40% at 50% 0%, rgba(245, 158, 11, .07), transparent 60%), var(--bg);
}
.scr { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-bottom: 12px; -webkit-overflow-scrolling: touch; }

/* ---------- cabecera ---------- */
.header { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0 10px; border-bottom: 1px solid #17171c; margin-bottom: 10px; }
.chip-tour { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; min-width: 96px; max-width: 38%; height: 52px; padding: 0 16px; border: 1px solid var(--line); border-radius: 18px; background: var(--card); text-align: left; }
.chip-tour small { font: 500 10px var(--f-mono); letter-spacing: .22em; color: var(--muted); text-transform: uppercase; }
.chip-tour b { font-size: 16px; font-weight: 700; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-name { font-family: var(--f-head); font-size: 17px; letter-spacing: .14em; color: #c9c9d1; }
.logo { width: 44px; height: 44px; border-radius: 12px; background: var(--amber); position: relative; box-shadow: 0 0 28px rgba(245, 158, 11, .25); flex: none; }
.logo::before { content: ""; position: absolute; inset: 11px; border-radius: 50%; background: #111114; }
.logo::after { content: ""; position: absolute; top: 11px; right: 11px; width: 11px; height: 22px; border-radius: 0 11px 11px 0; background: #fde0a0; }
.btn-menu { width: 52px; height: 52px; border: 1px solid var(--line); border-radius: 16px; background: var(--card); font-size: 22px; display: grid; place-items: center; }

/* ---------- pestañas ---------- */
.tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px; padding: 6px; border: 1px solid var(--line); border-radius: 20px; background: var(--card); margin-bottom: 10px; }
.tab { border: 0; background: transparent; padding: 12px 2px; border-radius: 14px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.tab[aria-selected="true"] { background: var(--card-2); color: #fff; box-shadow: inset 0 0 0 1px #2d2d36; }

/* ---------- pantalla Añadir (sin scroll) ---------- */
.hint { margin: 0 0 8px; text-align: center; color: var(--muted); font-size: 15px; flex: none; }
.cats { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(3, minmax(0, 1fr)); gap: 12px; }
.cat { min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: clamp(6px, 1.6dvh, 16px); padding: 6px; border: 1px solid var(--line); border-radius: 26px; background: linear-gradient(180deg, #17171c, #121216); transition: transform .08s, border-color .15s; }
.cat:active { transform: scale(.97); border-color: var(--amber); }
.cat svg { height: clamp(40px, 11dvh, 104px); width: auto; max-width: 70%; display: block; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .45)); }
.cat-label { font-size: clamp(11px, 1.9dvh, 15px); letter-spacing: .12em; text-align: center; }

.foot { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 10px; min-height: 52px; }
.sync { display: flex; align-items: center; gap: 8px; font: 500 14px var(--f-mono); color: var(--green); background: none; border: 0; padding: 6px 2px; }
.sync i { width: 9px; height: 9px; border-radius: 50%; background: currentColor; display: inline-block; }
.sync.pend { color: var(--amber); }
.sync.off { color: var(--muted); }
.sync.err { color: var(--red); }
.sync.busy i { animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.loc { border: 1px solid #7a5208; background: rgba(245, 158, 11, .06); color: var(--amber); border-radius: 22px; padding: 11px 16px; font-size: 15px; }
.loc.off { border-color: var(--line); color: var(--muted); background: transparent; }
.loc.bad { border-color: #7f1d1d; color: #fca5a5; background: rgba(239, 68, 68, .06); }

@media (orientation: landscape) and (max-height: 520px) {
  .cats { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr)); }
  .hint { display: none; }
  .header { padding: 2px 0 6px; margin-bottom: 6px; }
  .chip-tour, .btn-menu { height: 44px; }
  .logo { width: 36px; height: 36px; }
  .tabs { margin-bottom: 6px; padding: 3px; }
  .tab { padding: 8px 2px; }
  .foot { padding-top: 4px; min-height: 44px; }
}

/* ---------- botones y campos ---------- */
.btn { width: 100%; border: 0; border-radius: 18px; padding: 20px 16px; font-size: 16px; display: flex; align-items: center; justify-content: center; gap: 10px; }
.btn-amber { background: var(--amber); color: var(--amber-ink); box-shadow: 0 8px 30px rgba(245, 158, 11, .22); }
.btn-green { background: var(--green); color: #04210e; }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: #c9c9d1; font-family: var(--f-body); letter-spacing: 0; text-transform: none; font-size: 16px; padding: 14px; border-radius: 999px; }
.btn-line { background: var(--card); border: 1px solid var(--line); color: var(--text); }
.btn-danger { background: rgba(239, 68, 68, .1); border: 1px solid #7f1d1d; color: #fca5a5; }
.btn[disabled] { opacity: .45; }
.field { width: 100%; background: #1a1a20; border: 1px solid var(--line); border-radius: 16px; padding: 17px 16px; font-size: 17px; outline: none; }
.field:focus { border-color: var(--amber); }
.field::placeholder { color: #6b6b75; }
.lbl { display: block; margin: 14px 2px 8px; font-size: 14px; color: #b4b4be; letter-spacing: .08em; text-transform: uppercase; }
.money { display: flex; align-items: stretch; background: #1a1a20; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.money span { display: grid; place-items: center; padding: 0 16px; border-right: 1px solid var(--line); color: var(--muted); font-family: var(--f-mono); }
.money input { flex: 1; border: 0; background: transparent; padding: 17px 16px; font-family: var(--f-mono); font-size: 18px; outline: none; min-width: 0; }
.panel { border: 1px solid var(--line); border-radius: 22px; background: var(--card); padding: 6px 16px 18px; margin-bottom: 14px; }
.panel .btn { margin-top: 16px; }
.empty { border: 1px dashed #34343d; border-radius: 22px; padding: 38px 16px; text-align: center; color: var(--muted); font-size: 17px; }
.sec-title { font-size: 14px; color: #9a9aa5; margin: 8px 2px 10px; display: flex; align-items: center; justify-content: space-between; }
.tourline { font: 500 15px var(--f-mono); color: var(--amber); margin: 0 2px 12px; }

/* ---------- selector de gira ---------- */
.picker { padding-top: 14px; display: flex; flex-direction: column; gap: 14px; flex: 1; min-height: 0; overflow-y: auto; }
.picker h1 { font-size: 22px; margin: 18px 2px 4px; color: #b9b9c3; }
.cont { display: block; width: 100%; text-align: left; border: 2px solid var(--amber); border-radius: 20px; background: #232330; padding: 22px 20px; font-family: var(--f-head); letter-spacing: .06em; font-size: 17px; }
.tour-row { display: flex; gap: 10px; }
.tour-row .pick { flex: 1; min-width: 0; text-align: left; border: 1px solid var(--line); border-radius: 18px; background: var(--card); padding: 22px 20px; font-size: 18px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tour-row .del { width: 72px; flex: none; border: 1px solid #4a1d22; border-radius: 18px; background: #1d1417; font-size: 24px; }
.ver { text-align: center; color: #5d5d68; font: 12px var(--f-mono); margin: 10px 0 0; }

/* ---------- historial / listas ---------- */
.row { display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; padding: 14px; margin-bottom: 10px; border: 1px solid var(--line); border-radius: 20px; background: var(--card); }
.ico { width: 56px; height: 56px; flex: none; border-radius: 16px; display: grid; place-items: center; background: #1f1618; }
.ico svg { width: 36px; height: 36px; }
.ico.c-fuel { background: #2a2012; } .ico.c-toll { background: #172019; } .ico.c-parking { background: #151c2b; }
.ico.c-catering { background: #2a1619; } .ico.c-hotel { background: #231d17; } .ico.c-other { background: #221a2c; }
.row .mid { flex: 1; min-width: 0; }
.row .t { font-size: 19px; font-weight: 800; }
.row .s { font: 14px var(--f-mono); color: var(--muted); margin-top: 3px; overflow-wrap: anywhere; }
.row .amt { font: 700 20px var(--f-mono); white-space: nowrap; }
.row .amt.g { color: var(--green); }
.pend-badge { display: inline-block; margin-left: 6px; color: var(--amber); }
.btn-icon { width: 52px; height: 48px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); font-size: 20px; }

/* ---------- resumen ---------- */
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.kpi { border: 1px solid var(--line); border-radius: 20px; background: var(--card); padding: 16px; }
.kpi small, .saldo small { display: block; font-family: var(--f-head); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.kpi b { display: block; margin-top: 10px; font: 700 24px var(--f-mono); }
.saldo { border: 2px solid var(--red); border-radius: 22px; padding: 20px; margin-bottom: 24px; background: linear-gradient(135deg, rgba(239, 68, 68, .12), rgba(239, 68, 68, .02)); }
.saldo.ok { border-color: var(--green); background: linear-gradient(135deg, rgba(34, 197, 94, .12), rgba(34, 197, 94, .02)); }
.saldo b { display: block; margin: 10px 0; font: 700 40px var(--f-mono); color: var(--red); }
.saldo.ok b { color: var(--green); }
.saldo.give { border-color: var(--amber); background: linear-gradient(135deg, rgba(245, 158, 11, .14), rgba(245, 158, 11, .02)); }
.saldo.give b { color: var(--amber); }
.saldo .lbl-saldo { font: 700 20px var(--f-head); letter-spacing: .1em; text-transform: uppercase; color: #fff; }
.saldo .hint-saldo { margin-top: 4px; font-size: 14px; color: var(--muted); }
.saldo p { margin: 0; color: #cfcfd6; font-size: 17px; }
.red { color: var(--red); } .green { color: var(--green); }
.catrow { display: flex; align-items: center; gap: 14px; padding: 14px 16px; margin-bottom: 10px; border: 1px solid var(--line); border-radius: 18px; background: var(--card); }
.catrow svg { width: 34px; height: 34px; flex: none; }
.catrow .n { flex: 1; font-weight: 800; font-size: 18px; }
.catrow .v { font: 700 18px var(--f-mono); }
.bar { height: 6px; border-radius: 4px; background: #23232b; margin-top: 8px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--amber); border-radius: 4px; }

/* ---------- hojas (modales desde abajo) ---------- */
.sheet-bg { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .66); display: flex; align-items: flex-end; justify-content: center; animation: fade .12s ease-out; }
.sheet { width: 100%; max-width: 720px; max-height: 100dvh; display: flex; flex-direction: column; background: #101014; border: 1px solid var(--line); border-bottom: 0; border-radius: 28px 28px 0 0; padding: 14px 16px max(env(safe-area-inset-bottom), 14px); animation: up .16s ease-out; overflow-y: auto; }
.sheet.full { height: 100dvh; border-radius: 0; border: 0; padding-top: max(env(safe-area-inset-top), 10px); }
@keyframes up { from { transform: translateY(24px); opacity: .6; } }
@keyframes fade { from { opacity: 0; } }
.sheet-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; flex: none; }
.sheet-head svg { height: 44px; width: auto; }
.sheet-head h2 { margin: 0; font-size: 20px; flex: 1; }
.x { width: 46px; height: 46px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); font-size: 20px; }

/* entrada de importe con teclado propio */
.entry { display: flex; flex-direction: column; flex: 1; min-height: 0; gap: 8px; }
.amount { flex: none; text-align: center; font: 700 clamp(40px, 9dvh, 64px) var(--f-mono); padding: 6px 0 0; letter-spacing: -.01em; }
.amount.zero { color: #5a5a64; }
.geo { text-align: center; font: 14px var(--f-mono); color: var(--muted); min-height: 20px; flex: none; }
.geo.ok { color: var(--green); } .geo.bad { color: #fca5a5; }
.note { flex: none; }
.pad { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(4, minmax(46px, 1fr)); gap: 8px; }
.pad button { border: 1px solid var(--line); border-radius: 18px; background: var(--card); font: 600 clamp(22px, 4dvh, 30px) var(--f-mono); }
.pad button:active { background: var(--card-2); border-color: var(--amber); }
.pad .alt { color: var(--muted); }
.entry-actions { flex: none; display: grid; grid-template-columns: 1fr 2fr; gap: 10px; }
.entry-actions .btn { padding: 18px 10px; }

.menu-list { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.menu-item { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: var(--card); font-size: 17px; }
.menu-item .mi { flex: none; width: 30px; text-align: center; font-style: normal; font-size: 22px; }
.menu-item small { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 10px 2px; border-bottom: 1px solid #1d1d23; font-size: 15px; }
.kv span:first-child { color: var(--muted); }
.kv code { font-family: var(--f-mono); }
.note-box { margin: 10px 0; padding: 12px 14px; border-radius: 14px; font-size: 14px; line-height: 1.45; background: rgba(245, 158, 11, .08); border: 1px solid #5a3d06; color: #f6d58f; }
.note-box.bad { background: rgba(239, 68, 68, .08); border-color: #7f1d1d; color: #fca5a5; }
.note-box.good { background: rgba(34, 197, 94, .08); border-color: #14532d; color: #86efac; }
.banner { flex: none; margin: 0 0 8px; padding: 10px 14px; border-radius: 14px; font-size: 14px; background: rgba(245, 158, 11, .1); border: 1px solid #5a3d06; color: #f6d58f; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.banner button { border: 1px solid currentColor; background: transparent; border-radius: 10px; padding: 6px 12px; color: inherit; }

.toast { position: fixed; left: 50%; bottom: calc(max(env(safe-area-inset-bottom), 10px) + 70px); transform: translateX(-50%); z-index: 80; background: #26262e; border: 1px solid #3a3a45; color: #fff; padding: 14px 20px; border-radius: 16px; font-size: 16px; max-width: 90vw; box-shadow: 0 10px 30px rgba(0, 0, 0, .5); animation: up .15s ease-out; }
.toast.ok { border-color: #14532d; } .toast.bad { border-color: #7f1d1d; }

/* ---------- login ---------- */
.login-page { overflow: auto; display: grid; place-items: center; min-height: 100dvh; padding: 20px; background: radial-gradient(120% 40% at 50% 0%, rgba(245, 158, 11, .08), transparent 60%), var(--bg); }
.login { width: 100%; max-width: 380px; }
.brand-lg { margin: 0 0 18px; } .brand-lg .logo { width: 56px; height: 56px; } .brand-lg .logo::before { inset: 14px; } .brand-lg .logo::after { top: 14px; right: 14px; width: 14px; height: 28px; border-radius: 0 14px 14px 0; } .brand-lg .brand-name { font-size: 26px; color: #fff; }
.login h1 { font-size: 20px; margin: 10px 0 6px; color: #b9b9c3; }
.login .btn { margin-top: 22px; }
.login-err { background: rgba(239, 68, 68, .1); border: 1px solid #7f1d1d; color: #fca5a5; border-radius: 12px; padding: 12px 14px; margin: 10px 0; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- hoja de entrada en horizontal: importe a la izquierda, teclado a la derecha ---------- */
@media (orientation: landscape) and (max-height: 520px) {
  .sheet.full { padding-top: 6px; padding-bottom: max(env(safe-area-inset-bottom), 8px); }
  .sheet-head { margin-bottom: 4px; }
  .sheet-head svg { height: 34px; }
  .sheet-head h2 { font-size: 17px; }
  .entry { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: auto auto auto minmax(0, 1fr); column-gap: 14px; row-gap: 6px; }
  .entry > .amount { grid-column: 1; grid-row: 1; font-size: clamp(32px, 11dvh, 46px); padding-top: 0; }
  .entry > .geo { grid-column: 1; grid-row: 2; min-height: 18px; }
  .entry > .note { grid-column: 1; grid-row: 3; padding: 10px 14px; }
  .entry > .entry-actions { grid-column: 1; grid-row: 4; align-self: end; }
  .entry > .pad { grid-column: 2; grid-row: 1 / 5; grid-template-rows: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .pad button { border-radius: 14px; font-size: clamp(20px, 7dvh, 28px); }
  .entry-actions .btn { padding: 12px 8px; }
}

/* ---------- usuarios ---------- */
.user-row { padding: 12px 2px; border-bottom: 1px solid #1d1d23; }
.user-row.off b { color: var(--muted); text-decoration: line-through; }
.user-row small { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.user-row .user-tags { display: inline; color: var(--amber); }
.user-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.user-btn { width: auto; height: 40px; padding: 0 14px; font-size: 13px; }
.user-btn.danger { color: #fca5a5; border-color: #7f1d1d; }
.check-line { display: flex; gap: 10px; align-items: center; margin: 14px 2px 0; font-size: 15px; color: #c9c9d1; }
.check-line input { width: 20px; height: 20px; accent-color: var(--amber); }
.pw-show { font: 600 17px var(--f-mono); color: #fff; user-select: all; overflow-wrap: anywhere; }
