/* ============================================================
   PLATAFORMA RED PESAJE — Sistema de diseño institucional
   Dirección de Vialidad — reinterpretación moderna, no oficial.
   ============================================================ */

:root {
  /* Paleta */
  --color-primary: #005AA9;
  --color-primary-dark: #00458a;
  --color-secondary: #0A74C4;
  --color-success: #2E7D32;
  --color-warning: #F9A825;
  /* #F9A825 solo es apto como fondo (con texto oscuro encima) o borde decorativo:
     contra blanco da 1.97:1, por debajo del mínimo WCAG 1.4.11 (3:1) para objetos
     gráficos (arcos, líneas de gráficos, íconos). Para esos casos usar esta variante. */
  --color-warning-graphic: #C77D00;
  --color-danger: #C62828;
  --color-bg: #FFFFFF;
  --color-bg-alt: #F5F7FA;
  --color-text: #333333;
  --color-text-secondary: #666666;
  --color-border: #DDDDDD;

  --color-success-bg: #E8F5E9;
  --color-warning-bg: #FFF8E1;
  --color-danger-bg: #FDECEA;
  --color-info-bg: #E8F1FB;

  --font-sans: 'Inter', 'Open Sans', 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  --fs-h1: 40px;
  --fs-h2: 32px;
  --fs-h3: 24px;
  --fs-h4: 20px;
  --fs-body: 16px;
  --fs-small: 14px;

  --radius-sm: 6px;
  --radius-md: 10px;
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-modal: 0 12px 32px rgba(0, 0, 0, 0.18);

  --sidebar-width: 264px;
  --sidebar-width-collapsed: 72px;
  --header-height: 64px;
  --content-max-width: 1400px;

  --transition-fast: 150ms ease;
  --transition-base: 220ms ease;
}

:root[data-theme='dark'] {
  --color-bg: #10161d;
  --color-bg-alt: #161e27;
  --color-text: #e7ebf0;
  --color-text-secondary: #a7b1bc;
  --color-border: #2a3542;
  --color-success-bg: #16281a;
  --color-warning-bg: #2b2210;
  --color-danger-bg: #2b1414;
  --color-info-bg: #10202f;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --color-bg: #10161d;
    --color-bg-alt: #161e27;
    --color-text: #e7ebf0;
    --color-text-secondary: #a7b1bc;
    --color-border: #2a3542;
    --color-success-bg: #16281a;
    --color-warning-bg: #2b2210;
    --color-danger-bg: #2b1414;
    --color-info-bg: #10202f;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--color-bg-alt);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0 0 8px; font-weight: 700; line-height: 1.25; }
h1 { font-size: var(--fs-h1); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); }
h4 { font-size: var(--fs-h4); }
p { margin: 0 0 8px; }
small, .text-small { font-size: var(--fs-small); color: var(--color-text-secondary); }
a { color: var(--color-secondary); }

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--color-secondary);
  outline-offset: 2px;
}

.hidden { display: none !important; }

.skip-link {
  position: absolute; left: 8px; top: -48px;
  background: var(--color-primary); color: #fff;
  padding: 10px 16px; border-radius: var(--radius-sm);
  z-index: 1000; transition: top var(--transition-fast);
  font-weight: 600; text-decoration: none;
}
.skip-link:focus { top: 8px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ============================================================
   LOGIN
   ============================================================ */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
  padding: 24px;
}

.login-card {
  background: var(--color-bg);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-modal);
  width: 100%;
  max-width: 400px;
  padding: 40px 36px;
}

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

.login-brand .brand-mark {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
}

.login-brand .brand-text strong {
  display: block;
  font-size: 16px;
}
.login-brand .brand-text span {
  display: block;
  font-size: var(--fs-small);
  color: var(--color-text-secondary);
}

.login-error {
  background: var(--color-danger-bg);
  color: var(--color-danger);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: var(--fs-small);
  margin-bottom: 16px;
}

.login-demo {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
  font-size: 12px;
  color: var(--color-text-secondary);
}

/* ============================================================
   LAYOUT: HEADER + SIDEBAR
   ============================================================ */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-height);
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  z-index: 100;
}

.offline-banner {
  position: fixed;
  top: var(--header-height);
  left: 0; right: 0;
  z-index: 90;
  background: var(--color-warning-bg);
  color: #8a6100;
  border-bottom: 1px solid var(--color-warning-graphic);
  padding: 8px 20px;
  font-size: 13px;
  text-align: center;
}
.offline-banner .badge-count {
  position: static;
  display: inline-flex;
  margin-left: 6px;
  background: var(--color-warning-graphic);
}

