/* main.css — Tema municipal clar (versio demo CONMIX-0199/2025)
   Guia: docs/style-guide.md */

/* ======================================================================
   VARIABLES
   ====================================================================== */
:root {
  /* Base */
  --color-bg: #f8f9fa;
  --color-bg-card: #ffffff;
  --color-bg-soft: #f1f3f5;
  --color-bg-input: #ffffff;
  --color-bg-dark: #eef2f6;

  /* Text */
  --color-text: #212529;
  --color-text-strong: #000000;
  --color-muted: #5f6b7a;
  --color-border: #dee2e6;

  /* Municipals */
  --color-accent: #c81e1e;
  --color-accent-dark: #9f1717;
  --color-accent-soft: #fbe9e9;
  --color-danger: #c81e1e;
  --color-warning: #ffc107;
  --color-info: #007bff;
  --color-success: #198754;

  /* Rols */
  --color-pol: #007bff;
  --color-vdg: #b80f6f;
  --color-vul: #ffc107;

  /* Color de rol actiu (sovint sobreescrit a cada dashboard) */
  --rol-color: #c81e1e;

  /* Tipografia */
  --font-main: 'Open Sans', Arial, 'Helvetica Neue', sans-serif;
  --font-mono: 'Consolas', 'Courier New', monospace;

  /* UI */
  --border-radius: 12px;
  --shadow-soft: 0 8px 24px rgba(23, 32, 42, 0.06);
  --shadow-soft-lg: 0 16px 36px rgba(23, 32, 42, 0.1);
  --shadow-danger: 0 10px 24px rgba(200, 30, 30, 0.2);
  --transition: all 0.25s ease;
}

/* ======================================================================
   RESET I BASE
   ====================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-main);
  font-size: 1rem;
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  color: var(--color-text-strong);
  line-height: 1.35;
  letter-spacing: -0.01em;
}

h1,
.display-1,
.display-2,
.display-3,
.display-4 {
  font-size: clamp(2.1rem, 3.2vw, 2.6rem);
}

p,
li,
label,
.small {
  color: var(--color-text);
}

a {
  color: var(--color-info);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: #005ec4;
}

img {
  max-width: 100%;
}

.font-monospace {
  font-family: var(--font-mono) !important;
}

.container-xl {
  max-width: 1380px;
}

section {
  position: relative;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: #edf1f5;
}

::-webkit-scrollbar-thumb {
  background: #c4ccd4;
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: #a5b0bc;
}

/* ======================================================================
   BOOTSTRAP RETHEME (sense reescriure markup existent)
   ====================================================================== */
.text-success {
  color: var(--color-accent) !important;
}

.border-success {
  border-color: rgba(200, 30, 30, 0.35) !important;
}

.bg-success {
  background-color: var(--color-accent) !important;
}

.btn-success {
  --bs-btn-color: #fff;
  --bs-btn-bg: var(--color-accent);
  --bs-btn-border-color: var(--color-accent);
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: var(--color-accent-dark);
  --bs-btn-hover-border-color: var(--color-accent-dark);
  --bs-btn-active-color: #fff;
  --bs-btn-active-bg: #861212;
  --bs-btn-active-border-color: #861212;
  --bs-btn-focus-shadow-rgb: 200, 30, 30;
}

.btn-outline-success {
  --bs-btn-color: var(--color-accent);
  --bs-btn-border-color: var(--color-accent);
  --bs-btn-hover-bg: var(--color-accent);
  --bs-btn-hover-border-color: var(--color-accent);
  --bs-btn-active-bg: var(--color-accent-dark);
  --bs-btn-active-border-color: var(--color-accent-dark);
  --bs-btn-active-color: #fff;
  --bs-btn-focus-shadow-rgb: 200, 30, 30;
}

.badge.bg-danger,
.btn-danger {
  --bs-btn-focus-shadow-rgb: 200, 30, 30;
}

.bg-black {
  background-color: var(--color-bg-card) !important;
}

