:root {
  --navy: #081529;
  --navy-mid: #0D2040;
  --navy-light: #142952;
  --blue: #1B5FAD;
  --blue-bright: #2575CC;
  --cyan: #00B4D8;
  --cyan-soft: rgba(0,180,216,0.12);
  --green: #10B981;
  --green-soft: rgba(16,185,129,0.12);
  --amber: #F59E0B;
  --amber-soft: rgba(245,158,11,0.12);
  --red: #EF4444;
  --red-soft: rgba(239,68,68,0.1);
  --white: #FFFFFF;
  --gray-50: #F8FAFC;
  --gray-100: #EFF3F8;
  --gray-200: #D9E2EE;
  --gray-400: #8BA3C0;
  --gray-500: #5F7A9A;
  --gray-600: #3F5A78;
  --text: #0F2847;
  --text-light: #4A6080;
  --sidebar-w: 230px;
  --topbar-h: 58px;
  --radius: 10px;
  --shadow: 0 2px 12px rgba(8,21,41,0.08);
  --shadow-md: 0 4px 24px rgba(8,21,41,0.12);
}

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

body {
  font-family: 'Inter', sans-serif;
  background: var(--gray-50);
  color: var(--text);
  height: 100vh;
  display: flex;
  overflow: hidden;
}

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--navy);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar::-webkit-scrollbar { width: 3px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--navy-light); border-radius: 2px; }

.brand {
  padding: 18px 18px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  text-decoration: none;
}

.nav-section { padding: 12px 0 4px; }
.nav-label {
  font-size: 9.5px; font-weight: 600; color: var(--gray-500);
  letter-spacing: 0.1em; text-transform: uppercase;
  padding: 0 18px 6px;
}

.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 18px;
  cursor: pointer;
  transition: all 0.15s;
  border-left: 2px solid transparent;
  text-decoration: none;
}

.nav-item:hover { background: rgba(255,255,255,0.04); }

.nav-item.active {
  background: rgba(37,117,204,0.15);
  border-left-color: var(--cyan);
}

.nav-item.active .nav-icon { color: var(--cyan); }
.nav-item.active .nav-text { color: white; font-weight: 600; }

.nav-icon { font-size: 14px; width: 18px; text-align: center; color: var(--gray-400); flex-shrink: 0; }
.nav-text { font-size: 12.5px; color: rgba(255,255,255,0.65); font-weight: 400; }

.nav-badge {
  margin-left: auto;
  background: var(--red);
  color: white;
  font-size: 9px; font-weight: 700;
  padding: 2px 5px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.nav-badge.cyan { background: var(--cyan); color: var(--navy); }

.sidebar-footer {
  margin-top: auto;
  padding: 14px 18px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.user-card { display: flex; align-items: center; gap: 9px; }

.user-av {
  width: 30px; height: 30px;
  background: linear-gradient(135deg, var(--blue), var(--cyan));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: white;
  flex-shrink: 0;
}

.user-info { flex: 1; overflow: hidden; }
.user-name { font-size: 12px; font-weight: 600; color: white; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 10px; color: var(--gray-400); }

/* ── MAIN ── */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

/* ── TOPBAR ── */
.topbar {
  height: var(--topbar-h);
  background: white;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(8,21,41,0.05);
}

.page-title { font-size: 16px; font-weight: 700; color: var(--text); }
.page-sub { font-size: 11.5px; color: var(--text-light); margin-left: 2px; }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.search-box {
  display: flex; align-items: center; gap: 7px;
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px; color: var(--text-light);
  cursor: pointer;
  width: 200px;
}

.search-input {
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 6px 12px 6px 32px;
  font-size: 12px; color: var(--text);
  width: 260px;
  outline: none;
  font-family: inherit;
}

.search-input:focus { border-color: var(--blue); background: white; }

.icon-btn {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 14px;
  position: relative;
  color: var(--text-light);
  transition: all 0.15s;
}

.icon-btn:hover { background: var(--gray-200); }

.notif-dot {
  position: absolute;
  top: 5px; right: 5px;
  width: 7px; height: 7px;
  background: var(--red);
  border-radius: 50%;
  border: 1.5px solid white;
}

.topbar-user {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid var(--gray-200);
  cursor: pointer;
  background: white;
}

.topbar-av {
  width: 28px; height: 28px;
  background: linear-gradient(135deg, var(--blue), var(--cyan));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; color: white;
}

.topbar-name { font-size: 12px; font-weight: 600; color: var(--text); }
.topbar-role { font-size: 10px; color: var(--text-light); }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  border-radius: 7px;
  font-size: 12px; font-weight: 600;
  cursor: pointer;
  border: none;
  font-family: inherit;
  transition: all 0.15s;
}

.btn-primary { background: var(--blue); color: white; }
.btn-primary:hover { background: var(--blue-bright); }
.btn-outline { background: white; color: var(--blue-bright); border: 1px solid var(--gray-200); }
.btn-outline:hover { background: var(--gray-50); }
.btn-danger { background: var(--red-soft); color: var(--red); }

/* ── CONTENT ── */
.content { flex: 1; overflow-y: auto; padding: 22px 24px; }
.content::-webkit-scrollbar { width: 4px; }
.content::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: 2px; }

