/* ==========================================================================
   منصة «ميثاق القصيم» — غرفة العمليات الملكية للموارد البشرية وجودة البيانات
   Option 1: Dark Royal Command Center (SDAIA / Vision 2030) + Option 2 Light Toggle
   أمانة منطقة القصيم (27 بلدية) — المنصة الموحدة للموارد البشرية
   ========================================================================== */

:root,
[data-theme="dark"] {
  --bg: #040D0B;
  --bg-mesh:
    radial-gradient(circle at 18% 12%, rgba(16, 185, 129, 0.22), transparent 40%),
    radial-gradient(circle at 84% 10%, rgba(212, 175, 55, 0.16), transparent 36%),
    radial-gradient(circle at 52% 92%, rgba(13, 148, 136, 0.14), transparent 44%);
  --surface: rgba(12, 27, 24, 0.74);
  --surface-strong: rgba(14, 34, 29, 0.92);
  --surface-elevated: rgba(17, 39, 34, 0.88);
  --surface-subtle: rgba(255, 255, 255, 0.045);
  --surface-hover: rgba(255, 255, 255, 0.075);

  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.15);
  --border-accent: rgba(52, 211, 153, 0.32);
  --border-gold: rgba(229, 185, 92, 0.34);

  --ink: #F1FAF7;
  --ink-800: #E5F5F0;
  --ink-600: #B9D4CC;
  --ink-500: #8EB2A8;
  --ink-400: #6B8F85;
  --muted: #8EB2A8;

  --accent: #10B981;
  --accent-bright: #34D399;
  --accent-deep: #059669;
  --accent-2: #E5B95C;
  --accent-2-bright: #F3D182;

  --emerald-800: #34D399;
  --emerald-700: #10B981;
  --emerald-50: rgba(16, 185, 129, 0.12);
  --gold-700: #E5B95C;
  --gold-50: rgba(229, 185, 92, 0.12);

  --accent-soft: rgba(16, 185, 129, 0.14);
  --gold-soft: rgba(229, 185, 92, 0.14);

  --ok: #34D399;
  --ok-bg: rgba(16, 185, 129, 0.15);
  --warn: #E5B95C;
  --warn-bg: rgba(229, 185, 92, 0.15);
  --danger: #FB7185;
  --danger-bg: rgba(244, 63, 94, 0.15);
  --info: #38BDF8;
  --info-bg: rgba(56, 189, 248, 0.14);

  --hero-bg: linear-gradient(135deg, rgba(11, 46, 38, 0.86) 0%, rgba(7, 25, 22, 0.94) 60%, rgba(28, 25, 14, 0.78) 100%);
  --map-bg: radial-gradient(circle at 50% 50%, rgba(16, 185, 129, 0.18), rgba(4, 13, 11, 0.62));
  --ai-banner-bg: linear-gradient(135deg, #10B981 0%, #059669 100%);
  --ai-banner-ink: #031510;

  --pill-bg: rgba(255, 255, 255, 0.055);
  --pill-active-bg: linear-gradient(135deg, #10B981, #059669);
  --pill-active-ink: #031510;

  --bar-track: rgba(255, 255, 255, 0.08);
  --bar-grad-1: #34D399;
  --bar-grad-2: #059669;
  --grid-line: rgba(255, 255, 255, 0.07);
  --gauge-track: rgba(255, 255, 255, 0.10);

  --shadow: 0 22px 54px rgba(0, 0, 0, 0.44);
  --shadow-sm: 0 10px 26px rgba(0, 0, 0, 0.28);
  --shadow-glow: 0 0 28px rgba(16, 185, 129, 0.22);

  --input-bg: rgba(7, 19, 16, 0.82);
  --table-head-bg: rgba(255, 255, 255, 0.04);
  --table-row-hover: rgba(16, 185, 129, 0.06);
  --modal-backdrop: rgba(2, 8, 7, 0.76);
  --radius-xl: 24px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

[data-theme="light"] {
  --bg: #F1F6F4;
  --bg-mesh:
    radial-gradient(circle at 18% 12%, rgba(16, 185, 129, 0.14), transparent 44%),
    radial-gradient(circle at 84% 10%, rgba(200, 155, 60, 0.14), transparent 38%),
    radial-gradient(circle at 52% 92%, rgba(11, 93, 71, 0.08), transparent 46%);
  --surface: rgba(255, 255, 255, 0.88);
  --surface-strong: rgba(255, 255, 255, 0.96);
  --surface-elevated: #FFFFFF;
  --surface-subtle: rgba(11, 93, 71, 0.045);
  --surface-hover: rgba(11, 93, 71, 0.075);

  --border: rgba(11, 93, 71, 0.11);
  --border-strong: rgba(11, 93, 71, 0.20);
  --border-accent: rgba(11, 93, 71, 0.26);
  --border-gold: rgba(184, 134, 40, 0.34);

  --ink: #0B221D;
  --ink-800: #102B25;
  --ink-600: #2E4B44;
  --ink-500: #4C6961;
  --ink-400: #6D8780;
  --muted: #4C6961;

  --accent: #0B5D47;
  --accent-bright: #10B981;
  --accent-deep: #074333;
  --accent-2: #B88628;
  --accent-2-bright: #D4A13B;

  --emerald-800: #0B5D47;
  --emerald-700: #0F755A;
  --emerald-50: rgba(11, 93, 71, 0.08);
  --gold-700: #A1731C;
  --gold-50: rgba(200, 155, 60, 0.12);

  --accent-soft: rgba(11, 93, 71, 0.10);
  --gold-soft: rgba(200, 155, 60, 0.14);

  --ok: #059669;
  --ok-bg: rgba(5, 150, 105, 0.12);
  --warn: #B45309;
  --warn-bg: rgba(217, 119, 6, 0.13);
  --danger: #DC2626;
  --danger-bg: rgba(220, 38, 38, 0.11);
  --info: #0284C7;
  --info-bg: rgba(2, 132, 199, 0.11);

  --hero-bg: linear-gradient(135deg, rgba(255, 255, 255, 0.96) 0%, rgba(235, 247, 242, 0.94) 60%, rgba(252, 246, 232, 0.92) 100%);
  --map-bg: radial-gradient(circle at 50% 50%, rgba(11, 93, 71, 0.12), rgba(236, 246, 242, 0.92));
  --ai-banner-bg: linear-gradient(135deg, #0B5D47 0%, #073D2F 100%);
  --ai-banner-ink: #FFFFFF;

  --pill-bg: rgba(11, 93, 71, 0.065);
  --pill-active-bg: linear-gradient(135deg, #0B5D47, #108465);
  --pill-active-ink: #FFFFFF;

  --bar-track: rgba(11, 93, 71, 0.09);
  --bar-grad-1: #10B981;
  --bar-grad-2: #0B5D47;
  --grid-line: rgba(11, 93, 71, 0.08);
  --gauge-track: rgba(11, 93, 71, 0.11);

  --shadow: 0 18px 44px rgba(11, 45, 36, 0.09);
  --shadow-sm: 0 8px 20px rgba(11, 45, 36, 0.06);
  --shadow-glow: 0 0 24px rgba(11, 93, 71, 0.14);

  --input-bg: #FFFFFF;
  --table-head-bg: rgba(11, 93, 71, 0.045);
  --table-row-hover: rgba(11, 93, 71, 0.04);
  --modal-backdrop: rgba(6, 24, 19, 0.56);
}

/* ==================== RESET & BASE ==================== */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  font-size: 15px;
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'IBM Plex Sans Arabic', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  overflow-x: hidden;
  transition: background-color 0.35s ease, color 0.35s ease;
  -webkit-font-smoothing: antialiased;
}

.ambient-mesh {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image: var(--bg-mesh);
  pointer-events: none;
}

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

/* ==================== CINEMATIC KEYFRAME ANIMATIONS ==================== */
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulseLive {
  0%, 100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.55); transform: scale(1); }
  50% { box-shadow: 0 0 0 7px rgba(52, 211, 153, 0); transform: scale(1.06); }
}

@keyframes radarSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes dataFlow {
  from { stroke-dashoffset: 36; }
  to { stroke-dashoffset: 0; }
}

@keyframes nodePulse {
  0%, 100% { opacity: 0.75; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.22); }
}

