

:root {
  /* ---- COLOUR PALETTE ---- */
  
  /* Nashik Municipal Corporation brand colours */
  --color-primary: #0c6795;
  --color-primary-dark: #084b6d;
  --color-primary-light: #2080b0;
  --color-primary-lighter: #85b3c9;
  
  /* Secondary civic accent */
  --color-secondary: #be0108;
  --color-secondary-dark: #8f0006;
  --color-secondary-light: #f1c6c8;
  
  /* Semantic Colours */
  --color-success: #4caf50;           /* Green for positive/success states */
  --color-success-light: #e8f5e9;     /* Light green background */
  --color-warning: #ff9800;           /* Orange for warnings */
  --color-warning-light: #fff3e0;     /* Light orange background */
  --color-danger: #f44336;            /* Red for errors/danger */
  --color-danger-light: #ffebee;      /* Light red background */
  --color-info: #2080b0;
  --color-info-light: #e6f0f5;
  
  /* Neutral / Greyscale */
  --color-dark: #333;                 /* Dark text/backgrounds */
  --color-text: #1a202c;              /* Main text colour */
  --color-text-light: #4a5568;        /* Secondary/muted text */
  --color-text-lighter: #718096;      /* Very light text (captions) */
  --color-light: #f5f7fa;             /* Light background */
  --color-light-2: #ecf0f3;           /* Slightly darker light background */
  --color-surface: #ffffff;           /* Card/surface background */
  --color-border: #e0e0e0;            /* Border colour */
  --color-border-light: #f0f0f0;      /* Lighter border */
  --color-bg: #f7fafc;                /* Page background */
  
  /* Dark Mode (Future) */
  --color-dark-bg: #1a202c;           /* Dark mode background */
  --color-dark-surface: #2d3748;      /* Dark mode card/surface */
  --color-dark-text: #f7fafc;         /* Dark mode text */
  --color-dark-text-light: #cbd5e0;   /* Dark mode secondary text */
  
  /* Focus / Accessibility */
  --color-focus: #be0108;
  --color-focus-ring: rgba(190, 1, 8, 0.28);
  
  /* ---- TYPOGRAPHY ---- */
  
  /* Font Families */
  --font-base: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;  /* Windows system font */
  --font-devanagari: 'Noto Sans Devanagari', 'Mangal', sans-serif; /* For Marathi/Hindi */
  --font-mono: 'Courier New', Courier, monospace;  /* For code blocks */
  
  /* Font Sizes - Uniform sizing */
  --font-size-xs: 0.875rem;           /* 14px - Helper text */
  --font-size-sm: 0.875rem;           /* 14px - Secondary text (SAME as xs) */
  --font-size-base: 0.95rem;          /* 15px - Body text (UNIFORM) */
  --font-size-lg: 0.95rem;            /* 15px - Secondary text (SAME as base) */
  --font-size-xl: 1.25rem;            /* 20px - Shared heading size */
  --font-size-2xl: 1.5rem;            /* 24px - Large emphasis */
  --font-size-3xl: 1.75rem;           /* 28px - Display emphasis */
  --font-size-4xl: 2rem;              /* 32px - Large display emphasis */
  
  /* Font Weights */
  --font-weight-normal: 400;          /* Regular text */
  --font-weight-medium: 500;          /* Slightly heavier */
  --font-weight-semibold: 600;        /* Bold labels */
  --font-weight-bold: 700;            /* Strong emphasis */
  
  /* Line Heights */
  --line-height-tight: 1.2;           /* Headings, compact text */
  --line-height-normal: 1.6;          /* Body text, default */
  --line-height-relaxed: 1.8;         /* Loose text, readable copy */
  
  /* ---- SPACING ---- */
  /* Based on 8px unit scale */
  
  --space-0: 0;                       /* 0px */
  --space-1: 0.25rem;                 /* 4px - Micro spacing */
  --space-2: 0.5rem;                  /* 8px - Small spacing */
  --space-3: 0.75rem;                 /* 12px - Compact spacing */
  --space-4: 1rem;                    /* 16px - Standard spacing */
  --space-6: 1.5rem;                  /* 24px - Medium spacing */
  --space-8: 2rem;                    /* 32px - Large spacing */
  --space-12: 3rem;                   /* 48px - Extra large spacing */
  --space-16: 4rem;                   /* 64px - Hero spacing */
  
  /* ---- BORDER RADIUS ---- */
  
  --radius-none: 0;                   /* Square corners */
  --radius-sm: 0.25rem;               /* 4px - Slight rounding */
  --radius-base: 0.5rem;              /* 8px - Standard rounding */
  --radius-lg: 1rem;                  /* 16px - Prominent rounding */
  --radius-full: 9999px;              /* Fully rounded (pills, badges) */
  
  /* ---- SHADOWS ---- */
  
  --shadow-none: none;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-base: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.1);
  --shadow-elevation: 0 25px 50px rgba(0, 0, 0, 0.15);
  
  /* ---- TRANSITIONS & MOTION ---- */
  
  --transition-fast: 150ms;
  --transition-base: 250ms;
  --transition-slow: 350ms;
  --easing-ease-out: cubic-bezier(0.4, 0, 0.2, 1);
  --easing-ease-in: cubic-bezier(0.4, 0, 1, 1);
  --easing-ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  
  /* ---- RESPONSIVE BREAKPOINTS ---- */
  /* Use in @media queries */
  --breakpoint-xs: 0px;
  --breakpoint-sm: 640px;
  --breakpoint-md: 768px;
  --breakpoint-lg: 1024px;
  --breakpoint-xl: 1280px;
  --breakpoint-2xl: 1536px;
  
  /* ---- CONTAINER WIDTHS ---- */
  
  --container-max-width: 1440px;
  --container-padding: clamp(1rem, 2vw, 2rem);
}