.app-header .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: var(--sidebar-width);
  font-weight: 700;
}
.app-header .brand .brand-mark { width: 30px; height: 30px; }

.header-search {
  flex: 1;
  max-width: 420px;
  position: relative;
}
.header-search input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg-alt);
}
.header-search svg {
  position: absolute;
  left: 10px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px;
  color: var(--color-text-secondary);
}
.header-search-kbd {
  position: absolute;
  right: 10px; top: 50%; transform: translateY(-50%);
  font-family: inherit; font-size: 11px; font-weight: 600;
  color: var(--color-text-secondary);
  background: var(--color-bg); border: 1px solid var(--color-border);
  border-radius: 4px; padding: 2px 6px;
  pointer-events: none;
}
.header-search input:focus ~ .header-search-kbd { display: none; }

.global-search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  max-height: 60vh; overflow-y: auto;
  background: var(--color-bg); border: 1px solid var(--color-border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-modal);
  z-index: 200; padding: 6px;
}
.gs-group-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  color: var(--color-text-secondary); padding: 8px 10px 4px;
}
.gs-item {
  display: flex; flex-direction: column; gap: 1px;
  width: 100%; text-align: left; padding: 8px 10px; border-radius: var(--radius-sm);
  background: none; border: none; cursor: pointer; font: inherit; color: var(--color-text);
}
.gs-item:hover, .gs-item.active { background: var(--color-bg-alt); }
.gs-item-sub { font-size: 12px; color: var(--color-text-secondary); }
.gs-empty { padding: 16px 10px; text-align: center; color: var(--color-text-secondary); font-size: 13px; }

.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  position: relative;
  width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--color-text);
}
.icon-btn:hover { background: var(--color-bg-alt); }

.badge-count {
  position: absolute;
  top: 2px; right: 2px;
  background: var(--color-danger);
  color: #fff;
  font-size: 10px;
  min-width: 16px; height: 16px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.user-menu:hover { background: var(--color-bg-alt); }
.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
  flex-shrink: 0;
}
.user-menu .user-info { line-height: 1.2; text-align: left; }
.user-menu .user-info strong { display: block; font-size: 13px; }
.user-menu .user-info span { display: block; font-size: 12px; color: var(--color-text-secondary); }

.app-sidebar {
  position: fixed;
  top: var(--header-height); bottom: 0; left: 0;
  width: var(--sidebar-width);
  background: var(--color-bg);
  border-right: 1px solid var(--color-border);
  overflow-y: auto;
  transition: width var(--transition-base);
  z-index: 90;
}
.app-sidebar.collapsed { width: var(--sidebar-width-collapsed); }
.app-sidebar.collapsed .nav-label,
.app-sidebar.collapsed .nav-section-title { display: none; }

.nav-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--color-text-secondary);
  padding: 16px 20px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 20px;
  color: var(--color-text);
  text-decoration: none;
  cursor: pointer;
  border-left: 3px solid transparent;
  font-size: 14px;
}
.nav-item svg { width: 20px; height: 20px; flex-shrink: 0; }
.nav-item:hover { background: var(--color-bg-alt); }
.nav-item.active {
  background: var(--color-info-bg);
  color: var(--color-primary);
  border-left-color: var(--color-primary);
  font-weight: 600;
}

.sidebar-toggle {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  border-radius: 50%;
  cursor: pointer;
}

.app-main {
  margin-left: var(--sidebar-width);
  margin-top: var(--header-height);
  padding: 28px 32px 60px;
  width: calc(100% - var(--sidebar-width));
  min-width: 0;
  transition: margin-left var(--transition-base), width var(--transition-base);
}
.app-sidebar.collapsed ~ .app-main { margin-left: var(--sidebar-width-collapsed); width: calc(100% - var(--sidebar-width-collapsed)); }

