/* ==========================================================================
   MWDC Drought Resilience Network — Design System
   Built by Aristos AI · Every pixel matters, every interaction delights.
   
   Brand: Mid West Development Commission
   Primary: #370000 (deep burgundy — the MWDC signature)
   Accent: #ec4600 (vibrant orange — energy, action, drought earth)
   Warm:   #f79520 (warm orange — community, warmth, sun)
   
   Fonts: Barlow Condensed (headings — MWDC brand font)
          Inter (body — maximum readability for varying digital literacy)
   ========================================================================== */

/* ---- Design tokens ---- */
:root {
  /* MWDC brand colors */
  --mwdc-burgundy: #370000;
  --mwdc-burgundy-2: #4a0000;
  --mwdc-burgundy-3: #5c0a0a;
  --mwdc-burgundy-rgb: 55, 0, 0;
  --mwdc-orange: #ec4600;
  --mwdc-orange-2: #ff5722;
  --mwdc-orange-rgb: 236, 70, 0;
  --mwdc-warm: #f79520;
  --mwdc-warm-2: #ffb262;
  --mwdc-warm-rgb: 247, 149, 32;
  --mwdc-brown: #792a01;
  --mwdc-cream: #fff8f0;
  --mwdc-sand: #f5e6d3;

  /* Aristos co-brand (subtle, attribution only) */
  --aristos-jacarta: #2D2769;
  --aristos-lavender: #9889C0;

  /* Surface system */
  --bg: #faf7f2;
  --bg-2: #f5f0e8;
  --surface: #ffffff;
  --surface-2: #fafafa;
  --surface-elevated: #ffffff;
  --subtle: #f8f4ef;
  --overlay: rgba(55, 0, 0, 0.04);

  /* Borders */
  --border: #e8e0d4;
  --border-light: #f0ebe2;
  --border-strong: #d4c9b8;
  --border-focus: var(--mwdc-orange);

  /* Text */
  --ink: #1a0e08;
  --text-1: #2d1a10;
  --text-2: #6b5d50;
  --text-3: #9b8e80;
  --text-inverse: #ffffff;
  --text-on-burgundy: #fff8f0;
  --text-on-burgundy-2: rgba(255, 248, 240, 0.72);

  /* Semantic */
  --success: #059669;
  --success-bg: #ecfdf5;
  --success-border: #a7f3d0;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --warning-border: #fde68a;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --info: #2563eb;
  --info-bg: #eff6ff;
  --info-border: #bfdbfe;

  /* Subject area colors */
  --subject-water: #0e7490;
  --subject-water-bg: #ecfeff;
  --subject-agri: #65a30d;
  --subject-agri-bg: #f7fee7;
  --subject-comm: #c026d3;
  --subject-comm-bg: #fdf4ff;
  --subject-env: #059669;
  --subject-env-bg: #ecfdf5;

  /* Radii */
  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --r-2xl: 28px;
  --r-pill: 999px;
  --r-circle: 50%;

  /* Shadows — warm, earthy, not cold grey */
  --sh-xs: 0 1px 2px rgba(55, 0, 0, 0.04);
  --sh-sm: 0 1px 3px rgba(55, 0, 0, 0.06), 0 1px 2px rgba(55, 0, 0, 0.04);
  --sh-md: 0 4px 12px rgba(55, 0, 0, 0.06), 0 2px 4px rgba(55, 0, 0, 0, 04);
  --sh-lg: 0 12px 32px rgba(55, 0, 0, 0.08), 0 4px 8px rgba(55, 0, 0, 0.04);
  --sh-xl: 0 24px 56px rgba(55, 0, 0, 0.10), 0 8px 16px rgba(55, 0, 0, 0.06);
  --sh-focus: 0 0 0 3px rgba(236, 70, 0, 0.18);
  --sh-burgundy: 0 8px 24px rgba(55, 0, 0, 0.16);

  /* Transitions */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur-fast: 0.15s;
  --dur: 0.25s;
  --dur-slow: 0.4s;

  /* Layout */
  --nav-w: 264px;
  --nav-w-collapsed: 72px;
  --topbar-h: 64px;
  --content-max: 1280px;
  --gap: 24px;
  --gap-sm: 16px;
  --gap-xs: 8px;

  /* Type scale */
  --fs-xs: 0.75rem;
  --fs-sm: 0.875rem;
  --fs-base: 0.9375rem;
  --fs-md: 1rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.25rem;
  --fs-2xl: 1.5rem;
  --fs-3xl: 1.875rem;
  --fs-4xl: 2.25rem;
  --fs-5xl: 3rem;
  --fs-6xl: 3.75rem;

  /* Fonts */
  --font-head: "Barlow Condensed", "Inter", system-ui, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", ui-monospace, monospace;
}

/* ---- Reset & base ---- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: 1.6;
  color: var(--text-1);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
img, svg { display: block; max-width: 100%; }
a { color: var(--mwdc-orange); text-decoration: none; transition: color var(--dur-fast) var(--ease); }
a:hover { color: var(--mwdc-burgundy); }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea, select { font-family: inherit; font-size: inherit; }
ul, ol { list-style: none; }

/* ---- Accessibility ---- */
.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;
}
:focus-visible { outline: 2px solid var(--mwdc-orange); outline-offset: 2px; border-radius: var(--r-xs); }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  html { scroll-behavior: auto; }
}

/* ---- Typography ---- */
h1, h2, h3, h4, h5, h6 { font-family: var(--font-head); font-weight: 700; line-height: 1.15; color: var(--mwdc-burgundy); letter-spacing: -0.01em; }
h1 { font-size: var(--fs-4xl); font-weight: 800; }
h2 { font-size: var(--fs-3xl); }
h3 { font-size: var(--fs-2xl); }
h4 { font-size: var(--fs-xl); }
h5 { font-size: var(--fs-lg); }
h6 { font-size: var(--fs-md); }
p { line-height: 1.65; color: var(--text-2); }
strong { color: var(--text-1); font-weight: 600; }
code { font-family: var(--font-mono); font-size: 0.85em; background: var(--subtle); padding: 2px 6px; border-radius: var(--r-xs); color: var(--mwdc-burgundy); }

