:root {
  --color-bg:        #f5f5f5;
  --color-surface:   #ffffff;
  --color-text:      #1a1a1a;
  --color-muted:     #6b7280;
  --color-primary:   #2563eb;
  --color-primary-h: #1d4ed8;
  --color-danger:    #dc2626;
  --color-success:   #16a34a;
  --color-border:    #d1d5db;
  --radius:          6px;
  --shadow-sm:       0 1px 2px rgba(0,0,0,0.08);
  --shadow-md:       0 4px 12px rgba(0,0,0,0.1);
  --font-family:     system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --max-width:       960px;
  --spacing:         16px;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--spacing);
}

a {
  color: var(--color-primary);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

h1, h2, h3 { line-height: 1.3; font-weight: 600; }

.page-title  { margin: 24px 0 16px; font-size: 1.5rem; }
.text-muted  { color: var(--color-muted); }
.text-center { text-align: center; }
.text-danger { color: var(--color-danger); }
.text-success { color: var(--color-success); }
.hidden      { display: none !important; }

/* Navbar */
.navbar {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
}
.navbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}
.navbar-brand {
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--color-text);
}
.navbar-brand:hover { text-decoration: none; }
.navbar-nav {
  display: flex;
  align-items: center;
  gap: 16px;
}
.nav-link {
  color: var(--color-primary);
  font-size: 0.875rem;
}
.nav-user {
  font-size: 0.875rem;
  color: var(--color-muted);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 0.875rem;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.4;
}
.btn:hover {
  background: var(--color-bg);
  text-decoration: none;
}
.btn-primary {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}
.btn-primary:hover { background: var(--color-primary-h); }
.btn-secondary {
  background: #e5e7eb;
  color: #1a1a1a;
  border-color: #d1d5db;
}
.btn-secondary:hover { background: #d1d5db; }
.btn-sm {
  padding: 4px 10px;
  font-size: 0.8125rem;
}
.btn-danger {
  background: var(--color-danger);
  color: #fff;
  border-color: var(--color-danger);
}
.btn-danger:hover { opacity: 0.9; }
.btn-link {
  background: none;
  border: none;
  color: var(--color-primary);
  cursor: pointer;
  font-size: 0.875rem;
  padding: 0;
}
.btn-link:hover { text-decoration: underline; }

/* Forms */
.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  font-weight: 500;
  font-size: 0.875rem;
  margin-bottom: 4px;
}
.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  font-size: 0.9375rem;
  font-family: var(--font-family);
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: -1px;
}
.form-group .checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 0.9375rem;
}
.form-group .checkbox-label input[type="checkbox"] {
  margin: 0;
  width: auto;
  padding: 0;
  border: none;
  box-shadow: none;
}
.field-error {
  display: block;
  color: var(--color-danger);
  font-size: 0.8125rem;
  margin-top: 4px;
}

/* Alerts */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-top: 16px;
  margin-bottom: 16px;
  font-size: 0.875rem;
  animation: alertIn 0.35s ease-out;
}

@keyframes alertIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.alert-success {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
}
.alert-error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

/* Tables */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.table th,
.table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border);
}
.table th {
  font-weight: 600;
  color: var(--color-muted);
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.table tbody tr:hover {
  background: var(--color-bg);
}

/* Card / Section */
.card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  margin-bottom: 20px;
}
.card h2 {
  font-size: 1.125rem;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--color-border);
}
.card-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.btn-more-toggle { display: none; }
.more-actions { display: inline-flex; flex-direction: row; gap: 8px; }
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--color-border);
}
.card-header h2 {
  margin: 0;
  padding: 0;
  border: none;
}
.card-badge {
  font-size: 0.875rem;
  color: var(--color-muted);
}

/* Loading */
.loading {
  text-align: center;
  padding: 60px 0;
  color: var(--color-muted);
}

/* Badge */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  background: #e5e7eb;
  color: #374151;
}
.badge-ingreso {
  background: #d1e7dd;
  color: #0f5132;
}
.badge-cargo {
  background: #f8d7da;
  color: #842029;
}
.badge-success { background: #d1e7dd; color: #0f5132; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-danger  { background: #f8d7da; color: #842029; }
.badge-info    { background: #cff4fc; color: #055160; }

/* Inline forms */
.inline-flex {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

/* ─── Modal ──────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: modalFadeIn 0.2s ease-out;
}

.modal-box {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  padding: 24px;
  min-width: 320px;
  max-width: 440px;
  animation: modalSlideIn 0.2s ease-out;
}

.modal-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.modal-icon {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

.modal-icon--alert {
  color: var(--color-danger);
}

.modal-icon--confirm {
  color: var(--color-primary);
}

.modal-title {
  font-size: 1.0625rem;
  font-weight: 600;
}

.modal-body {
  font-size: 0.9375rem;
  color: var(--color-text);
  margin-bottom: 20px;
  line-height: 1.5;
}

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

@keyframes modalFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes modalSlideIn {
  from { opacity: 0; transform: scale(0.95) translateY(-4px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.inline-flex select,
.inline-flex input {
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  background: var(--color-surface);
}
.inline-flex select:focus,
.inline-flex input:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: -1px;
}

#btn-scroll-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  font-size: 1.25rem;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  z-index: 100;
}
#btn-scroll-top.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
#btn-scroll-top:hover {
  background: var(--color-primary-h);
}

/* Passkey row collapsible */
.passkey-actions { display: none; }
.passkey-actions.open { display: flex; gap: 4px; flex-wrap: wrap; }
.passkey-chevron { font-size: 0.8rem; color: #9ca3af; transition: transform 0.2s; }

@media (min-width: 768px) {
  .passkey-actions { display: flex; gap: 4px; }
  .passkey-chevron { display: none; }
}

@media (max-width: 767px) {
  .navbar-inner {
    flex-wrap: wrap;
    height: auto;
    padding: 8px 0;
  }
  .navbar-brand {
    width: 100%;
    text-align: center;
    padding: 4px 0;
  }
  .navbar-nav {
    width: 100%;
    justify-content: center;
    padding: 4px 0;
  }
  .card-actions { flex-wrap: wrap; }
  .btn-more-toggle { display: inline-flex; gap: 10px; background: #e5e7eb; }
  .more-actions { display: none; flex-direction: column; width: 100%; }
  .more-actions.open { display: flex; }
}
