:root {
  --bg: #080c14;
  --bg2: #0d1421;
  --bg3: #111827;
  --bg4: #1a2233;
  --border: #1e293b;
  --border2: #2d3748;
  --accent: #0ea5e9;
  --accent2: #38bdf8;
  --accent-dim: rgba(14,165,233,0.12);
  --accent-glow: rgba(14,165,233,0.25);
  --text: #e2e8f0;
  --text2: #94a3b8;
  --muted: #64748b;
  --success: #22c55e;
  --danger: #ef4444;
  --amber: #f59e0b;
  --purple: #a78bfa;
  --teal: #14b8a6;
  --sidebar-w: 240px;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
  --transition: 0.18s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body { background: var(--bg); color: var(--text); font-family: 'Inter', system-ui, -apple-system, sans-serif; min-height: 100vh; line-height: 1.6; }
a { color: var(--accent); text-decoration: none; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ── Layout ── */
#layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  overflow-y: auto;
}
.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo-icon {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--accent), #0369a1);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px;
  box-shadow: 0 0 14px var(--accent-glow);
}
.sidebar-logo-text { font-size: 0.92rem; font-weight: 700; color: var(--text); letter-spacing: 0.02em; line-height: 1.2; }
.sidebar-logo-sub { font-size: 0.68rem; color: var(--muted); font-weight: 400; }

.sidebar-section-label {
  font-size: 0.62rem; font-weight: 700; color: var(--muted); letter-spacing: 0.1em;
  text-transform: uppercase; padding: 16px 18px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 18px; margin: 1px 8px;
  border-radius: var(--radius-sm);
  color: var(--text2); font-size: 0.84rem;
  cursor: pointer; transition: background var(--transition), color var(--transition);
  text-decoration: none;
}
.nav-item:hover { background: var(--bg4); color: var(--text); }
.nav-item.active { background: var(--accent-dim); color: var(--accent); font-weight: 600; }
.nav-item .nav-icon { width: 18px; text-align: center; font-size: 1rem; }

.sidebar-bottom {
  margin-top: auto; padding: 12px 8px;
  border-top: 1px solid var(--border);
}

/* ── Main content ── */
.main { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 58px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(8px);
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-title { font-size: 1.05rem; font-weight: 700; }
.topbar-sub { font-size: 0.78rem; color: var(--text2); }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.page-content { padding: 24px; flex: 1; }

/* ── Cards ── */
.card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  transition: border-color var(--transition);
}
.card:hover { border-color: var(--border2); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.card-title { font-size: 0.78rem; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: 0.06em; }
.card-icon { font-size: 1.1rem; opacity: 0.6; }

.stat-value { font-size: 1.8rem; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; }
.stat-value-sm { font-size: 1.3rem; font-weight: 700; }
.stat-sub { font-size: 0.75rem; color: var(--text2); margin-top: 4px; }
.stat-accent { color: var(--accent); }
.stat-success { color: var(--success); }
.stat-danger { color: var(--danger); }
.stat-purple { color: var(--purple); }

/* ── Grids ── */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 700px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } .sidebar { display: none; } .main { margin-left: 0; } }