.navbar-dark {
  --bs-navbar-color: var(--color-text);
  --bs-navbar-brand-color: var(--color-text-strong);
  --bs-navbar-brand-hover-color: var(--color-accent-dark);
  --bs-navbar-hover-color: var(--color-accent-dark);
  --bs-navbar-active-color: var(--color-accent);
  --bs-navbar-toggler-border-color: var(--color-border);
}

.text-muted,
.form-text,
small {
  color: var(--color-muted) !important;
}

.table {
  --bs-table-color: var(--color-text);
}

/* ======================================================================
   TOOLTIPS
   ====================================================================== */
.tooltip {
  --bs-tooltip-bg: #ffffff;
  --bs-tooltip-color: #1e2a36;
  --bs-tooltip-opacity: 1;
  --bs-tooltip-max-width: 320px;
  --bs-tooltip-padding-x: 0.7rem;
  --bs-tooltip-padding-y: 0.6rem;
  font-size: 0.76rem;
}

.tooltip .tooltip-inner {
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-soft);
  text-align: left;
}

/* ======================================================================
   NAVBAR
   ====================================================================== */
.navbar {
  border-bottom: 1px solid var(--color-border) !important;
  background: #ffffff !important;
  backdrop-filter: saturate(120%) blur(3px);
  box-shadow: 0 6px 16px rgba(31, 48, 65, 0.06);
}

.navbar-brand {
  font-family: var(--font-mono);
}

.navbar-brand-title {
  line-height: 1.1;
  font-size: 1.08rem;
  font-weight: 700;
}

.navbar-brand-subtitle {
  font-size: 0.68rem;
  line-height: 1.2;
}

.municipal-menu {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.24rem;
  border: 1px solid #d8e1eb;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffffff 0%, #f6f9fc 100%);
  box-shadow: inset 0 1px 0 #ffffff, 0 6px 14px rgba(31, 48, 65, 0.08);
}

.municipal-menu .menu-link {
  display: inline-flex;
  align-items: center;
  gap: 0.34rem;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.42rem 0.92rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.1;
  color: #30465a;
  text-decoration: none;
  white-space: nowrap;
  transition: var(--transition);
}

.municipal-menu .menu-link:hover {
  color: #193247;
  border-color: #cfddea;
  background: #eaf2fb;
}

.municipal-menu .menu-link.active {
  color: #ffffff;
  border-color: var(--color-accent);
  background: linear-gradient(180deg, var(--color-accent) 0%, var(--color-accent-dark) 100%);
  box-shadow: 0 8px 16px rgba(200, 30, 30, 0.24);
}

.navbar-action {
  white-space: nowrap;
}

@media (max-width: 991.98px) {
  .municipal-menu {
    width: 100%;
    border-radius: 12px;
    overflow-x: auto;
    justify-content: flex-start;
  }
}

@media (max-width: 575.98px) {
  .navbar-brand-title {
    font-size: 1rem;
  }
  .navbar-brand-subtitle {
    font-size: 0.62rem;
  }
}

/* ======================================================================
   MUNICIPAL CHIPS (hero/footer)
   ====================================================================== */
.municipal-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 1rem;
}

.municipal-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid var(--color-border);
  background: #fff;
  border-radius: 999px;
  padding: 0.22rem 0.58rem;
  font-size: 0.7rem;
  color: #23303d;
  font-family: var(--font-mono);
}

.municipal-shield {
  width: 17px;
  height: 17px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.54rem;
  font-weight: 700;
  color: #fff;
}

.municipal-shield.tar {
  background: #c81e1e;
}

.municipal-shield.reu {
  background: #1f1f1f;
}

.municipal-shield.cam {
  background: #007bff;
}

.municipal-shield.mrg {
  background: #b71c1c;
}

.municipal-shield.con {
  background: #c9a227;
  color: #2f2f2f;
}

.municipal-shield.lca {
  background: #8d1a1a;
}

.municipal-shield.eca {
  background: #1f6fb2;
}

/* ======================================================================
   SOS
   ====================================================================== */
