/* Maine Revenue Sharing & TIF Tax Shift Calculator - Styles */
/* Civic Ledger identity: royal navy / gold / paper, serif throughout.
   Retoned 2026-07-20 (Track 1) off the shared civic-ledger palette. Light-default;
   the dark toggle below is repainted navy/gold too. The semantic data-viz palette
   (gains green, losses red, warnings gold, category hues) is deliberately kept. */

/* Shared civic-ledger tokens (--cl-* / --ms-*). Imported so every TIF page inherits
   the navy/gold palette without editing 20 HTML heads. Inert except token values. */
@import url('/css/civic-ledger.css');

/* CSS Custom Properties - Design System */
:root {
  /* Chrome / brand — navy spine, gold emphasis (was blue/purple/teal) */
  --color-primary: var(--cl-navy-4, #1e4470);
  --color-primary-dark: var(--cl-navy, #0d1f33);
  --color-primary-light: var(--cl-navy-3, #16324f);
  --color-secondary: var(--cl-gold-deep, #8a6206);
  --color-accent: var(--cl-gold-deep, #8a6206);
  /* Per-page <style> blocks reference these two fallback vars for chrome badges,
     buttons and borders (var(--primary-color,#2c5282) / var(--accent-color,#48bb78)).
     Defining them here retones that chrome navy/gold across every TIF page at once.
     Both carry white text, so both must stay dark enough: white on navy-4 ≈ 9.9:1,
     white on gold-deep ≈ 5.9:1 (both pass AA). */
  --primary-color: var(--cl-navy-4, #1e4470);
  --accent-color: var(--cl-gold-deep, #8a6206);
  /* Status — kept semantic (data encoding), harmonized to civic-ledger */
  --color-success: #1e7d4f;
  --color-warning: #8a6206;
  --color-error: #a3241d;

  /* Gradients */
  --gradient-primary: linear-gradient(135deg, var(--cl-navy, #0d1f33), var(--cl-navy-4, #1e4470));
  --gradient-background: linear-gradient(135deg, var(--cl-paper, #fbfaf7), var(--cl-paper-2, #f3f1ec));
  --gradient-card: linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(251, 250, 247, 0.92));

  /* Neutral colors */
  --color-white: hsl(0, 0%, 100%);
  --color-gray-50: hsl(220, 20%, 98%);
  --color-gray-100: hsl(220, 18%, 95%);
  --color-gray-200: hsl(220, 16%, 88%);
  --color-gray-300: hsl(220, 14%, 70%);
  --color-gray-400: #5a6b7f;   /* darkened from hsl(220,12%,55%): muted labels now ≥4.5:1 on paper */
  --color-gray-500: hsl(220, 10%, 40%);
  --color-gray-600: hsl(220, 12%, 30%);
  --color-gray-700: hsl(220, 15%, 20%);
  --color-gray-800: hsl(220, 18%, 15%);
  --color-gray-900: hsl(220, 20%, 10%);
  --color-text: hsl(220, 20%, 15%);

  /* Theme-aware colors for light mode — navy ink on paper */
  --bg-primary: var(--cl-white, #ffffff);
  --bg-secondary: var(--cl-paper, #fbfaf7);
  --text-primary: var(--cl-navy-ink, #0a1826);
  --text-secondary: #2b3d52;
  --border-color: #ded9cd;
  --card-bg: rgba(255, 255, 255, 0.95);
  --input-bg: var(--cl-white, #ffffff);
  --hover-bg: var(--cl-paper-2, #f3f1ec);

  /* Spacing - More compact */
  --space-xs: 0.375rem;
  --space-sm: 0.625rem;
  --space-md: 1rem;
  --space-lg: 1.25rem;
  --space-xl: 1.75rem;
  --space-2xl: 2.5rem;

  /* Typography — serif throughout (the editorial civic-ledger voice) */
  --font-family: Charter, "Bitstream Charter", Cambria, "Palatino Linotype", Georgia, serif;
  --font-weight-light: 300;
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  /* Border radius */
  --radius-sm: 0.5rem;
  --radius-md: 1rem;
  --radius-lg: 1.5rem;
  --radius-xl: 2rem;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.12);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.15);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.18);
  --shadow-glow: 0 0 20px rgba(201, 169, 98, 0.4);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 400ms ease;
}

/* Dark theme variables — navy surfaces, gold chrome (was slate/blue/purple) */
[data-theme="dark"] {
  --bg-primary: var(--cl-navy-ink, #0a1826);
  --bg-secondary: var(--cl-navy, #0d1f33);
  --text-primary: #eef2f8;
  --text-secondary: #c6d1e0;
  --border-color: rgba(233, 198, 107, 0.20);
  --card-bg: rgba(13, 31, 51, 0.95);
  --input-bg: var(--cl-navy-2, #142840);
  --hover-bg: var(--cl-navy-3, #16324f);
  --color-text: #eef2f8;
  --gradient-background: linear-gradient(135deg, var(--cl-navy-ink, #0a1826), var(--cl-navy-2, #142840));
  --gradient-card: linear-gradient(135deg, rgba(13, 31, 51, 0.95), rgba(20, 40, 64, 0.9));
  /* Decoupled brand vars in dark:
     --color-primary/-secondary/-accent are used as TEXT (headings, values) →
       flip to GOLD so they read on the navy canvas.
     --primary-color/--accent-color are used as BACKGROUNDS with white text
       (badges, buttons, table headers) → keep DARK (navy / gold-deep) from :root
       so the white text stays legible. This split is why dark mode reads clean. */
  --color-primary: var(--cl-gold, #c9a962);
  --color-primary-light: var(--cl-gold-2, #e9c66b);
  --color-secondary: var(--cl-gold-2, #e9c66b);
  --color-accent: var(--cl-gold-2, #e9c66b);
  --color-gray-600: #c6d1e0;
  --color-gray-700: #dbe3ee;
  /* Light-neutral surfaces/borders must go dark too, else cards built on them
     (e.g. the Revenue-Sharing Planner's .rsp-metric) stay white under navy. */
  --color-gray-50:  var(--cl-navy-2, #142840);
  --color-gray-100: var(--cl-navy-3, #16324f);
  --color-gray-200: rgba(233, 198, 107, 0.18);
  /* Muted greys used as TEXT must go light in dark (they now sit on navy cards). */
  --color-gray-400: #93a2b6;
  --color-gray-500: #a7b3c2;
}

/* Dark: spots that use --primary-color as TEXT (not a fill) read navy-on-navy —
   force those to gold. Fills (badges/headers) that use --primary-color as a
   background keep their dark navy from :root and are unaffected. */
[data-theme="dark"] .example-box strong,
[data-theme="dark"] .info-highlight strong,
[data-theme="dark"] .steps-guide h3,
[data-theme="dark"] #actual-rs-section h2,
[data-theme="dark"] .rs-history-table tr.rs-latest-year td,
[data-theme="dark"] [style*="color: var(--primary-color"],
[data-theme="dark"] [style*="color:var(--primary-color"] { color: var(--cl-gold, #c9a962) !important; }

/* Native form controls (sliders, checkboxes, radios) were rendering in the browser
   default blue — tint them to the brand (navy on light, gold on dark). */
input[type="range"], input[type="checkbox"], input[type="radio"] { accent-color: var(--cl-navy-4, #1e4470); }
[data-theme="dark"] input[type="range"],
[data-theme="dark"] input[type="checkbox"],
[data-theme="dark"] input[type="radio"] { accent-color: var(--cl-gold, #c9a962); }
/* Revenue-Sharing Planner badge: white text on a gold fill in dark → dark fill. */
[data-theme="dark"] .rsp-badge { background: var(--cl-navy-3, #16324f) !important; }
/* Finance-dashboard KPI figures: the darker category colours (blue, purple) fall
   below AA on the dark stat cards — lighten them in dark (hue kept). */
[data-theme="dark"] .stat-card.primary .stat-value { color: #93c5fd !important; }
[data-theme="dark"] .stat-card.purple  .stat-value { color: #c4b5fd !important; }
[data-theme="dark"] .stat-card.success .stat-value { color: #6ee7b7 !important; }
[data-theme="dark"] .stat-card.orange  .stat-value { color: #fdba74 !important; }
/* Light: the same KPI figures pass at desktop (large text, 3:1) but miss 4.5:1 at
   mobile sizes — shift each to its accessible-ink shade (hue/metric kept distinct). */
html:not([data-theme="dark"]) .stat-card.primary .stat-value { color: #235a94 !important; }
html:not([data-theme="dark"]) .stat-card.success .stat-value { color: #146c3f !important; }
html:not([data-theme="dark"]) .stat-card.purple  .stat-value { color: #6b4c9a !important; }
html:not([data-theme="dark"]) .stat-card.orange  .stat-value { color: #b45309 !important; }

/* Theme toggle button */
.theme-toggle {
  position: fixed;
  /* Sit just below the pia-shell launcher bar (--piai-shell-h is 56px) so
     the dark-mode toggle doesn't overlap the launcher / avatar. */
  top: calc(var(--piai-shell-h, 56px) + 12px);
  right: 20px;
  z-index: 1000;
  background: var(--card-bg);
  border: 2px solid var(--border-color);
  border-radius: 50%;
  width: 45px;
  height: 45px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-normal);
  box-shadow: var(--shadow-md);
  font-family: var(--font-family);
  font-weight: var(--font-weight-medium);
  color: var(--text-primary);
}

.theme-toggle:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--color-primary);
}

.theme-toggle-icon {
  font-size: 1.2rem;
  line-height: 1;
}

.theme-toggle-text {
  display: none;
}

/* Reset & Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Native <button>/<input>/<select> do NOT inherit font-family — the UA sets a
   sans-serif face. Force the serif system so inline-styled buttons (district
   presets, Clear All, etc.) match the "serif everywhere" identity. */
button, input, select, textarea, optgroup { font-family: inherit; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-family);
  font-weight: var(--font-weight-normal);
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--gradient-background);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  transition: background var(--transition-normal), color var(--transition-normal);
}

/* Animated background gradient */
body::before {
  content: '';
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(13, 31, 51, 0.05) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(201, 169, 98, 0.06) 0%, transparent 50%);
  animation: rotateBackground 20s linear infinite;
  z-index: -1;
}

@keyframes rotateBackground {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

/* Container */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: var(--space-md);
}

/* Header */
header {
  padding: var(--space-md) 0;
  text-align: center;
}

header h1 {
  font-size: clamp(1.5rem, 4vw, 2.25rem);
  font-weight: var(--font-weight-bold);
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: var(--space-xs);
  animation: fadeInDown 0.8s ease;
}

header p {
  font-size: clamp(0.875rem, 1.8vw, 1rem);
  color: var(--color-gray-600);
  font-weight: var(--font-weight-normal);
  animation: fadeIn 1s ease 0.2s backwards;
}

/* Navigation */
nav {
  margin: var(--space-lg) 0;
}

.nav-links {
  display: flex;
  gap: var(--space-sm);
  justify-content: center;
  flex-wrap: wrap;
  list-style: none;
}

.nav-links a {
  padding: var(--space-sm) var(--space-md);
  background: var(--card-bg);
  backdrop-filter: blur(10px);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  text-decoration: none;
  font-weight: var(--font-weight-medium);
  font-size: 0.9rem;
  transition: all var(--transition-normal);
}

.nav-links a:hover {
  background: var(--hover-bg);
  border-color: var(--color-primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.nav-links a.active {
  background: var(--gradient-primary);
  border-color: transparent;
  color: var(--color-white);
  box-shadow: var(--shadow-md);
}

/* Main Content */
main {
  min-height: 60vh;
  padding: var(--space-md) 0;
}

/* Cards */
.card {
  background: var(--card-bg);
  backdrop-filter: blur(20px);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  margin-bottom: var(--space-md);
  box-shadow: var(--shadow-md);
  transition: all var(--transition-normal), 
              background-color var(--transition-normal),
              border-color var(--transition-normal);
  animation: fadeInUp 0.6s ease backwards;
}

.card:hover {
  border-color: var(--color-primary-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

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

.card h2 {
  font-size: clamp(1.25rem, 2.5vw, 1.5rem);
  font-weight: var(--font-weight-semibold);
  color: var(--color-primary);
  margin-bottom: var(--space-sm);
}

.card h3 {
  font-size: clamp(1.1rem, 2vw, 1.25rem);
  font-weight: var(--font-weight-semibold);
  color: var(--color-accent);
  margin-bottom: var(--space-xs);
  margin-top: var(--space-md);
}

.card p {
  color: var(--color-gray-700);
  margin-bottom: var(--space-sm);
  line-height: 1.6;
  font-size: 0.95rem;
}

/* Forms */
.form-group {
  margin-bottom: var(--space-sm);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-sm);
}

.form-group label {
  display: block;
  font-weight: var(--font-weight-medium);
  color: var(--color-gray-700);
  margin-bottom: var(--space-xs);
  font-size: 0.875rem;
}

[data-theme="dark"] .form-group label {
  color: var(--text-secondary);
}

.form-group input,
.form-group select {
  width: 100%;
  padding: var(--space-sm) var(--space-sm);
  background: var(--input-bg);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 0.95rem;
  transition: all var(--transition-fast);
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--color-primary);
  background: var(--input-bg);
  box-shadow: 0 0 0 3px rgba(201, 169, 98, 0.28);
}

[data-theme="light"] .form-group input:focus,
[data-theme="light"] .form-group select:focus {
  background: var(--color-white);
}

.form-group input::placeholder {
  color: var(--color-gray-400);
}

.form-group small {
  display: block;
  margin-top: var(--space-xs);
  color: var(--color-gray-600);
  font-size: 0.8rem;
}

/* Buttons */
.btn {
  padding: var(--space-sm) var(--space-md);
  background: var(--gradient-primary);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--color-white);
  font-family: var(--font-family);
  font-size: 0.9rem;
  font-weight: var(--font-weight-semibold);
  cursor: pointer;
  transition: all var(--transition-normal);
  box-shadow: var(--shadow-sm);
}

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

.btn:active {
  transform: translateY(0);
}

.btn-secondary {
  background: linear-gradient(135deg, var(--color-gray-500), var(--color-gray-600));
}

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

/* Results Section */
.results {
  margin-top: var(--space-md);
  padding: var(--space-md);
  background: linear-gradient(135deg, rgba(201, 169, 98, 0.10), rgba(13, 31, 51, 0.05));
  border: 1.5px solid var(--color-accent);
  border-radius: var(--radius-md);
  animation: slideIn 0.4s ease;
}

.results.hidden {
  display: none;
}

.results h3 {
  color: var(--color-accent);
  margin-bottom: var(--space-sm);
  font-size: 1.1rem;
}

.result-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-xs) 0;
  border-bottom: 1px solid var(--color-gray-200);
}

[data-theme="dark"] .result-item {
  border-bottom-color: var(--border-color);
}

.result-item:last-child {
  border-bottom: none;
}

.result-label {
  color: var(--text-secondary);
  font-weight: var(--font-weight-medium);
  font-size: 0.9rem;
}

.result-value {
  font-size: 1.1rem;
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
}

.result-value.highlight {
  color: var(--color-accent);
  font-size: 1.25rem;
}

/* Calculator Sections */
.calculator-section {
  margin-bottom: var(--space-xl);
}

.calculator-section:last-child {
  margin-bottom: 0;
}

/* Two-column layout for calculator sections */
.calc-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-lg);
  margin-bottom: var(--space-md);
}

.calc-description {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.calc-inputs {
  display: flex;
  flex-direction: column;
}

.calc-results-wrapper {
  grid-column: 1 / -1;
}

@media (max-width: 968px) {
  .calc-layout {
    grid-template-columns: 1fr;
    gap: var(--space-md);
  }
  
  .calc-results-wrapper {
    grid-column: 1;
  }
}

/* Info Box */
.info-box {
  padding: var(--space-sm);
  background: rgba(13, 31, 51, 0.05);
  border-left: 3px solid var(--color-primary);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-md);
}

[data-theme="dark"] .info-box {
  background: rgba(201, 169, 98, 0.12);
  border-left-color: var(--cl-gold, #c9a962);
}

.info-box p {
  color: var(--color-gray-700);
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.5;
}

[data-theme="dark"] .info-box p {
  color: var(--text-secondary);
}

/* Alert Messages */
.alert {
  padding: var(--space-sm);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-sm);
  animation: slideIn 0.3s ease;
  font-size: 0.9rem;
}

.alert.error {
  background: rgba(239, 68, 68, 0.1);
  border: 1.5px solid var(--color-error);
  color: var(--color-error);
}

.alert.success {
  background: rgba(76, 201, 171, 0.1);
  border: 1.5px solid var(--color-success);
  color: var(--color-success);
}

/* Utility Classes */
.hidden {
  display: none !important;
}

/* Footer */
footer {
  text-align: center;
  padding: var(--space-lg) 0;
  margin-top: var(--space-xl);
  border-top: 1.5px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.85rem;
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Responsive Design */

/* Tablet breakpoint */
@media (max-width: 992px) {
  .form-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .calc-layout {
    grid-template-columns: 1fr;
    gap: var(--space-md);
  }
  
  .calc-results-wrapper {
    grid-column: 1;
  }
}

/* Mobile breakpoint */
@media (max-width: 768px) {
  :root {
    --space-lg: 1rem;
    --space-xl: 1.5rem;
    --space-2xl: 2rem;
  }

  html {
    font-size: 15px;
  }

  .container {
    padding: var(--space-sm);
  }

  .card {
    padding: var(--space-md);
    margin-bottom: var(--space-sm);
    border-radius: var(--radius-sm);
  }

  .card-grid {
    grid-template-columns: 1fr;
    gap: var(--space-sm);
  }

  .form-grid {
    grid-template-columns: 1fr;
    gap: var(--space-sm);
  }

  /* Navigation - horizontal scroll on mobile */
  nav {
    margin: var(--space-md) 0;
  }

  .nav-links {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: var(--space-xs);
    gap: var(--space-xs);
    justify-content: flex-start;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .nav-links::-webkit-scrollbar {
    display: none;
  }

  .nav-links li {
    flex-shrink: 0;
  }

  .nav-links a {
    text-align: center;
    padding: var(--space-sm) var(--space-md);
    font-size: 0.85rem;
    white-space: nowrap;
  }

  /* Result items stack on mobile */
  .result-item {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-xs);
  }

  .result-value {
    font-size: 1rem;
  }

  .result-value.highlight {
    font-size: 1.15rem;
  }

  /* Theme toggle and user profile positioning */
  .theme-toggle {
    top: 10px;
    right: 10px;
    width: 38px;
    height: 38px;
  }

  .theme-toggle-icon {
    font-size: 1rem;
  }

  /* User profile dropdown positioning fix for mobile */
  .user-profile-container {
    right: 55px;
    top: 10px;
  }

  .user-profile-button {
    width: 38px;
    height: 38px;
    font-size: 1rem;
  }

  .user-profile-dropdown {
    min-width: 180px;
    right: -40px;
  }

  /* Header adjustments */
  header {
    padding: var(--space-sm) 0;
    padding-top: 50px; /* Space for fixed buttons */
  }

  header h1 {
    font-size: clamp(1.25rem, 5vw, 1.75rem);
    line-height: 1.2;
  }

  header p {
    font-size: 0.875rem;
  }

  /* Calculator section spacing */
  .calculator-section {
    margin-bottom: var(--space-md);
  }

  /* Info boxes */
  .info-box {
    padding: var(--space-sm);
    font-size: 0.85rem;
  }

  /* Buttons */
  .btn {
    padding: var(--space-sm) var(--space-md);
    font-size: 0.9rem;
    width: 100%;
  }

  .btn-block {
    padding: var(--space-md);
  }

  /* Footer */
  footer {
    padding: var(--space-md) 0;
    font-size: 0.8rem;
  }
}

/* Small mobile breakpoint - iPhone sized (393px width) */
@media (max-width: 480px) {
  html {
    font-size: 14px;
  }

  .container {
    padding: 8px;
  }

  .card {
    padding: 12px;
  }

  header h1 {
    font-size: 1.15rem;
  }

  .nav-links a {
    padding: 6px 10px;
    font-size: 0.75rem;
  }

  .form-group label {
    font-size: 0.8rem;
  }

  .form-group input,
  .form-group select {
    padding: 8px;
    font-size: 0.9rem;
  }

  .card h2 {
    font-size: 1rem;
  }

  .card h3 {
    font-size: 0.95rem;
  }

  .result-label {
    font-size: 0.8rem;
  }

  /* Tooltips on small screens */
  .tooltip {
    width: 200px;
    font-size: 0.7rem;
    padding: 6px;
  }
}

/* Mobile grid override classes - use these in HTML */
@media (max-width: 768px) {
  .mobile-stack,
  .mobile-1-col {
    display: block !important;
  }
  
  .mobile-1-col > * {
    width: 100% !important;
    margin-bottom: 10px;
  }
  
  .mobile-2-col {
    grid-template-columns: 1fr 1fr !important;
  }
}

@media (max-width: 480px) {
  .mobile-2-col {
    grid-template-columns: 1fr !important;
  }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
  /* Larger tap targets */
  .btn {
    min-height: 44px;
  }

  .nav-links a {
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .form-group input,
  .form-group select {
    min-height: 44px;
  }

  .theme-toggle,
  .user-profile-button {
    min-width: 44px;
    min-height: 44px;
  }

  /* Tooltips show on tap - handled via JS typically */
  .tooltip-container:active .tooltip {
    visibility: visible;
    opacity: 1;
  }
}

/* Loading State */
.loading {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2.5px solid var(--color-gray-300);
  border-radius: 50%;
  border-top-color: var(--color-primary);
  animation: spin 0.8s linear infinite;
}

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

/* Stagger animation delays for cards */
.card-grid .card:nth-child(1) {
  animation-delay: 0s;
}

.card-grid .card:nth-child(2) {
  animation-delay: 0.1s;
}

.card-grid .card:nth-child(3) {
  animation-delay: 0.2s;
}

.card-grid .card:nth-child(4) {
  animation-delay: 0.3s;
}

/* ── Light-mode data-contrast remediation (Track 1, 2026-07-20) ───────────────
   The TIF data tables carry hardcoded semantic colours (gains green, losses red,
   category pink, gold figures, muted grey, an old blue link) tuned for punch, not
   WCAG — several miss AA on the light paper (measured 2.6–4.1:1 in a headless
   browser). Shift each to its accessible-ink shade while KEEPING the hue/meaning.
   Scoped to light mode via html:not([data-theme="dark"]) so the pages' existing
   [data-theme="dark"] overrides (which already recolour these inline styles) stay
   authoritative in dark mode. Both spaced/unspaced forms, mirroring those overrides. */

/* green — gains / "with TIF" (text) */
html:not([data-theme="dark"]) [style*="color: #38a169"], html:not([data-theme="dark"]) [style*="color:#38a169"] { color: #146c3f !important; }
/* red — losses / "without TIF" (text) */
html:not([data-theme="dark"]) [style*="color: #e53e3e"], html:not([data-theme="dark"]) [style*="color:#e53e3e"] { color: #c62828 !important; }
/* pink — category figures (text) */
html:not([data-theme="dark"]) [style*="color: #ec4899"], html:not([data-theme="dark"]) [style*="color:#ec4899"] { color: #a3164e !important; }
/* gold — dollar figures (text) */
html:not([data-theme="dark"]) [style*="color: #b7791f"], html:not([data-theme="dark"]) [style*="color:#b7791f"],
html:not([data-theme="dark"]) [style*="color: #d97706"], html:not([data-theme="dark"]) [style*="color:#d97706"] { color: #8a6206 !important; }
/* muted greys — labels / captions (text) */
html:not([data-theme="dark"]) [style*="color: #999"], html:not([data-theme="dark"]) [style*="color:#999"],
html:not([data-theme="dark"]) [style*="color: #999999"], html:not([data-theme="dark"]) [style*="color:#999999"],
html:not([data-theme="dark"]) [style*="color: #718096"], html:not([data-theme="dark"]) [style*="color:#718096"],
html:not([data-theme="dark"]) [style*="color: #7e889a"], html:not([data-theme="dark"]) [style*="color:#7e889a"] { color: #4d5a68 !important; }
/* old blue chrome (links, headings, table headers) → navy */
html:not([data-theme="dark"]) [style*="color: #3182ce"], html:not([data-theme="dark"]) [style*="color:#3182ce"],
html:not([data-theme="dark"]) [style*="color: #2c5282"], html:not([data-theme="dark"]) [style*="color:#2c5282"],
html:not([data-theme="dark"]) [style*="color: #2b6cb0"], html:not([data-theme="dark"]) [style*="color:#2b6cb0"] { color: #1e4470 !important; }
[style*="background: #2c5282"], [style*="background:#2c5282"] { background: #1e4470 !important; }

/* white-text badge/button backgrounds that missed AA (darken, keep hue).
   Unscoped: white on #38a169/#ef4444 fails in BOTH light and dark. */
[style*="background: #38a169"], [style*="background:#38a169"] { background: #146c3f !important; }
[style*="background: #ef4444"], [style*="background:#ef4444"] { background: #c62828 !important; }

/* ── Dark-mode remediation (Track 1) ──────────────────────────────────────────
   The pages' own [data-theme="dark"] overrides flip most light panels, but miss a
   few (amber/note/label backgrounds) and a few hardcoded dark text colours, which
   then read light-on-light or dark-on-navy. Fill exactly those gaps — same trusted
   attribute-selector pattern, navy/gold-tinted targets. Dark mode is the toggle,
   light is the default. */
[data-theme="dark"] [style*="background: #fef3c7"], [data-theme="dark"] [style*="background:#fef3c7"],
[data-theme="dark"] [style*="background: #fffbeb"], [data-theme="dark"] [style*="background:#fffbeb"] { background: rgba(201,169,98,.12) !important; }
[data-theme="dark"] [style*="background: #f0fdf4"], [data-theme="dark"] [style*="background:#f0fdf4"] { background: rgba(30,125,79,.16) !important; }
[data-theme="dark"] [style*="background: #edf2f7"], [data-theme="dark"] [style*="background:#edf2f7"],
[data-theme="dark"] [style*="background: #f9fafb"], [data-theme="dark"] [style*="background:#f9fafb"],
[data-theme="dark"] [style*="background: #fafafa"], [data-theme="dark"] [style*="background:#fafafa"] { background: var(--cl-navy-2, #142840) !important; }
[data-theme="dark"] [style*="color: #2d3748"], [data-theme="dark"] [style*="color:#2d3748"] { color: #c6d1e0 !important; }
[data-theme="dark"] [style*="color: #92400e"], [data-theme="dark"] [style*="color:#92400e"],
[data-theme="dark"] [style*="color: #78350f"], [data-theme="dark"] [style*="color:#78350f"],
[data-theme="dark"] [style*="color: #b45309"], [data-theme="dark"] [style*="color:#b45309"] { color: #fbbf24 !important; }
[data-theme="dark"] [style*="color: #0369a1"], [data-theme="dark"] [style*="color:#0369a1"] { color: #7dd3fc !important; }
[data-theme="dark"] [style*="color: #7c3aed"], [data-theme="dark"] [style*="color:#7c3aed"] { color: #c4b5fd !important; }

/* The legacy in-page profile button is replaced by piai-shell's account
   menu and was overlapping the page title on the TIF pages. Hide it. */
.user-profile-container {
  display: none !important;
}