.content-max {
  max-width: var(--content-max-width);
  margin: 0 auto;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.page-header h1 { font-size: 28px; margin-bottom: 4px; }
.page-header .page-subtitle { color: var(--color-text-secondary); font-size: var(--fs-small); }

.breadcrumb {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px;
  color: var(--color-text-secondary);
  margin-bottom: 6px;
}
.breadcrumb a { color: var(--color-text-secondary); text-decoration: none; }
.breadcrumb .current { color: var(--color-text); font-weight: 600; }

.app-footer {
  margin-left: var(--sidebar-width);
  padding: 20px 32px;
  border-top: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  font-size: 12px;
  transition: margin-left var(--transition-base);
}
.app-sidebar.collapsed ~ .app-footer { margin-left: var(--sidebar-width-collapsed); }

@media (max-width: 960px) {
  .app-sidebar { transform: translateX(-100%); width: 260px; }
  .app-sidebar.mobile-open { transform: translateX(0); }
  .app-main, .app-footer { margin-left: 0 !important; }
  .app-main { width: 100% !important; }
  .header-search { display: none; }
}

/* ============================================================
   BOTONES
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
  white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--color-primary-dark); }

.btn-secondary { background: var(--color-bg); color: var(--color-primary); border-color: var(--color-primary); }
.btn-secondary:hover:not(:disabled) { background: var(--color-info-bg); }

.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #a92121; }

.btn-ghost { background: transparent; color: var(--color-text); }
.btn-ghost:hover:not(:disabled) { background: var(--color-bg-alt); }

.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }

/* ============================================================
   FORMULARIOS
   ============================================================ */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}
.field .hint { font-size: 12px; color: var(--color-text-secondary); margin-top: 4px; }
.field .error-text { font-size: 12px; color: var(--color-danger); margin-top: 4px; display: none; }

.geocoder-results { margin-top: 8px; border: 1px solid var(--color-border); border-radius: var(--radius-sm); overflow: hidden; }
.geocoder-results:empty { display: none; border: none; }
.geocoder-result-item {
  display: block; width: 100%; text-align: left; padding: 8px 12px;
  border: none; border-bottom: 1px solid var(--color-border); background: var(--color-bg);
  cursor: pointer; font-size: 13px; color: var(--color-text);
}
.geocoder-result-item:last-child { border-bottom: none; }
.geocoder-result-item:hover { background: var(--color-info-bg); }

.input, select.input, textarea.input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  color: var(--color-text);
}
.input:focus, select.input:focus, textarea.input:focus {
  border-color: var(--color-secondary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(10, 116, 196, 0.15);
}
.input.invalid { border-color: var(--color-danger); }
textarea.input { resize: vertical; min-height: 90px; }

.form-row { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

.input-group { display: flex; align-items: stretch; }
.input-group .input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-group .input-suffix {
  display: flex; align-items: center; padding: 0 10px; white-space: nowrap;
  border: 1px solid var(--color-border); border-left: none;
  border-top-right-radius: var(--radius-sm); border-bottom-right-radius: var(--radius-sm);
  background: var(--color-bg-alt); color: var(--color-text-secondary); font-size: 14px;
}

.credential-box {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--color-bg-alt); border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  padding: 10px 12px; font-family: monospace; font-size: 15px; margin: 10px 0;
}

.checkbox-row, .radio-row {
  display: flex; align-items: center; gap: 8px; font-size: 14px;
}

.switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; background: var(--color-border);
  border-radius: 22px; cursor: pointer; transition: var(--transition-fast);
}
.switch .slider::before {
  content: ''; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: var(--transition-fast);
}
.switch input:checked + .slider { background: var(--color-primary); }
.switch input:checked + .slider::before { transform: translateX(18px); }

/* ============================================================
   CARDS / KPI
   ============================================================ */
.card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 20px;
  min-width: 0;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.card-header h3 { font-size: 16px; margin: 0; }