/* ===========================
   GLOBAL STYLES
   =========================== */

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

html {
  font-size: calc(16px * var(--font-scale, 1));
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-base);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: var(--line-height-normal);
  font-size: var(--font-size-base);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Support for Marathi/Hindi text */
[lang="mr"], [lang="hi"] {
  font-family: var(--font-devanagari), var(--font-base);
}

/* ===========================
   TYPOGRAPHY UTILITIES
   =========================== */

h1, h2, h3, h4, h5, h6 {
  font-family: inherit;
  font-size: var(--font-size-xl);
  font-style: normal;
  line-height: var(--line-height-tight);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text);
  margin-bottom: var(--space-4);
}

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

p {
  margin-bottom: var(--space-4);
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition-base) var(--easing-ease-out);
}

a:hover {
  color: var(--color-primary-dark);
  text-decoration: underline;
}

a:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ===========================
   CONTAINER & LAYOUT
   =========================== */

.container {
  width: 100%;
  max-width: var(--container-max-width);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--container-padding);
  padding-right: var(--container-padding);
}

.grid-2 {
  display: grid;
  grid-template-columns: 250px 1fr;
  gap: var(--space-8);
}

.dataset-card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2);
  min-width: 0;
}

.dataset-card-title {
  flex: 1 1 10rem;
  min-width: 0;
  margin: 0;
}

.dataset-card-metrics {
  flex: 0 1 auto;
  max-width: 100%;
  color: var(--color-text-light);
  font-size: var(--font-size-xs);
  text-align: right;
  white-space: normal;
}

.grid-auto {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-6);
}

/* ===========================
   BUTTON COMPONENT
   =========================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-base);
  cursor: pointer;
  border: none;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  transition: all var(--transition-base) var(--easing-ease-out);
  font-family: inherit;
  white-space: nowrap;
}

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

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Button Variants */

.btn-primary {
  background: var(--color-primary);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-dark);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: var(--color-secondary);
  color: white;
}

.btn-secondary:hover:not(:disabled) {
  background: var(--color-secondary-dark);
  box-shadow: var(--shadow-md);
}

.btn-ghost {
  background: transparent;
  color: var(--color-primary);
  border: 1px solid var(--color-border);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--color-light);
  border-color: var(--color-primary);
}

.btn-danger {
  background: var(--color-danger);
  color: white;
}

.btn-danger:hover:not(:disabled) {
  background: darken(var(--color-danger), 10%);
  box-shadow: var(--shadow-md);
}

.btn-success {
  background: var(--color-success);
  color: white;
}

.btn-success:hover:not(:disabled) {
  background: darken(var(--color-success), 10%);
  box-shadow: var(--shadow-md);
}

.btn-small {
  padding: var(--space-2) var(--space-3);
  font-size: var(--font-size-xs);
}