/* ---- App shell ---- */
.app {
  display: grid;
  grid-template-columns: var(--nav-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas: "nav topbar" "nav main";
  min-height: 100vh;
}

/* ---- Sidebar navigation ---- */
.nav {
  grid-area: nav;
  background: linear-gradient(180deg, var(--mwdc-burgundy) 0%, var(--mwdc-burgundy-2) 100%);
  color: var(--text-on-burgundy);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 50;
}
.nav-brand {
  padding: 20px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  gap: 12px;
}
.nav-brand img { height: 36px; width: auto; }
.nav-brand .brand-text {
  font-family: var(--font-head);
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-on-burgundy-2);
  line-height: 1.3;
}
.nav-section { padding: 16px 12px; }
.nav-section-label {
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 248, 240, 0.4);
  padding: 8px 12px 6px;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  color: var(--text-on-burgundy-2);
  font-size: var(--fs-base);
  font-weight: 500;
  transition: all var(--dur-fast) var(--ease);
  position: relative;
}
.nav-link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-on-burgundy);
}
.nav-link.active {
  background: rgba(236, 70, 0, 0.16);
  color: #fff;
  font-weight: 600;
}
.nav-link.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 24px;
  background: var(--mwdc-orange);
  border-radius: 0 3px 3px 0;
}
.nav-link .nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nav-label-wrap { display: flex; flex-direction: column; gap: 1px; }
.nav-label-wrap .nav-label { font-size: var(--fs-sm); }
.nav-label-wrap .nav-desc {
  font-size: 10px;
  color: rgba(255, 248, 240, 0.35);
  font-weight: 400;
  line-height: 1.2;
}
.nav-link:hover .nav-desc { color: rgba(255, 248, 240, 0.5); }
.nav-link.active .nav-desc { color: rgba(255, 248, 240, 0.5); }

/* ---- Breadcrumbs ---- */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.breadcrumbs a:hover { color: var(--mwdc-burgundy) !important; }

/* ---- User menu as link ---- */
.user-menu {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 6px 6px;
  border-radius: var(--r-pill);
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
}
.user-menu:hover { border-color: var(--mwdc-orange); box-shadow: var(--sh-sm); }
.user-menu .user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: var(--fs-sm); color: #fff;
}
.nav-label-wrap { display: flex; flex-direction: column; gap: 1px; }
.nav-label-wrap .nav-label { font-size: var(--fs-sm); }
.nav-label-wrap .nav-desc {
  font-size: 10px;
  color: rgba(255, 248, 240, 0.35);
  font-weight: 400;
  line-height: 1.2;
}
.nav-link:hover .nav-desc { color: rgba(255, 248, 240, 0.5); }
.nav-link.active .nav-desc { color: rgba(255, 248, 240, 0.5); }

/* ---- Breadcrumbs ---- */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.breadcrumbs a:hover { color: var(--mwdc-burgundy) !important; }

/* ---- User menu as link ---- */
.user-menu {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 6px 6px;
  border-radius: var(--r-pill);
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
}
.user-menu:hover { border-color: var(--mwdc-orange); box-shadow: var(--sh-sm); }
.user-menu .user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: var(--fs-sm); color: #fff;
}
.nav-link .nav-badge {
  margin-left: auto;
  background: var(--mwdc-orange);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--r-pill);
  line-height: 1.4;
}
.nav-footer {
  margin-top: auto;
  padding: 16px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: var(--fs-xs);
  color: rgba(255, 248, 240, 0.4);
}
.nav-footer a { color: rgba(255, 248, 240, 0.6); }
.nav-footer a:hover { color: #fff; }
.nav-footer .built-by { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.nav-footer .built-by img { height: 16px; opacity: 0.7; filter: brightness(0) invert(1); }

/* ---- Topbar ---- */
.topbar {
  grid-area: topbar;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: var(--sh-xs);
}
.topbar-title {
  font-family: var(--font-head);
  font-size: var(--fs-lg);
  font-weight: 600;
  color: var(--mwdc-burgundy);
}
.topbar-sub {
  font-size: var(--fs-xs);
  color: var(--text-3);
  font-weight: 500;
}
.topbar-spacer { flex: 1; }
.topbar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--subtle);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  padding: 8px 16px;
  width: 320px;
  transition: all var(--dur-fast) var(--ease);
}
.topbar-search:focus-within {
  border-color: var(--mwdc-orange);
  box-shadow: var(--sh-focus);
  background: var(--surface);
}
.topbar-search input {
  border: none;
  background: transparent;
  outline: none;
  flex: 1;
  font-size: var(--fs-sm);
  color: var(--text-1);
}
.topbar-search input::placeholder { color: var(--text-3); }

/* ---- User menu ---- */
.user-menu {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 6px 6px;
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease);
}
.user-menu:hover { background: var(--subtle); }
.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--r-circle);
  background: linear-gradient(135deg, var(--mwdc-burgundy), var(--mwdc-orange));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: var(--fs-sm);
  flex-shrink: 0;
}
.user-info { display: flex; flex-direction: column; line-height: 1.3; }
.user-name { font-size: var(--fs-sm); font-weight: 600; color: var(--text-1); }
.user-role { font-size: var(--fs-xs); color: var(--text-3); }

/* ---- Main content ---- */
.main {
  grid-area: main;
  padding: 32px;
  overflow-y: auto;
}
.main-inner { max-width: var(--content-max); margin: 0 auto; }

/* ---- Page header ---- */
.page-head { margin-bottom: 32px; }
.page-head .eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mwdc-orange);
  margin-bottom: 12px;
}
.page-head .eyebrow::before {
  content: "";
  width: 28px;
  height: 2px;
  background: var(--mwdc-orange);
  border-radius: 2px;
}
.page-head h1 {
  font-size: var(--fs-4xl);
  font-weight: 800;
  margin-bottom: 8px;
}
.page-head .lead {
  font-size: var(--fs-lg);
  color: var(--text-2);
  max-width: 68ch;
}

/* ---- Cards ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--r-lg);
  padding: 24px;
  box-shadow: var(--sh-sm);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
@media (hover: hover) {
  .card:hover {
    transform: translateY(-2px);
    box-shadow: var(--sh-lg);
    border-color: var(--border-strong);
  }
}
.card-ic {
  width: 48px;
  height: 48px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  font-size: 22px;
}
.card h3 { font-size: var(--fs-lg); margin-bottom: 8px; }
.card p { font-size: var(--fs-sm); }

/* ---- Grid ---- */
.grid { display: grid; gap: var(--gap); }
.g-2 { grid-template-columns: repeat(2, 1fr); }
.g-3 { grid-template-columns: repeat(3, 1fr); }
.g-4 { grid-template-columns: repeat(4, 1fr); }
.g-auto { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  font-weight: 600;
  font-family: var(--font-body);
  transition: all var(--dur-fast) var(--ease);
  white-space: nowrap;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: var(--mwdc-burgundy);
  color: #fff;
}
.btn-primary:hover {
  background: var(--mwdc-burgundy-3);
  color: #fff;
  box-shadow: var(--sh-burgundy);
}
.btn-accent {
  background: var(--mwdc-orange);
  color: #fff;
}
.btn-accent:hover {
  background: var(--mwdc-orange-2);
  color: #fff;
  box-shadow: 0 4px 12px rgba(236, 70, 0, 0.3);
}
.btn-outline {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text-1);
}
.btn-outline:hover {
  background: var(--subtle);
  border-color: var(--mwdc-orange);
  color: var(--mwdc-burgundy);
}
.btn-ghost {
  background: transparent;
  color: var(--text-2);
}
.btn-ghost:hover { background: var(--subtle); color: var(--text-1); }
.btn-sm { padding: 6px 14px; font-size: var(--fs-xs); }
.btn-lg { padding: 14px 28px; font-size: var(--fs-md); }

