/* Punto24 Finanzas — identidad P24 exacta.
   Fondo negro #000000 · violeta #7B2FFF · verde neón #B4E33D · lima #C7FF00.
   Cero azul rey. Móvil primero, usable en escritorio. */

:root {
  --bg: #000000;
  --surface: #111111;
  --surface-2: #1c1c1c;
  --surface-3: #262626;
  --violet: #7b2fff;
  --violet-dark: #5f1fd6;
  --violet-soft: #a678ff;
  --neon: #b4e33d;
  --lime: #c7ff00;
  --text: #ffffff;
  --muted: #b8b8b8;
  --muted-2: #8a8a8a;
  --border: #2e2e2e;
  --danger: #ff5a5a;
  --warn: #ffb020;
  --radius: 14px;
  --tabbar-h: 64px;
  --header-h: 60px;
  --max-w: 720px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--violet-soft); }
.muted { color: var(--muted); font-size: .85rem; }
.small { font-size: .82rem; }
.money { font-variant-numeric: tabular-nums; font-weight: 700; }
.pos { color: var(--neon); }
.neg { color: var(--danger); }

/* ---------- Pantallas ---------- */
.screen { min-height: 100dvh; }
#screen-app { display: flex; flex-direction: column; }
#screen-app[hidden] { display: none; }

/* ---------- Login ---------- */
.login-wrap {
  max-width: 400px;
  margin: 0 auto;
  padding: 48px 20px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.login-logo { width: 168px; height: 168px; object-fit: contain; }
.login-logo-sm { width: 96px; height: 96px; }
.login-title { margin: 16px 0 2px; font-size: 1.5rem; text-align: center; }
.login-sub { margin: 0 0 24px; color: var(--muted); text-align: center; }
#login-form, #change-pass-form { width: 100%; }

/* ---------- Formularios ---------- */
.field { display: block; margin-bottom: 14px; }
.field > span {
  display: block;
  margin-bottom: 6px;
  font-size: .85rem;
  color: var(--muted);
}
input, select, textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--violet);
  outline-offset: 0;
  border-color: var(--violet);
}
textarea { resize: vertical; min-height: 64px; }
input[type="checkbox"] { width: auto; accent-color: var(--violet); }
label.check { display: flex; align-items: center; gap: 8px; margin: 6px 0; font-size: .95rem; }
.form-row { display: flex; gap: 10px; }
.form-row > * { flex: 1; min-width: 0; }
.error {
  background: #2a0d0d;
  border: 1px solid var(--danger);
  color: #ffb3b3;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: .9rem;
}
.notice {
  background: #171208;
  border: 1px solid var(--warn);
  color: #ffd98a;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: .9rem;
}
.info-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--violet);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: .9rem;
  color: var(--muted);
  margin: 10px 0;
}