.btn-large {
  padding: var(--space-4) var(--space-6);
  font-size: var(--font-size-base);
}

.btn-block {
  display: flex;
  width: 100%;
}

/* ===========================
   CARD COMPONENT
   =========================== */

.card {
  background: var(--color-surface);
  border-radius: var(--radius-base);
  box-shadow: var(--shadow-base);
  padding: var(--space-6);
  margin-bottom: var(--space-4);
  transition: box-shadow var(--transition-base) var(--easing-ease-out);
}

.card:hover {
  box-shadow: var(--shadow-lg);
}

.card-header {
  margin-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-border);
  padding-bottom: var(--space-4);
}

.card-body {
  margin-bottom: var(--space-4);
}

.card-footer {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border);
}

#page-help .faq-list {
  display: grid;
  gap: var(--space-4);
  max-width: 56rem;
  margin-bottom: var(--space-8);
}

#page-help.active {
  min-height: 0;
}

#page-help .faq-card {
  margin: 0;
  padding: var(--space-4) var(--space-6);
  border: 1px solid var(--color-border-light);
}

#page-help .faq-question {
  margin: 0;
  color: var(--color-primary);
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-tight);
}

#page-help .faq-question button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  line-height: inherit;
  text-align: left;
  cursor: pointer;
}

#page-help .faq-question button:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

#page-help .faq-question button > span:first-child {
  min-width: 0;
  overflow-wrap: anywhere;
}

#page-help .faq-indicator {
  width: 0.55rem;
  height: 0.55rem;
  flex: 0 0 auto;
  margin-right: var(--space-1);
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform var(--transition-base) var(--easing-ease-out);
}

#page-help .faq-question button[aria-expanded="true"] .faq-indicator {
  transform: rotate(225deg);
}

#page-help .faq-answer-panel {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  transition: grid-template-rows var(--transition-base) var(--easing-ease-out), opacity var(--transition-base) var(--easing-ease-out);
}

#page-help .faq-answer-panel[aria-hidden="false"] {
  grid-template-rows: 1fr;
  opacity: 1;
}

#page-help .faq-answer-inner {
  min-height: 0;
  overflow: hidden;
}

#page-help .faq-answer {
  margin: 0;
  padding-top: var(--space-4);
  color: var(--color-text-light);
  line-height: var(--line-height-relaxed);
}

@media (prefers-reduced-motion: reduce) {
  #page-help .faq-answer-panel,
  #page-help .faq-indicator {
    transition: none;
  }
}

/* ===========================
   FORM ELEMENTS
   =========================== */

input,
select,
textarea {
  width: 100%;
  padding: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-base);
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  transition: border-color var(--transition-base) var(--easing-ease-out), box-shadow var(--transition-base) var(--easing-ease-out);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-focus-ring);
}

input:disabled,
select:disabled,
textarea:disabled {
  background: var(--color-light);
  cursor: not-allowed;
  opacity: 0.6;
}

label {
  display: block;
  margin-bottom: var(--space-2);
  font-weight: var(--font-weight-medium);
  color: var(--color-text);
}

.form-group {
  margin-bottom: var(--space-6);
}

.checkbox-group label,
.radio-group label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  margin-bottom: var(--space-3);
}

.checkbox-group input[type="checkbox"],
.radio-group input[type="radio"] {
  width: auto;
  margin: 0;
}

/* ===========================
   TABLE COMPONENT
   =========================== */

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  margin-bottom: var(--space-4);
}

thead {
  background: var(--color-light);
}

th, td {
  padding: var(--space-3);
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

th {
  font-weight: var(--font-weight-semibold);
  color: var(--color-text);
}

tbody tr:hover {
  background: var(--color-light);
}

/* ===========================
   BADGE & CHIP COMPONENTS
   =========================== */

.badge {
  display: inline-block;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  white-space: nowrap;
}

.badge-primary {
  background: var(--color-primary);
  color: white;
}

.badge-secondary {
  background: var(--color-secondary-light);
  color: var(--color-secondary-dark);
}

.badge-success {
  background: var(--color-success-light);
  color: var(--color-success);
}

.badge-warning {
  background: var(--color-warning-light);
  color: var(--color-warning);
}

.badge-danger {
  background: var(--color-danger-light);
  color: var(--color-danger);
}

.badge-info {
  background: var(--color-info-light);
  color: var(--color-info);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--color-surface);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  cursor: pointer;
  transition: all var(--transition-base) var(--easing-ease-out);
}

