/* ─── TOKENS ─────────────────────────────────────────────────────────────── */
:root {
  --bg: #0F0E0D;
  --bg2: #1A1917;
  --bg3: #242220;
  --bg4: #2E2B28;
  --border: #333230;
  --border2: #3D3A36;
  --text: #E8E6E3;
  --text2: #A19F9D;
  --text3: #605E5C;
  --accent: #F2C811;
  --accent2: #E8A838;
  --green: #4EC994;
  --red: #E8534A;
  --blue: #5B8FF9;
  --sidebar-w: 220px;
  --radius: 8px;
  --font-display: 'Syne', sans-serif;
  --font-mono: 'DM Mono', monospace;
}

/* ─── RESET ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: var(--font-mono);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: var(--font-mono); }
input, select, textarea {
  font-family: var(--font-mono);
  font-size: 14px;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 10px 14px;
  width: 100%;
  transition: border-color .2s;
  outline: none;
}
input:focus, select:focus { border-color: var(--accent); }
input::placeholder { color: var(--text3); }
select option { background: var(--bg3); }

/* ─── SIDEBAR ────────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed; top: 0; left: 0;
  width: var(--sidebar-w); height: 100vh;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 100;
  padding: 24px 0;
}
.sidebar-logo {
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px 24px;
  border-bottom: 1px solid var(--border);
}
.logo-mark {
  width: 36px; height: 36px;
  background: var(--accent);
  color: #000;
  font-family: var(--font-display);
  font-weight: 800; font-size: 20px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px;
  flex-shrink: 0;
}
.logo-text { display: flex; flex-direction: column; line-height: 1.2; }
.logo-main { font-family: var(--font-display); font-weight: 700; font-size: 15px; }
.logo-sub { font-size: 11px; color: var(--accent); letter-spacing: .05em; }

.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--bg4); border: 1px solid var(--border2);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; color: var(--accent);
}
.user-info { display: flex; flex-direction: column; }
.user-name { font-size: 13px; font-weight: 600; }
.user-role { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.user-role.admin { color: var(--accent); }
.user-role.viewer { color: var(--text3); }

.nav-links { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 6px;
  font-size: 13px; color: var(--text2);
  transition: background .15s, color .15s;
}
.nav-link svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-link:hover { background: var(--bg3); color: var(--text); }
.nav-link.active { background: var(--accent); color: #000; font-weight: 600; }
.nav-link.active svg { stroke: #000; }

.nav-logout {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 24px;
  font-size: 12px; color: var(--text3);
  border-top: 1px solid var(--border);
  transition: color .15s;
}
.nav-logout svg { width: 14px; height: 14px; }
.nav-logout:hover { color: var(--red); }

/* ─── MAIN ───────────────────────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  padding: 40px;
  max-width: 1400px;
}

/* ─── PAGE HEADER ────────────────────────────────────────────────────────── */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 36px; gap: 20px;
}
.page-title {
  font-family: var(--font-display); font-size: 28px; font-weight: 700;
  line-height: 1.2; margin-bottom: 4px;
}
.page-title span { color: var(--accent); }
.page-sub { font-size: 13px; color: var(--text2); }
.back-link { font-size: 12px; color: var(--text3); display: block; margin-bottom: 8px; }
.back-link:hover { color: var(--accent); }