@keyframes scanSweep {
  0% { transform: translateX(110%); }
  100% { transform: translateX(-110%); }
}

@keyframes spinSlow {
  to { transform: rotate(360deg); }
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.anim-fade-up {
  animation: fadeSlideUp 0.52s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.stagger-1 { animation-delay: 0.05s; }
.stagger-2 { animation-delay: 0.11s; }
.stagger-3 { animation-delay: 0.17s; }
.stagger-4 { animation-delay: 0.23s; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-bright);
  display: inline-block;
  flex-shrink: 0;
  animation: pulseLive 2.2s infinite;
}

/* ==================== SLEEK FLOATING TOP BAR ==================== */
.topbar {
  position: sticky;
  top: 12px;
  z-index: 60;
  margin: 12px 18px 0;
  padding: 10px 16px;
  border-radius: 20px;
  background: var(--surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  flex-shrink: 0;
}

.brand-emblem {
  width: 40px;
  height: 40px;
  border-radius: 13px;
  background: var(--pill-active-bg);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: 0 8px 20px rgba(16, 185, 129, 0.26);
}

.brand-titles {
  min-width: 0;
}

.brand-main {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.2px;
  white-space: nowrap;
}

.tender-pill {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--gold-soft);
  color: var(--accent-2);
  border: 1px solid var(--border-gold);
}

.brand-sub {
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Desktop Segmented 5-Role Switcher */
.role-switcher {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--pill-bg);
  border: 1px solid var(--border);
  padding: 4px;
  border-radius: 14px;
  min-width: 0;
}

.role-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 7px 12px;
  border-radius: 10px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.22s ease;
}