.chip:hover {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

.city-services-grid {
  display: grid;
  max-width: min(100%, calc(100vw - var(--container-padding) - var(--container-padding)));
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
  gap: var(--space-4);
  align-items: stretch;
}

.city-service-card {
  display: flex;
  min-width: 0;
  min-height: 220px;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-3);
  margin-bottom: 0;
  padding: var(--space-5, 1.25rem);
  cursor: pointer;
}

.city-service-card:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 3px;
}

.service-card__visual {
  display: grid;
  width: 68px;
  height: 56px;
  flex: 0 0 56px;
  place-items: center;
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-base);
  background: var(--color-info-light);
}

.service-card__icon {
  display: block;
  width: 56px;
  height: 42px;
  fill: none;
  stroke: var(--color-primary-dark);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.service-card__icon .service-card__accent {
  stroke: var(--color-secondary);
}

.service-card__icon .service-card__accent-fill {
  fill: var(--color-secondary);
  stroke: var(--color-secondary);
}

.city-service-card h3 {
  min-height: 2.6em;
  margin: 0;
  font-size: var(--font-size-lg);
  line-height: var(--line-height-tight);
}

.city-service-card p {
  max-width: 38ch;
  margin: 0;
  color: var(--color-text-light);
}

@media (max-width: 639px) {
  .city-services-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .city-service-card {
    display: grid;
    grid-template-columns: 68px minmax(0, 1fr);
    grid-template-rows: auto auto;
    align-items: start;
    column-gap: var(--space-3);
    row-gap: var(--space-2);
    min-height: 144px;
  }

  .city-service-card .service-card__visual {
    grid-row: 1 / span 2;
  }

  .city-service-card h3 {
    min-height: 0;
  }

  .city-service-card p {
    max-width: none;
  }
}

/* ===========================
   MODAL COMPONENT
   =========================== */

.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 2000;
  justify-content: center;
  align-items: center;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--color-surface);
  border-radius: var(--radius-base);
  max-width: 600px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  padding: var(--space-8);
  box-shadow: var(--shadow-elevation);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-6);
}

.modal-title {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-semibold);
}

.modal-close {
  background: none;
  border: none;
  font-size: var(--font-size-xl);
  cursor: pointer;
  color: var(--color-text-light);
  padding: var(--space-2);
}

.modal-close:hover {
  color: var(--color-text);
}

/* ===========================
   TAB COMPONENT
   =========================== */

.tabs {
  display: flex;
  border-bottom: 2px solid var(--color-border);
  margin-bottom: var(--space-6);
  gap: 0;
}

.tab {
  padding: var(--space-3) var(--space-6);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition-base) var(--easing-ease-out);
  color: var(--color-text-light);
  font-weight: var(--font-weight-medium);
}

.tab:hover {
  color: var(--color-text);
}

.tab.active {
  border-bottom-color: var(--color-primary);
  color: var(--color-primary);
  font-weight: var(--font-weight-semibold);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* ===========================
   TOAST / NOTIFICATION
   =========================== */

.toast {
  position: fixed;
  top: var(--space-8);
  right: var(--space-8);
  background: var(--color-surface);
  padding: var(--space-4) var(--space-6);
  border-radius: var(--radius-base);
  box-shadow: var(--shadow-xl);
  z-index: 3000;
  display: none;
  border-left: 4px solid var(--color-primary);
}

.toast.show {
  display: block;
  animation: slideIn var(--transition-base) var(--easing-ease-out);
}

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

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

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

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

/* ===========================
   BREADCRUMB COMPONENT
   =========================== */

.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-6);
  font-size: var(--font-size-sm);
}

.breadcrumb a {
  color: var(--color-primary);
}

.breadcrumb span {
  color: var(--color-text-light);
}

/* ===========================
   ANIMATIONS
   =========================== */