/* ── KPI ROW ── */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}

.kpi-card {
  background: white;
  border-radius: var(--radius);
  padding: 16px 18px;
  border: 1px solid var(--gray-100);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.kpi-top { display: flex; align-items: flex-start; justify-content: space-between; }
.kpi-label { font-size: 11px; font-weight: 500; color: var(--text-light); }

.kpi-icon {
  width: 34px; height: 34px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
}

.kpi-icon.blue { background: rgba(27,95,173,0.1); }
.kpi-icon.cyan { background: var(--cyan-soft); }
.kpi-icon.green { background: var(--green-soft); }
.kpi-icon.amber { background: var(--amber-soft); }
.kpi-icon.red { background: var(--red-soft); }

.kpi-value {
  font-size: 26px; font-weight: 800;
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  line-height: 1;
}

.kpi-value span { font-size: 13px; font-weight: 500; color: var(--text-light); margin-left: 2px; }
.kpi-delta { font-size: 11px; font-weight: 600; display: flex; align-items: center; gap: 3px; }
.kpi-delta.up { color: var(--green); }
.kpi-delta.down { color: var(--red); }
.kpi-delta.neutral { color: var(--text-light); }

/* ── CARD ── */
.card {
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--gray-100);
  box-shadow: var(--shadow);
}

.card-header {
  display: flex; align-items: center;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--gray-100);
  gap: 8px;
}

.card-title { font-size: 13px; font-weight: 700; color: var(--text); flex: 1; }
.card-sub { font-size: 10.5px; color: var(--text-light); margin-top: 1px; }
.card-icon { font-size: 14px; }

.card-action {
  font-size: 11px; font-weight: 600; color: var(--blue-bright);
  cursor: pointer; padding: 4px 8px;
  border-radius: 5px;
  background: rgba(37,117,204,0.06);
  white-space: nowrap;
}

.card-body { padding: 14px 16px; }

/* ── TABLE ── */
.data-table { width: 100%; border-collapse: collapse; }

.data-table th {
  font-size: 10px; font-weight: 600; color: var(--gray-400);
  text-transform: uppercase; letter-spacing: 0.06em;
  padding: 0 12px 10px 0;
  text-align: left;
  white-space: nowrap;
}

.data-table td {
  font-size: 12px; color: var(--text);
  padding: 10px 12px 10px 0;
  border-top: 1px solid var(--gray-100);
  vertical-align: middle;
}

.data-table tr:hover td { background: var(--gray-50); }

/* ── AVATAR ROW ── */
.av-row { display: flex; align-items: center; gap: 8px; }

.av {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700;
  flex-shrink: 0;
}

.av-name { font-size: 12px; font-weight: 600; color: var(--text); }
.av-sub { font-size: 10px; color: var(--text-light); font-family: 'JetBrains Mono', monospace; }

