/* ============================================================
   roomie-split — tema futurista (dark · neón · glassmorphism)
   Mobile-first: una columna, sin contenedores anidados.
   ============================================================ */

:root {
  --bg:        #0a0a14;
  --bg-2:      #0e0b1a;
  --violet:    #7c5cff;
  --violet-2:  #a58bff;
  --cyan:      #5cc8ff;
  --lime:      #5cff9d;
  --coral:     #ff6b6b;
  --amber:     #ffcf5c;
  --text:      #eef0f7;
  --muted:     #9aa0b4;
  --line:      rgba(255, 255, 255, 0.09);
  --glass:     rgba(255, 255, 255, 0.045);
  --glass-2:   rgba(255, 255, 255, 0.07);
  --radius:    18px;
  --shadow:    0 18px 50px rgba(0, 0, 0, 0.45);
  font-synthesis: none;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  position: relative;
  overflow-x: hidden;
}

/* Fondos decorativos */
.bg-grid {
  position: fixed; inset: 0; z-index: -2;
  background-image:
    linear-gradient(rgba(124, 92, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(124, 92, 255, 0.05) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(ellipse 90% 60% at 50% 0%, #000 40%, transparent 100%);
}
.bg-glow {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(600px 400px at 15% -5%, rgba(124, 92, 255, 0.28), transparent 60%),
    radial-gradient(500px 400px at 100% 10%, rgba(92, 200, 255, 0.18), transparent 60%);
}

/* ===== Tipografía base ===== */
h1, h2, h3, .brand-name { font-family: 'Space Grotesk', sans-serif; }
.accent { color: var(--violet-2); }

/* ===== Topbar ===== */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  background: rgba(10, 10, 20, 0.72);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--text); }
.brand-mark {
  color: var(--violet-2); font-size: 20px;
  filter: drop-shadow(0 0 8px rgba(124, 92, 255, 0.7));
}
.brand-mark.big { font-size: 40px; }
.brand-name { font-weight: 700; font-size: 18px; letter-spacing: -0.02em; }
.topnav { display: flex; align-items: center; gap: 8px; }
.nav-link {
  color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 500;
  padding: 7px 12px; border-radius: 10px; transition: all .16s;
}
.nav-link:hover { color: var(--text); background: var(--glass); }
.nav-link.active { color: var(--text); background: var(--glass-2); }
.nav-user {
  font-size: 13px; color: var(--muted); padding-left: 6px;
  border-left: 1px solid var(--line); margin-left: 4px;
}
.nav-logout {
  color: var(--muted); text-decoration: none; font-size: 17px;
  padding: 4px 8px; border-radius: 8px;
}
.nav-logout:hover { color: var(--coral); background: var(--glass); }

/* ===== Layout ===== */
.wrap { max-width: 1080px; margin: 0 auto; padding: 22px 18px 60px; }

/* ===== Glass card ===== */
.glass {
  background: var(--glass);
  border: 1px solid var(--line);
  backdrop-filter: blur(10px);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card { padding: 20px; margin-bottom: 16px; }
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 14px; letter-spacing: -0.01em; }
.card-title-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-title-row .card-title { margin-bottom: 0; }

/* ===== Flashes ===== */
.flashes { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.flash {
  padding: 11px 15px; border-radius: 12px; font-size: 14px;
  border: 1px solid var(--line);
}
.flash-ok    { background: rgba(92, 255, 157, 0.1); border-color: rgba(92, 255, 157, 0.3); color: var(--lime); }
.flash-error { background: rgba(255, 107, 107, 0.1); border-color: rgba(255, 107, 107, 0.32); color: var(--coral); }

/* ===== Dashboard head ===== */
.dash-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 14px; margin-bottom: 20px;
}
.page-title { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.page-sub { color: var(--muted); font-size: 14px; margin-top: 2px; }

/* ===== KPIs ===== */
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 16px; }
.kpi { padding: 18px; display: flex; flex-direction: column; gap: 4px; }
.kpi-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.kpi-value { font-family: 'Space Grotesk'; font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.kpi-value.sm { font-size: 20px; }
.kpi-foot { font-size: 12px; color: var(--muted); }

/* ===== Balance hero ===== */
.balance-hero { padding: 26px 24px; margin-bottom: 16px; position: relative; overflow: hidden; }
.balance-hero::after {
  content: ''; position: absolute; inset: 0; opacity: .5; pointer-events: none;
}
.balance-hero.pos::after  { background: radial-gradient(400px 200px at 90% 120%, rgba(92,255,157,.22), transparent 70%); }
.balance-hero.neg::after  { background: radial-gradient(400px 200px at 90% 120%, rgba(255,107,107,.2), transparent 70%); }
.balance-hero.zero::after { background: radial-gradient(400px 200px at 90% 120%, rgba(124,92,255,.2), transparent 70%); }
.bh-label { font-size: 13px; color: var(--muted); }
.bh-amount { display: block; font-family: 'Space Grotesk'; font-size: 30px; font-weight: 700; margin: 4px 0; letter-spacing: -0.02em; }
.balance-hero.pos .bh-amount  { color: var(--lime); }
.balance-hero.neg .bh-amount  { color: var(--coral); }
.balance-hero.zero .bh-amount { color: var(--violet-2); }
.bh-sub { font-size: 14px; color: var(--muted); }

/* ===== Charts ===== */
.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.chart-box { position: relative; height: 240px; }
.empty { color: var(--muted); font-size: 14px; padding: 8px 0; }

/* ===== Transferencias ===== */
.badge {
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--cyan); background: rgba(92,200,255,.12);
  border: 1px solid rgba(92,200,255,.3); padding: 3px 9px; border-radius: 20px;
}
.transfer-list { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.transfer-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--glass-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 15px; font-size: 15px;
}
.tfrom { color: var(--coral); font-weight: 600; }
.tarrow { color: var(--muted); }
.tto { color: var(--lime); font-weight: 600; }
.tamount { margin-left: auto; font-family: 'Space Grotesk'; font-weight: 700; font-size: 16px; }
.transfer-hint { color: var(--muted); font-size: 13px; margin-top: 12px; }
.cut-form { margin-top: 16px; }

/* ===== Filtros ===== */
.filters {
  display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap;
  margin-bottom: 16px; padding-bottom: 16px; border-bottom: 1px solid var(--line);
}
.filters label { flex: 1; min-width: 140px; }
.filters .btn { flex: 0 0 auto; }

/* ===== Expense list ===== */
.expense-list { display: flex; flex-direction: column; gap: 10px; }
.ex-owner { font-size: 14px; opacity: .5; padding: 4px; }
.expense-row {
  display: flex; align-items: center; gap: 13px;
  background: var(--glass-2); border: 1px solid var(--line);
  border-radius: 14px; padding: 12px 14px; transition: border-color .15s;
}
.expense-row:hover { border-color: rgba(124,92,255,.4); }
.ex-cat {
  flex: 0 0 42px; height: 42px; display: grid; place-items: center;
  font-size: 20px; border-radius: 12px;
  background: color-mix(in srgb, var(--cat) 18%, transparent);
  border: 1px solid color-mix(in srgb, var(--cat) 40%, transparent);
}
.ex-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.ex-desc { font-weight: 600; font-size: 15px; }
.ex-meta { font-size: 12.5px; color: var(--muted); }
.ex-parts { font-size: 12px; color: var(--violet-2); }
.ex-note { font-size: 12.5px; color: var(--muted); font-style: italic; }
.ex-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.ex-amount { font-family: 'Space Grotesk'; font-weight: 700; font-size: 16px; }
.ex-actions { display: flex; gap: 4px; }
.icon-btn {
  background: transparent; border: 1px solid var(--line); color: var(--muted);
  width: 30px; height: 30px; border-radius: 9px; cursor: pointer; font-size: 14px;
  display: grid; place-items: center; transition: all .15s;
}
.icon-btn:hover { color: var(--text); border-color: var(--violet); background: var(--glass); }
.icon-btn.danger:hover { color: var(--coral); border-color: var(--coral); }

/* ===== Botones ===== */
.btn {
  font-family: 'Inter'; font-size: 14px; font-weight: 600; cursor: pointer;
  border-radius: 12px; padding: 11px 18px; border: 1px solid transparent;
  transition: transform .12s, box-shadow .15s, background .15s; white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(135deg, var(--violet), var(--cyan));
  color: #0a0a14; box-shadow: 0 8px 24px rgba(124,92,255,.35);
}
.btn-primary:hover { box-shadow: 0 10px 30px rgba(124,92,255,.5); }
.btn-ghost { background: var(--glass-2); border-color: var(--line); color: var(--text); text-decoration: none; display: inline-block; }
.btn-ghost:hover { border-color: var(--violet); }
.btn-ghost.sm { padding: 7px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-cut {
  width: 100%; background: rgba(255,107,107,.12); border: 1px solid rgba(255,107,107,.4);
  color: var(--coral);
}
.btn-cut:hover:not(:disabled) { background: rgba(255,107,107,.2); }
.btn:disabled { opacity: .4; cursor: not-allowed; }

/* ===== Auth ===== */
.auth-page { display: grid; place-items: center; }
.auth-page .wrap { display: grid; place-items: center; min-height: 100vh; width: 100%; }
.auth-card { width: 100%; max-width: 400px; padding: 34px 28px;
  background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(12px);
  border-radius: 22px; box-shadow: var(--shadow); }
.auth-head { text-align: center; margin-bottom: 24px; }
.auth-head h1 { font-size: 24px; margin-top: 8px; }
.auth-sub { color: var(--muted); font-size: 14px; margin-top: 4px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-alt { text-align: center; margin-top: 18px; font-size: 14px; color: var(--muted); }
.auth-alt a { color: var(--violet-2); text-decoration: none; font-weight: 600; }

/* ===== Formularios ===== */
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 500; }
.opt { color: var(--muted); font-weight: 400; }
input, select, textarea {
  font-family: 'Inter'; font-size: 15px; color: var(--text);
  background: rgba(0,0,0,.28); border: 1px solid var(--line);
  border-radius: 11px; padding: 12px 14px; width: 100%; transition: border-color .15s;
  line-height: 1.35;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--violet); }
textarea { resize: vertical; }

/* Selects al mismo tamaño que los inputs de texto, con flecha propia */
select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  padding-right: 40px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%239aa0b4' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
}
select option { background: var(--bg-2); color: var(--text); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Campo de contraseña con ojo para mostrar/ocultar */
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 46px; }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px; display: grid; place-items: center;
  background: transparent; border: none; cursor: pointer; font-size: 16px;
  color: var(--muted); border-radius: 9px; padding: 0; transition: color .15s, background .15s;
}
.pw-toggle:hover { color: var(--text); background: var(--glass-2); }