/* ---------- Botones ---------- */
.btn {
  display: inline-block;
  border: none;
  border-radius: 12px;
  padding: 12px 18px;
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  background: var(--surface-3);
  color: var(--text);
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--violet); color: #fff; }
.btn-primary:hover { background: var(--violet-dark); }
.btn-neon { background: var(--neon); color: #000; }
.btn-lime { background: var(--lime); color: #000; }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-danger { background: transparent; border: 1px solid var(--danger); color: var(--danger); }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 12px; font-size: .88rem; border-radius: 9px; }

/* ---------- Header / perfil ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.header-logo { width: 40px; height: 40px; object-fit: contain; }
.header-titles { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.header-titles strong { font-size: 1.05rem; line-height: 1.2; }
.header-titles span { font-size: .8rem; color: var(--muted); }
.profile-btn {
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 1.2rem;
  cursor: pointer;
}
.profile-menu {
  position: absolute;
  top: var(--header-h);
  right: 10px;
  z-index: 30;
  width: min(280px, calc(100vw - 20px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .7);
}
.profile-info { padding: 10px 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.profile-info strong, .profile-info span { display: block; }
.menu-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--text);
  font-size: 1rem;
  padding: 11px 12px;
  border-radius: 9px;
  cursor: pointer;
}
.menu-item:hover { background: var(--surface-2); }
.menu-danger { color: var(--danger); }

/* ---------- Vista y tarjetas ---------- */
.view {
  flex: 1;
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 16px 14px calc(var(--tabbar-h) + 24px);
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.card h2 { margin: 0 0 10px; font-size: 1.05rem; }
.card h3 { margin: 0 0 8px; font-size: .95rem; }
.card-title-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 6px 0; }
.row + .row { border-top: 1px solid var(--border); }
.row .label { color: var(--muted); }
.row .value { text-align: right; }
.divider { border: none; border-top: 1px solid var(--border); margin: 12px 0; }
.readonly-note {
  display: inline-block;
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: .82rem;
  margin-bottom: 12px;
}
.pill {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: .78rem;
  font-weight: 700;
  background: var(--surface-3);
  color: var(--text);
  white-space: nowrap;
}
.pill-violet { background: var(--violet); color: #fff; }
.pill-neon { background: var(--neon); color: #000; }
.pill-lime { background: var(--lime); color: #000; }
.pill-warn { background: var(--warn); color: #000; }
.pill-danger { background: var(--danger); color: #fff; }

/* ---------- Finanzas ---------- */
.filters { display: flex; gap: 10px; margin-bottom: 12px; }
.filters .field { flex: 1; margin-bottom: 0; }
.summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.summary-cell {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}
.summary-cell .label { font-size: .8rem; color: var(--muted); }
.summary-cell .value { font-size: 1.15rem; font-weight: 800; margin-top: 2px; }
.summary-cell button.value {
  background: none; border: none; padding: 0;
  color: var(--text); font: inherit; cursor: pointer; text-align: left;
  text-decoration: underline dotted var(--violet-soft);
  text-underline-offset: 3px;
}
.machine-block { margin-bottom: 14px; }
.machine-block > h3 { display: flex; justify-content: space-between; align-items: baseline; }
.tx-row { cursor: pointer; }
.tx-row .concept { flex: 1; min-width: 0; }
.tx-row .concept small { display: block; color: var(--muted-2); font-size: .78rem; }
.kind-ingreso { color: var(--neon); }
.kind-costo { color: var(--warn); }
.kind-gasto { color: var(--danger); }
.empty { color: var(--muted-2); text-align: center; padding: 18px 8px; font-size: .92rem; }

/* ---------- Listas ---------- */
.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
}
.list-item + .list-item { border-top: 1px solid var(--border); }
.list-item .main { flex: 1; min-width: 0; }
.list-item .main strong { display: block; }
.list-item .main small { color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions .btn { flex: 1; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .btn { flex: 1; white-space: nowrap; }
.chip-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; }
.chip {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: .88rem;
  cursor: pointer;
}
.chip.active { background: var(--violet); border-color: var(--violet); color: #fff; }

/* ---------- Inventario ---------- */
.restock-head { text-align: left; }
.restock-head .total { font-size: 1.6rem; font-weight: 800; color: var(--lime); }
.stock-bar {
  height: 10px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
  margin: 8px 0 4px;
}
.stock-bar > div { height: 100%; background: var(--neon); }
.stock-bar.low > div { background: var(--warn); }
.stock-bar.crit > div { background: var(--danger); }

/* ---------- Barra inferior ---------- */
.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
  background: #0d0d0d;
  border-top: 1px solid var(--border);
  z-index: 20;
}
.tab {
  flex: 1;
  border: none;
  background: none;
  color: var(--muted);
  font-size: .85rem;
  font-weight: 700;
  cursor: pointer;
  padding: 8px 4px;
}
.tab.active { color: var(--lime); }
.tab:disabled { opacity: .35; cursor: default; }

/* ---------- Modal / toast ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .65); }
.modal-card {
  position: relative;
  width: 100%;
  max-width: var(--max-w);
  max-height: 88dvh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px 18px 0 0;
  padding: 16px 16px calc(20px + env(safe-area-inset-bottom));
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-head h2 { margin: 0; font-size: 1.15rem; }
.modal-close {
  border: none; background: var(--surface-3); color: var(--text);
  width: 34px; height: 34px; border-radius: 50%; font-size: 1rem; cursor: pointer;
}
.modal-body .btn { margin-top: 6px; }
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + 16px);
  transform: translateX(-50%);
  z-index: 60;
  background: var(--surface-3);
  border: 1px solid var(--violet);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 16px;
  font-size: .92rem;
  max-width: calc(100vw - 32px);
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .6);
}
.toast[hidden] { display: none; }

/* ---------- Escritorio ---------- */
@media (min-width: 760px) {
  .modal { align-items: center; padding: 24px; }
  .modal-card { border-radius: 18px; }
  .view { padding-top: 24px; }
  .summary-grid { grid-template-columns: repeat(4, 1fr); }
}