@keyframes slideIn {
  from {
    transform: translateX(400px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

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

/* ===========================
   UTILITY CLASSES
   =========================== */

.text-center {
  text-align: center;
}

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

.text-left {
  text-align: left;
}

.text-muted {
  color: var(--color-text-light);
}

.text-small {
  font-size: var(--font-size-sm);
}

.text-large {
  font-size: var(--font-size-lg);
}

.hidden {
  display: none !important;
}

.invisible {
  visibility: hidden;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }

.p-0 { padding: 0; }
.p-1 { padding: var(--space-1); }
.p-2 { padding: var(--space-2); }
.p-3 { padding: var(--space-3); }
.p-4 { padding: var(--space-4); }
.p-6 { padding: var(--space-6); }
.p-8 { padding: var(--space-8); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }

/* ===========================
   RESPONSIVE DESIGN
   =========================== */

@media (max-width: 768px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }

  .card {
    padding: var(--space-4);
  }

  .modal-content {
    padding: var(--space-6);
  }
}

@media (max-width: 640px) {
  :root {
    --container-padding: 0.75rem;
  }

  #page-help .faq-list {
    gap: var(--space-3);
  }

  #page-help .faq-card {
    padding: var(--space-4);
  }

  body {
    font-size: var(--font-size-sm);
  }

  .tabs {
    overflow-x: auto;
  }

  .tab {
    padding: var(--space-2) var(--space-3);
    white-space: nowrap;
  }
}

/* ===========================
   PRINT STYLES
   =========================== */

@media print {
  * {
    background: transparent !important;
    box-shadow: none !important;
  }

  a {
    text-decoration: underline;
  }

  a[href]:after {
    content: " (" attr(href) ")";
  }

  img {
    max-width: 100% !important;
  }

  @page {
    margin: 0.5cm;
  }
}

/* ===========================
   HIGH CONTRAST MODE SUPPORT
   =========================== */

@media (prefers-contrast: more) {
  :root {
    --color-text: #000000;
    --color-border: #000000;
  }

  .btn, .card, input, select, textarea {
    border-width: 2px;
  }
}

/* ===========================
   REDUCED MOTION SUPPORT
   =========================== */

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

/* ===========================
   ACCESSIBILITY ADDITIONS
   =========================== */

/* Visually hidden but readable by screen readers */
.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;
}

/* Skip-to-content link — visible only on focus */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-4);
  z-index: 10000;
  background: var(--color-primary);
  color: white;
  padding: var(--space-3) var(--space-6);
  border-radius: 0 0 var(--radius-base) var(--radius-base);
  font-weight: var(--font-weight-semibold);
  text-decoration: none;
  transition: top 0.15s;
}
.skip-link:focus {
  top: 0;
  outline: 3px solid white;
  outline-offset: 2px;
}

/* Floating accessibility controls */
.a11y-launcher,
.a11y-panel {
  font-family: var(--font-base);
}

.a11y-launcher[hidden],
.a11y-panel[hidden] {
  display: none !important;
}

.a11y-launcher {
  position: fixed;
  z-index: 1500;
  display: grid;
  place-items: center;
  width: 3.5rem;
  height: 3.5rem;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  isolation: isolate;
}

.a11y-launcher[data-position="bottom-left"] {
  bottom: calc(env(safe-area-inset-bottom, 0px) + 1rem);
  left: calc(env(safe-area-inset-left, 0px) + 1rem);
}

.a11y-launcher[data-position="bottom-right"] {
  right: calc(env(safe-area-inset-right, 0px) + 1rem);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 1rem);
}

.a11y-launcher[data-position="top-left"] {
  top: max(env(safe-area-inset-top, 0px), var(--a11y-header-clearance, 1rem));
  left: calc(env(safe-area-inset-left, 0px) + 1rem);
}

.a11y-launcher[data-position="top-right"] {
  top: max(env(safe-area-inset-top, 0px), var(--a11y-header-clearance, 1rem));
  right: calc(env(safe-area-inset-right, 0px) + 1rem);
}

.a11y-launcher-symbol {
  position: relative;
  z-index: 1;
  font-size: 1.65rem;
  line-height: 1;
}

.a11y-launcher-ring {
  position: absolute;
  inset: -0.5rem;
  z-index: 0;
  border: 2px solid var(--color-primary-light);
  border-radius: inherit;
  opacity: 0;
  pointer-events: none;
}

.a11y-launcher.a11y-first-open .a11y-launcher-ring {
  animation: a11y-first-open-ring 750ms ease-out both;
}