/* ---- Badges & pills ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.badge-burgundy { background: rgba(55, 0, 0, 0.08); color: var(--mwdc-burgundy); }
.badge-orange { background: rgba(236, 70, 0, 0.1); color: var(--mwdc-orange); }
.badge-warm { background: rgba(247, 149, 32, 0.12); color: #b45309; }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-info { background: var(--info-bg); color: var(--info); }

/* Subject area badges */
.badge-water { background: var(--subject-water-bg); color: var(--subject-water); }
.badge-agri { background: var(--subject-agri-bg); color: var(--subject-agri); }
.badge-comm { background: var(--subject-comm-bg); color: var(--subject-comm); }
.badge-env { background: var(--subject-env-bg); color: var(--subject-env); }

/* ---- Callouts ---- */
.callout {
  border-radius: var(--r-lg);
  padding: 20px 24px;
  border: 1px solid var(--border-light);
  border-left: 4px solid var(--mwdc-warm);
  background: var(--subtle);
}
.callout h4 { color: var(--mwdc-burgundy); margin-bottom: 8px; }
.callout p { font-size: var(--fs-sm); }
.callout-info { border-left-color: var(--info); background: var(--info-bg); }
.callout-success { border-left-color: var(--success); background: var(--success-bg); }
.callout-warn { border-left-color: var(--warning); background: var(--warning-bg); }
.callout-danger { border-left-color: var(--danger); background: var(--danger-bg); }

/* ---- Tables ---- */
.tbl-wrap {
  overflow-x: auto;
  border: 1px solid var(--border-light);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
}
table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
th {
  background: var(--mwdc-burgundy);
  color: #fff;
  text-align: left;
  padding: 12px 16px;
  font-weight: 700;
  font-size: var(--fs-xs);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}
td { padding: 14px 16px; border-top: 1px solid var(--border-light); vertical-align: top; }
tbody tr:nth-child(even) { background: var(--subtle); }
tbody tr:hover { background: rgba(236, 70, 0, 0.04); }