.btn-sos {
  width: 168px;
  height: 168px;
  border-radius: 50%;
  border: 3px solid var(--color-danger);
  background: radial-gradient(circle at 34% 30%, #ffebe9 0%, #ffd4cf 55%, #ffc1b8 100%);
  color: var(--color-danger);
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  cursor: pointer;
  position: relative;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 3px;
  box-shadow: var(--shadow-danger);
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease;
  z-index: 1;
}

.btn-sos:hover {
  transform: scale(1.03);
  background: radial-gradient(circle at 34% 30%, #ffe0dd 0%, #ffc9c2 62%, #ffb3a8 100%);
  box-shadow: 0 14px 30px rgba(200, 30, 30, 0.24);
}

.btn-sos:active {
  transform: scale(0.96);
}

.btn-sos .sos-icon {
  font-size: 2rem;
  line-height: 1;
}

.btn-sos .sos-label {
  font-size: 1.08rem;
  letter-spacing: 2px;
}

.btn-sos .sos-sub {
  font-size: 0.58rem;
  opacity: 0.88;
}

.sos-ring-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sos-ring {
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgba(200, 30, 30, 0.28);
  pointer-events: none;
}

.sos-ring-1 {
  width: 210px;
  height: 210px;
  animation: pulse-ring 2.6s ease-out infinite;
}

.sos-ring-2 {
  width: 260px;
  height: 260px;
  animation: pulse-ring 2.6s ease-out infinite 0.55s;
}

.sos-ring-3 {
  width: 310px;
  height: 310px;
  animation: pulse-ring 2.6s ease-out infinite 1.1s;
}

@media (max-width: 576px) {
  .btn-sos {
    width: 190px;
    height: 190px;
  }

  .sos-ring-1 {
    width: 240px;
    height: 240px;
  }

  .sos-ring-2 {
    width: 290px;
    height: 290px;
  }

  .sos-ring-3 {
    width: 340px;
    height: 340px;
  }
}

/* ======================================================================
   CARDS I BADGES
   ====================================================================== */
.feature-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  padding: 1.25rem;
  transition: var(--transition);
  height: 100%;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}

.feature-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  background: var(--color-accent);
  transform: scaleY(0);
  transform-origin: bottom;
  transition: transform 0.25s ease;
}

.feature-card:hover {
  border-color: #c6ced6;
  box-shadow: var(--shadow-soft-lg);
  transform: translateY(-2px);
}

.feature-card:hover::before {
  transform: scaleY(1);
}

.req-badge {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--color-accent-dark);
  background: var(--color-accent-soft);
  border: 1px solid rgba(200, 30, 30, 0.28);
  padding: 2px 7px;
  border-radius: 999px;
  cursor: help;
  vertical-align: middle;
  white-space: nowrap;
}

.btn-glow {
  box-shadow: 0 6px 14px rgba(200, 30, 30, 0.18);
  transition: box-shadow 0.2s ease, transform 0.12s ease;
}

.btn-glow:hover {
  box-shadow: 0 10px 24px rgba(200, 30, 30, 0.26);
}

.btn-glow:active {
  transform: scale(0.98);
}

.btn-neon {
  background: #fff;
  border: 1px solid var(--color-accent);
  color: var(--color-accent);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 0.58rem 1.28rem;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.btn-neon::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(200, 30, 30, 0.12), transparent);
  transition: left 0.45s ease;
}

.btn-neon:hover::before {
  left: 100%;
}

.btn-neon:hover {
  background: #fff5f5;
  color: var(--color-accent-dark);
  box-shadow: var(--shadow-soft);
}

.btn-neon:active {
  transform: scale(0.98);
}

/* ======================================================================
   STATUS DOT
   ====================================================================== */
.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.status-dot.online {
  background: var(--color-success);
  animation: pulse-dot 2.1s ease-in-out infinite;
}

.status-dot.offline {
  background: var(--color-danger);
}

/* ======================================================================
   CCTV
   ====================================================================== */
.camera-card {
  background: #ffffff;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  box-shadow: var(--shadow-soft);
}

.camera-card:hover {
  border-color: #c1cad4;
  box-shadow: var(--shadow-soft-lg);
}

