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

:root {
  --bg:        #F7F6F3;
  --surface:   #FFFFFF;
  --border:    #E2E0D8;
  --border2:   #CBC9C0;
  --text:      #1A1917;
  --text2:     #5F5D57;
  --text3:     #9B9890;
  --blue:      #1A5FB4;
  --blue-light:#EBF2FC;
  --green:     #2E7D32;
  --green-light:#E8F5E9;
  --amber:     #E65100;
  --amber-light:#FFF3E0;
  --red:       #B71C1C;
  --red-light: #FFEBEE;
  --purple:    #4527A0;
  --purple-light:#EDE7F6;
  --teal:      #00695C;
  --teal-light:#E0F2F1;
  --sidebar-w: 220px;
  --radius:    8px;
  --radius-lg: 12px;
  --shadow:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-lg: 0 4px 16px rgba(0,0,0,.12);
}

body {
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* ─── PAGES ─────────────────────────────────────────────────── */
.page { min-height: 100vh; }
.page.hidden { display: none !important; }
.page.active { display: block; }

/* ─── LOGIN ─────────────────────────────────────────────────── */
#page-login {
  display: flex; align-items: center; justify-content: center;
  background: #0F1117;
  position: relative; overflow: hidden;
}
.login-bg {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 30% 50%, #1A3A6E22 0%, transparent 60%),
              radial-gradient(ellipse at 70% 30%, #1A5FB411 0%, transparent 50%);
}
.login-grid {
  position: absolute; inset: 0;
  background-image: linear-gradient(rgba(255,255,255,.03) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(255,255,255,.03) 1px, transparent 1px);
  background-size: 40px 40px;
}
.login-wrap { position: relative; z-index: 1; width: 100%; max-width: 400px; padding: 1.5rem; }
.login-card {
  background: #1A1D26;
  border: 1px solid #2A2D38;
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.login-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 2rem; }
.logo-icon {
  width: 44px; height: 44px; border-radius: 10px;
  background: var(--blue); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
}
.logo-icon.sm { width: 32px; height: 32px; font-size: 16px; border-radius: 7px; }
.logo-title { font-size: 18px; font-weight: 600; color: #fff; }
.logo-sub { font-size: 12px; color: #6B7280; }
.btn-ms {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 10px; border-radius: var(--radius);
  background: #2A2D38; border: 1px solid #3A3D48;
  color: #fff; font-size: 14px; font-family: 'DM Sans', sans-serif;
  cursor: pointer; margin-bottom: 1rem; font-weight: 500;
  transition: background .15s;
}
.btn-ms:hover { background: #3A3D48; }
.divider {
  display: flex; align-items: center; gap: 10px;
  color: #4B5563; font-size: 12px; margin-bottom: 1rem;
}
.divider::before, .divider::after { content:''; flex:1; border-top: 1px solid #2A2D38; }
.login-card .field { margin-bottom: 12px; }
.login-card .field label { display: block; font-size: 12px; color: #9CA3AF; margin-bottom: 4px; font-weight: 500; }
.login-card input {
  width: 100%; padding: 9px 12px; border-radius: var(--radius);
  background: #2A2D38; border: 1px solid #3A3D48;
  color: #fff; font-size: 14px; font-family: 'DM Sans', sans-serif;
  outline: none; transition: border .15s;
}
.login-card input:focus { border-color: var(--blue); }
.login-hint { margin-top: 1rem; font-size: 11px; color: #4B5563; text-align: center; }
.w-full { width: 100%; justify-content: center; }

/* ─── APP LAYOUT ─────────────────────────────────────────────── */
#page-app { display: flex; min-height: 100vh; }
#page-app.hidden { display: none !important; }

/* ─── SIDEBAR ───────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w); background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 10;
}
.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--border);
  font-size: 15px; font-weight: 600; color: var(--text);
}
.sidebar-nav { flex: 1; padding: .5rem; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: var(--radius);
  color: var(--text2); font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all .15s; text-decoration: none;
}
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: var(--blue-light); color: var(--blue); }
.nav-item i { font-size: 17px; }
.sidebar-footer {
  padding: .75rem 1rem; border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
}
.user-info { flex: 1; font-size: 12px; overflow: hidden; }
.user-info .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-info .role { color: var(--text3); font-size: 11px; }
.btn-logout {
  width: 32px; height: 32px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--bg);
  color: var(--text2); cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all .15s; font-size: 17px; flex-shrink: 0;
}
.btn-logout:hover { background: var(--red-light); color: var(--red); border-color: var(--red); }

/* ─── MAIN ───────────────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w); flex: 1;
  padding: 1.5rem; max-width: 100%;
}

/* ─── PAGE HEADER ────────────────────────────────────────────── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.5rem; flex-wrap: wrap; gap: 12px;
}
.page-header h1 { font-size: 20px; font-weight: 600; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ─── FILTERS ────────────────────────────────────────────────── */
.filters-bar { display: flex; gap: 8px; margin-bottom: 1rem; flex-wrap: wrap; }
.search-input {
  flex: 1; min-width: 200px; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 13px; font-family: 'DM Sans', sans-serif;
  background: var(--surface); color: var(--text); outline: none;
}
.search-input:focus { border-color: var(--blue); }
.filter-select {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 13px; font-family: 'DM Sans', sans-serif;
  background: var(--surface); color: var(--text); outline: none; cursor: pointer;
}

/* ─── KPI GRID ───────────────────────────────────────────────── */
.kpi-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px; margin-bottom: 1.5rem;
}
.kpi-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1rem;
}
.kpi-label { font-size: 12px; color: var(--text2); margin-bottom: 6px; display: flex; align-items: center; gap: 5px; }
.kpi-value { font-size: 22px; font-weight: 600; line-height: 1; }
.kpi-sub { font-size: 11px; color: var(--text3); margin-top: 4px; }

/* ─── CHARTS ─────────────────────────────────────────────────── */
.charts-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem; margin-bottom: 1rem;
}
.chart-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.25rem;
}
.chart-title { font-size: 12px; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 1rem; }

/* ─── CARD ───────────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.25rem; margin-bottom: 1rem;
}
.card-title { font-size: 12px; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 1rem; }

/* ─── TABLE ──────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; padding: 10px 14px;
  font-size: 11px; font-weight: 600; color: var(--text2);
  border-bottom: 1px solid var(--border);
  text-transform: uppercase; letter-spacing: .05em;
  white-space: nowrap;
}
td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg); }

/* ─── BADGES ─────────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 99px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.b-blue   { background: var(--blue-light);   color: var(--blue); }
.b-green  { background: var(--green-light);  color: var(--green); }
.b-amber  { background: var(--amber-light);  color: var(--amber); }
.b-red    { background: var(--red-light);    color: var(--red); }
.b-purple { background: var(--purple-light); color: var(--purple); }
.b-teal   { background: var(--teal-light);   color: var(--teal); }
.b-gray   { background: var(--bg);           color: var(--text2); border: 1px solid var(--border); }

/* ─── BUTTONS ────────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius);
  background: var(--blue); color: #fff; border: none;
  font-size: 13px; font-weight: 500; font-family: 'DM Sans', sans-serif;
  cursor: pointer; transition: background .15s; white-space: nowrap;
}
.btn-primary:hover { background: #1450A0; }
.btn-secondary {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--radius);
  background: transparent; color: var(--text);
  border: 1px solid var(--border);
  font-size: 13px; font-weight: 500; font-family: 'DM Sans', sans-serif;
  cursor: pointer; transition: all .15s; white-space: nowrap;
}
.btn-secondary:hover { background: var(--bg); }
.btn-icon {
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius); border: 1px solid var(--border);
  background: transparent; color: var(--text2); cursor: pointer;
  transition: all .15s; font-size: 16px;
}
.btn-icon:hover { background: var(--bg); color: var(--text); }
.btn-sm { padding: 5px 10px !important; font-size: 12px !important; }
.btn-danger { background: var(--red-light) !important; color: var(--red) !important; border-color: var(--red) !important; }

/* ─── FORMS ──────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field label { font-size: 12px; font-weight: 500; color: var(--text2); }
.field label small { font-weight: 400; color: var(--text3); }
.field input, .field select, .field textarea {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 13px; font-family: 'DM Sans', sans-serif;
  background: var(--surface); color: var(--text); outline: none;
  transition: border .15s;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--blue); }
.field textarea { resize: vertical; min-height: 60px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 12px; }
.form-section {
  font-size: 11px; font-weight: 600; color: var(--text3);
  text-transform: uppercase; letter-spacing: .06em;
  margin: 1rem 0 .5rem; padding-bottom: .5rem;
  border-bottom: 1px solid var(--border);
}
.input-group { display: flex; gap: 6px; }
.input-group input { flex: 1; }

/* ─── TOGGLE BUTTONS ─────────────────────────────────────────── */
.toggle-group { display: flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 4px; }
.toggle-btn {
  flex: 1; padding: 7px 10px; font-size: 12px; font-weight: 500;
  border: none; background: transparent; color: var(--text2);
  cursor: pointer; font-family: 'DM Sans', sans-serif; transition: all .15s;
}
.toggle-btn.active { background: var(--blue); color: #fff; }

/* ─── ROLE GRID ──────────────────────────────────────────────── */
.role-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.role-card {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 12px 8px; border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer; text-align: center; transition: all .15s;
}
.role-card i { font-size: 20px; color: var(--text2); }
.role-card span { font-size: 12px; font-weight: 600; }
.role-card small { font-size: 10px; color: var(--text3); }
.role-card.selected { border-color: var(--blue); background: var(--blue-light); }
.role-card.selected i, .role-card.selected span { color: var(--blue); }

/* ─── MODAL ──────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 2rem 1rem; z-index: 100; overflow-y: auto;
}
.modal-overlay.hidden { display: none !important; }
.modal {
  background: var(--surface); border-radius: var(--radius-lg);
  border: 1px solid var(--border); width: min(560px, 95vw);
  box-shadow: var(--shadow-lg);
}
.modal-lg { width: min(720px, 95vw); }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 16px; font-weight: 600; }
.modal-body { padding: 1.5rem; max-height: 70vh; overflow-y: auto; }
.modal-footer {
  display: flex; gap: 8px; justify-content: flex-end;
  padding: 1rem 1.5rem; border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

/* ─── STEPS ──────────────────────────────────────────────────── */
.steps { display: flex; margin-bottom: 1.5rem; border-bottom: 1px solid var(--border); }
.step {
  flex: 1; padding: 8px 4px; text-align: center; font-size: 12px;
  color: var(--text3); border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.step.active { color: var(--blue); border-bottom-color: var(--blue); font-weight: 600; }
.step.done { color: var(--green); border-bottom-color: var(--green); }

/* ─── ACTA PREVIEW ───────────────────────────────────────────── */
.acta-preview {
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem;
  font-size: 12px; color: #1a1a1a; line-height: 1.7;
}
.acta-preview h3 { font-size: 14px; text-align: center; color: var(--blue); margin-bottom: .25rem; }
.acta-preview .acta-sub { text-align: center; font-size: 10px; color: #666; border-bottom: 1px solid #ddd; padding-bottom: .5rem; margin-bottom: .75rem; }
.acta-preview table { width: 100%; border-collapse: collapse; font-size: 11px; }
.acta-preview td { padding: 3px 6px; border-bottom: .5px solid #eee; }
.firma-area { display: flex; gap: 3rem; margin-top: 1rem; border-top: 1px solid #ddd; padding-top: .75rem; }
.firma-box { flex: 1; text-align: center; }
.firma-line { border-top: 1px solid #999; margin-top: 40px; padding-top: 4px; font-size: 10px; color: #888; }

/* ─── FIRMA CANVAS ───────────────────────────────────────────── */
.firma-canvas {
  border: 1px solid var(--border); border-radius: var(--radius);
  cursor: crosshair; touch-action: none; width: 100%; height: 150px;
  display: block; margin-bottom: 8px;
}
.hint { font-size: 13px; color: var(--text2); margin-bottom: .75rem; }

/* ─── HISTORIAL ──────────────────────────────────────────────── */
.hist-item { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); align-items: flex-start; }
.hist-item:last-child { border-bottom: none; }
.hist-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.hist-dot.create  { background: var(--green); }
.hist-dot.edit    { background: var(--amber); }
.hist-dot.mail    { background: var(--blue); }
.hist-dot.sign    { background: var(--purple); }
.hist-dot.login   { background: var(--teal); }
.hist-dot.print   { background: #795548; }
.hist-dot.useradd { background: #00796B; }

/* ─── ALERT ──────────────────────────────────────────────────── */
.alert {
  padding: 10px 14px; border-radius: var(--radius);
  font-size: 13px; margin-bottom: 1rem;
}
.alert.hidden { display: none; }
.alert-success { background: var(--green-light); color: var(--green); }
.alert-error   { background: var(--red-light);   color: var(--red); }
.alert-info    { background: var(--blue-light);   color: var(--blue); }
.alert-warn    { background: var(--amber-light);  color: var(--amber); }
.global-alert {
  position: fixed; top: 16px; right: 16px; z-index: 999;
  min-width: 280px; max-width: 400px;
  padding: 12px 16px; border-radius: var(--radius);
  font-size: 13px; box-shadow: var(--shadow-lg);
  animation: slideIn .2s ease;
}
.global-alert.hidden { display: none; }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ─── QR BOX ─────────────────────────────────────────────────── */
.qr-box { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 1rem; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); }

/* ─── DETAIL GRID ────────────────────────────────────────────── */
.det-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1.5rem; }
.det-section-title { font-size: 11px; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: .06em; margin-bottom: .75rem; padding-bottom: .5rem; border-bottom: 1px solid var(--border); }
.det-row { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px solid var(--border); }
.det-row:last-child { border-bottom: none; }
.det-label { font-size: 12px; color: var(--text2); }
.det-value { font-size: 13px; font-weight: 500; text-align: right; max-width: 60%; word-break: break-word; }
code { font-family: 'DM Mono', monospace; font-size: 12px; background: var(--bg); padding: 1px 5px; border-radius: 4px; }

/* ─── SECTION ────────────────────────────────────────────────── */
.section { display: block; }
.section.hidden { display: none; }

/* ─── EMPTY STATE ────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 3rem; color: var(--text3); }
.empty-state i { font-size: 40px; display: block; margin-bottom: .5rem; opacity: .4; }

/* ─── USO BAR ────────────────────────────────────────────────── */
.uso-bar-wrap { background: var(--bg); border-radius: 3px; height: 5px; min-width: 60px; overflow: hidden; }
.uso-bar { height: 5px; border-radius: 3px; }

/* ─── RESPONSIVE ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { display: none; }
  .main { margin-left: 0; padding: 1rem; }
}

/* ─── BOTON EXPORTAR ────────────────────────────────────────── */
.btn-export {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--radius);
  background: var(--green-light); color: var(--green);
  border: 1px solid var(--green);
  font-size: 12px; font-weight: 500; cursor: pointer;
  font-family: 'DM Sans', sans-serif; white-space: nowrap;
  transition: all .15s;
}
.btn-export:hover { background: var(--green); color: #fff; }
