:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel2: #334155;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --green: #16a34a;
  --green-d: #15803d;
  --red: #dc2626;
  --red-d: #b91c1c;
  --blue: #2563eb;
  --line: #334155;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text);
  overscroll-behavior: none;
}
body { user-select: none; }

.screen { display: none; min-height: 100vh; flex-direction: column; }
.screen.active { display: flex; }

/* ---------- LOGIN ---------- */
#scr-login { align-items: center; justify-content: center; }
.login-box { width: min(92vw, 420px); text-align: center; }
.brand { font-size: 2.2rem; font-weight: 800; margin-bottom: .3rem; }
.login-sub { color: var(--muted); font-size: 1.2rem; margin: 0 0 1.4rem; }
.pin-dots { display: flex; gap: 1.1rem; justify-content: center; margin-bottom: 1rem; height: 26px; }
.pin-dots span { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--panel2); }
.pin-dots span.on { background: var(--green); border-color: var(--green); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 1rem; }
.keypad button {
  font-size: 2rem; font-weight: 700; padding: 1.1rem 0;
  background: var(--panel); color: var(--text); border: none; border-radius: 16px;
  cursor: pointer;
}
.keypad button:active { background: var(--panel2); transform: scale(.97); }
.keypad .k-muted { color: var(--muted); }

/* ---------- TOPBAR ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: .9rem 1.1rem; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.who { font-size: 1.15rem; font-weight: 600; }
.topbar-actions { display: flex; gap: .6rem; }
.link {
  background: transparent; color: var(--muted); border: 1px solid var(--line);
  padding: .55rem .9rem; border-radius: 10px; font-size: 1rem; cursor: pointer;
}
.link:active { background: var(--panel2); }
.link.danger { color: #fca5a5; border-color: #7f1d1d; }
.mov-title { font-size: 1.3rem; font-weight: 700; }

/* ---------- HOME ---------- */
.cur-tabs { display: flex; gap: 10px; padding: 1rem 1.1rem .2rem; }
.cur-tab {
  flex: 1; padding: .9rem; font-size: 1.15rem; font-weight: 700;
  background: var(--panel); color: var(--muted); border: 2px solid var(--line);
  border-radius: 12px; cursor: pointer;
}
.cur-tab.active { color: var(--text); border-color: var(--blue); background: #1e293b; }
.total-card { margin: 1rem 1.1rem; padding: 1.4rem; background: var(--panel); border-radius: 16px; text-align: center; }
.total-label { color: var(--muted); font-size: 1rem; letter-spacing: .05em; text-transform: uppercase; }
.total-amount { font-size: 2.8rem; font-weight: 800; margin-top: .3rem; }
.actions-row { display: flex; gap: 14px; padding: 0 1.1rem; }
.big-btn {
  flex: 1; padding: 1.5rem 0; font-size: 1.5rem; font-weight: 800;
  border: none; border-radius: 16px; color: #fff; cursor: pointer;
}
.big-btn:active { transform: scale(.98); }
.big-btn.deposito { background: var(--green); }
.big-btn.retiro { background: var(--red); }

.stock-wrap { margin: 1.2rem 1.1rem 2rem; }
.stock-table { width: 100%; border-collapse: collapse; font-size: 1.15rem; }
.stock-table th { text-align: left; color: var(--muted); font-weight: 600; padding: .5rem .3rem; border-bottom: 1px solid var(--line); }
.stock-table td { padding: .7rem .3rem; border-bottom: 1px solid var(--line); }
.stock-table td:nth-child(2), .stock-table td:nth-child(3),
.stock-table th:nth-child(2), .stock-table th:nth-child(3) { text-align: right; }
.stock-table .cant { font-weight: 700; }
.stock-table tr.zero td { color: var(--muted); }

/* ---------- MOVIMIENTO ---------- */
.mov-total-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.2rem; margin: 1rem 1.1rem 0; border-radius: 14px; font-size: 1.2rem; font-weight: 700;
}
#scr-mov.deposito .mov-total-bar { background: var(--green-d); }
#scr-mov.retiro .mov-total-bar { background: var(--red-d); }
.mov-total { font-size: 1.9rem; }
.denoms { padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: 12px; }
.denom-row {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px;
  background: var(--panel); border-radius: 14px; padding: .8rem 1rem;
}
.denom-info { display: flex; flex-direction: column; }
.denom-val { font-size: 1.35rem; font-weight: 800; }
.denom-sub { color: var(--muted); font-size: .95rem; }
.denom-sub.avail { color: #fbbf24; }
.stepper { display: flex; align-items: center; gap: 10px; }
.stepper button {
  width: 54px; height: 54px; font-size: 1.8rem; font-weight: 800; border: none; border-radius: 12px;
  background: var(--panel2); color: var(--text); cursor: pointer;
}
.stepper button:active { transform: scale(.94); }
.stepper input {
  width: 90px; height: 54px; text-align: center; font-size: 1.5rem; font-weight: 800;
  background: var(--bg); color: var(--text); border: 2px solid var(--line); border-radius: 12px;
}
.nota {
  margin: .2rem 1.1rem 0; padding: .9rem 1rem; font-size: 1.05rem;
  background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 12px;
}
.confirm-row { display: flex; gap: 14px; padding: 1rem 1.1rem 2rem; margin-top: auto; }
.big-btn.cancel { background: var(--panel2); }
.big-btn.confirm { background: var(--blue); }
#scr-mov.retiro .big-btn.confirm { background: var(--red); }
#scr-mov.deposito .big-btn.confirm { background: var(--green); }

/* ---------- HISTORIAL ---------- */
.hist-list { padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: 10px; }
.hist-item { background: var(--panel); border-radius: 12px; padding: .9rem 1rem; border-left: 5px solid var(--line); }
.hist-item.deposito { border-left-color: var(--green); }
.hist-item.retiro { border-left-color: var(--red); }
.hist-top { display: flex; justify-content: space-between; font-weight: 700; font-size: 1.1rem; }
.hist-meta { color: var(--muted); font-size: .9rem; margin-top: .2rem; }
.hist-lineas { color: var(--muted); font-size: .95rem; margin-top: .3rem; }
.hist-ajuste { display: inline-block; font-size: .75rem; background: #78350f; color: #fde68a; padding: .1rem .5rem; border-radius: 6px; margin-left: .4rem; }

/* ---------- ADMIN ---------- */
.admin-body { padding: 1rem 1.1rem 2rem; }
.admin-body h3 { margin: 1.2rem 0 .6rem; }
.admin-list { display: flex; flex-direction: column; gap: 8px; }
.admin-row { display: flex; align-items: center; justify-content: space-between; background: var(--panel); padding: .7rem 1rem; border-radius: 10px; gap: 8px; }
.admin-row .grow { flex: 1; }
.admin-row.off { opacity: .45; }
.admin-add { display: flex; flex-wrap: wrap; gap: 8px; margin-top: .8rem; }
.admin-add input, .admin-add select {
  padding: .7rem; font-size: 1rem; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
}
.admin-add input[type=text] { flex: 1; min-width: 140px; }
.admin-add button, .admin-row button {
  padding: .6rem 1rem; font-size: 1rem; font-weight: 700; border: none; border-radius: 10px;
  background: var(--blue); color: #fff; cursor: pointer;
}
.admin-row button.mini { background: var(--panel2); }
.chk { display: flex; align-items: center; gap: .4rem; color: var(--muted); }

/* ---------- MSG ---------- */
.msg { min-height: 1.4rem; text-align: center; padding: .3rem 1rem; font-size: 1rem; }
.msg.err { color: #fca5a5; }
.msg.ok { color: #86efac; }