.camera-feed {
  aspect-ratio: 16/9;
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.08) 0, rgba(255, 255, 255, 0.08) 1px, transparent 1px, transparent 4px),
    radial-gradient(ellipse at center, #2b2f35 0%, #191c22 100%);
  position: relative;
  min-height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.camera-feed .scanline {
  position: absolute;
  width: 100%;
  height: 3px;
  pointer-events: none;
  background: linear-gradient(transparent, rgba(204, 223, 245, 0.6), transparent);
  animation: scanline 2.5s linear infinite;
}

.cam-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 6px 8px;
}

.cam-id {
  font-family: var(--font-mono);
  font-size: 0.57rem;
  color: rgba(222, 236, 255, 0.95);
}

.cam-ts,
.cam-bottom {
  font-family: var(--font-mono);
  font-size: 0.53rem;
  color: rgba(208, 223, 240, 0.9);
}

.cam-ts {
  text-align: right;
}

.rec-dot {
  color: #ffefef;
  background: #c81e1e;
  border-radius: 999px;
  padding: 0 5px;
  font-size: 0.54rem;
  font-weight: 700;
  font-family: var(--font-mono);
  width: fit-content;
}

.offline-overlay {
  position: absolute;
  inset: 0;
  background: rgba(25, 29, 36, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: #ffb3b3;
}

.camera-info {
  padding: 8px 10px;
  background: #ffffff;
  border-top: 1px solid var(--color-border);
}

.camera-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

@media (min-width: 576px) {
  .camera-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 992px) {
  .camera-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 1400px) {
  .camera-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ======================================================================
   COMPLIANCE BADGES
   ====================================================================== */
.compliance-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.45px;
  border: 1px solid;
  transition: var(--transition);
  background: #fff;
}

.compliance-badge:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-soft);
}

.compliance-badge.rgpd {
  color: #13795b;
  border-color: #91d5be;
  background: #ecf9f3;
}

.compliance-badge.ens {
  color: #0a58ca;
  border-color: #95bff8;
  background: #edf4ff;
}

.compliance-badge.wcag {
  color: #8a6d00;
  border-color: #ffe08a;
  background: #fff8df;
}

.compliance-badge.ai-act {
  color: #6f42c1;
  border-color: #ccb9ee;
  background: #f5f0ff;
}

.compliance-badge.eudi {
  color: #8b6f00;
  border-color: #f3de8b;
  background: #fff8de;
}

.compliance-badge.lopdgdd {
  color: #0f766e;
  border-color: #8ddad2;
  background: #ebfbf9;
}

/* ======================================================================
   TOASTS
   ====================================================================== */
.alert-toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  border-left: 4px solid;
  background: #ffffff;
  font-size: 0.84rem;
  margin-bottom: 8px;
  box-shadow: var(--shadow-soft-lg);
  color: var(--color-text);
}

.alert-toast.alert-success {
  border-left-color: var(--color-success);
}

.alert-toast.alert-danger {
  border-left-color: var(--color-danger);
}

.alert-toast.alert-warning {
  border-left-color: var(--color-warning);
}

.alert-toast.alert-info {
  border-left-color: var(--color-info);
}

.alert-close {
  background: none;
  border: none;
  color: #768596;
  cursor: pointer;
  padding: 0;
  margin-left: auto;
  font-size: 1.1rem;
  line-height: 1;
  flex-shrink: 0;
}

.alert-close:hover {
  color: #1a2b3c;
}

/* ======================================================================
   DASHBOARD LAYOUT
   ====================================================================== */
.dash-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: 268px;
  flex-shrink: 0;
  background: #ffffff;
  border-right: 1px solid #e4eaf1;
  display: flex;
  flex-direction: column;
  transition: transform 0.28s cubic-bezier(.4,0,.2,1);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  /* Scrollbar fina */
  scrollbar-width: thin;
  scrollbar-color: #d8e2ec transparent;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: #d8e2ec; border-radius: 2px; }