.role-btn:hover {
  color: var(--ink);
  background: var(--surface-hover);
}

.role-btn.active {
  background: var(--pill-active-bg);
  color: var(--pill-active-ink);
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.24);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--pill-bg);
  color: var(--ink);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.icon-btn:hover {
  border-color: var(--border-accent);
  background: var(--accent-soft);
  color: var(--accent-bright);
  transform: translateY(-1px);
}

.menu-toggle {
  display: none;
}

.mobile-role-wrap {
  display: none;
}

.mobile-role-select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--pill-bg);
  border: 1px solid var(--border-accent);
  color: var(--ink);
  border-radius: 11px;
  padding: 6px 12px 6px 26px;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  max-width: 144px;
  text-overflow: ellipsis;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2334D399' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 8px center;
}

.mobile-role-select option {
  background: #0B1B18;
  color: #F1FAF7;
}

[data-theme="light"] .mobile-role-select option {
  background: #FFFFFF;
  color: #0B221D;
}

/* ==================== BUTTONS ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 13px;
  padding: 10px 16px;
  font-size: 0.83rem;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.22s cubic-bezier(0.22, 1, 0.36, 1);
  white-space: nowrap;
}

.btn svg {
  flex-shrink: 0;
}

.btn-sm {
  padding: 7px 13px;
  font-size: 0.77rem;
  border-radius: 10px;
}

.btn-primary {
  background: var(--pill-active-bg);
  color: var(--pill-active-ink);
  box-shadow: 0 10px 26px rgba(16, 185, 129, 0.24);
}

.btn-primary:hover {
  transform: translateY(-1.5px);
  box-shadow: 0 14px 32px rgba(16, 185, 129, 0.34);
  filter: brightness(1.06);
}

.btn-gold {
  background: linear-gradient(135deg, #E5B95C, #C89B3C);
  color: #161105;
  box-shadow: 0 10px 24px rgba(229, 185, 92, 0.24);
}

.btn-gold:hover {
  transform: translateY(-1.5px);
  filter: brightness(1.06);
}

.btn-outline,
.btn-soft,
.hero-btn-glass {
  background: var(--pill-bg);
  color: var(--ink);
  border: 1px solid var(--border);
}

.btn-outline:hover,
.btn-soft:hover,
.hero-btn-glass:hover {
  border-color: var(--border-accent);
  background: var(--accent-soft);
  color: var(--ink);
  transform: translateY(-1px);
}

.btn-danger-soft {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(244, 63, 94, 0.28);
}

.btn-danger-soft:hover {
  background: rgba(244, 63, 94, 0.22);
}

/* ==================== APP SHELL & SIDEBAR ==================== */
.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  gap: 18px;
  padding: 16px 18px 40px;
  max-width: 1580px;
  margin: 0 auto;
  align-items: start;
}

.drawer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--modal-backdrop);
  backdrop-filter: blur(6px);
  z-index: 80;
}

.drawer-backdrop.open {
  display: block;
}

.sidebar {
  position: sticky;
  top: 84px;
  background: var(--surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 14px 12px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: calc(100vh - 102px);
  overflow-y: auto;
}

.sidebar-mobile-head {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px 12px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.sidebar-mobile-actions {
  display: none;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.nav-group-label {
  font-size: 0.69rem;
  font-weight: 700;
  color: var(--ink-400);
  padding: 10px 10px 4px;
  letter-spacing: 0.2px;
}

.nav-group-label:first-of-type {
  padding-top: 2px;
}

.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 11px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 0.81rem;
  font-weight: 600;
  cursor: pointer;
  text-align: right;
  transition: all 0.2s ease;
}

.nav-item:hover {
  background: var(--surface-hover);
  color: var(--ink);
}

.nav-item.active {
  background: var(--accent-soft);
  border-color: var(--border-accent);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px rgba(52, 211, 153, 0.14);
}

.nav-item.active .nav-icon {
  color: var(--accent-bright);
}

.nav-item-left {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-400);
  flex-shrink: 0;
}

.nav-badge {
  font-size: 0.67rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  flex-shrink: 0;
}

.nav-badge.ok { background: var(--ok-bg); color: var(--ok); }
.nav-badge.gold { background: var(--gold-soft); color: var(--accent-2); }
.nav-badge.danger { background: var(--danger-bg); color: var(--danger); }

.sidebar-footer-card {
  margin-top: 10px;
  padding: 12px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent-soft), var(--gold-soft));
  border: 1px solid var(--border-accent);
}

.sidebar-footer-title {
  font-size: 0.77rem;
  font-weight: 700;
  color: var(--accent-bright);
  margin-bottom: 4px;
}

[data-theme="light"] .sidebar-footer-title {
  color: var(--accent);
}

.sidebar-footer-text {
  font-size: 0.7rem;
  color: var(--muted);
  line-height: 1.5;
}

