@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@500&display=swap');

:root {
  --bg: #f8f9fc;
  --surface: #ffffff;
  --surface-2: #f2f4f8;
  --line: #ebedf3;
  --text: #1a1d29;
  --text-muted: #8b93a7;
  --accent: #ec4899;
  --accent-hover: #db2777;
  --accent-soft: #fce7f3;
  --ok: #16a34a;
  --ok-soft: #dcfce7;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --err: #dc2626;
  --err-soft: #fee2e2;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16,24,40,0.04), 0 2px 8px rgba(16,24,40,0.05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 14.5px;
  line-height: 1.5;
}

h1, h2, h3, .display {
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  margin: 0;
  color: var(--text);
}

.mono { font-family: 'JetBrains Mono', monospace; }

a { color: inherit; }

/* --- Layout general --- */
.app-shell { display: flex; min-height: 100vh; }

.rail {
  width: 232px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 22px 14px;
}

.rail-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 24px;
}

.rail-logo {
  width: 38px; height: 38px;
  border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
  font-size: 14px;
  color: #fff;
  background: var(--accent);
  flex-shrink: 0;
}

.rail-brand-text { font-weight: 700; font-size: 14.5px; color: var(--text); line-height: 1.25; }
.rail-brand-text span { display: block; font-weight: 500; font-size: 11.5px; color: var(--text-muted); }

.rail-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.rail-link {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px;
  border-radius: 9px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: 0.12s ease;
}
.rail-link svg { width: 18px; height: 18px; flex-shrink: 0; }
.rail-link:hover { background: var(--surface-2); color: var(--text); }
.rail-link.active { background: var(--accent-soft); color: var(--accent-hover); font-weight: 600; }

.rail-bottom {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
  padding: 14px 10px 4px;
}
.rail-user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-hover);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12.5px; flex-shrink: 0;
}
.rail-user-info { flex: 1; min-width: 0; }
.rail-user-info .name { font-weight: 600; font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail-user-info .role { font-size: 11.5px; color: var(--text-muted); }
.rail-logout-btn {
  width: 30px; height: 30px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); background: none; border: none; cursor: pointer;
  flex-shrink: 0;
}
.rail-logout-btn:hover { background: var(--surface-2); color: var(--err); }
.rail-logout-btn svg { width: 17px; height: 17px; }

.main { flex: 1; padding: 32px 40px; max-width: 1600px; }

.page-header {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 28px;
  flex-wrap: wrap; gap: 12px;
}

.page-header h1 { font-size: 24px; }
.page-header .eyebrow {
  display: block; color: var(--accent); font-size: 11px; letter-spacing: 0.1em;
  font-weight: 700; margin-bottom: 6px; text-transform: uppercase;
}
.page-subtitle { color: var(--text-muted); font-size: 13.5px; margin: 4px 0 0; }