.grid { display: grid; gap: 20px; min-width: 0; }
.grid-kpi { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.dashboard-top { display: grid; grid-template-columns: 300px 1fr; gap: 20px; align-items: start; }
@media (max-width: 900px) { .dashboard-top { grid-template-columns: 1fr; } }

.kpi-card {
  display: flex; align-items: center; gap: 14px;
  border-left-width: 4px;
  border-left-style: solid;
}
.kpi-accent-neutral { border-left-color: var(--color-border); }
.kpi-accent-primary { border-left-color: var(--color-primary); }
.kpi-accent-success { border-left-color: var(--color-success); }
.kpi-accent-warning { border-left-color: var(--color-warning-graphic); }
.kpi-accent-danger { border-left-color: var(--color-danger); }

.kpi-icon {
  width: 46px; height: 46px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.kpi-icon svg { width: 24px; height: 24px; }
.kpi-icon-neutral { background: var(--color-bg-alt); color: var(--color-text-secondary); }
.kpi-icon-primary { background: var(--color-info-bg); color: var(--color-primary); }
.kpi-icon-success { background: var(--color-success-bg); color: var(--color-success); }
.kpi-icon-warning { background: var(--color-warning-bg); color: var(--color-warning-graphic); }
.kpi-icon-danger { background: var(--color-danger-bg); color: var(--color-danger); }

.kpi-value { font-size: 26px; font-weight: 700; line-height: 1.1; }
.kpi-label { font-size: 13px; color: var(--color-text-secondary); }
.kpi-delta { font-size: 12px; font-weight: 600; }
.kpi-delta.up { color: var(--color-success); }
.kpi-delta.down { color: var(--color-danger); }

.kpi-clickable { cursor: pointer; transition: border-color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast); }
.kpi-clickable:hover { box-shadow: var(--shadow-modal); transform: translateY(-2px); }

/* ============================================================
   BADGES / ALERTAS / TOAST
   ============================================================ */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge-success { background: var(--color-success-bg); color: var(--color-success); }
.badge-warning { background: var(--color-warning-bg); color: #8a6100; }
.badge-danger { background: var(--color-danger-bg); color: var(--color-danger); }
.badge-info { background: var(--color-info-bg); color: var(--color-primary); }
.badge-neutral { background: var(--color-bg-alt); color: var(--color-text-secondary); }

.alert {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  border: 1px solid transparent;
}
.alert-success { background: var(--color-success-bg); color: var(--color-success); border-color: #b6dab8; }
.alert-warning { background: var(--color-warning-bg); color: #8a6100; border-color: #f0d896; }
.alert-danger { background: var(--color-danger-bg); color: var(--color-danger); border-color: #edb7b3; }
.alert-info { background: var(--color-info-bg); color: var(--color-primary); border-color: #b7d4ec; }

.toast-container {
  position: fixed;
  bottom: 20px; right: 20px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 1000;
}
.toast {
  min-width: 260px; max-width: 360px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-primary);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-modal);
  padding: 12px 16px;
  font-size: 14px;
  animation: toast-in var(--transition-base);
}
.toast.success { border-left-color: var(--color-success); }
.toast.warning { border-left-color: var(--color-warning); }
.toast.danger { border-left-color: var(--color-danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ============================================================
   TABS
   ============================================================ */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--color-border); margin-bottom: 20px; overflow-x: auto; }
.tab-btn {
  padding: 10px 16px; border: none; background: transparent;
  font-weight: 600; font-size: 14px; color: var(--color-text-secondary);
  cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap;
}
.tab-btn.active { color: var(--color-primary); border-bottom-color: var(--color-primary); }

/* ============================================================
   TABLAS
   ============================================================ */
.pagination-bar { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 14px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--color-border); border-radius: var(--radius-md); }
table.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table thead th {
  background: var(--color-bg-alt);
  text-align: left;
  padding: 12px 14px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--color-text-secondary);
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}
.data-table td { padding: 12px 14px; border-bottom: 1px solid var(--color-border); }
.data-table tbody tr:nth-child(even) { background: rgba(0,0,0,0.015); }
.data-table tbody tr:hover { background: var(--color-info-bg); }
.data-table .actions-cell { display: flex; gap: 6px; }
.data-table tbody tr.row-total { background: var(--color-info-bg); border-top: 2px solid var(--color-border); }
.data-table tbody tr.row-total:hover { background: var(--color-info-bg); }

.filters-bar {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end;
  margin-bottom: 16px; padding: 16px; background: var(--color-bg);
  border: 1px solid var(--color-border); border-radius: var(--radius-md);
}
.filters-bar .field { margin-bottom: 0; min-width: 160px; }

.pagination { display: flex; align-items: center; gap: 6px; justify-content: flex-end; margin-top: 14px; }
.pagination button {
  min-width: 32px; height: 32px; border-radius: var(--radius-sm);
  border: 1px solid var(--color-border); background: var(--color-bg); cursor: pointer;
}
.pagination button.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

/* Tablas → tarjetas apiladas en pantallas angostas */
@media (max-width: 720px) {
  .data-table thead { display: none; }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
  .table-wrap { border: none; }
  .data-table tr {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    margin-bottom: 12px;
    padding: 4px 14px;
  }
  .data-table tr:nth-child(even) { background: var(--color-bg); }
  .data-table td {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--color-border);
    text-align: right;
  }
  .data-table td:last-child { border-bottom: none; }
  .data-table td::before {
    content: attr(data-label);
    font-size: 12px; font-weight: 600; color: var(--color-text-secondary);
    text-align: left; margin-right: auto;
  }
  .data-table td.actions-cell { justify-content: flex-end; flex-wrap: wrap; }
  .data-table td.actions-cell::before { content: none; }
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 32, 0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 500; padding: 20px;
}
.modal {
  background: var(--color-bg);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-modal);
  width: 100%; max-width: 560px;
  max-height: 90vh;
  display: flex; flex-direction: column;
}
.modal.modal-lg { max-width: 820px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--color-border);
}
.modal-header h3 { margin: 0; }
.modal-close { border: none; background: transparent; cursor: pointer; padding: 4px; color: var(--color-text-secondary); }
.modal-body { padding: 22px; overflow-y: auto; }
.modal-footer {
  padding: 16px 22px; border-top: 1px solid var(--color-border);
  display: flex; justify-content: flex-end; gap: 10px;
}

