:root {
  --primary: #0047FF;
  --primary-dark: #0033CC;
  --primary-light: #3B82F6;
  --primary-gradient: linear-gradient(135deg, #3B82F6, #0033CC);
  --sidebar-bg: #07102B;
  --sidebar-hover: #0D1F4A;
  --sidebar-active: #0047FF;
  --surface: #FFFFFF;
  --surface-2: #F5F7FF;
  --surface-3: #EEF2FF;
  --border: #E2E8F0;
  --text: #0F172A;
  --text-secondary: #475569;
  --text-muted: #94A3B8;
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --info: #3B82F6;
  --radius: 4px;
  --radius-sm: 2px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 10px 40px rgba(0,0,0,.1);
  --shadow-lg: 0 20px 60px rgba(0,71,255,.15);
  --transition: .2s cubic-bezier(.4,0,.2,1);
  --chart-1: #0047FF; --chart-2: #10B981; --chart-3: #F59E0B; --chart-4: #EF4444;
  --chart-5: #7C3AED; --chart-6: #0EA5E9; --chart-7: #EC4899; --chart-8: #64748B;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body { font-family: 'Inter', 'Segoe UI', system-ui, sans-serif; background: var(--surface-2); color: var(--text); line-height: 1.5; -webkit-font-smoothing: antialiased; }

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

h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.25rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 20px; border-radius: 4px; font-size: .875rem; font-weight: 600; cursor: pointer; border: none; transition: var(--transition); text-decoration: none; white-space: nowrap; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { filter: brightness(1.1); }
.btn-secondary { background: var(--surface-3); color: var(--primary); }
.btn-secondary:hover { filter: brightness(.96); }
.btn-ghost { background: var(--surface-3); color: var(--text-secondary); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-ghost.btn-icon { background: transparent; border: none; }
.btn-ghost.btn-icon:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.1); }
.btn-sm { padding: 6px 14px; font-size: .8rem; }
.btn-icon { padding: 8px; border-radius: 4px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Inputs ── */
.input-group { display: flex; flex-direction: column; gap: 6px; }
.input-group label { font-size: .8rem; font-weight: 600; color: var(--text-secondary); letter-spacing: .4px; }
.input-hint { font-size: .72rem; color: var(--text-muted); line-height: 1.4; }
.input, textarea.input { padding: 11px 14px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-size: .9rem; color: var(--text); background: var(--surface); transition: var(--transition); outline: none; width: 100%; font-family: inherit; }
.pwd-wrap { position: relative; }
.pwd-wrap .input { padding-right: 42px; }
.pwd-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; border: none; border-radius: var(--radius-sm); background: transparent; color: var(--text-muted); cursor: pointer; transition: var(--transition); }
.pwd-toggle:hover { color: var(--text); background: var(--surface-2); }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,71,255,.1); }
select.input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; cursor: pointer; }
.input-icon-wrap { position: relative; }
.input-icon-wrap:has(.icon:not(.icon-right)) .input { padding-left: 40px; }
.input-icon-wrap .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }

/* ── Cards ── */
.card { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); padding: 20px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; }