/* ---- Subject tiles ---- */
.subject-tile {
  display: flex;
  flex-direction: column;
  padding: 28px;
  border-radius: var(--r-xl);
  cursor: pointer;
  transition: all var(--dur) var(--ease);
  position: relative;
  overflow: hidden;
  min-height: 180px;
}
.subject-tile:hover { transform: translateY(-4px); box-shadow: var(--sh-xl); }
.subject-tile::after {
  content: "";
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 4px;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--dur) var(--ease);
}
.subject-tile:hover::after { transform: scaleX(1); }
.subject-tile-water { background: linear-gradient(135deg, #ecfeff, #cffafe); }
.subject-tile-water::after { background: var(--subject-water); }
.subject-tile-water h3 { color: var(--subject-water); }
.subject-tile-agri { background: linear-gradient(135deg, #f7fee7, #ecfccb); }
.subject-tile-agri::after { background: var(--subject-agri); }
.subject-tile-agri h3 { color: var(--subject-agri); }
.subject-tile-comm { background: linear-gradient(135deg, #fdf4ff, #fae8ff); }
.subject-tile-comm::after { background: var(--subject-comm); }
.subject-tile-comm h3 { color: var(--subject-comm); }
.subject-tile-env { background: linear-gradient(135deg, #ecfdf5, #d1fae5); }
.subject-tile-env::after { background: var(--subject-env); }
.subject-tile-env h3 { color: var(--subject-env); }
.subject-tile .tile-count {
  font-family: var(--font-head);
  font-size: var(--fs-5xl);
  font-weight: 800;
  color: var(--text-1);
  line-height: 1;
  margin-top: auto;
}
.subject-tile .tile-label {
  font-size: var(--fs-sm);
  color: var(--text-2);
  font-weight: 500;
}

/* ---- Stat cards ---- */
.stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-value {
  font-family: var(--font-head);
  font-size: var(--fs-4xl);
  font-weight: 800;
  color: var(--mwdc-burgundy);
  line-height: 1;
}
.stat-label {
  font-size: var(--fs-sm);
  color: var(--text-2);
  font-weight: 500;
}
.stat-trend {
  font-size: var(--fs-xs);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.stat-trend.up { color: var(--success); }
.stat-trend.down { color: var(--danger); }

/* ---- Resource card ---- */
.resource-card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--r-lg);
  padding: 20px;
  transition: all var(--dur) var(--ease);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.resource-card:hover {
  border-color: var(--mwdc-orange);
  box-shadow: var(--sh-md);
  transform: translateY(-2px);
}
.resource-card .res-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.resource-card h4 { font-size: var(--fs-md); color: var(--text-1); margin: 0; }
.resource-card .res-excerpt { font-size: var(--fs-sm); color: var(--text-2); line-height: 1.5; }
.resource-card .res-source { font-size: var(--fs-xs); color: var(--text-3); }

/* ---- Chat ---- */
.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--topbar-h) - 64px);
  max-height: 720px;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.chat-msg {
  display: flex;
  gap: 12px;
  max-width: 80%;
}
.chat-msg.user { align-self: flex-end; flex-direction: row-reverse; }
.chat-msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--r-circle);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: var(--fs-sm);
}
.chat-msg.user .chat-msg-avatar { background: var(--mwdc-orange); color: #fff; }
.chat-msg.ai .chat-msg-avatar { background: var(--mwdc-burgundy); color: #fff; }
.chat-msg-bubble {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--r-lg);
  padding: 14px 18px;
  font-size: var(--fs-sm);
  line-height: 1.6;
  box-shadow: var(--sh-xs);
}
.chat-msg.user .chat-msg-bubble { background: var(--mwdc-burgundy); color: #fff; border-color: var(--mwdc-burgundy); }
.chat-msg.ai .chat-msg-bubble { background: var(--surface); }
.chat-msg-bubble .source-cards {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.chat-msg-bubble .source-card {
  font-size: var(--fs-xs);
  padding: 8px 12px;
  background: var(--subtle);
  border-radius: var(--r-sm);
  border-left: 3px solid var(--mwdc-warm);
}
.chat-input-bar {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  gap: 12px;
  align-items: flex-end;
  border-radius: 0 0 var(--r-xl) var(--r-xl);
}
.chat-input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 16px;
  font-size: var(--fs-sm);
  resize: none;
  min-height: 44px;
  max-height: 120px;
  outline: none;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.chat-input:focus { border-color: var(--mwdc-orange); box-shadow: var(--sh-focus); }
.chat-suggestions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 0 24px 12px;
}
.chat-suggestion {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  color: var(--text-2);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
  background: var(--surface);
}
.chat-suggestion:hover { border-color: var(--mwdc-orange); color: var(--mwdc-burgundy); background: rgba(236, 70, 0, 0.04); }

/* ---- Listen button ---- */
.btn-listen {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--r-pill);
  background: rgba(247, 149, 32, 0.1);
  color: #b45309;
  font-size: var(--fs-xs);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
  border: 1px solid transparent;
}
.btn-listen:hover { background: rgba(247, 149, 32, 0.18); border-color: var(--mwdc-warm); }
.btn-listen.playing { background: var(--mwdc-warm); color: #fff; }

/* ---- Demo banner ---- */
.demo-banner {
  background: linear-gradient(90deg, var(--warning-bg), #fef3c7);
  border-bottom: 1px solid var(--warning-border);
  padding: 8px 24px;
  font-size: var(--fs-xs);
  color: #92400e;
  text-align: center;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.demo-banner strong { color: #78350f; }

/* ---- Forms ---- */
.form-group { margin-bottom: 20px; }
.form-label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-1);
  margin-bottom: 6px;
}
.form-input, .form-textarea, .form-select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  color: var(--text-1);
  background: var(--surface);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
  outline: none;
}
.form-input:focus, .form-textarea:focus, .form-select:focus {
  border-color: var(--mwdc-orange);
  box-shadow: var(--sh-focus);
}
.form-textarea { min-height: 120px; resize: vertical; }
.form-hint { font-size: var(--fs-xs); color: var(--text-3); margin-top: 4px; }

/* ---- Empty state ---- */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-3);
}
.empty-state .empty-ic {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  border-radius: var(--r-circle);
  background: var(--subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
}

/* ---- Loading ---- */
.loading-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}
.loading-dots span {
  width: 8px;
  height: 8px;
  border-radius: var(--r-circle);
  background: var(--mwdc-orange);
  animation: bounce-dot 1.4s infinite ease-in-out both;
}
.loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.loading-dots span:nth-child(2) { animation-delay: -0.16s; }
@keyframes bounce-dot {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* ---- Responsive ---- */
@media (max-width: 1024px) {
  .app { grid-template-columns: 1fr; grid-template-areas: "topbar" "main"; }
  .nav { display: none; }
  .g-3, .g-4 { grid-template-columns: repeat(2, 1fr); }
  .topbar-search { width: 200px; }
}
@media (max-width: 640px) {
  .main { padding: 20px 16px; }
  .g-2, .g-3, .g-4 { grid-template-columns: 1fr; }
  .topbar-search { display: none; }
  .topbar { padding: 0 16px; }
  .page-head h1 { font-size: var(--fs-3xl); }
  .user-info { display: none; }
}

/* ---- Print ---- */
@media print {
  .nav, .topbar, .demo-banner { display: none; }
  .app { grid-template-columns: 1fr; grid-template-areas: "main"; }
  .main { padding: 0; }
  .card, .tbl-wrap { box-shadow: none; }
  * { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}

/* ==========================================================================
   HERO — Split-screen with portrait image
   The CEO portrait (head-to-knees, 2:3 ratio) is treated as an editorial
   hero image, not a pasted photo. The image blends seamlessly into the
   burgundy brand panel via a gradient mask on the left edge.
   ========================================================================== */

.hero {
  display: grid;
  grid-template-columns: 1fr 480px;
  border-radius: var(--r-2xl);
  overflow: hidden;
  margin-bottom: 32px;
  background: linear-gradient(135deg, var(--mwdc-burgundy) 0%, var(--mwdc-burgundy-2) 50%, #2a0000 100%);
  position: relative;
  min-height: 560px;
  box-shadow: var(--sh-xl);
}

/* ---- Copy panel ---- */
.hero-copy {
  padding: 56px 48px 48px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  z-index: 2;
}
.hero-copy::before {
  content: "";
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 120px;
  background: linear-gradient(to right, transparent, var(--mwdc-burgundy-2) 80%);
  pointer-events: none;
  z-index: 3;
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: rgba(236, 70, 0, 0.18);
  border: 1px solid rgba(236, 70, 0, 0.3);
  border-radius: var(--r-pill);
  color: var(--mwdc-warm-2);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 24px;
  align-self: flex-start;
}
.hero-eyebrow .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--mwdc-warm);
  box-shadow: 0 0 12px var(--mwdc-warm);
  animation: pulse-dot 2.5s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.85); }
}

.hero-headline {
  font-family: var(--font-head);
  font-size: clamp(2.5rem, 5vw, 3.75rem);
  font-weight: 800;
  line-height: 1.02;
  letter-spacing: -0.025em;
  color: #fff;
  margin-bottom: 8px;
}
.hero-headline .accent {
  color: var(--mwdc-warm-2);
  display: block;
}

.hero-sub {
  font-family: var(--font-head);
  font-size: var(--fs-lg);
  font-weight: 500;
  color: rgba(255, 248, 240, 0.55);
  letter-spacing: 0.02em;
  margin-bottom: 20px;
}

.hero-lead {
  font-size: var(--fs-md);
  line-height: 1.65;
  color: rgba(255, 248, 240, 0.78);
  max-width: 48ch;
  margin-bottom: 32px;
}

.hero-cta-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.hero-cta-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.18);
}
.hero-cta-secondary:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

/* ---- Image panel ---- */
.hero-image {
  position: relative;
  overflow: hidden;
  background: var(--mwdc-burgundy-2);
}
.hero-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 20%;
  filter: saturate(0.92) contrast(1.05);
}
/* Gradient blend: image fades into burgundy on the left edge */
.hero-image::before {
  content: "";
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 40%;
  background: linear-gradient(to right, var(--mwdc-burgundy) 0%, rgba(55, 0, 0, 0.6) 40%, transparent 100%);
  z-index: 2;
  pointer-events: none;
}
/* Bottom gradient for depth */
.hero-image::after {
  content: "";
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 40%;
  background: linear-gradient(to top, rgba(55, 0, 0, 0.7) 0%, transparent 100%);
  z-index: 2;
  pointer-events: none;
}