/* ─── BUTTONS ────────────────────────────────────────────────────────────── */
.btn-primary {
  background: var(--accent); color: #000;
  font-family: var(--font-mono); font-size: 13px; font-weight: 600;
  padding: 10px 20px; border: none; border-radius: var(--radius);
  transition: background .15s, transform .1s;
  white-space: nowrap; display: inline-block;
}
.btn-primary:hover { background: var(--accent2); transform: translateY(-1px); }
.btn-full { width: 100%; text-align: center; }
.btn-outline {
  background: transparent; color: var(--text2);
  border: 1px solid var(--border2);
  font-size: 12px; padding: 7px 14px; border-radius: var(--radius);
  transition: border-color .15s, color .15s;
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-view {
  font-size: 12px; color: var(--accent);
  padding: 6px 12px; border: 1px solid var(--accent);
  border-radius: 4px; transition: background .15s;
}
.btn-view:hover { background: var(--accent); color: #000; }
.btn-delete {
  background: none; border: none;
  font-size: 16px; padding: 4px 8px;
  border-radius: 4px; color: var(--text3);
  transition: color .15s;
}
.btn-delete:hover { color: var(--red); }
.btn-delete-sm {
  background: none; border: 1px solid var(--border);
  color: var(--text3); font-size: 11px;
  padding: 4px 10px; border-radius: 4px;
  transition: border-color .15s, color .15s;
}
.btn-delete-sm:hover { border-color: var(--red); color: var(--red); }

/* ─── FLASH MESSAGES ─────────────────────────────────────────────────────── */
.flash-container { margin-bottom: 20px; }
.flash {
  padding: 12px 16px; border-radius: var(--radius);
  font-size: 13px; margin-bottom: 8px;
  border-left: 3px solid;
}
.flash-success { background: #4EC99420; border-color: var(--green); color: var(--green); }
.flash-error { background: #E8534A20; border-color: var(--red); color: var(--red); }

/* ─── STATS ROW ──────────────────────────────────────────────────────────── */
.stats-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px; margin-bottom: 40px;
}
.stat-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
}
.stat-num {
  font-family: var(--font-display); font-size: 28px; font-weight: 700;
  color: var(--accent); line-height: 1;
}
.stat-label { font-size: 11px; color: var(--text3); margin-top: 6px; text-transform: uppercase; letter-spacing: .06em; }

/* ─── SECTION HEADER ─────────────────────────────────────────────────────── */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.section-header h2 { font-family: var(--font-display); font-size: 18px; font-weight: 700; }
.section-count { font-size: 11px; color: var(--text3); }

/* ─── DATASET GRID ───────────────────────────────────────────────────────── */
.datasets-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.dataset-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  display: flex; flex-direction: column; gap: 10px;
  transition: border-color .2s, transform .15s;
}
.dataset-card:hover { border-color: var(--border2); transform: translateY(-2px); }
.dataset-top { display: flex; align-items: flex-start; justify-content: space-between; }
.dataset-icon { font-size: 24px; }
.dataset-area-badge {
  font-size: 10px; font-weight: 600; padding: 2px 8px;
  border-radius: 99px; text-transform: uppercase; letter-spacing: .06em;
  background: var(--bg4); color: var(--text3);
}
.dataset-area-badge.ventas { background: #F2C81120; color: var(--accent); }
.dataset-area-badge.finanzas { background: #5B8FF920; color: var(--blue); }
.dataset-area-badge.rrhh { background: #4EC99420; color: var(--green); }
.dataset-area-badge.operaciones { background: #E8534A20; color: var(--red); }
.dataset-name { font-family: var(--font-display); font-size: 15px; font-weight: 700; }
.dataset-meta { font-size: 11px; color: var(--text3); display: flex; justify-content: space-between; }
.dataset-uploader { font-size: 11px; color: var(--text3); }
.dataset-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 4px; }

/* ─── EMPTY STATE ────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 60px 20px;
  border: 1px dashed var(--border); border-radius: var(--radius);
  color: var(--text2);
}
.empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h3 { font-family: var(--font-display); font-size: 18px; margin-bottom: 8px; }
.empty-state p { font-size: 13px; color: var(--text3); margin-bottom: 20px; }

/* ─── KPI STRIP ──────────────────────────────────────────────────────────── */
.kpi-strip {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px; margin-bottom: 36px;
}
.kpi-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-top: 2px solid var(--accent);
  border-radius: var(--radius); padding: 16px;
}
.kpi-label { font-size: 11px; color: var(--text3); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px; }
.kpi-value { font-family: var(--font-display); font-size: 24px; font-weight: 700; color: var(--text); line-height: 1; }
.kpi-sub { font-size: 10px; color: var(--text3); margin-top: 6px; }

/* ─── CHART BUILDER ──────────────────────────────────────────────────────── */
.chart-builder-bar {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  margin-bottom: 36px;
}
.chart-builder-bar h3 { font-family: var(--font-display); font-size: 15px; margin-bottom: 16px; }
.builder-controls { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.builder-controls select { max-width: 200px; width: auto; }
.builder-controls .btn-primary { padding: 10px 16px; }

/* ─── CHARTS GRID ────────────────────────────────────────────────────────── */
.charts-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 20px; margin-bottom: 36px;
}
.chart-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
}
.chart-card.cascade { border-color: var(--accent); border-top: 2px solid var(--accent); }
.chart-title { font-size: 13px; font-weight: 600; color: var(--text2); margin-bottom: 16px; }
.chart-canvas-wrap { position: relative; height: 280px; }

/* ─── DATA TABLE ─────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.data-table {
  width: 100%; border-collapse: collapse;
  font-size: 12px; white-space: nowrap;
}
.data-table th {
  background: var(--bg3); color: var(--text3);
  padding: 10px 14px; text-align: left;
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
}
.data-table td {
  padding: 9px 14px; border-bottom: 1px solid var(--border);
  color: var(--text2);
}
.data-table tr:hover td { background: var(--bg3); }

/* ─── USERS TABLE ────────────────────────────────────────────────────────── */
.users-table-wrap { overflow-x: auto; }
.users-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.users-table th {
  background: var(--bg3); color: var(--text3); padding: 10px 16px;
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  border-bottom: 1px solid var(--border);
}
.users-table td { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.role-badge {
  font-size: 10px; font-weight: 600; padding: 2px 8px;
  border-radius: 99px; text-transform: uppercase;
}
.role-badge.admin { background: #F2C81130; color: var(--accent); }
.role-badge.viewer { background: var(--bg4); color: var(--text3); }

/* ─── LOGIN ──────────────────────────────────────────────────────────────── */
.login-page { display: flex; min-height: 100vh; }
.login-left {
  flex: 1; background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  justify-content: center; padding: 60px;
}
.login-logo-mark {
  width: 56px; height: 56px;
  background: var(--accent); color: #000;
  font-family: var(--font-display); font-weight: 800; font-size: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px; margin-bottom: 24px;
}
.login-title {
  font-family: var(--font-display); font-size: 42px; font-weight: 800;
  line-height: 1.1; margin-bottom: 16px;
}
.login-title span { color: var(--accent); }
.login-tagline { font-size: 15px; color: var(--text2); max-width: 360px; line-height: 1.6; }
.login-features { margin-top: 48px; display: flex; flex-direction: column; gap: 12px; }
.lf-item { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--text2); }
.lf-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }

.login-right {
  width: 440px; display: flex;
  align-items: center; justify-content: center;
  padding: 40px;
}
.login-card { width: 100%; }
.login-card h2 { font-family: var(--font-display); font-size: 24px; font-weight: 700; margin-bottom: 6px; }
.login-sub { font-size: 13px; color: var(--text3); margin-bottom: 28px; }
.login-form { display: flex; flex-direction: column; gap: 16px; }
.login-hint {
  margin-top: 20px; padding: 12px 16px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 12px; color: var(--text3);
}

/* ─── FORM PAGE ──────────────────────────────────────────────────────────── */
.form-page { display: grid; grid-template-columns: 1fr 320px; gap: 32px; align-items: start; }
.form-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px;
}
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 12px; color: var(--text3); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px; }
.file-drop {
  border: 2px dashed var(--border2); border-radius: var(--radius);
  padding: 40px 20px; text-align: center; cursor: pointer;
  transition: border-color .2s;
}
.file-drop:hover, .file-drop.dragover { border-color: var(--accent); }
.file-drop.has-file { border-color: var(--green); border-style: solid; }
.file-drop-icon { font-size: 32px; margin-bottom: 12px; }
.file-drop-text { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.file-drop-sub { font-size: 12px; color: var(--text3); }
.file-name-display { margin-top: 10px; font-size: 13px; color: var(--green); }
.upload-tips {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px;
}
.upload-tips h3 { font-family: var(--font-display); font-size: 15px; margin-bottom: 14px; }
.upload-tips ul { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.upload-tips li { font-size: 13px; color: var(--text2); padding-left: 16px; position: relative; }
.upload-tips li::before { content: '→'; position: absolute; left: 0; color: var(--accent); }

/* ─── ADMIN LAYOUT ───────────────────────────────────────────────────────── */
.admin-layout { display: grid; grid-template-columns: 360px 1fr; gap: 32px; align-items: start; }
.admin-form-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px;
}
.admin-form-card h3, .admin-users-list h3 {
  font-family: var(--font-display); font-size: 16px; margin-bottom: 20px;
}
.admin-users-list { overflow-x: auto; }

/* ─── RESPONSIVE ─────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .main-content { margin-left: 0; padding: 20px; }
  .login-left { display: none; }
  .login-right { width: 100%; }
  .form-page, .admin-layout { grid-template-columns: 1fr; }
  .charts-grid { grid-template-columns: 1fr; }
}