@keyframes a11y-first-open-ring {
  0% {
    transform: scale(0.72);
    opacity: 0.9;
  }
  100% {
    transform: scale(1.35);
    opacity: 0;
  }
}

.a11y-panel {
  position: fixed;
  z-index: 1600;
  right: max(1rem, env(safe-area-inset-right, 0px));
  bottom: max(1rem, env(safe-area-inset-bottom, 0px));
  width: min(36rem, calc(100% - 2rem - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)));
  max-height: calc(100vh - 2rem - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  max-height: calc(100dvh - 2rem - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  overflow: auto;
  overscroll-behavior: contain;
  padding: 1rem;
  border: 1px solid var(--color-border);
  border-top: 4px solid var(--color-primary);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-xl);
}

.a11y-panel.a11y-first-open {
  animation: a11y-panel-arrive 240ms ease-out both;
}

@keyframes a11y-panel-arrive {
  from {
    opacity: 0.75;
    transform: translateY(0.5rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.a11y-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.a11y-panel-header h2 {
  color: var(--color-text);
  font-size: 1.35rem;
  line-height: 1.25;
}

.a11y-close {
  flex: 0 0 auto;
  width: 2.75rem;
  height: 2.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-base);
  background: var(--color-light);
  color: var(--color-text);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.a11y-note,
.a11y-help {
  color: var(--color-text-light);
  font-size: 0.875rem;
}

.a11y-note {
  margin-bottom: 1rem;
}

.a11y-section {
  margin: 0 0 1rem;
  padding: 0;
  border: 0;
}

.a11y-section h3,
.a11y-position legend {
  margin-bottom: 0.5rem;
  color: var(--color-text);
  font-size: 1rem;
  font-weight: var(--font-weight-semibold);
}

.a11y-profile-status {
  margin-bottom: 0.5rem;
  color: var(--color-text-light);
  font-size: 0.875rem;
}

.a11y-profile-grid,
.a11y-control-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 8.5rem), 1fr));
  gap: 0.5rem;
}

.a11y-profile,
.a11y-control {
  min-width: 0;
  min-height: 2.75rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-base);
  background: var(--color-light);
  color: var(--color-text);
  font: inherit;
  font-size: 0.875rem;
  line-height: 1.3;
  text-align: left;
  cursor: pointer;
}

.a11y-profile[aria-pressed="true"],
.a11y-control[aria-pressed="true"] {
  border-color: var(--color-primary);
  background: var(--color-info-light);
  box-shadow: inset 0 0 0 1px var(--color-primary);
}

.a11y-profile:hover,
.a11y-control:hover,
.a11y-close:hover,
.a11y-reset:hover {
  border-color: var(--color-primary);
}

.a11y-profile:hover:not([aria-pressed="true"]),
.a11y-control:hover:not([aria-pressed="true"]) {
  background: var(--color-info-light);
}

.a11y-control {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.a11y-control > span:first-child {
  flex: 0 0 1.1rem;
  color: var(--color-primary-dark);
  font-weight: var(--font-weight-bold);
  text-align: center;
}

.a11y-field {
  display: grid;
  gap: 0.35rem;
  margin-top: 0.75rem;
  color: var(--color-text);
  font-weight: var(--font-weight-medium);
}

.a11y-field > span:first-child {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
}

.a11y-field output {
  color: var(--color-text-light);
  font-variant-numeric: tabular-nums;
}

.a11y-field input[type="range"] {
  width: 100%;
  accent-color: var(--color-primary);
}

.a11y-field select {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-base);
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit;
}

.a11y-position {
  padding: 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-base);
}

.a11y-position legend {
  padding: 0 0.25rem;
}

.a11y-position .a11y-help {
  margin-bottom: 0.5rem;
}

.a11y-position-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.35rem 0.75rem;
}

.a11y-position-grid label,
.a11y-checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.5rem;
  color: var(--color-text);
  cursor: pointer;
}

.a11y-position-grid input,
.a11y-checkbox-row input {
  width: 1rem;
  height: 1rem;
  flex: 0 0 auto;
  accent-color: var(--color-primary);
}

.a11y-checkbox-row {
  margin-top: 0.75rem;
  font-weight: var(--font-weight-medium);
}

.a11y-help {
  margin-top: 0.25rem;
}