/* ── Capçalera: logo ── */
.sidebar-header {
  padding: 1.1rem 1.1rem 0.85rem;
  border-bottom: 1px solid #edf1f5;
  background: linear-gradient(135deg, #fafbfc 0%, #ffffff 100%);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  margin-bottom: 1rem;
}
.sidebar-logo-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--rol-color);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--rol-color) 30%, transparent);
}
.sidebar-logo-icon i { color: #fff; font-size: .85rem; }
.sidebar-logo-text  { font-family: var(--font-mono); font-size: .82rem; font-weight: 700; color: #1f2f41; line-height: 1.2; }
.sidebar-logo-sub   { font-size: .6rem; color: #8a9bb0; font-family: var(--font-mono); font-weight: 400; }

/* ── Avatar + info usuari ── */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: .6rem .7rem;
  border-radius: 10px;
  background: #f5f8fc;
  border: 1px solid #e4eaf1;
  margin-bottom: .55rem;
}
.sidebar-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--rol-color);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: .78rem;
  font-weight: 700;
  color: #fff;
  box-shadow: 0 2px 6px color-mix(in srgb, var(--rol-color) 35%, transparent);
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name {
  font-size: .78rem;
  font-weight: 600;
  color: #1f2f41;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  line-height: 1.2;
}
.sidebar-user-rol {
  font-family: var(--font-mono);
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--rol-color);
  margin-top: 1px;
}

/* ── Municipi / pill ── */
.sidebar-location {
  display: flex; align-items: center; gap: 5px;
  font-family: var(--font-mono);
  font-size: .65rem; color: #8a9bb0;
  padding: .15rem 0 .05rem .1rem;
}
.sidebar-location i { color: var(--rol-color); font-size: .62rem; }

/* ── Separador de secció ── */
.sidebar-section-label {
  font-family: var(--font-mono);
  font-size: .58rem;
  font-weight: 700;
  letter-spacing: .1em;
  color: #b0beca;
  text-transform: uppercase;
  padding: .65rem 1.1rem .25rem;
}

/* ── Navegació ── */
.sidebar-nav {
  list-style: none;
  padding: .4rem 0;
  flex: 1;
}

.sidebar-nav li { padding: 0 .65rem; margin-bottom: 2px; }

.sidebar-nav a,
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: .52rem .75rem;
  color: #44515f;
  font-size: .83rem;
  font-weight: 500;
  transition: all .18s ease;
  border-radius: 9px;
  text-decoration: none;
  position: relative;
}

/* Icona amb fons subtle */
.sidebar-icon {
  width: 28px; height: 28px;
  border-radius: 7px;
  background: transparent;
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem;
  flex-shrink: 0;
  transition: all .18s ease;
  color: #768596;
}

/* Hover */
.sidebar-nav a:hover,
.sidebar-link:hover {
  color: var(--rol-color);
  background: color-mix(in srgb, var(--rol-color) 7%, transparent);
}
.sidebar-nav a:hover .sidebar-icon,
.sidebar-link:hover .sidebar-icon {
  background: color-mix(in srgb, var(--rol-color) 12%, transparent);
  color: var(--rol-color);
}

/* Actiu */
.sidebar-nav a.active,
.sidebar-link.active {
  color: var(--rol-color);
  background: color-mix(in srgb, var(--rol-color) 10%, transparent);
  font-weight: 600;
}
.sidebar-nav a.active .sidebar-icon,
.sidebar-link.active .sidebar-icon {
  background: var(--rol-color);
  color: #ffffff;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--rol-color) 40%, transparent);
}
/* Accent dot actiu */
.sidebar-nav a.active::after {
  content: '';
  position: absolute;
  right: .6rem;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--rol-color);
  opacity: .55;
}

/* Badge dins sidebar-link */
.sidebar-link .badge {
  font-size: .58rem !important;
  padding: .2em .45em;
  border-radius: 999px;
}