/* ==================== MAIN WORKSPACE ==================== */
.main-content {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.loading-shell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 90px 20px;
  color: var(--muted);
  font-weight: 600;
}

.loading-spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--accent-bright);
  animation: spinSlow 0.8s linear infinite;
}

/* ==================== OPTION 1 COMMAND CENTER BENTO ==================== */
.bento-command {
  display: grid;
  grid-template-columns: 1.48fr 1fr;
  gap: 18px;
  align-items: stretch;
}

.bento-col-main,
.bento-col-side {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}

/* Hero Showcase Card with Qassim 27-Node Radar Constellation */
.hero-card {
  background: var(--hero-bg);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-xl);
  padding: 22px 24px;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: 1.12fr 0.96fr;
  gap: 18px;
  align-items: center;
  position: relative;
  overflow: hidden;
}

.hero-card.compact-hero {
  grid-template-columns: 1.35fr 0.75fr;
  padding: 20px 24px;
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.73rem;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent-bright);
  border: 1px solid rgba(52, 211, 153, 0.22);
  margin-bottom: 12px;
}

[data-theme="light"] .hero-eyebrow {
  color: var(--accent);
}

.hero-title {
  margin: 0 0 9px;
  font-size: 1.56rem;
  font-weight: 700;
  line-height: 1.34;
  letter-spacing: -0.3px;
  color: var(--ink);
}