/* ---- Attribution overlay on image ---- */
.hero-attribution {
  position: absolute;
  bottom: 24px;
  right: 24px;
  z-index: 4;
  text-align: right;
  padding: 12px 18px;
  background: rgba(55, 0, 0, 0.55);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: var(--r-md);
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.hero-attribution .name {
  font-family: var(--font-head);
  font-size: var(--fs-md);
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}
.hero-attribution .title {
  font-size: var(--fs-xs);
  color: rgba(255, 248, 240, 0.65);
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* ---- Decorative glow ---- */
.hero-glow {
  position: absolute;
  pointer-events: none;
  z-index: 1;
}
.hero-glow-1 {
  top: -80px;
  right: 30%;
  width: 320px;
  height: 320px;
  background: radial-gradient(circle, rgba(236, 70, 0, 0.12) 0%, transparent 65%);
}
.hero-glow-2 {
  bottom: -100px;
  left: -60px;
  width: 280px;
  height: 280px;
  background: radial-gradient(circle, rgba(247, 149, 32, 0.08) 0%, transparent 65%);
}

/* ---- Responsive ---- */
@media (max-width: 1024px) {
  .hero {
    grid-template-columns: 1fr;
    grid-template-rows: 360px 1fr;
    min-height: auto;
  }
  .hero-image {
    order: 1;
  }
  .hero-image img {
    object-position: center 25%;
  }
  .hero-image::before {
    width: 100%;
    height: 55%;
    background: linear-gradient(to top, var(--mwdc-burgundy) 0%, rgba(55, 0, 0, 0.5) 50%, transparent 100%);
    top: auto;
    bottom: 0;
  }
  .hero-image::after { display: none; }
  .hero-copy {
    order: 2;
    padding: 40px 32px;
  }
  .hero-copy::before { display: none; }
  .hero-attribution {
    bottom: 16px;
    right: 16px;
  }
}

@media (max-width: 640px) {
  .hero {
    grid-template-rows: 280px 1fr;
    border-radius: var(--r-lg);
  }
  .hero-image { order: 1; }
  .hero-copy {
    order: 2;
    padding: 32px 24px;
  }
  .hero-headline { font-size: clamp(2rem, 8vw, 2.5rem); }
  .hero-lead { font-size: var(--fs-sm); }
  .hero-attribution {
    bottom: 12px;
    right: 12px;
    padding: 8px 12px;
  }
  .hero-attribution .name { font-size: var(--fs-sm); }
  .hero-attribution .title { font-size: 10px; }
  .hero-cta-row .btn { flex: 1; }
}

/* ==========================================================================
   CHAT — Conversational AI interface
   ========================================================================== */

.chat-container {
  display: flex;
  flex-direction: column;
  height: 600px;
  max-height: 70vh;
  background: var(--mwdc-cream);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.chat-msg {
  display: flex;
  gap: 12px;
  max-width: 80%;
  animation: chat-msg-in 0.3s ease-out;
}
@keyframes chat-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat-msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: var(--fs-sm);
  flex-shrink: 0;
}
.chat-msg.ai .chat-msg-avatar {
  background: linear-gradient(135deg, var(--mwdc-burgundy), var(--mwdc-orange));
  color: #fff;
}
.chat-msg.user .chat-msg-avatar {
  background: linear-gradient(135deg, var(--mwdc-warm), #b45309);
  color: #fff;
}

.chat-msg-bubble {
  background: #fff;
  border-radius: var(--r-lg);
  padding: 14px 18px;
  box-shadow: var(--sh-sm);
  font-size: var(--fs-sm);
  line-height: 1.6;
  color: var(--text-1);
}
.chat-msg.user .chat-msg-bubble {
  background: var(--mwdc-burgundy);
  color: #fff;
}
.chat-msg-bubble p { margin-bottom: 8px; }
.chat-msg-bubble p:last-child { margin-bottom: 0; }
.chat-msg-bubble strong { color: var(--mwdc-orange); font-weight: 700; }
.chat-msg.user .chat-msg-bubble strong { color: var(--mwdc-warm-2); }

/* Source cards in chat responses */
.source-cards {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.source-card {
  display: block;
  padding: 8px 12px;
  background: rgba(236, 70, 0, 0.06);
  border: 1px solid rgba(236, 70, 0, 0.15);
  border-radius: var(--r-md);
  font-size: var(--fs-xs);
  color: var(--text-2);
  text-decoration: none;
  transition: all 0.15s ease;
}
.source-card:hover {
  background: rgba(236, 70, 0, 0.12);
  border-color: rgba(236, 70, 0, 0.3);
  color: var(--mwdc-burgundy);
}

/* Typing indicator */
.chat-typing {
  display: flex;
  gap: 4px;
  padding: 4px 0;
}
.chat-typing span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-3);
  animation: typing-bounce 1.4s ease-in-out infinite;
}
.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* Suggestion chips */
.chat-suggestions {
  padding: 12px 24px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  border-top: 1px solid var(--border);
  background: #fff;
}
.chat-suggestion {
  padding: 6px 14px;
  background: var(--mwdc-cream);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.15s ease;
}
.chat-suggestion:hover {
  background: rgba(236, 70, 0, 0.08);
  border-color: var(--mwdc-orange);
  color: var(--mwdc-burgundy);
}

/* Input bar */
.chat-input-bar {
  padding: 16px 24px;
  display: flex;
  gap: 12px;
  border-top: 1px solid var(--border);
  background: #fff;
}
.chat-input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 10px 16px;
  font-size: var(--fs-sm);
  font-family: inherit;
  resize: none;
  max-height: 120px;
  outline: none;
  transition: border-color 0.15s ease;
}
.chat-input:focus {
  border-color: var(--mwdc-orange);
  box-shadow: 0 0 0 3px rgba(236, 70, 0, 0.1);
}

@media (max-width: 640px) {
  .chat-container { height: 500px; }
  .chat-msg { max-width: 90%; }
  .chat-messages { padding: 16px; }
  .chat-suggestions { padding: 10px 16px; }
  .chat-input-bar { padding: 12px 16px; }
}

/* ==========================================================================
   TABLES — data tables for admin views
   ========================================================================== */

.tbl-wrap {
  overflow-x: auto;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--sh-sm);
}
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}
.tbl thead th {
  text-align: left;
  padding: 12px 16px;
  font-weight: 600;
  color: var(--text-2);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  background: var(--mwdc-cream);
}
.tbl tbody td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-1);
  vertical-align: middle;
}
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover { background: var(--mwdc-cream); }

/* ---- Form elements ---- */
.form-select {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 10px 14px;
  font-size: var(--fs-sm);
  font-family: inherit;
  background: var(--surface);
  color: var(--text-1);
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s ease;
  appearance: none;
  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='%236b5d50' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}
.form-select:focus { border-color: var(--mwdc-orange); box-shadow: 0 0 0 3px rgba(236,70,0,0.1); }
.form-hint {
  display: block;
  font-size: var(--fs-xs);
  color: var(--text-3);
  margin-top: 4px;
}

/* ---- Badges ---- */
.badge-danger { background: rgba(220,38,38,0.1); color: var(--danger); }
.badge-info { background: rgba(59,130,246,0.1); color: #2563eb; }
.badge-orange { background: rgba(236,70,0,0.1); color: var(--mwdc-orange); }

/* ---- User avatar ---- */
.user-avatar {
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

/* ---- Empty state ---- */
.empty-state {
  text-align: center;
  padding: 64px 24px;
  color: var(--text-3);
}
.empty-ic {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}
.empty-state h3 {
  font-size: var(--fs-xl);
  color: var(--text-2);
  margin-bottom: 8px;
}
.empty-state p {
  font-size: var(--fs-sm);
  color: var(--text-3);
}

/* ---- Callouts ---- */
.callout-info {
  background: rgba(59,130,246,0.06);
  border-left: 4px solid #2563eb;
}
.callout-danger {
  background: rgba(220,38,38,0.06);
  border-left: 4px solid var(--danger);
}
.callout-success {
  background: rgba(5,150,105,0.06);
  border-left: 4px solid var(--success);
}

/* ==========================================================================
   UX OVERHAUL — World-class components for non-technical users
   ========================================================================== */

/* ---- Page head with guidance ---- */
.page-head {
  margin-bottom: 32px;
}
.page-head .eyebrow {
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--mwdc-orange);
  margin-bottom: 8px;
}
.page-head h1 {
  font-family: var(--font-head);
  font-size: var(--fs-4xl);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--text-1);
  margin-bottom: 8px;
}
.page-head .lead {
  font-size: var(--fs-md);
  line-height: 1.65;
  color: var(--text-2);
  max-width: 64ch;
}