/* ============================================================
   DROPDOWN / PANEL NOTIFICACIONES
   ============================================================ */
.dropdown-panel {
  position: absolute; top: calc(100% + 8px); right: 0;
  width: 340px; max-height: 420px; overflow-y: auto;
  background: var(--color-bg); border: 1px solid var(--color-border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-modal);
  z-index: 200;
}
.dropdown-panel .panel-header {
  padding: 14px 16px; border-bottom: 1px solid var(--color-border);
  display: flex; align-items: center; justify-content: space-between; font-weight: 600;
}
.notification-item { padding: 12px 16px; border-bottom: 1px solid var(--color-border); font-size: 13px; cursor: pointer; }
.notification-item:last-child { border-bottom: none; }
.notification-item.unread { background: var(--color-info-bg); }
.notification-item .time { font-size: 11px; color: var(--color-text-secondary); margin-top: 2px; }

/* ============================================================
   ACCORDION / TOOLTIP / TIMELINE
   ============================================================ */
.accordion-item { border: 1px solid var(--color-border); border-radius: var(--radius-sm); margin-bottom: 8px; overflow: hidden; }
.accordion-trigger {
  width: 100%; text-align: left; padding: 12px 14px; background: var(--color-bg-alt);
  border: none; font-weight: 600; cursor: pointer; display: flex; justify-content: space-between; align-items: center;
}
.accordion-panel { padding: 14px; display: none; }
.accordion-item.open .accordion-panel { display: block; }

[data-tooltip] { position: relative; }
[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: #222; color: #fff; padding: 4px 8px; border-radius: 4px; font-size: 12px;
  white-space: nowrap; z-index: 300;
}

.timeline { border-left: 2px solid var(--color-border); margin-left: 8px; padding-left: 20px; }
.timeline-item { position: relative; padding-bottom: 18px; }
.timeline-item::before {
  content: ''; position: absolute; left: -25px; top: 4px;
  width: 10px; height: 10px; border-radius: 50%; background: var(--color-primary);
}
.timeline-item .timeline-date { font-size: 12px; color: var(--color-text-secondary); }

/* ============================================================
   LOADER / SKELETON / EMPTY STATE
   ============================================================ */
