:root {
  --blue: #1258ca;
  --blue-dark: #0b3f93;
  --blue-soft: #e8f0fd;
  --red: #c70a1a;
  --green: #0f7a4d;
  --green-soft: #e3f5ec;
  --amber: #a15c00;
  --amber-soft: #fdf1dc;
  --ink: #0f1b2d;
  --muted: #5b6b82;
  --line: #e3e8f0;
  --bg: #f4f6fa;
  --card: #ffffff;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 27, 45, .05), 0 8px 24px -18px rgba(15, 27, 45, .35);
}

* { box-sizing: border-box; }

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 24px; font-weight: 650; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 600; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.mono { font-variant-numeric: tabular-nums; }

/* ---------- estructura ---------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex: 0 0 232px;
  background: #0e1a2b;
  color: #c7d2e2;
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 14px; border-bottom: 1px solid rgba(255,255,255,.09); }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; flex: 0 0 34px;
  background: var(--blue); color: #fff; display: grid; place-items: center;
  font-weight: 700; font-size: 14px; letter-spacing: -.02em;
}
.brand-name { color: #fff; font-weight: 650; font-size: 14.5px; line-height: 1.15; }
.brand-sub { color: #8ea3bf; font-size: 11.5px; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: #7d90aa; padding: 12px 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 10px; border-radius: 9px;
  color: #c7d2e2; font-size: 14px; text-decoration: none;
}
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: var(--blue); color: #fff; font-weight: 600; }
.nav .count { margin-left: auto; background: rgba(255,255,255,.14); border-radius: 20px; padding: 0 7px; font-size: 11.5px; }
.nav a.active .count { background: rgba(255,255,255,.22); }

.sidebar-foot { margin-top: auto; border-top: 1px solid rgba(255,255,255,.09); padding-top: 12px; }
.who { display: flex; align-items: center; gap: 9px; padding: 0 6px 10px; }
.who-dot { width: 28px; height: 28px; border-radius: 50%; background: #26374f; color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 600; }
.who-name { color: #fff; font-size: 13px; font-weight: 600; line-height: 1.2; }
.who-role { color: #8ea3bf; font-size: 11.5px; }
.linkbtn { background: none; border: 0; color: #9fb2ca; font-size: 13px; padding: 6px; cursor: pointer; text-align: left; }
.linkbtn:hover { color: #fff; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 26px; background: rgba(255,255,255,.92); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20; backdrop-filter: blur(8px);
}
.topbar-title { font-size: 13px; color: var(--muted); }
.content { padding: 24px 26px 60px; max-width: 1280px; width: 100%; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- piezas ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }

.grid { display: grid; gap: 16px; }
.grid.kpi { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.kpi-card { padding: 16px 18px; }
.kpi-label { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.kpi-value { font-size: 26px; font-weight: 680; letter-spacing: -.02em; margin-top: 6px; }
.kpi-foot { font-size: 12.5px; color: var(--muted); margin-top: 4px; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.badge.ok { background: var(--green-soft); color: var(--green); }
.badge.warn { background: var(--amber-soft); color: var(--amber); }
.badge.bad { background: #fde8ea; color: var(--red); }
.badge.info { background: var(--blue-soft); color: var(--blue-dark); }
.badge.neutral { background: #eef1f6; color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 8px 13px; border-radius: 9px; font-size: 13.5px; font-weight: 600;
  cursor: pointer; text-decoration: none; line-height: 1.2;
}
.btn:hover { border-color: #cfd8e6; text-decoration: none; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--blue); padding: 6px 8px; }
.btn.sm { padding: 5px 9px; font-size: 12.5px; border-radius: 8px; }
.btn.danger { color: var(--red); border-color: #f2c9ce; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); font-size: 13.8px; vertical-align: middle; }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 650; background: #fbfcfe; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafcff; }
.table-wrap { overflow-x: auto; }

form.stack { display: grid; gap: 14px; }
.field { display: grid; gap: 5px; }
.field label { font-size: 12.5px; font-weight: 600; color: #33455e; }
.field .hint { font-size: 12px; color: var(--muted); }
input, select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid #d5dce8; border-radius: 9px;
  background: #fff; font: inherit; font-size: 14px; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(18,88,202,.18); border-color: var(--blue); }
textarea { min-height: 110px; resize: vertical; }
.row { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.row.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.check input { width: auto; }

.alert { padding: 11px 14px; border-radius: 10px; font-size: 13.5px; margin-bottom: 16px; border: 1px solid transparent; }
.alert.ok { background: var(--green-soft); color: #0b5c3a; border-color: #bfe6d3; }
.alert.err { background: #fde8ea; color: #8d1120; border-color: #f3c3c9; }
.alert ul { margin: 6px 0 0 18px; padding: 0; }

.empty { padding: 34px 18px; text-align: center; color: var(--muted); font-size: 13.5px; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.filters .field { min-width: 140px; }
.filters input, .filters select { padding: 7px 10px; font-size: 13.5px; }

.pagination { display: flex; gap: 6px; flex-wrap: wrap; padding: 14px 18px; }
.pagination a, .pagination span { padding: 5px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; }
.pagination .active { background: var(--blue); color: #fff; border-color: var(--blue); }

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(1200px 500px at 50% -10%, #e8f0fd 0%, var(--bg) 60%); }
.login-card { width: 100%; max-width: 390px; }
.login-head { text-align: center; margin-bottom: 18px; }
.login-head .brand-mark { margin: 0 auto 10px; width: 44px; height: 44px; font-size: 16px; border-radius: 12px; }
.login-head h1 { font-size: 20px; }
.login-head p { color: var(--muted); font-size: 13.5px; margin: 6px 0 0; }
.login-foot { margin-top: 16px; text-align: center; font-size: 12.5px; color: var(--muted); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); padding: 0 18px; overflow-x: auto; }
.tabs a { padding: 11px 12px; font-size: 13.5px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--blue); border-bottom-color: var(--blue); font-weight: 600; }

.list { display: grid; }
.list-item { display: flex; gap: 12px; padding: 13px 18px; border-bottom: 1px solid var(--line); align-items: flex-start; }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }

.bar { height: 7px; border-radius: 99px; background: #edf1f7; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--blue); }

.mobile-only { display: none; }

@media (max-width: 1080px) {
  .grid.kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; padding: 12px 12px 10px; }
  .brand { border-bottom: 0; padding-bottom: 8px; }
  .nav { flex-direction: row; overflow-x: auto; gap: 6px; padding-bottom: 4px; }
  .nav-label, .sidebar-foot { display: none; }
  .nav a { white-space: nowrap; padding: 7px 11px; font-size: 13px; }
  .content { padding: 16px 14px 50px; }
  .topbar { padding: 11px 14px; }
  .grid.two, .grid.three, .row, .row.three { grid-template-columns: 1fr; }
  h1 { font-size: 21px; }
  .kpi-value { font-size: 22px; }
  th, td { padding: 10px 12px; font-size: 13.2px; }
  .mobile-only { display: block; }
}