/* ---- Intro / guidance panel ---- */
.intro-panel {
  background: linear-gradient(135deg, var(--mwdc-cream) 0%, #faf7f2 100%);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 28px 32px;
  margin-bottom: 28px;
  position: relative;
  overflow: hidden;
}
.intro-panel::before {
  content: "";
  position: absolute;
  top: 0; left: 0;
  width: 4px; height: 100%;
  background: linear-gradient(to bottom, var(--mwdc-orange), var(--mwdc-warm));
}
.intro-panel h3 {
  font-family: var(--font-head);
  font-size: var(--fs-xl);
  font-weight: 700;
  color: var(--text-1);
  margin-bottom: 8px;
}
.intro-panel p {
  font-size: var(--fs-md);
  line-height: 1.65;
  color: var(--text-2);
  max-width: 60ch;
}
.intro-panel .intro-steps {
  display: flex;
  gap: 20px;
  margin-top: 20px;
  flex-wrap: wrap;
}
.intro-step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  color: var(--text-2);
  text-decoration: none;
  transition: all var(--dur-fast) var(--ease);
}
.intro-step:hover {
  border-color: var(--mwdc-orange);
  box-shadow: var(--sh-sm);
  color: var(--text-1);
  transform: translateY(-1px);
}
.intro-step .step-num {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--mwdc-burgundy);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-xs); font-weight: 700;
  flex-shrink: 0;
}

/* ---- Getting started guide ---- */
.getting-started {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}
.gs-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 24px;
  text-decoration: none;
  transition: all var(--dur) var(--ease);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.gs-card::after {
  content: "";
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--mwdc-orange), var(--mwdc-warm));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--dur) var(--ease);
}
.gs-card:hover {
  border-color: var(--mwdc-orange);
  box-shadow: var(--sh-md);
  transform: translateY(-2px);
}
.gs-card:hover::after { transform: scaleX(1); }
.gs-card .gs-num {
  font-family: var(--font-head);
  font-size: var(--fs-3xl);
  font-weight: 800;
  color: var(--mwdc-cream);
  line-height: 1;
  margin-bottom: 12px;
  position: absolute;
  top: 16px; right: 20px;
}
.gs-card .gs-icon {
  width: 44px; height: 44px;
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 16px;
  font-size: 22px;
}
.gs-card h4 {
  font-family: var(--font-head);
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--text-1);
  margin-bottom: 6px;
}
.gs-card p {
  font-size: var(--fs-sm);
  color: var(--text-2);
  line-height: 1.5;
  margin-bottom: 16px;
  flex-grow: 1;
}
.gs-card .gs-link {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--mwdc-orange);
  display: flex;
  align-items: center;
  gap: 4px;
}
.gs-card:hover .gs-link { gap: 8px; }

/* ---- Help banner (for pages that need context) ---- */
.help-banner {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 20px 24px;
  background: linear-gradient(135deg, rgba(236,70,0,0.04), rgba(247,149,32,0.04));
  border: 1px solid rgba(236,70,0,0.12);
  border-radius: var(--r-lg);
  margin-bottom: 24px;
}
.help-banner .help-ic {
  width: 40px; height: 40px;
  border-radius: var(--r-md);
  background: rgba(236,70,0,0.1);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: var(--mwdc-orange);
}
.help-banner h4 {
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--text-1);
  margin-bottom: 4px;
}
.help-banner p {
  font-size: var(--fs-sm);
  color: var(--text-2);
  line-height: 1.6;
}

/* ---- Section divider ---- */
.section-divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 32px 0 24px;
}
.section-divider::before,
.section-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}
.section-divider span {
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
}

/* ---- Stat card polish ---- */
.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stat-value {
  font-family: var(--font-head);
  font-size: var(--fs-3xl);
  font-weight: 800;
  color: var(--mwdc-burgundy);
  line-height: 1;
}
.stat-label {
  font-size: var(--fs-sm);
  color: var(--text-3);
  font-weight: 500;
}

/* ---- Subject tile polish ---- */
.subject-tile {
  display: flex;
  flex-direction: column;
  padding: 24px;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  transition: all var(--dur) var(--ease);
  min-height: 200px;
}
.subject-tile:hover {
  transform: translateY(-3px);
  box-shadow: var(--sh-lg);
  border-color: var(--mwdc-orange);
}
.tile-count {
  font-family: var(--font-head);
  font-size: var(--fs-2xl);
  font-weight: 800;
  color: var(--mwdc-burgundy);
}
.tile-label {
  font-size: var(--fs-xs);
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ---- Resource card polish ---- */
.resource-card {
  display: flex;
  flex-direction: column;
  padding: 20px;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  transition: all var(--dur) var(--ease);
  min-height: 200px;
}
.resource-card:hover {
  border-color: var(--mwdc-orange);
  box-shadow: var(--sh-md);
  transform: translateY(-2px);
}
.res-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.resource-card h4 {
  font-family: var(--font-head);
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--text-1);
  margin-bottom: 8px;
  line-height: 1.3;
}
.res-excerpt {
  font-size: var(--fs-sm);
  color: var(--text-2);
  line-height: 1.55;
  margin-bottom: 16px;
  flex-grow: 1;
}
.res-source {
  font-size: var(--fs-xs);
  color: var(--text-3);
  font-weight: 500;
}

/* ---- Listen button polish ---- */
.btn-listen {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  background: rgba(236,70,0,0.06);
  border: 1px solid rgba(236,70,0,0.15);
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--mwdc-orange);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
  text-decoration: none;
}
.btn-listen:hover {
  background: rgba(236,70,0,0.12);
  border-color: var(--mwdc-orange);
}
.btn-listen.playing {
  background: var(--mwdc-orange);
  color: #fff;
  animation: listen-pulse 1.5s ease-in-out infinite;
}
@keyframes listen-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(236,70,0,0.4); }
  50% { box-shadow: 0 0 0 6px rgba(236,70,0,0); }
}