/* ── STATUS PILLS ── */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 20px;
  font-size: 10.5px; font-weight: 600;
  white-space: nowrap;
}

.pill-dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

.pill.confirmado,.pill.activo,.pill.completado,.pill.dispensado,.pill.pagado,.pill.normal { background: var(--green-soft); color: var(--green); }
.pill.pendiente,.pill.espera,.pill.revision { background: var(--amber-soft); color: var(--amber); }
.pill.urgente,.pill.critico,.pill.vencido,.pill.rechazado { background: var(--red-soft); color: var(--red); }
.pill.en-curso,.pill.activa,.pill.programado,.pill.emitida { background: rgba(37,117,204,0.1); color: var(--blue-bright); }
.pill.inactivo,.pill.cancelado { background: var(--gray-100); color: var(--gray-500); }

/* ── TAG ── */
.tag {
  font-size: 10px; font-weight: 600; color: var(--text-light);
  background: var(--gray-100);
  padding: 2px 7px; border-radius: 4px;
  white-space: nowrap;
}

/* ── MINI TABS ── */
.mini-tabs { display: flex; gap: 4px; }

.mini-tab {
  font-size: 11px; font-weight: 600;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-light);
  background: var(--gray-50);
  border: 1px solid var(--gray-100);
  transition: all 0.15s;
  white-space: nowrap;
}

.mini-tab.active { background: var(--blue); color: white; border-color: var(--blue); }

/* ── GRID LAYOUTS ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.grid-3-1 { display: grid; grid-template-columns: 1fr 1fr 320px; gap: 14px; }
.mb-4 { margin-bottom: 18px; }
.mb-3 { margin-bottom: 14px; }

/* ── FILTER BAR ── */
.filter-bar {
  display: flex; align-items: center; gap: 10px;
  background: white;
  border: 1px solid var(--gray-100);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
  flex-wrap: wrap;
}

.filter-label { font-size: 11px; font-weight: 600; color: var(--text-light); white-space: nowrap; }

.filter-select {
  font-size: 11px; color: var(--text);
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  padding: 5px 10px;
  cursor: pointer;
  font-family: inherit;
  outline: none;
}

.filter-sep { width: 1px; height: 20px; background: var(--gray-200); }
.filter-spacer { flex: 1; }

/* ── PROGRESS BAR ── */
.prog-bar { height: 6px; background: var(--gray-100); border-radius: 3px; overflow: hidden; }
.prog-fill { height: 100%; border-radius: 3px; }
.prog-fill.blue { background: linear-gradient(90deg, var(--blue), var(--cyan)); }
.prog-fill.green { background: var(--green); }
.prog-fill.amber { background: var(--amber); }
.prog-fill.red { background: var(--red); }

/* ── TIMELINE ── */
.timeline { padding: 4px 0; }

.timeline-item {
  display: flex; gap: 12px;
  padding-bottom: 16px;
  position: relative;
}

.timeline-item:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 14px; top: 28px;
  width: 1px; height: calc(100% - 12px);
  background: var(--gray-200);
}

.timeline-dot {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
  z-index: 1;
}

.timeline-content { flex: 1; }
.timeline-title { font-size: 12px; font-weight: 600; color: var(--text); }
.timeline-sub { font-size: 11px; color: var(--text-light); margin-top: 2px; }
.timeline-time { font-size: 10px; color: var(--gray-400); margin-top: 3px; font-family: 'JetBrains Mono', monospace; }

/* ── ALERT BANNER ── */
.alert {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 10px;
  font-size: 12px;
}