/* ── Badge ── */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 99px; font-size: .75rem; font-weight: 600; }
.badge-blue { background: #EEF2FF; color: var(--primary); }
.badge-green { background: #ECFDF5; color: var(--success); }
.badge-yellow { background: #FFFBEB; color: var(--warning); }
.badge-red { background: #FEF2F2; color: var(--danger); }
.badge-gray { background: var(--surface-3); color: var(--text-secondary); }

.avatar { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .8rem; flex-shrink: 0; background: var(--primary-gradient); color: #fff; }
.avatar-sm { width: 28px; height: 28px; font-size: .7rem; }

/* ── App Shell ── */
.app-shell { display: flex; height: 100vh; overflow: hidden; }
.sidebar { width: 240px; flex-shrink: 0; background: var(--sidebar-bg); display: flex; flex-direction: column; overflow: hidden; }
.sidebar-logo { padding: 18px 16px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid rgba(255,255,255,.07); flex-shrink: 0; color: var(--primary-light); }
.sidebar-logo-text { font-size: 1.15rem; font-weight: 800; color: #fff; white-space: nowrap; overflow: hidden; }
.sidebar-logo-text span { color: var(--primary-light); }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 8px; }
.nav-section { margin-bottom: 4px; }
.nav-section-label { padding: 8px 10px 4px; font-size: .65rem; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase; color: rgba(255,255,255,.3); white-space: nowrap; overflow: hidden; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius-sm); color: rgba(255,255,255,.6); text-decoration: none; font-size: .8125rem; font-weight: 500; cursor: pointer; transition: var(--transition); white-space: nowrap; }
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active { background: var(--sidebar-active); color: #fff; box-shadow: 0 4px 12px rgba(0,71,255,.4); }
.nav-item svg { flex-shrink: 0; }
.nav-item .nav-label { overflow: hidden; text-overflow: ellipsis; flex: 1; }
.sidebar-footer { padding: 12px 8px; border-top: 1px solid rgba(255,255,255,.07); }
.user-pill { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); position: relative; }
.user-info { overflow: hidden; flex: 1; }
.user-info .name { font-size: .85rem; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-info .role { font-size: .72rem; color: rgba(255,255,255,.4); white-space: nowrap; }
.user-menu-btn { color: rgba(255,255,255,.5) !important; }
.user-menu-btn:hover { color: #fff !important; background: rgba(255,255,255,.1) !important; }
.user-menu { position: absolute; bottom: calc(100% + 6px); left: 0; right: 0; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: 0 -4px 16px rgba(0,0,0,.15); z-index: 200; overflow: hidden; }
.user-menu-item { display: flex; align-items: center; gap: 10px; padding: 10px 14px; font-size: .875rem; color: var(--text); cursor: pointer; transition: background .15s; }
.user-menu-item:hover { background: var(--surface-3); }
.user-menu-danger { color: #ef4444 !important; }
.user-menu-danger:hover { background: rgba(239,68,68,.08) !important; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.topbar { height: 60px; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 24px; gap: 16px; flex-shrink: 0; }
.topbar-spacer { flex: 1; }
.topbar-btn { width: 36px !important; height: 36px !important; padding: 0 !important; justify-content: center; }
.page { flex: 1; min-width: 0; overflow-y: auto; padding: 24px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head > * { min-width: 0; }
.head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); padding: 20px; display: flex; flex-direction: column; gap: 8px; }
.stat-card .stat-icon { width: 40px; height: 40px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; }
.stat-card .stat-value { font-size: 1.75rem; font-weight: 800; color: var(--text); line-height: 1; }
.stat-card .stat-label { font-size: .8rem; color: var(--text-muted); font-weight: 500; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table { width: max-content; min-width: 100%; border-collapse: collapse; font-size: .875rem; }
thead th { padding: 10px 16px; text-align: center; font-size: .75rem; font-weight: 600; color: var(--text-muted); letter-spacing: 0; text-transform: capitalize; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
tbody td { padding: 12px 16px; border-bottom: 1px solid var(--border); color: var(--text); white-space: nowrap; }
tbody td:last-child { text-align: center; }
tbody tr:hover td { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }
.pg-bar { display:flex; align-items:center; gap:16px; padding:10px 16px; border-top:1px solid var(--border); font-size:.8rem; color:var(--text-muted); flex-wrap:wrap; }
.pg-info { margin-right:auto; }
.pg-size { display:flex; align-items:center; gap:6px; }
.pg-size select { border:1px solid var(--border); border-radius:var(--radius-sm); background:var(--surface); color:var(--text); padding:3px 6px; font-size:.8rem; }
.pg-nav { display:flex; align-items:center; gap:2px; }
.pg-nav span { padding:0 8px; font-size:.82rem; }
.pg-nav button { width:28px; height:28px; border:1px solid var(--border); border-radius:var(--radius-sm); background:var(--surface); color:var(--text); cursor:pointer; display:flex; align-items:center; justify-content:center; transition:var(--transition); }
.pg-nav button:hover:not(:disabled) { background:var(--surface-2); }
.pg-nav button:disabled { opacity:.35; cursor:not-allowed; }

/* ── Modal ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 1000; opacity: 0; pointer-events: none; transition: var(--transition); padding: 20px; }
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal-box { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 28px; width: 360px; max-width: 100%; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; position: relative; transform: translateY(12px); transition: var(--transition); }
.modal-overlay.open .modal-box { transform: translateY(0); }
.modal { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 28px; width: 90%; max-width: 560px; max-height: calc(100vh - 48px); overflow-y: auto; transform: translateY(12px); transition: var(--transition); position: relative; }
.modal-overlay.open .modal { transform: translateY(0); }
.modal.modal-wide { max-width: 860px; }
.modal-close { position: absolute; top: 14px; right: 14px; background: none; border: none; cursor: pointer; color: var(--text-muted); padding: 4px; border-radius: 6px; display: flex; }
.modal-close:hover { background: var(--surface-2); color: var(--text); }
.modal-icon { width: 52px; height: 52px; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin-bottom: 4px; }
.modal-icon.danger { background: #FEF2F2; color: var(--danger); }
.modal-icon.info { background: #EEF2FF; color: var(--primary); }
.modal-title { font-size: 1.05rem; font-weight: 700; }
.modal-msg { font-size: .88rem; color: var(--text-secondary); line-height: 1.5; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; width: 100%; }
.modal-actions .btn { flex: 1; }
.modal-header { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.modal-header h2 { flex: 1; }
.modal-footer { display: flex; gap: 10px; margin-top: 22px; }
.modal-footer .btn { flex: 1; justify-content: center; }

/* ── Login ── */
.login-screen { min-height: 100vh; display: flex; align-items: stretch; background: var(--surface); }
.login-left { flex: 1; background: var(--sidebar-bg); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px; position: relative; overflow: hidden; }
.login-left::before { content: ''; position: absolute; width: 600px; height: 600px; background: radial-gradient(circle, rgba(0,71,255,.25) 0%, transparent 70%); top: 50%; left: 50%; transform: translate(-50%, -50%); pointer-events: none; }
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 20px; text-align: center; position: relative; z-index: 1; color: var(--primary-light); }
.login-brand h1 { color: #fff; font-size: 2rem; font-weight: 800; }
.login-brand h1 span { color: var(--primary-light); }
.login-tagline { color: rgba(255,255,255,.5); font-size: .95rem; max-width: 340px; line-height: 1.6; }
.login-right { width: 440px; flex-shrink: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px 56px; }
.login-form-wrap { width: 100%; }
.login-form-wrap h2 { font-size: 1.5rem; font-weight: 800; margin-bottom: 6px; }
.login-form-wrap p { color: var(--text-muted); font-size: .875rem; margin-bottom: 32px; }
.login-form-wrap .form-fields { display: flex; flex-direction: column; gap: 18px; }
.login-form-wrap .btn-primary { width: 100%; justify-content: center; padding: 13px; font-size: .95rem; margin-top: 8px; }
.login-error { background: #FEF2F2; border: 1px solid #FECACA; color: var(--danger); padding: 10px 14px; border-radius: var(--radius-sm); font-size: .85rem; display: none; margin-bottom: 16px; }
.login-error.show { display: block; }

/* ── Toast ── */
.toast-wrap { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 8px; z-index: 9999; }
.toast { background: var(--text); color: #fff; padding: 12px 18px; border-radius: var(--radius-sm); font-size: .85rem; font-weight: 500; box-shadow: var(--shadow-md); display: flex; align-items: center; gap: 10px; animation: slideIn .3s ease; min-width: 260px; }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
.spinner-sm { display: inline-block; width: 14px; height: 14px; border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; animation: spin .6s linear infinite; vertical-align: middle; opacity: .7; }

/* ── Dataset upload / preview ── */
.dropzone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 40px 20px; text-align: center; cursor: pointer; transition: var(--transition); background: var(--surface); }
.dropzone:hover, .dropzone.drag { border-color: var(--primary); background: var(--surface-3); }
.dropzone svg { color: var(--text-muted); }
.dropzone .dz-title { font-weight: 600; margin-top: 10px; }
.dropzone .dz-sub { font-size: .8rem; color: var(--text-muted); margin-top: 4px; }
.dataset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.dataset-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 10px; cursor: pointer; transition: var(--transition); }
.dataset-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.dataset-card-title { font-weight: 700; font-size: .95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dataset-card-meta { font-size: .78rem; color: var(--text-muted); display: flex; gap: 10px; flex-wrap: wrap; }
.col-type-chip { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 99px; font-size: .74rem; font-weight: 600; background: var(--surface-3); color: var(--text-secondary); border: 1px solid var(--border); }
.col-type-integer, .col-type-float { color: #0369A1; background: #E0F2FE; border-color: #BAE6FD; }
.col-type-datetime { color: #7C3AED; background: #F5F3FF; border-color: #DDD6FE; }
.col-type-boolean { color: #B45309; background: #FFFBEB; border-color: #FDE68A; }

/* ── Dashboards & widgets ── */
.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.dashboard-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 10px; cursor: pointer; transition: var(--transition); }
.dashboard-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.widget-board { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; align-items: start; }
.widget-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; overflow: hidden; grid-column: span 12; }
.widget-card.size-sm { grid-column: span 4; }
.widget-card.size-md { grid-column: span 6; }
.widget-card.size-lg { grid-column: span 8; }
.widget-card.size-full { grid-column: span 12; }
@media (max-width: 900px) { .widget-card, .widget-card.size-sm, .widget-card.size-md, .widget-card.size-lg { grid-column: span 12; } }
.widget-card.dragging { opacity: .4; }
.widget-card-head { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: grab; }
.widget-card-head:active { cursor: grabbing; }
.widget-card-head .title { font-weight: 700; font-size: .875rem; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.widget-card-body { padding: 16px; flex: 1; overflow-x: auto; }
.widget-kpi-value { font-size: 2.2rem; font-weight: 800; color: var(--text); line-height: 1; }
.widget-kpi-label { font-size: .82rem; color: var(--text-muted); margin-top: 6px; }
.widget-empty { color: var(--text-muted); font-size: .85rem; text-align: center; padding: 24px 8px; }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.field-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 99px; background: var(--surface-3); border: 1px solid var(--border); font-size: .8rem; font-weight: 500; cursor: pointer; transition: var(--transition); }
.field-chip:hover { border-color: var(--primary); }
.field-chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.field-chip .rm { display: flex; opacity: .7; }
.field-chip .rm:hover { opacity: 1; }
.builder-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 8px 0; border-bottom: 1px solid var(--border); }
.builder-row:last-child { border-bottom: none; }
.builder-section-label { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin: 16px 0 8px; }
.builder-section-label:first-child { margin-top: 0; }
.chart-type-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.chart-type-btn { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 14px; border: 1.5px solid var(--border); border-radius: var(--radius); cursor: pointer; font-size: .72rem; font-weight: 600; color: var(--text-secondary); background: var(--surface); transition: var(--transition); }
.chart-type-btn:hover { border-color: var(--primary); }
.chart-type-btn.active { border-color: var(--primary); background: var(--surface-3); color: var(--primary); }

.legend-row { display: flex; flex-wrap: wrap; gap: 10px 16px; margin-top: 10px; font-size: .78rem; }
.legend-item { display: flex; align-items: center; gap: 6px; color: var(--text-secondary); }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }

/* ── Informes ─────────────────────────────────────────── */
.rep-controls { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-end; margin-bottom: 16px; }
.rep-controls .input-group { min-width: 130px; }
.rep-controls .rep-control-wide { min-width: 240px; flex: 1 1 240px; max-width: 320px; }
.rep-title { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.rep-subtitle { font-size: .8rem; color: var(--text-muted); margin-top: 2px; }
.rep-warning { display: flex; align-items: center; gap: 8px; padding: 10px 14px; margin-bottom: 12px; border-radius: var(--radius); background: #FFFBEB; color: #92400E; font-size: .85rem; }
.rep-table { font-variant-numeric: tabular-nums; }
.rep-table thead th:not(:first-child) { text-align: right; }
.rep-table tbody td { padding: 7px 16px; }
.rep-table tbody td:last-child { text-align: right; }
.rep-table td.num { text-align: right; }
.rep-table td.pct { color: var(--text-secondary); font-size: .8rem; }
.rep-table .rep-label { display: flex; align-items: center; gap: 4px; }
.rep-table tr.rep-header td { background: var(--surface-3); font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-secondary); padding-top: 10px; }
.rep-table tr.rep-subtotal td { font-weight: 600; }
.rep-table tr.rep-total td { font-weight: 700; border-top: 1px solid var(--text-muted); background: var(--surface-2); }
.rep-table tr.rep-child td { font-size: .8rem; color: var(--text-secondary); }
.rep-toggle { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border: none; background: none; color: var(--text-muted); cursor: pointer; border-radius: 3px; padding: 0; }
.rep-toggle:hover { background: var(--surface-3); color: var(--primary); }
.rep-toggle-space { display: inline-block; width: 18px; }

.rep-charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 16px; margin-bottom: 16px; }
.rep-chart-card { min-width: 0; }
.rep-chart-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.rep-chart-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.rep-chart-tools select.input { width: auto; max-width: 240px; }
.rep-segment { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.rep-segment button { border: none; background: var(--surface); padding: 6px 12px; font-size: .78rem; color: var(--text-secondary); cursor: pointer; }
.rep-segment button + button { border-left: 1px solid var(--border); }
.rep-segment button.active { background: var(--surface-3); color: var(--primary); font-weight: 600; }
.rep-bars { display: flex; flex-direction: column; gap: 10px; }
.rep-bar-row { display: grid; grid-template-columns: minmax(110px, 38%) 1fr; gap: 10px; align-items: center; }
.rep-bar-label { font-size: .78rem; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rep-bar-track { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.rep-bar-line { display: flex; align-items: center; gap: 6px; height: 10px; }
.rep-bar { display: block; height: 8px; border-radius: 0 4px 4px 0; flex-shrink: 0; max-width: calc(100% - 64px); }
.rep-bar-value { font-size: .7rem; color: var(--text-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
@media (max-width: 520px) { .rep-charts { grid-template-columns: 1fr; } }

/* ── Roles y permisos ─────────────────────────────────── */
.role-icon { width: 30px; height: 30px; border-radius: var(--radius); background: var(--surface-3); color: var(--primary); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.perm-title { margin: 20px 0 6px; padding-top: 16px; border-top: 1px solid var(--border); color: var(--primary); font-weight: 700; }
.perm-sections { display: flex; flex-direction: column; gap: 14px; }
.perm-group-header { font-weight: 600; margin-bottom: 8px; }
.perm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; margin-left: 24px; padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); }
.perm-check { display: flex; align-items: center; gap: 8px; font-size: .85rem; cursor: pointer; }
.perm-check input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; flex-shrink: 0; }
@media (max-width: 640px) { .form-grid-2, .perm-grid { grid-template-columns: 1fr; } .perm-grid { margin-left: 8px; } }

/* ── Presupuestos y gastos ────────────────────────────── */
.bud-section-title { font-size: .95rem; margin-bottom: 12px; color: var(--text-secondary); }
.bud-filters { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.bud-filters select.input { width: auto; min-width: 200px; }
.bud-subtitle { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin: -8px 0 18px; font-size: .85rem; color: var(--text-secondary); }
.bud-subtitle span { display: inline-flex; align-items: center; gap: 5px; }
.bud-progress { position: relative; height: 10px; background: var(--surface-3); border-radius: 99px; overflow: visible; }
.bud-progress-fill { height: 100%; background: #0047FF; border-radius: 99px; }
.bud-progress-fill.over { background: var(--danger); }
.bud-progress-mark { position: absolute; top: -4px; width: 2px; height: 18px; background: var(--text); border-radius: 2px; transform: translateX(-1px); }
.bud-progress-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: .82rem; color: var(--text-secondary); margin-bottom: 10px; }
.bud-progress-head span:first-child { font-weight: 600; color: var(--text); }
.bud-alert { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: .85rem; color: var(--danger); font-weight: 600; }
.bud-card-figures { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.bud-card-figures div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.bud-card-figures span { font-size: .7rem; color: var(--text-muted); }
.bud-card-figures strong { font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bud-over { color: var(--danger) !important; }
.bud-table td.num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.bud-table td.bud-desc { white-space: normal; min-width: 220px; max-width: 420px; }
.bud-table tbody td:last-child { text-align: right; }
.bud-muted { color: var(--text-muted); font-size: .8rem; }
.bud-attach { display: inline-flex; align-items: center; gap: 4px; margin: 2px 4px 2px 0; padding: 3px 8px; border: 1px solid var(--border); border-radius: 99px; background: var(--surface-2); font-size: .75rem; color: var(--primary); cursor: pointer; }
.bud-attach:hover { border-color: var(--primary); }
.bud-attach button { border: none; background: none; color: var(--text-muted); cursor: pointer; display: inline-flex; padding: 0; }
.bud-attach button:hover { color: var(--danger); }
.bud-attach-list { display: flex; flex-wrap: wrap; margin-bottom: 8px; }
.bud-preview-img { display: block; max-width: 100%; max-height: 65vh; margin: 0 auto; border-radius: var(--radius); }
.bud-preview-pdf { width: 100%; height: 65vh; border: 1px solid var(--border); border-radius: var(--radius); }

/* ── Dashboard principal ──────────────────────────────── */
.dash-hint { display: flex; align-items: center; gap: 6px; font-size: .82rem; color: var(--text-muted); margin-bottom: 14px; }
.dash-star { border: none; background: none; color: var(--text-muted); cursor: pointer; padding: 2px; border-radius: var(--radius-sm); display: inline-flex; }
.dash-star:hover { color: #B45309; }
.dash-star.active, .dash-star-btn.active { color: #B45309; }
.dash-star.active svg, .dash-star-btn.active svg { fill: #F59E0B; stroke: #B45309; }
.dash-switch { width: auto; min-width: 200px; max-width: 280px; }