/* ---- Badge polish ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.badge-burgundy { background: rgba(55,0,0,0.08); color: var(--mwdc-burgundy); }
.badge-success { background: rgba(5,150,105,0.1); color: var(--success); }
.badge-water { background: var(--subject-water-bg); color: var(--subject-water); }
.badge-agri { background: var(--subject-agri-bg); color: var(--subject-agri); }
.badge-comm { background: var(--subject-comm-bg); color: var(--subject-comm); }
.badge-env { background: var(--subject-env-bg); color: var(--subject-env); }

/* ---- Card polish ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--sh-xs);
  transition: box-shadow var(--dur-fast) var(--ease);
}
.card:hover { box-shadow: var(--sh-sm); }
.card h3, .card h4 { color: var(--text-1); }
.card-ic {
  width: 40px; height: 40px;
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 12px;
}

/* ---- Responsive getting started ---- */
@media (max-width: 1024px) {
  .getting-started { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .getting-started { grid-template-columns: 1fr; }
  .page-head h1 { font-size: var(--fs-3xl); }
  .intro-panel { padding: 20px; }
  .help-banner { padding: 16px; }
}



/* ==========================================================================
   FOOTER — Site-wide footer with security features
   ========================================================================== */
.site-footer {
  background: linear-gradient(180deg, var(--mwdc-burgundy) 0%, #2a0000 100%);
  color: var(--text-on-burgundy);
  margin-top: auto;
}
.footer-inner {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 48px 32px 32px;
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr 1.5fr;
  gap: 40px;
}
.footer-col { display: flex; flex-direction: column; }
.footer-brand img { margin-bottom: 12px; }
.footer-tagline {
  font-family: var(--font-head);
  font-size: var(--fs-lg);
  font-weight: 700;
  color: #fff;
  margin-bottom: 8px;
}
.footer-desc {
  font-size: var(--fs-sm);
  line-height: 1.6;
  color: var(--text-on-burgundy-2);
  margin-bottom: 16px;
}
.footer-built-by {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-xs);
  color: var(--text-on-burgundy-2);
}
.footer-built-by img { height: 20px; width: auto; }
.footer-heading {
  font-family: var(--font-head);
  font-size: var(--fs-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--mwdc-warm);
  margin-bottom: 16px;
}
.footer-links {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.footer-links a {
  font-size: var(--fs-sm);
  color: var(--text-on-burgundy-2);
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease);
}
.footer-links a:hover { color: var(--mwdc-orange); }
.footer-security-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.footer-security-list li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: var(--fs-xs);
  color: var(--text-on-burgundy-2);
  line-height: 1.5;
}
.footer-security-list svg {
  color: var(--mwdc-warm);
  flex-shrink: 0;
  margin-top: 2px;
}
.footer-bottom {
  border-top: 1px solid rgba(255, 248, 240, 0.08);
  padding: 16px 32px;
}
.footer-bottom-inner {
  max-width: var(--content-max);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-xs);
  color: var(--text-on-burgundy-2);
  flex-wrap: wrap;
}
.footer-sep { color: rgba(255, 248, 240, 0.3); }
.footer-admin-link {
  color: var(--text-on-burgundy-2);
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease);
}
.footer-admin-link:hover { color: var(--mwdc-orange); }
.footer-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  font-weight: 600;
}
.footer-badge-dev {
  background: rgba(247, 149, 32, 0.15);
  color: var(--mwdc-warm);
}
.footer-badge-prod {
  background: rgba(5, 150, 105, 0.15);
  color: #6ee7b7;
}
@media (max-width: 1024px) {
  .footer-inner { grid-template-columns: 1fr 1fr; gap: 32px; padding: 32px 24px 24px; }
}
@media (max-width: 640px) {
  .footer-inner { grid-template-columns: 1fr; gap: 24px; padding: 24px 16px; }
  .footer-bottom { padding: 12px 16px; }
  .footer-bottom-inner { justify-content: center; text-align: center; }
}

/* ==========================================================================
   TOAST NOTIFICATIONS
   ========================================================================== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: 380px;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--sh-lg);
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-1);
  pointer-events: auto;
  opacity: 0;
  transform: translateX(100%);
  transition: all 0.3s var(--ease-out);
  border-left: 4px solid var(--text-3);
}
.toast.toast-show {
  opacity: 1;
  transform: translateX(0);
}
.toast-success { border-left-color: var(--success); }
.toast-success .toast-ic { color: var(--success); }
.toast-error { border-left-color: var(--danger); }
.toast-error .toast-ic { color: var(--danger); }
.toast-warning { border-left-color: var(--warning); }
.toast-warning .toast-ic { color: var(--warning); }
.toast-info { border-left-color: var(--info); }
.toast-info .toast-ic { color: var(--info); }
.toast-ic { flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.toast-msg { flex: 1; line-height: 1.4; }
.toast-close {
  flex-shrink: 0;
  width: 24px; height: 24px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 18px;
  color: var(--text-3);
  border-radius: var(--r-xs);
  transition: all var(--dur-fast) var(--ease);
}
.toast-close:hover { background: var(--bg-2); color: var(--text-1); }
@media (max-width: 640px) {
  .toast-container { top: 10px; right: 10px; left: 10px; max-width: none; }
  .toast { transform: translateY(-100%); }
  .toast.toast-show { transform: translateY(0); }
}

/* ==========================================================================
   MOBILE BOTTOM NAV
   ========================================================================== */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 6px 0 env(safe-area-inset-bottom, 8px);
  z-index: 100;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.06);
}
.mobile-nav-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 4px;
  text-decoration: none;
  color: var(--text-3);
  font-size: 10px;
  font-weight: 600;
  font-family: var(--font-head);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  transition: color var(--dur-fast) var(--ease);
  flex: 1;
  min-width: 0;
}
.mobile-nav-link.active { color: var(--mwdc-orange); }
.mobile-nav-link:active { color: var(--mwdc-burgundy); }
@media (max-width: 1024px) {
  .mobile-nav { display: flex; }
  .main { padding-bottom: 70px; }
}
@media (max-width: 640px) {
  .mobile-nav-link span { font-size: 9px; }
}

/* ==========================================================================
   MOBILE PIXEL-PERFECT SWEEP — All pages, all cards
   Targets inline grid/flex layouts that don't collapse on mobile
   ========================================================================== */

