/* ── Reset & Variables ────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:           #0f0f13;
  --bg-surface:   #1a1a22;
  --bg-card:      #22222e;
  --border:       #2e2e3e;
  --accent:       #7c6af7;
  --accent-hover: #9b8cf9;
  --accent-dim:   rgba(124,106,247,.15);
  --text:         #e8e8f0;
  --text-muted:   #7878a0;
  --text-faint:   #444460;
  --green:        #3ecf8e;
  --red:          #f05252;
  --yellow:       #f5a623;
  --sidebar-w:    220px;
  --radius:       8px;
  --font:         'Inter', system-ui, sans-serif;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  height: 100vh;
  overflow: hidden;
}

.hidden { display: none !important; }

/* ── Login ───────────────────────────────────────────────────────────────── */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: var(--bg);
}

.login-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 360px;
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 28px;
}

.logo-mark { color: var(--accent); font-size: 20px; }
.logo-text  { font-size: 20px; font-weight: 700; letter-spacing: -.5px; }

.login-card h2 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 24px;
  color: var(--text);
}

.login-card form { display: flex; flex-direction: column; gap: 16px; }

.login-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.login-card input {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
}

.login-card input:focus { border-color: var(--accent); }

.login-card button[type=submit] {
  margin-top: 4px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 11px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}

.login-card button[type=submit]:hover  { background: var(--accent-hover); }
.login-card button[type=submit]:active { opacity: .85; }

.error-msg { color: var(--red); font-size: 13px; text-align: center; }

/* ── App layout ──────────────────────────────────────────────────────────── */
.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.nav-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  text-align: left;
  padding: 8px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  transition: background .12s, color .12s;
}

.nav-btn:hover  { background: var(--bg-card); color: var(--text); }
.nav-btn.active { background: var(--accent-dim); color: var(--accent); }

.sidebar-footer {
  padding: 12px 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tc-badge {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 8px 10px;
  font-size: 12px;
}

.tc-label { color: var(--text-muted); }
#tc-valor  { font-weight: 700; color: var(--green); }

.currency-toggle {
  display: flex;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 3px;
  gap: 2px;
}

.currency-btn {
  flex: 1;
  border: none;
  background: none;
  color: var(--text-muted);
  border-radius: 6px;
  padding: 5px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s, color .12s;
}

.currency-btn.active {
  background: var(--accent);
  color: #fff;
}

.logout-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius);
  padding: 7px;
  font-size: 12px;
  cursor: pointer;
  transition: border-color .12s, color .12s;
}

.logout-btn:hover { border-color: var(--red); color: var(--red); }

/* Main content */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px;
  background: var(--bg);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Shared components ───────────────────────────────────────────────────── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 24px;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.4px;
}

.page-subtitle { color: var(--text-muted); font-size: 13px; margin-top: 2px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s;
}

.btn:hover    { background: var(--accent-hover); }
.btn-ghost {
  background: none;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-card); color: var(--text); }

/* Cards grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
}

.stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 6px;
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -.5px;
}

/* Table */
.table-wrap {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  text-align: left;
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-card); }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.badge-green  { background: rgba(62,207,142,.15); color: var(--green); }
.badge-yellow { background: rgba(245,166,35,.15);  color: var(--yellow); }
.badge-red    { background: rgba(240,82,82,.15);   color: var(--red); }
.badge-gray   { background: var(--bg-card);         color: var(--text-muted); }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.form-group label { font-size: 12px; font-weight: 600; color: var(--text-muted); }

.form-group input,
.form-group select,
.form-group textarea {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 12px;
  color: var(--text);
  font-size: 13.5px;
  outline: none;
  transition: border-color .12s;
  font-family: var(--font);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--accent); }

.form-group select option { background: var(--bg-card); }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

/* Loading */
.loading {
  display: flex; align-items: center; justify-content: center;
  padding: 48px; color: var(--text-muted); font-size: 13px;
  gap: 10px;
}

.spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Finanzas */
.finanzas-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 28px;
}

.chart-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.chart-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: .4px;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 56px 20px;
  color: var(--text-muted);
}

.empty-state-icon { font-size: 36px; margin-bottom: 12px; }
.empty-state h3   { font-size: 15px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.empty-state p    { font-size: 13px; }

/* Toast */
#toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 999;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 13px;
  animation: slideIn .2s ease;
  max-width: 320px;
}

.toast-success { border-color: var(--green); }
.toast-error   { border-color: var(--red); }

@keyframes slideIn {
  from { transform: translateY(12px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* Scrollbar */
::-webkit-scrollbar       { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