/* ── Tables ── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
thead tr { background: var(--bg4); border-bottom: 1px solid var(--border2); }
th { padding: 10px 14px; text-align: left; font-size: 0.72rem; font-weight: 700; color: var(--text2); text-transform: uppercase; letter-spacing: 0.06em; white-space: nowrap; }
td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr { transition: background var(--transition); }
tbody tr:hover { background: var(--bg4); }
tbody tr:last-child td { border-bottom: none; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 15px; border-radius: var(--radius-sm);
  font-size: 0.83rem; font-weight: 600;
  border: none; cursor: pointer; transition: all var(--transition); white-space: nowrap;
  text-decoration: none;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent2); box-shadow: 0 0 16px var(--accent-glow); }
.btn-secondary { background: var(--bg4); color: var(--text); border: 1px solid var(--border2); }
.btn-secondary:hover { background: var(--border2); }
.btn-success { background: rgba(34,197,94,0.15); color: var(--success); border: 1px solid rgba(34,197,94,0.3); }
.btn-success:hover { background: rgba(34,197,94,0.25); }
.btn-danger { background: rgba(239,68,68,0.12); color: var(--danger); border: 1px solid rgba(239,68,68,0.25); }
.btn-danger:hover { background: rgba(239,68,68,0.22); }
.btn-purple { background: rgba(167,139,250,0.12); color: var(--purple); border: 1px solid rgba(167,139,250,0.25); }
.btn-xs { padding: 4px 10px; font-size: 0.76rem; }
.btn-sm { padding: 5px 12px; font-size: 0.8rem; }
.btn-block { display: flex; width: 100%; }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 20px;
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.03em; white-space: nowrap;
}
.badge-accent { background: var(--accent-dim); color: var(--accent); }
.badge-success { background: rgba(34,197,94,0.12); color: var(--success); }
.badge-danger { background: rgba(239,68,68,0.12); color: var(--danger); }
.badge-amber { background: rgba(245,158,11,0.12); color: var(--amber); }
.badge-purple { background: rgba(167,139,250,0.12); color: var(--purple); }
.badge-muted { background: var(--bg4); color: var(--text2); }

/* ── Forms ── */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 0.78rem; font-weight: 600; color: var(--text2); margin-bottom: 5px; }
.form-control {
  width: 100%; background: var(--bg4);
  border: 1px solid var(--border2); border-radius: var(--radius-sm);
  color: var(--text); padding: 8px 12px; font-size: 0.85rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
textarea.form-control { resize: vertical; min-height: 70px; }
select.form-control option { background: var(--bg4); }

/* ── Modals ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  display: none; align-items: center; justify-content: center;
  z-index: 999; padding: 16px;
  backdrop-filter: blur(2px);
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 14px;
  width: 100%; max-width: 520px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-md);
  animation: slideUp 0.18s ease;
}
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 0;
}
.modal-title { font-size: 1rem; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 1.1rem; padding: 4px 6px; border-radius: 4px; }
.modal-close:hover { color: var(--text); background: var(--bg4); }
.modal-body { padding: 16px 20px 20px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding-top: 8px; }

/* ── Tabs ── */
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--bg4); border-radius: var(--radius-sm); margin-bottom: 16px; width: fit-content; }
.tab-btn {
  padding: 6px 16px; border-radius: 6px; border: none; background: transparent;
  color: var(--text2); font-size: 0.8rem; font-weight: 600; cursor: pointer;
  transition: all var(--transition);
}
.tab-btn.active { background: var(--bg2); color: var(--accent); box-shadow: var(--shadow); }
.tab-btn:hover:not(.active) { color: var(--text); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Calendar ── */
.cal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.cal-title { font-size: 1rem; font-weight: 700; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-day-name { text-align: center; font-size: 0.7rem; font-weight: 700; color: var(--muted); padding: 6px 0; text-transform: uppercase; }
.cal-day {
  aspect-ratio: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  padding: 4px 3px; border-radius: 8px;
  font-size: 0.8rem; cursor: pointer; position: relative;
  transition: background var(--transition);
  min-height: 44px;
}
.cal-day:hover { background: var(--bg4); }
.cal-day.today { background: var(--accent-dim); color: var(--accent); font-weight: 800; }
.cal-day.today .cal-day-num { background: var(--accent); color: #fff; border-radius: 50%; width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; font-size: 0.78rem; }
.cal-day.other-month { opacity: 0.3; }
.cal-day.has-events .cal-day-num { position: relative; }
.cal-event-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); margin: 1px auto 0; }
.cal-event-dot.dot-purple { background: var(--purple); }
.cal-events-preview { width: 100%; }
.cal-event-pill {
  font-size: 0.58rem; padding: 1px 4px; border-radius: 3px;
  background: var(--accent-dim); color: var(--accent);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-top: 2px; display: block;
}

/* ── Toast ── */
.toast-container { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 9999; }
.toast {
  background: var(--bg4); border: 1px solid var(--border2);
  border-radius: var(--radius-sm); padding: 10px 16px;
  font-size: 0.84rem; box-shadow: var(--shadow-md);
  display: flex; align-items: center; gap: 8px;
  animation: slideIn 0.2s ease; max-width: 320px;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--accent); }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* ── Empty state ── */
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-state-icon { font-size: 2.5rem; margin-bottom: 10px; opacity: 0.4; }

/* ── Utility ── */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.font-bold { font-weight: 700; }
.text-muted { color: var(--text2); }
.text-sm { font-size: 0.82rem; }
.text-xs { font-size: 0.72rem; }
.text-accent { color: var(--accent); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-amber { color: var(--amber); }
.text-right { text-align: right; }
.w-full { width: 100%; }

/* ── Priority colors ── */
.prio-alta { border-left: 3px solid var(--danger) !important; }
.prio-media { border-left: 3px solid var(--amber) !important; }
.prio-baja { border-left: 3px solid var(--success) !important; }

/* ── Finance ── */
.saldo-positivo { color: var(--success); font-weight: 700; }
.saldo-negativo { color: var(--danger); font-weight: 700; }
.mov-ingreso { color: var(--success); }
.mov-egreso { color: var(--danger); }
.mov-transferencia { color: var(--accent); }

/* ── Login page ── */
.login-container {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at top, rgba(14,165,233,0.07) 0%, transparent 60%), var(--bg);
}
.login-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 36px 32px;
  width: 100%; max-width: 360px;
  box-shadow: 0 0 60px rgba(14,165,233,0.06);
}
.login-logo { text-align: center; margin-bottom: 24px; }
.login-logo-icon {
  width: 54px; height: 54px; border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), #0369a1);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 10px; font-size: 24px;
  box-shadow: 0 0 30px var(--accent-glow);
}
.login-logo h1 { font-size: 1.2rem; font-weight: 800; }
.login-logo p { color: var(--text2); font-size: 0.8rem; margin-top: 2px; }