.a11y-storage-notice {
  margin: 0.75rem 0;
  padding: 0.65rem;
  border: 1px solid var(--color-warning);
  border-radius: var(--radius-base);
  background: var(--color-warning-light);
  color: var(--color-text);
  font-size: 0.875rem;
}

.a11y-storage-notice[hidden] {
  display: none;
}

.a11y-reset {
  width: 100%;
  min-height: 2.75rem;
  margin-top: 0.75rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--color-primary);
  border-radius: var(--radius-base);
  background: var(--color-surface);
  color: var(--color-primary-dark);
  font: inherit;
  font-weight: var(--font-weight-semibold);
  cursor: pointer;
}

.a11y-panel :focus-visible,
.a11y-launcher:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 3px;
}

body.a11y-high-contrast {
  --color-text: #000;
  --color-text-light: #111;
  --color-text-lighter: #222;
  --color-bg: #fff;
  --color-surface: #fff;
  --color-light: #f2f2f2;
  --color-light-2: #e8e8e8;
  --color-border: #000;
  --color-border-light: #333;
  --color-primary: #003b70;
  --color-primary-dark: #002c55;
  --color-focus: #000;
  --color-info-light: #fff3a6;
  background: #fff;
  color: #000;
}

body.a11y-high-contrast a {
  color: #003b70 !important;
}

body.a11y-highlight-links a {
  text-decoration: underline !important;
  text-decoration-thickness: 2px !important;
  text-underline-offset: 0.15em;
}

body.a11y-text-spacing p,
body.a11y-text-spacing li,
body.a11y-text-spacing label,
body.a11y-text-spacing td,
body.a11y-text-spacing th {
  letter-spacing: 0.04em !important;
  word-spacing: 0.16em !important;
}

body.a11y-line-relaxed p,
body.a11y-line-relaxed li,
body.a11y-line-relaxed label {
  line-height: 1.8 !important;
}

body.a11y-line-loose p,
body.a11y-line-loose li,
body.a11y-line-loose label {
  line-height: 2 !important;
}

body.a11y-hide-images img[alt=""],
body.a11y-hide-images img[aria-hidden="true"],
body.a11y-hide-images [role="img"][aria-hidden="true"],
body.a11y-hide-images svg[aria-hidden="true"] {
  visibility: hidden !important;
}

body.a11y-hide-images .hero {
  background-image: none !important;
}

body.a11y-large-cursor,
body.a11y-large-cursor * {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Cpath d='M4 2v23l6-6 4 9 4-2-4-9 9 0z' fill='%23000' stroke='%23fff' stroke-width='2'/%3E%3C/svg%3E") 4 2, auto !important;
}

body.a11y-large-targets a,
body.a11y-large-targets button,
body.a11y-large-targets input,
body.a11y-large-targets select,
body.a11y-large-targets textarea,
body.a11y-large-targets [role="button"] {
  min-height: 2.75rem;
}

body.a11y-pause-animations *,
body.a11y-pause-animations *::before,
body.a11y-pause-animations *::after {
  animation: none !important;
  scroll-behavior: auto !important;
  transition: none !important;
}

@media (max-width: 480px) {
  .a11y-panel {
    right: max(0.75rem, env(safe-area-inset-right, 0px));
    bottom: max(0.75rem, env(safe-area-inset-bottom, 0px));
    width: calc(100% - 1.5rem - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px));
    padding: 0.85rem;
    border-radius: var(--radius-base);
  }

  .a11y-panel-header h2 {
    font-size: 1.2rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .a11y-launcher.a11y-first-open .a11y-launcher-ring,
  .a11y-panel.a11y-first-open {
    animation: none !important;
  }
}

.back-to-top[hidden] {
  display: none !important;
}

.back-to-top {
  position: fixed;
  z-index: 1450;
  right: calc(env(safe-area-inset-right, 0px) + 1rem);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 1rem + 3.5rem + 0.75rem);
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  transition: background-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.back-to-top:hover {
  background: var(--color-primary-dark);
  box-shadow: var(--shadow-xl);
  transform: translateY(-2px);
}

.back-to-top:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 3px;
}

.back-to-top svg {
  width: 1.35rem;
  height: 1.35rem;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

@media (max-width: 480px) {
  .back-to-top {
    right: calc(env(safe-area-inset-right, 0px) + 0.75rem);
    width: 2.875rem;
    height: 2.875rem;
  }
}