/* ── Footer ── */
.sidebar-footer {
  padding: .85rem 1rem 1rem;
  border-top: 1px solid #edf1f5;
  background: #fafbfc;
}
.sidebar-footer .sidebar-version {
  font-family: var(--font-mono);
  font-size: .58rem;
  color: #b0beca;
  margin-bottom: .55rem;
  line-height: 1.6;
}
.sidebar-logout {
  display: flex; align-items: center; gap: 8px;
  padding: .5rem .75rem;
  border-radius: 9px;
  border: 1px solid #f1d0d0;
  background: #fff9f9;
  color: #c0392b;
  font-family: var(--font-mono);
  font-size: .75rem;
  font-weight: 600;
  text-decoration: none;
  transition: all .18s ease;
  width: 100%;
  justify-content: center;
}
.sidebar-logout:hover {
  background: #c0392b;
  border-color: #c0392b;
  color: #fff;
}
.sidebar-logout i { font-size: .78rem; }

/* ── Main ── */
.dash-main {
  flex: 1;
  padding: 1.6rem;
  min-width: 0;
  overflow-x: hidden;
  background: var(--color-bg);
}

/* ── Overlay mòbil ── */
.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.32);
  z-index: 1039;
  backdrop-filter: blur(2px);
}
.sidebar-backdrop.show { display: block; }

@media (max-width: 991.98px) {
  .sidebar {
    position: fixed;
    left: 0; top: 0;
    z-index: 1040;
    transform: translateX(-100%);
    box-shadow: var(--shadow-soft-lg);
    height: 100vh;
  }
  .sidebar.show,
  .sidebar.open { transform: translateX(0); }
  .dash-main { padding: 1rem; }
}

/* ======================================================================
   MAPA GIS (Leaflet + components)
   ====================================================================== */

/* Contenidor exterior */
.map-gis-outer,
[id="map-gis"] {
  border: 1px solid var(--color-border);
  border-radius: 10px;
  overflow: hidden;
}

/* Canvas Leaflet */
.gis-canvas {
  display: block;
  width: 100%;
}

.leaflet-container {
  background: #e8edf3 !important;
}

.leaflet-control-zoom a {
  background: #ffffff !important;
  color: #1f2f41 !important;
  border-color: var(--color-border) !important;
}

/* ── Toolbar ── */
.gis-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 12px;
  background: #ffffff;
  border-bottom: 1px solid var(--color-border);
  flex-wrap: wrap;
}

[data-bs-theme="dark"] .gis-toolbar {
  background: #1a1d21;
  border-bottom-color: #2c2f34;
}