.loader {
  width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid var(--color-border); border-top-color: var(--color-primary);
  animation: spin 0.8s linear infinite; margin: 24px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  background: linear-gradient(90deg, var(--color-bg-alt) 25%, rgba(0,0,0,0.04) 37%, var(--color-bg-alt) 63%);
  background-size: 400% 100%;
  animation: skeleton-loading 1.4s ease infinite;
  border-radius: var(--radius-sm);
}
@keyframes skeleton-loading { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

.empty-state { text-align: center; padding: 48px 20px; color: var(--color-text-secondary); }
.empty-state svg { width: 48px; height: 48px; margin-bottom: 12px; opacity: .6; }

/* ============================================================
   GAUGE (velocímetro de operatividad)
   ============================================================ */
.gauge-card { text-align: center; }
.gauge-wrap { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.gauge-svg-wrap {
  width: 100%;
  max-width: 260px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: transform var(--transition-fast);
}
.gauge-svg-wrap:hover, .gauge-svg-wrap:focus-visible { transform: scale(1.03); }
.gauge-svg { width: 100%; height: auto; display: block; }
.gauge-tick { font-size: 11px; font-weight: 600; fill: var(--color-text-secondary); }
.gauge-needle { transform-box: view-box; }
.gauge-value { font-size: 34px; font-weight: 700; line-height: 1.15; margin-top: 2px; }
.gauge-caption { font-size: 13px; color: var(--color-text-secondary); }

/* ============================================================
   MAPA
   ============================================================ */
.map-page { display: grid; grid-template-columns: 280px 1fr; gap: 20px; align-items: start; }
@media (max-width: 900px) { .map-page { grid-template-columns: 1fr; } }
#gis-map { height: 620px; width: 100%; border-radius: var(--radius-md); border: 1px solid var(--color-border); }
.map-legend-item { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: 13px; }
.map-legend-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.leaflet-popup-content h4 { margin: 0 0 6px; color: var(--color-primary); font-size: 14px; }
.leaflet-popup-content p { margin: 2px 0; font-size: 13px; }

/* Mapa en modo oscuro: se invierten los tiles de OSM y se re-tiñen los controles de Leaflet */
.map-dark .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.95) contrast(0.9); }
:root[data-theme='dark'] .leaflet-popup-content-wrapper,
:root[data-theme='dark'] .leaflet-popup-tip { background: var(--color-bg); color: var(--color-text); }
:root[data-theme='dark'] .leaflet-bar a { background: var(--color-bg); color: var(--color-text); border-color: var(--color-border); }
:root[data-theme='dark'] .leaflet-bar a:hover { background: var(--color-bg-alt); }
:root[data-theme='dark'] .leaflet-control-attribution { background: rgba(16, 22, 29, 0.8); color: var(--color-text-secondary); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .leaflet-popup-content-wrapper,
  :root:not([data-theme='light']) .leaflet-popup-tip { background: var(--color-bg); color: var(--color-text); }
  :root:not([data-theme='light']) .leaflet-bar a { background: var(--color-bg); color: var(--color-text); border-color: var(--color-border); }
}

/* ============================================================
   CALENDARIO
   ============================================================ */
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
@media (max-width: 640px) {
  .calendar-grid { gap: 3px; }
  .calendar-cell { min-height: 56px; padding: 4px; font-size: 10.5px; }
  .calendar-day-name { font-size: 10px; }
  .calendar-event-chip { display: none; }
  .calendar-cell.has-events .day-number::after { content: ' •'; color: var(--color-primary); }
}
.calendar-day-name { text-align: center; font-size: 12px; color: var(--color-text-secondary); padding-bottom: 6px; font-weight: 600; }
.calendar-cell {
  min-height: 92px; border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  padding: 6px; font-size: 12px; background: var(--color-bg); cursor: pointer;
}
.calendar-cell:hover { border-color: var(--color-secondary); }
.calendar-cell.today { border-color: var(--color-primary); border-width: 2px; }
.calendar-cell.out-of-month { opacity: .4; }
.calendar-cell .day-number { font-weight: 700; margin-bottom: 4px; }
.calendar-cell .day-events { display: flex; flex-direction: column; gap: 2px; }
.calendar-event-chip {
  font-size: 10.5px; padding: 1px 5px; border-radius: 4px; background: var(--color-info-bg); color: var(--color-primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.calendar-event-chip.holiday { background: var(--color-danger-bg); color: var(--color-danger); }
.calendar-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }

/* Utilidades */
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.text-center { text-align: center; }
.text-muted { color: var(--color-text-secondary); }
.w-100 { width: 100%; }

/* ============================================================
   IMPRESIÓN / REPORTES PDF (Ctrl+P sobre una vista ya filtrada)
   ============================================================ */
.print-only { display: none; }

@media print {
  .app-header, .app-sidebar, .app-footer, .skip-link,
  .filters-bar, .pagination-bar, .btn, .header-search,
  .modal-overlay, .toast-container, .global-search-results,
  .page-header select, .page-header .field {
    display: none !important;
  }
  .data-table:not(.data-table--sin-acciones) th:last-child,
  .data-table:not(.data-table--sin-acciones) td:last-child { display: none; }

  .app-main { margin-left: 0 !important; width: 100% !important; }
  .content-max { max-width: none !important; padding: 0 !important; }
  body { background: #fff !important; color: #000 !important; }
  .card, .table-wrap { box-shadow: none !important; border: 1px solid #999 !important; break-inside: avoid; }
  .badge { border: 1px solid currentColor; }

  .print-only { display: block; margin-top: 24px; padding-top: 12px; border-top: 1px solid #999; font-size: 11px; color: #555; }
}
