:root {
  --color-bg: #0f172a;
  --color-bg-soft: #f4f5f7;
  --color-surface: #ffffff;
  --color-primary: #c0392b;
  --color-primary-dark: #9c2c1f;
  --color-navy: #0f172a;
  --color-navy-soft: #1e293b;
  --color-text: #1a1d23;
  --color-text-muted: #5b6472;
  --color-border: #e1e4e9;
  --color-success-bg: #e7f7ee;
  --color-success-text: #1b7943;
  --color-error-bg: #fdecea;
  --color-error-text: #9c2c1f;
  --radius: 10px;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--color-text);
  background: var(--color-bg-soft);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--color-primary);
}

h1, h2, h3 {
  font-weight: 700;
  color: var(--color-navy);
  letter-spacing: -0.01em;
}

/* ---------- Auth layout (login / forgot / reset) ---------- */

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at top left, #1e293b 0%, var(--color-navy) 55%, #050914 100%);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--color-surface);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 40px 36px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.auth-brand .badge {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 18px;
  flex-shrink: 0;
}

.auth-brand .name {
  font-size: 15px;
  font-weight: 700;
  color: var(--color-navy);
  line-height: 1.25;
}

.auth-brand .sub {
  font-size: 12.5px;
  color: var(--color-text-muted);
}

.auth-card h1 {
  font-size: 22px;
  margin: 0 0 6px;
}

.auth-card p.lead {
  color: var(--color-text-muted);
  margin: 0 0 24px;
  font-size: 14.5px;
}

.auth-footer-link {
  margin-top: 20px;
  text-align: center;
  font-size: 14px;
  color: var(--color-text-muted);
}

/* ---------- Forms ---------- */

.field {
  margin-bottom: 18px;
}

.field label {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--color-navy);
  margin-bottom: 6px;
}

.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="date"],
.field input[type="datetime-local"],
.field input[type="number"],
.field select {
  width: 100%;
  padding: 11px 13px;
  font-size: 15px;
  border: 1.5px solid var(--color-border);
  border-radius: 8px;
  background: #fff;
  color: var(--color-text);
  transition: border-color 0.15s ease;
  line-height: 1.3;
  font-family: inherit;
}

input[type="date"],
input[type="datetime-local"] {
  padding: 8px 10px;
  font-size: 14px;
  border: 1.5px solid var(--color-border);
  border-radius: 8px;
  background: #fff;
  color: var(--color-text);
  font-family: inherit;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--color-primary);
}

.field .hint {
  font-size: 12.5px;
  color: var(--color-text-muted);
  margin-top: 5px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 700;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  background: var(--color-primary);
  color: #fff;
  transition: background 0.15s ease;
  text-decoration: none;
}

.btn:hover {
  background: var(--color-primary-dark);
}

.btn.btn-secondary {
  background: var(--color-navy-soft);
}

.btn.btn-secondary:hover {
  background: var(--color-navy);
}

.btn.btn-sm {
  width: auto;
  padding: 7px 12px;
  font-size: 13.5px;
}

.btn.btn-danger {
  background: #b02a37;
}

.btn.btn-danger:hover {
  background: #8f2029;
}

.btn.btn-outline {
  background: transparent;
  color: var(--color-navy);
  border: 1.5px solid var(--color-border);
}

.btn.btn-outline:hover {
  background: var(--color-bg-soft);
}

/* ---------- Alerts ---------- */

.alert {
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 18px;
}

.alert-success {
  background: var(--color-success-bg);
  color: var(--color-success-text);
}

.alert-error {
  background: var(--color-error-bg);
  color: var(--color-error-text);
}

/* ---------- App shell (dashboard / users) ---------- */

.app-shell {
  min-height: 100vh;
  display: flex;
}

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--color-navy);
  color: #fff;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 32px;
}

.sidebar .brand .badge {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  flex-shrink: 0;
}

.sidebar .brand .name {
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.3;
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.sidebar nav a {
  color: #cbd5e1;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14.5px;
  font-weight: 600;
}

.sidebar nav a:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.sidebar nav a.active {
  background: var(--color-primary);
  color: #fff;
}

.sidebar .user-box {
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding-top: 16px;
  font-size: 13.5px;
}

.sidebar .user-box .u-name {
  font-weight: 700;
  color: #fff;
}

.sidebar .user-box .u-role {
  color: #94a3b8;
  text-transform: capitalize;
}

.sidebar form.logout-form {
  margin-top: 12px;
}

.sidebar form.logout-form button {
  width: 100%;
  background: transparent;
  border: 1.5px solid rgba(255, 255, 255, 0.18);
  color: #fff;
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
}

.sidebar form.logout-form button:hover {
  background: rgba(255, 255, 255, 0.08);
}

.content {
  flex: 1;
  min-width: 0;
  padding: 36px 44px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-header h1 {
  font-size: 26px;
  margin: 0;
}

.page-header p {
  color: var(--color-text-muted);
  margin: 4px 0 0;
  font-size: 14.5px;
}

.card {
  background: var(--color-surface);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 18px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--color-surface);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.stat-card .value {
  font-size: 30px;
  font-weight: 800;
  color: var(--color-navy);
}

.stat-card .label {
  font-size: 13.5px;
  color: var(--color-text-muted);
  margin-top: 4px;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
}

table.data-table th,
table.data-table td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--color-border);
}

table.data-table th {
  color: var(--color-text-muted);
  font-weight: 700;
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

table.data-table tr:last-child td {
  border-bottom: none;
}

.badge-role,
.badge-status {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.badge-role.admin {
  background: #fde8e6;
  color: var(--color-primary-dark);
}

.badge-role.operador {
  background: #e3edfb;
  color: #2453a6;
}

.badge-status.activo {
  background: var(--color-success-bg);
  color: var(--color-success-text);
}

.badge-status.inactivo {
  background: #f1f2f4;
  color: var(--color-text-muted);
}

.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.inline-form {
  display: inline;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--color-text-muted);
}

/* ---------- Popups (<dialog>) ---------- */

dialog {
  border: none;
  border-radius: 14px;
  padding: 28px;
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  overflow-y: auto;
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.55);
}

@media (max-width: 720px) {
  .app-shell {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
  }

  .content {
    padding: 24px;
  }
}