.hero-desc {
  margin: 0 0 18px;
  font-size: 0.84rem;
  color: var(--muted);
  line-height: 1.68;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* Interactive Qassim 27-Node Constellation Box */
.map-box {
  height: 244px;
  border-radius: 20px;
  background: var(--map-bg);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.constellation-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.radar-sweep-group {
  transform-origin: 185px 96px;
  animation: radarSpin 11s linear infinite;
}

.flow-line {
  stroke-dasharray: 5 7;
  animation: dataFlow 2.6s linear infinite;
}

.flow-line-slow {
  stroke-dasharray: 3 8;
  animation: dataFlow 3.8s linear infinite;
}

.hub-halo {
  transform-origin: 185px 96px;
  animation: nodePulse 3.2s ease-in-out infinite;
}

.muni-node-group {
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.muni-node-group:hover .node-dot {
  filter: drop-shadow(0 0 8px currentColor);
  transform-box: fill-box;
  transform-origin: center;
  transform: scale(1.32);
}

.node-dot {
  transition: transform 0.2s ease, filter 0.2s ease;
}

.map-tooltip {
  position: absolute;
  top: 10px;
  right: 12px;
  background: var(--surface-strong);
  border: 1px solid var(--border-accent);
  border-radius: 11px;
  padding: 7px 11px;
  font-size: 0.72rem;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 5;
  box-shadow: var(--shadow-sm);
}

.map-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

.map-caption {
  position: absolute;
  bottom: 10px;
  right: 11px;
  left: 11px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  font-size: 0.69rem;
  color: var(--muted);
  background: var(--surface-strong);
  padding: 6px 11px;
  border-radius: 10px;
  border: 1px solid var(--border);
  backdrop-filter: blur(10px);
}

.map-caption strong {
  color: var(--ink);
}

/* ==================== 4 KPI GLASS CARDS ==================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.kpi-card {
  background: var(--surface);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 15px 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  transition: transform 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease;
}

.kpi-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-accent);
  box-shadow: var(--shadow), var(--shadow-glow);
}

.kpi-card.gold:hover {
  border-color: var(--border-gold);
}

.kpi-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.kpi-label {
  font-size: 0.76rem;
  color: var(--muted);
  font-weight: 500;
}

.kpi-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-bright);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

[data-theme="light"] .kpi-icon {
  color: var(--accent);
}

.kpi-card.gold .kpi-icon {
  background: var(--gold-soft);
  color: var(--accent-2);
}

.kpi-card.danger .kpi-icon {
  background: var(--danger-bg);
  color: var(--danger);
}

.kpi-card.info .kpi-icon {
  background: var(--info-bg);
  color: var(--info);
}

.kpi-value {
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--ink);
  line-height: 1.15;
}

.kpi-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 0.72rem;
  color: var(--muted);
}

.kpi-delta {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent-bright);
}

[data-theme="light"] .kpi-delta {
  color: var(--accent);
}

.kpi-chip {
  font-size: 0.67rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}
.kpi-chip.ok { background: var(--ok-bg); color: var(--ok); }
.kpi-chip.gold { background: var(--gold-soft); color: var(--accent-2); }
.kpi-chip.danger { background: var(--danger-bg); color: var(--danger); }
.kpi-chip.info { background: var(--info-bg); color: var(--info); }

/* ==================== DUAL GLOWING RADIAL GAUGES ==================== */
.gauges-card {
  background: var(--surface);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 18px;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.gauge-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 7px;
  padding: 14px 10px;
  border-radius: 16px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  transition: border-color 0.22s ease, transform 0.22s ease;
}

.gauge-box:hover {
  border-color: var(--border-accent);
  transform: translateY(-2px);
}

.gauge-ring-wrap {
  position: relative;
  width: 114px;
  height: 114px;
}

.gauge-svg {
  width: 114px;
  height: 114px;
  transform: rotate(-90deg);
}

.gauge-track {
  fill: none;
  stroke: var(--gauge-track);
  stroke-width: 9;
}

.gauge-fill {
  fill: none;
  stroke-width: 9;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s cubic-bezier(0.22, 1, 0.36, 1);
}

.gauge-fill.emerald {
  stroke: var(--accent-bright);
  filter: drop-shadow(0 0 8px rgba(52, 211, 153, 0.45));
}

[data-theme="light"] .gauge-fill.emerald {
  stroke: var(--accent);
  filter: none;
}

.gauge-fill.gold {
  stroke: var(--accent-2);
  filter: drop-shadow(0 0 8px rgba(229, 185, 92, 0.42));
}

[data-theme="light"] .gauge-fill.gold {
  filter: none;
}

.gauge-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.gauge-val {
  font-size: 1.32rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.1;
}

.gauge-sub {
  font-size: 0.67rem;
  color: var(--muted);
  margin-top: 2px;
}

.gauge-label {
  font-size: 0.81rem;
  font-weight: 700;
  color: var(--ink);
}

.gauge-caption {
  font-size: 0.7rem;
  color: var(--muted);
}

/* ==================== LIVE MUNICIPALITY COMPLIANCE BARS CARD ==================== */
.bars-card {
  background: var(--surface);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
}

.bar-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bar-item {
  display: grid;
  grid-template-columns: minmax(112px, 132px) 1fr 48px;
  align-items: center;
  gap: 10px;
  padding: 5px 8px;
  margin: 0 -8px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.18s ease;
}

.bar-item:hover {
  background: var(--surface-hover);
}

.bar-name {
  font-size: 0.77rem;
  font-weight: 600;
  color: var(--ink-800);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bar-track {
  height: 9px;
  border-radius: 999px;
  background: var(--bar-track);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--bar-grad-2), var(--bar-grad-1));
  transition: width 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}

.bar-fill.gold {
  background: linear-gradient(90deg, #C89B3C, #F3D182);
}

.bar-fill.coral {
  background: linear-gradient(90deg, #E11D48, #FB7185);
}

.bar-pct {
  font-size: 0.77rem;
  font-weight: 700;
  text-align: left;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* ==================== LUMINOUS AI BANNER (MATCHING OPTION 1) ==================== */
.ai-banner {
  background: var(--ai-banner-bg);
  color: var(--ai-banner-ink);
  border-radius: var(--radius-xl);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  box-shadow: 0 18px 38px rgba(16, 185, 129, 0.24);
}

.ai-banner h3 {
  margin: 0;
  font-size: 0.93rem;
  font-weight: 700;
}

.ai-banner p {
  margin: 3px 0 0;
  font-size: 0.74rem;
  opacity: 0.88;
}

.ai-banner-btn {
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.18);
  color: inherit;
  padding: 9px 15px;
  border-radius: 12px;
  font-size: 0.79rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: all 0.2s ease;
}

.ai-banner-btn:hover {
  background: rgba(255, 255, 255, 0.28);
  transform: translateY(-1px);
}

/* ==================== GLASS CARDS & CHARTS ==================== */
.card {
  background: var(--surface);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.card-title {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--ink);
}

.card-subtitle {
  margin: 3px 0 0;
  font-size: 0.76rem;
  color: var(--muted);
}

.chip {
  font-size: 0.71rem;
  font-weight: 700;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-bright);
  border: 1px solid rgba(52, 211, 153, 0.22);
  white-space: nowrap;
}

[data-theme="light"] .chip {
  color: var(--accent);
}

.charts-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.charts-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.chart-wrap {
  position: relative;
  width: 100%;
  height: 265px;
}

.chart-wrap.tall {
  height: 310px;
}

.chart-wrap.hero-trend {
  height: 225px;
}

/* ==================== FILTER PILLS, INPUTS, TOOLBARS ==================== */
.pill-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.filter-pill {
  border: 1px solid var(--border);
  background: var(--pill-bg);
  color: var(--muted);
  border-radius: 10px;
  padding: 6px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.filter-pill:hover {
  border-color: var(--border-accent);
  color: var(--ink);
}

.filter-pill.active {
  background: var(--pill-active-bg);
  color: var(--pill-active-ink);
  border-color: transparent;
}

.input,
.select {
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 8px 12px;
  font-size: 0.81rem;
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.input:focus,
.select:focus {
  border-color: var(--accent-bright);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.16);
}

.input::placeholder {
  color: var(--ink-400);
}

.select option {
  background: #0B1B18;
  color: #F1FAF7;
}

[data-theme="light"] .select option {
  background: #FFFFFF;
  color: #0B221D;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-label {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--muted);
}

/* ==================== BADGES & AVATARS ==================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.71rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-gold { background: var(--gold-soft); color: var(--accent-2); }
.badge-neutral { background: var(--pill-bg); color: var(--muted); border: 1px solid var(--border); }

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--accent-soft);
  border: 1px solid var(--border-accent);
  color: var(--accent-bright);
  font-weight: 700;
  font-size: 0.78rem;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

[data-theme="light"] .avatar {
  color: var(--accent);
}

/* ==================== TABLES ==================== */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border-radius: 14px;
  border: 1px solid var(--border);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.81rem;
}

.data-table th {
  text-align: right;
  padding: 11px 13px;
  background: var(--table-head-bg);
  color: var(--muted);
  font-weight: 700;
  font-size: 0.74rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 11px 13px;
  border-bottom: 1px solid var(--border);
  color: var(--ink);
  vertical-align: middle;
}

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

.data-table tbody tr:hover {
  background: var(--table-row-hover);
}

.us-cell {
  color: var(--ok) !important;
  font-weight: 600;
}

/* ==================== MUNICIPALITIES GRID ==================== */
.muni-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.muni-card {
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  cursor: pointer;
  transition: all 0.22s ease;
}

.muni-card:hover {
  border-color: var(--border-accent);
  background: var(--surface-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.muni-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.muni-name {
  font-size: 0.89rem;
  font-weight: 700;
  color: var(--ink);
  margin-top: 2px;
}

.score-bar {
  height: 7px;
  border-radius: 999px;
  background: var(--bar-track);
  overflow: hidden;
}

.score-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}
.score-bar-fill.score-high { background: linear-gradient(90deg, var(--bar-grad-2), var(--bar-grad-1)); }
.score-bar-fill.score-mid { background: linear-gradient(90deg, #C89B3C, #F3D182); }
.score-bar-fill.score-low { background: linear-gradient(90deg, #E11D48, #FB7185); }

.muni-stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  text-align: center;
}

.muni-stat-v {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--ink);
}

.muni-stat-l {
  font-size: 0.68rem;
  color: var(--muted);
}

/* ==================== AI SCANNER PANEL ==================== */
.ai-scanner-panel {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-xl);
  padding: 22px 24px;
  background: var(--hero-bg);
  border: 1px solid var(--border-accent);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

.ai-scanner-panel::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(52, 211, 153, 0.14), transparent);
  transform: translateX(110%);
  pointer-events: none;
}

.ai-scanner-panel.scanning::after {
  animation: scanSweep 1.3s ease-in-out infinite;
}

.scan-progress-track {
  height: 8px;
  border-radius: 999px;
  background: var(--bar-track);
  overflow: hidden;
  margin-top: 14px;
}

.scan-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #10B981, #34D399, #E5B95C);
  transition: width 0.22s ease;
}

.scan-live-feed {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
  font-size: 0.78rem;
  color: var(--muted);
}

/* ==================== OFFICIAL A4 DOCUMENT & QR (ALWAYS CRISP WHITE PAPER!) ==================== */
.doc-paper {
  background: #FFFFFF;
  color: #0E221D;
  border-radius: 16px;
  border: 1px solid #D5E2DD;
  padding: 34px 38px;
  max-width: 820px;
  margin: 0 auto;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.34);
}

.doc-paper * {
  color: inherit;
}

.doc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 2px solid #0B5D47;
  margin-bottom: 22px;
}

.doc-emblem-circle {
  width: 62px;
  height: 62px;
  border-radius: 16px;
  background: linear-gradient(135deg, #0B5D47, #073D2F);
  display: grid;
  place-items: center;
}

.doc-table {
  width: 100%;
  border-collapse: collapse;
  margin: 18px 0 22px;
  font-size: 0.85rem;
}

.doc-table td {
  padding: 10px 12px;
  border: 1px solid #D8E4DF;
}

.doc-table td.lbl {
  background: #F4F9F7;
  font-weight: 700;
  color: #0B5D47;
  width: 24%;
}

.doc-footer {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-top: 26px;
  padding-top: 18px;
  border-top: 1px dashed #B9CEC7;
}

.doc-seal {
  width: 118px;
  height: 118px;
  border-radius: 50%;
  border: 2.5px double #0B5D47;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: #0B5D47;
  background: rgba(11, 93, 71, 0.04);
}

/* ==================== INTEGRATIONS, TIMELINE & GOVERNANCE ==================== */
.integrations-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.integration-card {
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.integration-card:hover {
  border-color: var(--border-accent);
  transform: translateY(-2px);
}

.timeline-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 78px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
}

.timeline-day {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--accent-2);
  background: var(--gold-soft);
  padding: 4px 8px;
  border-radius: 8px;
  text-align: center;
}

/* ==================== EXPORT STRIP ==================== */
.export-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

/* ==================== FLOATING AI ASSISTANT ==================== */
.ai-fab {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 75;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 11px 18px;
  border-radius: 999px;
  border: 1px solid rgba(52, 211, 153, 0.42);
  background: linear-gradient(135deg, #0D3A2F, #06211B);
  color: #F1FAF7;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.46), 0 0 22px rgba(16, 185, 129, 0.25);
  transition: all 0.22s ease;
}

.ai-fab:hover {
  transform: translateY(-2px);
  border-color: #34D399;
}

.ai-drawer {
  position: fixed;
  bottom: 76px;
  left: 20px;
  width: min(410px, calc(100vw - 24px));
  max-height: 76vh;
  z-index: 85;
  background: var(--surface-strong);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border: 1px solid var(--border-accent);
  border-radius: 22px;
  box-shadow: 0 26px 68px rgba(0, 0, 0, 0.56);
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.ai-drawer.open {
  display: flex;
  animation: fadeSlideUp 0.26s ease both;
}

.ai-drawer-head {
  padding: 14px 16px;
  background: linear-gradient(135deg, #0C4B3B, #072C23);
  color: #F1FAF7;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid rgba(52, 211, 153, 0.25);
}

.ai-drawer-title {
  font-weight: 700;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-drawer-sub {
  font-size: 0.71rem;
  color: #A7D7C5;
  margin-top: 2px;
}

.ai-close-btn {
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #FFFFFF;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 190px;
  max-height: 310px;
}

.ai-msg {
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 0.8rem;
  line-height: 1.62;
  white-space: pre-line;
  max-width: 92%;
}

.ai-msg.bot {
  align-self: flex-start;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  color: var(--ink);
}

.ai-msg.user {
  align-self: flex-end;
  background: var(--pill-active-bg);
  color: var(--pill-active-ink);
  font-weight: 600;
}

.ai-chips {
  padding: 8px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  border-top: 1px solid var(--border);
}

.ai-chip {
  border: 1px solid var(--border);
  background: var(--pill-bg);
  color: var(--muted);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
}

.ai-chip:hover {
  border-color: var(--border-accent);
  color: var(--ink);
  background: var(--accent-soft);
}

.ai-input-row {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
}

/* ==================== MODAL & TOASTS ==================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 95;
  background: var(--modal-backdrop);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-backdrop.open {
  display: flex;
}

.modal-card {
  width: min(740px, 100%);
  max-height: 86vh;
  overflow-y: auto;
  background: var(--surface-strong);
  border: 1px solid var(--border-accent);
  border-radius: 22px;
  padding: 20px 22px;
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.56);
  animation: fadeSlideUp 0.24s ease both;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.modal-head h3 {
  margin: 0;
  font-size: 1.04rem;
  color: var(--accent-bright);
}

[data-theme="light"] .modal-head h3 {
  color: var(--accent);
}

.toast-stack {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(400px, calc(100vw - 32px));
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 15px;
  border-radius: 14px;
  background: var(--surface-strong);
  border: 1px solid var(--border-accent);
  color: var(--ink);
  font-size: 0.81rem;
  font-weight: 600;
  box-shadow: var(--shadow);
  animation: toastIn 0.28s ease both;
}

/* ==================== RESPONSIVE BREAKPOINTS ==================== */
@media (max-width: 1280px) {
  .bento-command {
    grid-template-columns: 1fr;
  }
  .role-btn {
    padding: 6px 9px;
    font-size: 0.74rem;
  }
  .tender-pill {
    display: none;
  }
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 1fr;
    padding: 12px 14px 86px;
  }
  .menu-toggle {
    display: grid;
  }
  .role-switcher,
  .desktop-only-action,
  .brand-sub {
    display: none;
  }
  .mobile-role-wrap {
    display: block;
  }
  .sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(296px, 84vw);
    max-height: 100vh;
    border-radius: 22px 0 0 22px;
    z-index: 90;
    transform: translateX(110%);
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-mobile-head,
  .sidebar-mobile-actions {
    display: flex;
  }
  .muni-grid,
  .integrations-grid,
  .charts-grid-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  /* Ultra-clean 58px Mobile Topbar — ZERO clutter! */
  .topbar {
    top: 8px;
    margin: 8px 10px 0;
    padding: 8px 11px;
    border-radius: 16px;
    min-height: 56px;
    gap: 8px;
  }
  .brand-emblem {
    width: 34px;
    height: 34px;
    border-radius: 10px;
  }
  .brand-main {
    font-size: 0.9rem;
  }
  .icon-btn {
    width: 35px;
    height: 35px;
    border-radius: 10px;
  }
  .mobile-role-select {
    max-width: 132px;
    font-size: 0.72rem;
    padding: 6px 9px 6px 22px;
  }
  .app-shell {
    padding: 10px 10px 84px;
    gap: 12px;
  }
  .hero-card,
  .hero-card.compact-hero {
    grid-template-columns: 1fr;
    padding: 16px;
    gap: 14px;
    border-radius: 20px;
  }
  .hero-title {
    font-size: 1.24rem;
  }
  .hero-desc {
    font-size: 0.8rem;
    margin-bottom: 14px;
  }
  .hero-actions .btn {
    flex: 1 1 auto;
    font-size: 0.76rem;
    padding: 9px 12px;
  }
  .map-box {
    height: 215px;
  }
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .kpi-card {
    padding: 13px;
    border-radius: 16px;
  }
  .kpi-value {
    font-size: 1.32rem;
  }
  .gauges-card {
    padding: 12px;
    gap: 10px;
  }
  .gauge-ring-wrap,
  .gauge-svg {
    width: 96px;
    height: 96px;
  }
  .gauge-val {
    font-size: 1.08rem;
  }
  .charts-grid-2,
  .charts-grid-3,
  .muni-grid,
  .integrations-grid,
  .form-grid {
    grid-template-columns: 1fr !important;
  }
  .card,
  .bars-card {
    padding: 15px;
    border-radius: 18px;
  }
  .bar-item {
    grid-template-columns: 104px 1fr 44px;
    gap: 8px;
  }
  .ai-banner {
    flex-direction: column;
    align-items: flex-start;
  }
  .ai-banner-btn {
    width: 100%;
    justify-content: center;
  }
  .timeline-item {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .doc-paper {
    padding: 18px;
  }
  .doc-header,
  .doc-footer {
    flex-direction: column;
    align-items: flex-start;
  }
  .ai-fab {
    bottom: 14px;
    left: 14px;
    padding: 10px 15px;
    font-size: 0.78rem;
  }
  .ai-drawer {
    left: 10px;
    right: 10px;
    width: auto;
    bottom: 66px;
  }
}

/* ==================== PRINT STYLESHEET ==================== */
@media print {
  body {
    background: #FFFFFF !important;
    color: #0E221D !important;
  }
  .no-print,
  .topbar,
  .sidebar,
  .ai-fab,
  .ai-drawer,
  .toast-stack,
  .modal-backdrop,
  .ambient-mesh {
    display: none !important;
  }
  .app-shell {
    display: block;
    padding: 0;
  }
  .card,
  .kpi-card,
  .hero-card,
  .gauges-card,
  .bars-card {
    background: #FFFFFF !important;
    color: #0E221D !important;
    box-shadow: none !important;
    border: 1px solid #CCCCCC !important;
    break-inside: avoid;
  }
  .doc-paper {
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
  }
}


/* Final micro-polish */
.chart-box { position: relative; height: 250px; width: 100%; }
.chart-box.tall { height: 295px; }
.chart-box.hero-trend { height: 215px; }
.workspace { padding-bottom: 92px; }
[data-theme="light"] .ai-banner { color: #FFFFFF; }
[data-theme="light"] .ai-banner .ai-btn { background: rgba(255,255,255,0.22); color: #FFFFFF; border-color: rgba(255,255,255,0.45); }


/* ==================== PAGE PRESENTATION GUIDE BAR ==================== */
.page-guide-bar {
  background: var(--surface);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--border-gold);
  border-radius: 18px;
  padding: 12px 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s ease, background 0.2s ease;
}
.page-guide-bar.collapsed {
  padding: 9px 15px;
  border-color: var(--border);
}
.page-guide-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}
.page-guide-title-wrap {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.guide-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--gold-soft);
  color: var(--accent-2);
  font-size: 0.72rem;
  font-weight: 700;
  border: 1px solid var(--border-gold);
}
.guide-view-name {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--ink);
}
.guide-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--pill-bg);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 5px 11px;
  font-family: inherit;
  font-size: 0.73rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.18s ease, border-color 0.18s ease;
}
.guide-toggle-btn:hover {
  color: var(--ink);
  border-color: var(--border-accent);
}
.page-guide-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.guide-cell {
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
}
.guide-k {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent-bright);
  margin-bottom: 4px;
}
[data-theme="light"] .guide-k { color: var(--accent); }
.guide-k.gold { color: var(--accent-2); }
.guide-k.info { color: var(--info); }
.guide-cell p {
  margin: 0;
  font-size: 0.76rem;
  line-height: 1.58;
  color: var(--ink-700);
}
@media (max-width: 900px) {
  .page-guide-grid { grid-template-columns: 1fr; gap: 8px; }
  .guide-view-name { font-size: 0.8rem; }
}


/* ==================== CLEAN SUB-TAB BAR (5-SECTION SIMPLIFICATION) ==================== */
.subtab-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  background: var(--surface);
  backdrop-filter: blur(18px);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 6px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.subtab-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}
.subtab-btn:hover {
  color: var(--ink);
  background: var(--pill-bg);
}
.subtab-btn.active {
  background: var(--pill-active-bg);
  color: var(--pill-active-ink);
  box-shadow: 0 6px 18px rgba(16, 185, 129, 0.22);
}
.subtab-btn.active .nav-badge {
  background: rgba(0, 0, 0, 0.22);
  color: #FFFFFF;
}