.alert.warning { background: var(--amber-soft); color: #92400E; border-left: 3px solid var(--amber); }
.alert.danger { background: var(--red-soft); color: #991B1B; border-left: 3px solid var(--red); }
.alert.info { background: var(--cyan-soft); color: #0C4A6E; border-left: 3px solid var(--cyan); }
.alert.success { background: var(--green-soft); color: #064E3B; border-left: 3px solid var(--green); }

/* ── CANVAS ── */
canvas { display: block; }

/* ── SECTION HEADER ── */
.section-row { display: flex; align-items: center; margin-bottom: 12px; }
.section-eyebrow { font-size: 10px; font-weight: 700; color: var(--text-light); text-transform: uppercase; letter-spacing: 0.08em; }
.section-divider { flex: 1; height: 1px; background: var(--gray-100); margin-left: 12px; }

/* ── PAGINATION ── */
.pagination { display: flex; align-items: center; gap: 4px; margin-top: 14px; justify-content: flex-end; }

.page-btn {
  width: 28px; height: 28px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--gray-200);
  background: white;
  color: var(--text-light);
  transition: all 0.15s;
}

.page-btn:hover { background: var(--gray-50); }
.page-btn.active { background: var(--blue); color: white; border-color: var(--blue); }

/* ── STAT CHIP ── */
.stat-chip {
  display: flex; flex-direction: column; align-items: center;
  padding: 10px 16px;
  background: var(--gray-50);
  border-radius: 8px;
  border: 1px solid var(--gray-100);
}

.stat-chip-val { font-size: 20px; font-weight: 800; color: var(--text); font-family: 'JetBrains Mono', monospace; line-height: 1; }
.stat-chip-label { font-size: 10px; color: var(--text-light); margin-top: 3px; text-align: center; }

/* ── RESPONSIVE ── */
@media (max-width: 1200px) {
  .grid-3-1 { grid-template-columns: 1fr 1fr; }
  .grid-3-1 > :nth-child(3) { grid-column: 1 / -1; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
}

/* ── HAMBURGER BUTTON ── */
.hamburger-btn {
  display: none;
  align-items: center; justify-content: center;
  width: 36px; height: 36px;
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
  color: var(--text);
  flex-shrink: 0;
  margin-right: 4px;
}

/* ── SIDEBAR OVERLAY ── */
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(8,21,41,0.5);
  z-index: 199;
  backdrop-filter: blur(2px);
}

#sidebar-overlay.show { display: block; }

/* ── TABLET (1024px) ── */
@media (max-width: 1024px) {
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-3-1 { grid-template-columns: 1fr; }
  .grid-3-1 > * { grid-column: 1; }
}

/* ── MOBILE (768px) ── */
@media (max-width: 768px) {

  /* Sidebar: off-screen, slides in */
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 200;
    height: 100vh;
    width: 260px;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 32px rgba(8,21,41,0.25);
  }

  /* Main takes full width */
  .main { width: 100%; }

  /* Show hamburger */
  .hamburger-btn { display: flex; }

  /* Topbar: tighten up */
  .topbar { padding: 0 14px; gap: 8px; }
  .search-box { display: none; }
  .topbar-name, .topbar-role { display: none; }
  .topbar-user { padding: 5px 6px; }

  /* Content padding */
  .content { padding: 14px; }

  /* Grids: single column */
  .kpi-row { grid-template-columns: 1fr 1fr; gap: 10px; }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .grid-3-1 { grid-template-columns: 1fr; }
  .grid-3-1 > * { grid-column: 1; }

  /* Tables: horizontal scroll */
  .card-body { padding: 10px 12px; }
  .card-header { padding: 12px 14px 10px; flex-wrap: wrap; gap: 6px; }

  .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .data-table { min-width: 560px; }

  /* KPI cards */
  .kpi-card { padding: 12px 14px; }
  .kpi-value { font-size: 22px; }

  /* Filter bar */
  .filter-bar { flex-wrap: wrap; gap: 8px; padding: 10px 12px; }
  .filter-spacer { display: none; }
  .filter-bar .btn { width: 100%; justify-content: center; }

  /* Mini tabs */
  .mini-tabs { flex-wrap: wrap; }

  /* Page title */
  .page-title { font-size: 14px; }
  .page-sub { display: none; }
}

/* ── SMALL MOBILE (480px) ── */
@media (max-width: 480px) {
  .kpi-row { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kpi-value { font-size: 19px; }
  .kpi-label { font-size: 10px; }
  .content { padding: 10px; }
  .card-header { gap: 4px; }
  .card-action { font-size: 10px; padding: 3px 6px; }
}