/* Chips de capa */
.gis-chips {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.gis-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1.5px solid var(--cc, #6c757d);
  font-size: .7rem;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: background .14s, color .14s;
  background: transparent;
  color: var(--cc, #6c757d);
  white-space: nowrap;
  line-height: 1;
}

.gis-chip:hover {
  background: color-mix(in srgb, var(--cc, #6c757d) 12%, transparent);
}

.gis-chip.active {
  background: var(--cc, #6c757d);
  color: #fff;
}

.gis-chip-n {
  background: rgba(0, 0, 0, .12);
  border-radius: 10px;
  padding: 1px 5px;
  font-size: .62rem;
  min-width: 16px;
  text-align: center;
}

.gis-chip:not(.active) .gis-chip-n {
  background: color-mix(in srgb, var(--cc, #6c757d) 15%, transparent);
}

/* Separador */
.gis-sep {
  width: 1px;
  height: 22px;
  background: var(--color-border);
  flex-shrink: 0;
}

/* Selects de filtre */
.gis-filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.gis-sel {
  height: 28px;
  font-size: .72rem;
  font-family: var(--font-mono);
  border: 1px solid var(--color-border);
  border-radius: 20px;
  padding: 0 10px;
  background: #fff;
  color: var(--color-text);
  cursor: pointer;
  outline: none;
  max-width: 160px;
}

.gis-sel:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px rgba(200, 30, 30, .12);
}

[data-bs-theme="dark"] .gis-sel {
  background: #22252a;
  color: #cdd5de;
  border-color: #3a3e46;
}

/* Botons d'acció */
.gis-actions {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.gis-act-btn {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: 1px solid var(--color-border);
  background: #fff;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .13s, border-color .13s, color .13s;
  font-size: .78rem;
}

.gis-act-btn:hover {
  background: var(--color-bg-hover, #f0f3f7);
  border-color: var(--color-accent);
  color: var(--color-accent);
}

[data-bs-theme="dark"] .gis-act-btn {
  background: #22252a;
  border-color: #3a3e46;
  color: #8a95a3;
}

/* Stats overlay (Leaflet control) */
.gis-stats {
  background: rgba(255, 255, 255, .93);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(0, 0, 0, .09);
  border-radius: 8px;
  padding: 9px 12px;
  font-family: var(--font-mono);
  font-size: .68rem;
  pointer-events: none;
  box-shadow: 0 2px 14px rgba(0, 0, 0, .1);
  min-width: 155px;
}

.gis-stat {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 2px 0;
}

.gis-stat-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.gis-stat-sub {
  margin-left: auto;
  font-size: .63rem;
}

.gis-stat-alert {
  color: #dc3545;
  font-weight: 600;
}

/* Llegenda (Leaflet control) */
.gis-legend {
  background: rgba(255, 255, 255, .93);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(0, 0, 0, .09);
  border-radius: 8px;
  padding: 10px 13px;
  font-family: var(--font-mono);
  font-size: .69rem;
  box-shadow: 0 2px 14px rgba(0, 0, 0, .1);
}

.gis-legend-title {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #6c757d;
  font-size: .62rem;
  margin-bottom: 7px;
}

.gis-legend-row {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 4px;
  color: #495057;
}

.gis-legend-ic {
  width: 17px;
  height: 17px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 8px;
  flex-shrink: 0;
}

.gis-legend-tri {
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  flex-shrink: 0;
}

.gis-tri-alta  { border-bottom: 12px solid #dc3545; }
.gis-tri-mitja { border-bottom: 12px solid #fd7e14; }
.gis-tri-baixa { border-bottom: 12px solid #ffc107; }

/* ======================================================================
   CHAT
   ====================================================================== */
.chat-container {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  background: #ffffff;
  height: 100%;
  min-height: 350px;
  box-shadow: var(--shadow-soft);
  padding: 0.5rem;
}

.chat-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-body,
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-footer {
  padding: 0.75rem;
  border-top: 1px solid var(--color-border);
}

.chat-msg {
  display: flex;
  flex-direction: column;
  max-width: 82%;
}

.chat-msg.enviat {
  align-self: flex-end;
  align-items: flex-end;
}

.chat-msg.rebut {
  align-self: flex-start;
  align-items: flex-start;
}

.chat-msg.sistema {
  align-self: center;
}

.chat-bubble {
  padding: 0.52rem 0.78rem;
  border-radius: 12px;
  font-size: 0.84rem;
  word-break: break-word;
  border: 1px solid var(--color-border);
  background: #fff;
}

.chat-msg.enviat .chat-bubble {
  background: #edf4ff;
  border-color: #cde0ff;
}

.chat-msg.rebut .chat-bubble {
  background: #ffffff;
}

.chat-msg.sistema .chat-bubble {
  background: #fff4e4;
  border-color: #ffe0aa;
  color: #7f5f0a;
  font-size: 0.74rem;
  font-family: var(--font-mono);
}

.chat-de {
  font-weight: 700;
}

.chat-hora {
  font-size: 0.64rem;
  color: var(--color-muted);
  margin-top: 2px;
  font-family: var(--font-mono);
}

/* ======================================================================
   PANELL ALERTA
   ====================================================================== */
.alert-active-panel {
  background: #fff1f1;
  border: 1px solid rgba(200, 30, 30, 0.55);
  border-radius: var(--border-radius);
  padding: 1rem;
  animation: alert-flash 1.8s ease-in-out infinite;
}

/* ======================================================================
   MISC
   ====================================================================== */
.spinner-neon {
  width: 36px;
  height: 36px;
  border: 3px solid #dde4ec;
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.kpi-card {
  background: #ffffff;
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  padding: 1.1rem;
  box-shadow: var(--shadow-soft);
}

.kpi-value {
  font-family: var(--font-mono);
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--rol-color);
  line-height: 1;
}

.kpi-label {
  font-size: 0.74rem;
  color: var(--color-muted);
  margin-top: 6px;
}

.table-dark-custom {
  --bs-table-bg: #ffffff;
  --bs-table-color: var(--color-text);
  --bs-table-border-color: #dce3ea;
  --bs-table-striped-bg: #f8fbfe;
  --bs-table-hover-bg: #f1f6fb;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}

.table-dark-custom th {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.2px;
}

.section-header {
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 0.75rem;
  margin-bottom: 1.25rem;
}

.section-title {
  font-family: var(--font-mono);
  color: var(--rol-color);
  font-size: 1rem;
}

.section-note {
  color: var(--color-muted);
  font-size: 1rem;
  margin-top: 0.35rem;
  max-width: 68ch;
}

.glitch {
  position: relative;
}

.glitch::before {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  color: rgba(200, 30, 30, 0.34);
  animation: glitch-1 6s infinite;
  clip-path: polygon(0 0, 100% 0, 100% 28%, 0 28%);
  opacity: 0.4;
  pointer-events: none;
}

.blink {
  animation: blink 1.25s step-end infinite;
}

.fade-in-up {
  animation: fadeInUp 0.55s ease both;
}

.btn-xs {
  font-size: 0.68rem;
  line-height: 1;
  padding: 0.2rem 0.38rem;
}

/* ======================================================================
   FORMULARIS
   ====================================================================== */
.form-control,
.form-select {
  background: var(--color-bg-input) !important;
  color: var(--color-text) !important;
  border-color: #ccd5df !important;
  border-radius: 10px;
}

.form-control:focus,
.form-select:focus {
  background: var(--color-bg-input) !important;
  border-color: #90b8f8 !important;
  box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.16) !important;
  color: var(--color-text) !important;
}

.form-control::placeholder {
  color: #8995a2 !important;
}

/* ======================================================================
   LOGIN
   ====================================================================== */
.login-page {
  background: radial-gradient(circle at 8% 10%, #fff4f3 0%, #f8f9fa 45%, #edf2f7 100%);
}

.login-wrapper {
  max-width: 560px;
}

.login-card {
  background: #ffffff;
  border: 1px solid var(--color-border);
  border-radius: 16px;
  box-shadow: var(--shadow-soft-lg);
}

.quick-access-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  margin-bottom: 1.2rem;
}

.quick-login-btn {
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 0.85rem 0.9rem;
  text-align: left;
  background: #ffffff;
  transition: var(--transition);
  width: 100%;
}

.quick-login-btn .label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 700;
}

.quick-login-btn .hint {
  display: block;
  font-size: 0.75rem;
  color: var(--color-muted);
}

.quick-login-btn.ciutada {
  border-color: rgba(200, 30, 30, 0.34);
  background: #fff4f4;
  color: #8f1414;
}

.quick-login-btn.policia {
  border-color: rgba(0, 123, 255, 0.34);
  background: #edf4ff;
  color: #0d4fa8;
}

.quick-login-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-soft);
}

@media (min-width: 576px) {
  .quick-access-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* ======================================================================
   MODALS I OVERRIDES DE CONTINGUT LEGAT
   ====================================================================== */
.modal-content.bg-black {
  background: #ffffff !important;
  color: var(--color-text);
}

.modal-content.bg-black .text-success {
  color: var(--color-accent) !important;
}

.modal-content.bg-black .modal-header,
.modal-content.bg-black .modal-footer {
  border-color: var(--color-border) !important;
}

.modal-content.bg-black .btn-close-white {
  filter: none;
}

/* ======================================================================
   RESPONSIVE
   ====================================================================== */
@media (max-width: 767.98px) {
  body {
    font-size: 0.98rem;
  }

  .kpi-value {
    font-size: 1.65rem;
  }

  .btn-neon,
  .btn-glow,
  .quick-login-btn {
    font-size: 0.8rem;
  }
}