/* --- Componentes --- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-2 { grid-template-columns: 1fr 1fr; }

@media (max-width: 1000px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}

.stat-card { position: relative; overflow: hidden; }
.stat-card .value { font-family: 'JetBrains Mono', monospace; font-size: 28px; font-weight: 500; }
.stat-card .label { color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; margin-top: 4px; }
.stat-card::after {
  content: ''; position: absolute; right: -10px; top: -10px; width: 60px; height: 60px;
  border-radius: 50%; background: var(--accent-soft);
}

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); }
td { padding: 12px; border-bottom: 1px solid var(--line); font-size: 13.5px; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface-2); }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent); color: #fff; border: none;
  padding: 10px 18px; border-radius: 9px; font-weight: 600; font-size: 13.5px;
  cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--accent-hover); }
.btn.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: transparent; color: var(--err); border: 1px solid var(--err); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

input, select, textarea {
  width: 100%; background: var(--surface); border: 1px solid var(--line); color: var(--text);
  padding: 10px 12px; border-radius: 8px; font-family: inherit; font-size: 13.5px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 6px; font-weight: 500; }
.field { margin-bottom: 16px; }

.badge {
  display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11px;
  font-weight: 600;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.err { background: var(--err-soft); color: var(--err); }
.badge.neutral { background: var(--surface-2); color: var(--text-muted); }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state h3 { color: var(--text); margin-bottom: 8px; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(17,20,29,0.45); display: none;
  align-items: center; justify-content: center; z-index: 50;
}
.modal-backdrop.open { display: flex; }
.modal { background: var(--surface); border-radius: var(--radius); box-shadow: 0 8px 30px rgba(16,24,40,0.18);
  padding: 28px; width: 480px; max-width: 92vw; max-height: 86vh; overflow-y: auto; }
.modal h2 { font-size: 18px; margin-bottom: 20px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

.toast {
  position: fixed; bottom: 24px; right: 24px; background: var(--text);
  color: #fff;
  padding: 12px 18px; border-radius: 9px; font-size: 13px; z-index: 100;
  opacity: 0; transform: translateY(8px); transition: 0.2s ease;
  box-shadow: 0 8px 24px rgba(16,24,40,0.2);
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--err); }

.login-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 30% 20%, rgba(236,72,153,0.08), transparent 45%), var(--bg);
}
.login-card { width: 340px; }
.login-card .rail-logo { margin: 0 auto 20px; width: 48px; height: 48px; font-size: 18px; }

/* --- Dashboard --- */
.metric-card {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
}
.metric-icon {
  width: 42px; height: 42px; border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.metric-icon svg { width: 20px; height: 20px; }
.metric-icon.blue { background: #dbeafe; color: #2563eb; }
.metric-icon.green { background: #d1fae5; color: #059669; }
.metric-icon.amber { background: #fef3c7; color: #d97706; }
.metric-icon.orange { background: #ffedd5; color: #ea580c; }
.metric-icon.purple { background: #ede9fe; color: #7c3aed; }
.metric-icon.cyan { background: #cffafe; color: #0891b2; }

.metric-label { font-size: 12.5px; color: var(--text-muted); font-weight: 500; margin-bottom: 6px; }
.metric-value { font-size: 24px; font-weight: 700; color: var(--text); }
.metric-trend { font-size: 12px; margin-top: 6px; font-weight: 600; }
.metric-trend.up { color: var(--ok); }
.metric-trend.down { color: var(--err); }
.metric-trend span { color: var(--text-muted); font-weight: 500; }

.quick-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 24px; }
@media (max-width: 1000px) { .quick-actions { grid-template-columns: repeat(2, 1fr); } }

.quick-action-btn {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px; cursor: pointer; text-decoration: none; color: var(--text);
  font-weight: 600; font-size: 13.5px;
  transition: 0.12s ease;
}
.quick-action-btn:hover { border-color: var(--accent); transform: translateY(-1px); }
.quick-action-btn .qa-icon {
  width: 34px; height: 34px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.quick-action-btn .qa-icon svg { width: 17px; height: 17px; }

.chart-card-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 18px; }
.chart-card-header h2 { font-size: 15px; margin-bottom: 3px; }
.chart-card-header p { margin: 0; font-size: 12.5px; color: var(--text-muted); }

.chart-tabs { display: flex; gap: 4px; background: var(--surface-2); border-radius: 8px; padding: 3px; }
.chart-tab {
  border: none; background: none; padding: 6px 12px; border-radius: 6px;
  font-size: 12px; font-weight: 600; color: var(--text-muted); cursor: pointer;
}
.chart-tab.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(16,24,40,0.08); }

.donut-legend { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.donut-legend-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.donut-legend-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.donut-legend-row .name { flex: 1; color: var(--text); }
.donut-legend-row .amount { font-weight: 600; }
.donut-legend-row .pct { color: var(--text-muted); font-size: 12px; width: 38px; text-align: right; }

.dashboard-charts { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-bottom: 24px; }
@media (max-width: 1000px) { .dashboard-charts { grid-template-columns: 1fr; } }

.donut-wrap { position: relative; }
.donut-center { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); text-align: center; pointer-events: none; }
.donut-center .total-value { font-size: 19px; font-weight: 700; color: var(--text); }
.donut-center .total-label { font-size: 11px; color: var(--text-muted); }