/* ---- Tablet (<=1024px) ---- */
@media (max-width: 1024px) {
  /* Two-column grids with fixed sidebars → stack */
  .grid[style*="grid-template-columns: 1fr 300px"],
  .grid[style*="grid-template-columns: 1fr 320px"],
  .grid[style*="grid-template-columns: 1fr 340px"],
  .grid[style*="grid-template-columns: 1fr 480px"],
  .grid[style*="grid-template-columns: 2fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
  /* Tools/admin 2-col grids → stack */
  .grid[style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
  /* Horizontal card rows that overflow → wrap */
  .card[style*="display: flex; align-items: center; gap: 16px"] {
    flex-wrap: wrap;
  }
}

/* ---- Mobile (<=640px) ---- */
@media (max-width: 640px) {
  /* Page heads — tighter spacing */
  .page-head { margin-bottom: 20px; }
  .page-head h1 { font-size: var(--fs-2xl) !important; }
  .page-head .lead { font-size: var(--fs-sm); }

  /* All grids → single column */
  .grid[style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }

  /* Cards — full width, tighter padding */
  .card { padding: 16px !important; border-radius: var(--r-md) !important; }
  .card .card-ic { width: 32px; height: 32px; margin-bottom: 8px; }

  /* Horizontal flex layouts → wrap or stack */
  [style*="display: flex; align-items: center; justify-content: space-between"] {
    flex-wrap: wrap;
    gap: 8px !important;
  }
  [style*="display: flex; align-items: flex-start; justify-content: space-between"] {
    flex-wrap: wrap;
    gap: 8px !important;
  }
  [style*="display: flex; gap: 16px"] {
    gap: 10px !important;
    flex-wrap: wrap;
  }
  [style*="display: flex; gap: 12px"] {
    gap: 8px !important;
    flex-wrap: wrap;
  }

  /* Quick-link cards on home → stack vertically */
  .card[style*="display: flex; align-items: center; gap: 16px; cursor: pointer"] {
    flex-direction: column;
    align-items: stretch !important;
    text-align: left !important;
    gap: 8px !important;
  }
  .card[style*="display: flex; align-items: center; gap: 16px; cursor: pointer"] > * {
    width: 100%;
  }

  /* Knowledge/Community search bars → full width */
  [style*="display: flex; gap: 16px; margin-bottom: 20px"] {
    flex-direction: column;
    gap: 10px !important;
  }
  [style*="flex: 1; min-width: 240px"],
  [style*="flex: 1; min-width: 280px"] {
    min-width: 0 !important;
    width: 100% !important;
  }

  /* Topic chips → wrap nicely */
  [style*="display: flex; gap: 8px; flex-wrap: wrap"] {
    gap: 6px !important;
  }

  /* Tables → horizontal scroll */
  .tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tbl-wrap table { min-width: 500px; }

  /* Forms → full width inputs */
  input[type="text"], input[type="email"], input[type="search"],
  input[type="password"], input[type="number"], textarea, select {
    width: 100% !important;
    max-width: 100% !important;
  }

  /* Buttons → full width on mobile for primary actions */
  .btn { width: 100%; justify-content: center; }
  .btn-sm { width: auto; }
  .btn-row { flex-direction: column; gap: 8px; }
  .btn-row .btn { width: 100%; }

  /* Hero — already handled but tighten */
  .hero { min-height: 400px !important; border-radius: var(--r-lg) !important; }
  .hero-copy { padding: 24px 20px !important; }

  /* Community compose box → stack */
  [style*="display: flex; gap: 16px; margin-bottom: 20px; padding: 16px 20px"] {
    flex-direction: column;
    gap: 10px !important;
    padding: 14px !important;
  }

  /* Community post actions → wrap */
  [style*="display: flex; gap: 4px; padding-top: 12px"] {
    flex-wrap: wrap;
    gap: 6px !important;
  }

  /* Observations meta row → stack */
  [style*="display: flex; gap: 16px; font-size: var(--fs-sm)"] {
    flex-direction: column;
    gap: 6px !important;
  }

  /* Admin settings rows → stack */
  [style*="display: flex; justify-content: space-between; padding: 10px 0"] {
    flex-direction: column;
    gap: 6px !important;
    align-items: flex-start !important;
  }

  /* Admin settings forms → stack */
  [style*="display: flex; gap: 8px; align-items: center"] {
    flex-direction: column;
    align-items: stretch !important;
    gap: 8px !important;
  }
  [style*="display: flex; gap: 8px; align-items: center"] .btn {
    width: 100%;
  }

  /* Login container → full width */
  [style*="max-width: 480px; margin: 60px auto"] {
    margin: 20px auto !important;
    max-width: 100% !important;
  }

  /* Tools subscription gate → tighter */
  [style*="text-align: center; padding: 48px 32px; max-width: 560px"] {
    padding: 24px 16px !important;
  }
  [style*="max-width: 420px; margin-left: auto; margin-right: auto"] {
    max-width: 100% !important;
  }

  /* Tools tab bar → scrollable */
  [style*="display: flex; gap: 8px; margin-bottom: 24px; border-bottom"] {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap !important;
  }

  /* Article detail sidebar → stack above content */
  .grid[style*="grid-template-columns: 1fr 300px"] > *:last-child {
    order: -1;
  }

  /* Article author row → stack */
  [style*="display: flex; align-items: center; gap: 16px; padding: 16px 0"] {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 10px !important;
  }

  /* Article related → stack */
  [style*="display: flex; gap: 16px; align-items: flex-start"] {
    flex-direction: column;
    gap: 10px !important;
  }

  /* Audit log header → stack */
  [style*="display: flex; align-items: center; gap: 12px"] {
    flex-wrap: wrap;
    gap: 8px !important;
  }

  /* Stats badges → wrap */
  [style*="display: flex; gap: 10px; margin-bottom: 16px"] {
    flex-wrap: wrap;
    gap: 8px !important;
  }

  /* Help banners → tighter */
  .help-banner { padding: 14px !important; }
  .help-banner h4 { font-size: var(--fs-sm); }
  .help-banner p { font-size: var(--fs-xs); line-height: 1.5; }

  /* Intro panels → tighter */
  .intro-panel { padding: 16px !important; }

  /* Empty states → tighter */
  .empty-state { padding: 32px 16px !important; }
  .empty-state .empty-ic { width: 48px; height: 48px; font-size: 24px; }
  .empty-state h3 { font-size: var(--fs-lg); }
  .empty-state p { font-size: var(--fs-sm); }

  /* Getting started cards → tighter */
  .gs-card { padding: 16px !important; }
  .gs-card .gs-num { width: 28px; height: 28px; font-size: var(--fs-sm); }

  /* Subject area cards → tighter */
  [style*="display: flex; align-items: baseline; gap: 8px"] {
    flex-wrap: wrap;
    gap: 6px !important;
  }

  /* Topbar — hide search on small mobile, show compact */
  .topbar { padding: 0 12px; }
  .topbar-search { display: none; }
  .topbar-title { font-size: var(--fs-md); }
  .topbar-sub { display: none; }
  .user-info { display: none; }

  /* Main content — tighter padding */
  .main { padding: 16px 12px 80px !important; }

  /* Breadcrumbs — smaller */
  .breadcrumbs { font-size: 10px; }

  /* Footer bottom — center */
  .footer-bottom-inner { justify-content: center; text-align: center; }
}

/* ---- Very small mobile (<=380px) ---- */
@media (max-width: 380px) {
  .page-head h1 { font-size: var(--fs-xl) !important; }
  .card { padding: 14px !important; }
  .hero-copy { padding: 20px 16px !important; }
  .hero-headline { font-size: 1.75rem !important; }
  .mobile-nav-link span { font-size: 8px; }
  .mobile-nav-link svg { width: 20px; height: 20px; }
}

/* ---- Touch targets: minimum 44px for accessibility ---- */
@media (pointer: coarse) {
  .btn, .chip, .nav-link, .mobile-nav-link, .ask-chip,
  .ask-action-btn, .ask-send-btn, .toast-close {
    min-height: 44px;
  }
}

/* ---- Landscape mobile ---- */
@media (max-width: 900px) and (orientation: landscape) and (max-height: 500px) {
  .hero { min-height: 280px !important; }
  .page-head { margin-bottom: 12px; }
  .page-head .lead { display: none; }
}