/* Participants chips */
.participants { border: none; }
.participants legend { font-size: 13px; color: var(--muted); font-weight: 500; margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.chip span {
  display: block; padding: 8px 14px; border-radius: 20px; font-size: 14px;
  background: var(--glass-2); border: 1px solid var(--line); color: var(--muted); transition: all .15s;
}
.chip input:checked + span {
  background: linear-gradient(135deg, rgba(124,92,255,.3), rgba(92,200,255,.25));
  border-color: var(--violet); color: var(--text);
}
.hint { font-size: 12px; color: var(--muted); margin-top: 8px; display: block; }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100; display: none;
  background: rgba(5,5,12,.7); backdrop-filter: blur(4px);
  padding: 18px; overflow-y: auto;
}
.modal-overlay.open { display: grid; place-items: center; }
.modal { width: 100%; max-width: 480px; padding: 24px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal-head h2 { font-size: 19px; }
.modal-form { display: flex; flex-direction: column; gap: 15px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px; }

/* ===== Historial ===== */
.settlement-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.settlement-date { display: block; font-family: 'Space Grotesk'; font-weight: 600; font-size: 16px; }
.settlement-total { display: block; font-size: 13px; color: var(--muted); margin-top: 2px; }
.settlement-dl { display: flex; gap: 8px; }
.settlement-meta { display: block; font-size: 12px; color: var(--muted); margin-top: 12px; }

/* ============================================================
   Responsive — móvil primero (regla de Abraham: 1 columna)
   ============================================================ */
@media (max-width: 720px) {
  .kpis { grid-template-columns: 1fr; }
  .charts { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .dash-head { flex-direction: column; align-items: stretch; }
  .dash-head .btn { width: 100%; }
  .page-title { font-size: 21px; }
  .nav-user { display: none; }
  .settlement-head { flex-direction: column; }
  .chart-box { height: 220px; }
  .filters { flex-direction: column; align-items: stretch; }
  .filters label { min-width: 0; }
  .filters .btn { width: 100%; }
}
