/* ==========================================================================
   Enhanced CanCham Members — Premium Mobile-first theme (light/dark)
   ALL ORIGINAL FEATURES PRESERVED + ENHANCEMENTS
   ========================================================================== */

/* ========== Enhanced Design Tokens ========== */
:root{
  /* Enhanced Brand Colors */
  --brand: #dc2626;
  --brand-50: #fef2f2;
  --brand-100: #fee2e2;
  --brand-500: #ef4444;
  --brand-600: #b91c1c;
  --brand-700: #991b1b;
  --brand-900: #7f1d1d;

  /* Enhanced Neutrals with Better Contrast */
  --white: #ffffff;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;

  /* Semantic Colors */
  --bg: var(--gray-50);
  --fg: var(--gray-900);
  --muted: var(--gray-500);
  --border: var(--gray-200);
  --card: var(--white);
  --surface: var(--gray-100);

  /* State Colors */
  --success: #059669;
  --success-bg: #ecfdf5;
  --success-border: #a7f3d0;
  
  --error: var(--brand);
  --error-bg: var(--brand-50);
  --error-border: #fecaca;
  
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --warning-border: #fde68a;

  /* ORIGINAL COMPATIBILITY */
  --ok: var(--success);
  --ok-bg: var(--success-bg);
  --err: var(--error);
  --err-bg: var(--error-bg);
  --warn: var(--warning);
  --warn-bg: var(--warning-bg);
  --accent: var(--surface);

  /* Enhanced Shadows with Depth */
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
  --shadow-xl: 0 20px 25px rgba(0,0,0,0.1), 0 10px 10px rgba(0,0,0,0.04);
  --shadow-2xl: 0 25px 50px rgba(0,0,0,0.25);

  /* ORIGINAL SHADOWS FOR COMPATIBILITY */
  --shadow-1: var(--shadow-sm);
  --shadow-2: var(--shadow-lg);
  --shadow-3: var(--shadow-xl);

  /* Interactive Effects */
  --ring: rgba(220,38,38,0.3);
  --glow-brand: 0 0 0 4px var(--ring);
  --glow-success: 0 0 0 4px rgba(5,150,105,0.3);

  /* Animation & Transitions */
  --transition-fast: 0.15s ease-out;
  --transition-normal: 0.25s ease-out;
  --transition-slow: 0.4s ease-out;
  --spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
  --ease-out-back: cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Spacing Scale */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;

  /* Typography Scale */
  --font-xs: 0.75rem;
  --font-sm: 0.875rem;
  --font-base: 1rem;
  --font-lg: 1.125rem;
  --font-xl: 1.25rem;
  --font-2xl: 1.5rem;
  --font-3xl: 1.875rem;
  --font-4xl: 2.25rem;

  /* Safe Areas */
  --safe-top: env(safe-area-inset-top,0px);
  --safe-bottom: env(safe-area-inset-bottom,0px);
}

/* Dark Mode Enhanced */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0e1a;
    --fg: var(--gray-100);
    --muted: var(--gray-400);
    --border: var(--gray-800);
    --card: #0f1629;
    --surface: var(--gray-800);
    --accent: var(--gray-800);
    --ring: rgba(248,113,113,0.4);
    --ok-bg: #0f2a20;
    --err-bg: #2a0f0f;
    --warn-bg: #1f1a0c;
  }
}

/* ========== Enhanced Base Styles ========== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  line-height: 1.15;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--space-16) + var(--safe-top));
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  font-size: var(--font-base);
  line-height: 1.6;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  position: relative;
}

/* Subtle background texture */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: 
    radial-gradient(circle at 25% 25%, rgba(220,38,38,0.02) 0%, transparent 50%),
    radial-gradient(circle at 75% 75%, rgba(220,38,38,0.015) 0%, transparent 50%);
  pointer-events: none;
  z-index: -1;
}

/* ========== Enhanced Layout ========== */
.container {
  margin: 0 auto;
  padding: calc(var(--space-6) + var(--safe-top)) var(--space-4) calc(var(--space-16) + var(--safe-bottom));
  max-width: 640px;
  width: 100%;
}

@media (min-width: 768px) {
  .container {
    max-width: 880px;
    padding-left: var(--space-6);
    padding-right: var(--space-6);
  }
}

@media (min-width: 1024px) {
  .container {
    max-width: 1040px;
    padding-left: var(--space-8);
    padding-right: var(--space-8);
  }
}

@media (min-width: 1280px) {
  .container {
    max-width: 1180px;
  }
}

@media (min-width: 1440px) {
  .container {
    max-width: 1280px;
  }
}

.center { display: block }
@media (min-width: 768px) {
  .center { display: flex; min-height: 100vh; align-items: center; justify-content: center }
}

/* ========== Enhanced Card + Glass title ========== */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow-2);
  transition: all var(--transition-normal);
}

.card:hover {
  box-shadow: var(--shadow-xl);
  border-color: rgba(220,38,38,0.1);
}

.card h1 { margin: 0 0 8px; font-size: 22px; line-height: 1.25 }

.glass-title {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: -4px -6px 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: linear-gradient(to bottom right,
    color-mix(in srgb, var(--card) 60%, transparent),
    color-mix(in srgb, var(--accent) 50%, transparent)
  );
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  box-shadow: var(--shadow-1);
}

.glass-title .kicker {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: 11px;
  font-weight: 800;
}

.glass-title .title {
  font-size: 20px;
  font-weight: 900;
  letter-spacing: -.01em;
}

@media (min-width: 1024px) {
  .card { padding: 24px }
  .card h1 { font-size: 26px }
  .glass-title .title { font-size: 22px }
}

.card p.sub { margin: 0 0 14px; color: var(--muted); font-size: 14px }
.card--brand { border-color: color-mix(in srgb, var(--brand) 40%, var(--border)) }
.card--muted { background: color-mix(in srgb, var(--card) 92%, var(--accent)) }

/* ========== Enhanced Auth / Forms ========== */
.form { display: block; width: 100%; max-width: 520px; margin: 0 auto }
@media (min-width: 1024px) { .form { max-width: 640px } }
@media (min-width: 1024px) { .card.auth.form { max-width: 680px } }
@media (min-width: 1440px) { .card.auth.form { max-width: 760px } }

.card.auth {
  padding: 24px;
  border-radius: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-2);
}

.card.auth h1 { margin: 0 0 8px; font-size: 22px; line-height: 1.2 }
.card.auth .sub { margin: 0 0 18px; color: var(--muted); font-size: 14px }

.form-row { margin: 14px 0 }
.form-row > label {
  display: block;
  font-weight: 700;
  margin: 0 0 6px;
  color: var(--fg);
  font-size: 13px;
  letter-spacing: .01em;
}

.field { margin: 14px 0 }
.label {
  display: block;
  margin: 0 0 6px;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: .01em;
}

.input,
select,
textarea {
  width: 100%;
  display: block;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  background: var(--card);
  color: var(--fg);
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s, color .15s;
}

@media (prefers-color-scheme: dark) {
  .input, select, textarea {
    background: var(--card);
    color: var(--fg);
  }
}

.input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: var(--glow-brand);
}

.help { color: var(--muted); font-size: 12px; margin-top: 6px }

/* Actions: column on mobile, row on larger */
.form-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
  margin-top: 14px;
}

@media (min-width: 560px) {
  .form-actions {
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 12px;
  }
}

/* Align primary + "forgot" nicely */
.auth-actions { align-items: center }
@media (min-width: 560px) {
  .auth-actions { justify-content: space-between }
  .auth-actions .auth-forgot { margin-left: auto }
}

/* ========== Enhanced Buttons ========== */
.btn {
  appearance: none;
  border: 0;
  border-radius: 12px;
  font-weight: 800;
  padding: 14px 16px;
  text-align: center;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  text-decoration: none;
  transition: transform .02s, box-shadow .15s, background .15s, color .15s, border-color .15s;
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.2) 0%, transparent 100%);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.btn:hover::before {
  opacity: 1;
}

button.btn { line-height: 1 }
.btn:active { transform: translateY(1px) }
.btn-block { display: block; width: 100% }

.btn-primary {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-600) 100%);
  color: #fff;
  box-shadow: 0 6px 14px rgba(220,38,38,.20);
}

.btn-primary:hover {
  background: var(--brand-600);
  box-shadow: var(--shadow-lg), 0 6px 20px rgba(220,38,38,0.4);
  transform: translateY(-1px);
}

.btn-secondary {
  background: color-mix(in srgb, var(--brand) 10%, var(--card));
  color: var(--fg);
  border: 1px solid color-mix(in srgb, var(--brand) 20%, var(--border));
}

.btn-secondary:hover {
  background: color-mix(in srgb, var(--brand) 16%, var(--card));
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-outline {
  background: transparent;
  color: var(--brand);
  border: 1px solid var(--brand);
}

.btn-outline:hover {
  background: color-mix(in srgb, var(--brand) 10%, transparent);
  box-shadow: var(--glow-brand);
}

.btn-danger { background: #b91c1c; color: #fff }
.btn-danger:hover { background: #991b1b }

.btn-with-icon {
  gap: var(--space-2);
}

.btn-with-icon svg {
  flex-shrink: 0;
}

/* ========== Links / Meta ========== */
.links { display: flex; gap: 12px; flex-wrap: wrap }
.link { color: var(--brand); text-decoration: none; font-weight: 700 }
.link:hover { text-decoration: underline }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap }
.muted { color: var(--muted); font-size: 14px }

/* ========== Enhanced Feedback ========== */
.flash {
  border-radius: 12px;
  padding: 12px 14px;
  margin: 0 0 12px;
  border: 1px solid var(--border);
}

.flash.ok {
  color: var(--ok);
  background: var(--ok-bg);
  border-color: color-mix(in srgb, var(--ok) 35%, var(--border));
}

.flash.error {
  color: var(--err);
  background: var(--err-bg);
  border-color: color-mix(in srgb, var(--brand) 35%, var(--border));
}

.flash.warn {
  color: var(--warn);
  background: var(--warn-bg);
  border-color: color-mix(in srgb, var(--warn) 35%, var(--border));
}

/* Enhanced flash messages with icons */
.flash-enhanced {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: 16px;
  border: 1px solid var(--border);
  margin-top: var(--space-6);
  font-weight: 500;
  animation: slideDown 0.3s var(--spring);
}

@keyframes slideDown {
  0% {
    opacity: 0;
    transform: translateY(-10px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.flash-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-top: 1px;
}

[data-countdown] { font-variant-numeric: tabular-nums }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0 }

/* ========== Enhanced Tiles (cards / grids) ========== */
.tiles {
  display: grid;
  gap: 16px;
  padding: 0;
  margin: 0;
  grid-template-columns: 1fr;
}

.tiles > li { list-style: none; min-width: 0 }
.tiles > li > * { min-width: 0 }

@media (min-width: 768px) { .tiles { grid-template-columns: repeat(2, minmax(0,1fr)) } }
@media (min-width: 1024px) { .tiles { grid-template-columns: repeat(3, minmax(0,1fr)) } }
@media (min-width: 1440px) { .tiles { grid-template-columns: repeat(4, minmax(0,1fr)) } }

.tile {
  display: block;
  text-decoration: none;
  color: var(--fg);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  box-shadow: var(--shadow-1);
  transition: transform .06s, box-shadow .2s, border-color .2s, background .2s;
  position: relative;
  overflow: hidden;
}

.tile::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, 
    rgba(220,38,38,0.02) 0%, 
    transparent 50%);
  opacity: 0;
  transition: opacity var(--transition-normal);
}

.tile:hover::before {
  opacity: 1;
}

.tile:hover {
  border-color: var(--brand);
  background: var(--accent);
  box-shadow: 0 10px 24px rgba(220,38,38,.10);
  transform: translateY(-2px);
}

.tile:active { transform: translateY(1px) }

.tile .title {
  font-weight: 900;
  letter-spacing: -.01em;
  line-height: 1.25;
  position: relative;
  z-index: 2;
}

.tile .desc {
  color: var(--muted);
  font-size: 13px;
  margin-top: 6px;
  line-height: 1.35;
  position: relative;
  z-index: 2;
}

.tile--highlight {
  border-color: color-mix(in srgb, var(--brand) 35%, var(--border));
  background: color-mix(in srgb, var(--brand) 6%, var(--card));
}

/* Enhanced tile styles */
.tile-enhanced {
  position: relative;
  display: block;
  text-decoration: none;
  color: var(--fg);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: var(--space-6);
  box-shadow: var(--shadow-md);
  transition: all var(--transition-normal) var(--spring);
  overflow: hidden;
  height: 100%;
}

.tile-enhanced:hover {
  border-color: rgba(220,38,38,0.3);
  box-shadow: var(--shadow-xl), var(--glow-brand);
  transform: translateY(-4px);
}

.tile-background {
  position: absolute;
  inset: 0;
  z-index: 1;
  opacity: 0;
  transition: opacity var(--transition-normal);
}

.tile-enhanced:hover .tile-background {
  opacity: 1;
}

.tile-pattern {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, 
    rgba(220,38,38,0.03) 0%, 
    transparent 50%);
}

.tile-content {
  position: relative;
  z-index: 2;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.tile-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.tile-title {
  margin: 0;
  font-size: var(--font-lg);
  font-weight: 700;
  line-height: 1.3;
  color: var(--fg);
  flex: 1;
}

.tile-description {
  margin: 0;
  color: var(--muted);
  font-size: var(--font-sm);
  line-height: 1.5;
  flex: 1;
}

.tile-arrow {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  z-index: 3;
  width: 24px;
  height: 24px;
  opacity: 0;
  transform: translateX(-8px);
  transition: all var(--transition-normal);
  color: var(--brand);
}

.tile-enhanced:hover .tile-arrow {
  opacity: 1;
  transform: translateX(0);
}

/* Enhanced grid layouts */
.tiles-grid {
  display: grid;
  gap: var(--space-5);
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .tiles-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .tiles-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-6);
  }
}

@media (min-width: 1280px) {
  .tiles-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.tile-container {
  opacity: 1;
  transform: translateY(0);
}

.tile-container.animate {
  animation: fadeInUp 0.6s var(--spring) both;
  animation-play-state: paused;
}

@keyframes fadeInUp {
  0% {
    opacity: 0;
    transform: translateY(30px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* State tags */
.tag {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.tag.ok {
  color: var(--ok);
  background: var(--ok-bg);
  border: 1px solid rgba(16,185,129,.35);
}

.tag.error {
  color: var(--err);
  background: var(--err-bg);
  border: 1px solid rgba(239,68,68,.35);
}

.tag.warn {
  color: #92400e;
  background: #fffbeb;
  border: 1px solid rgba(217,119,6,.35);
}

.tile-tag {
  flex-shrink: 0;
  display: inline-block;
  padding: var(--space-1) var(--space-2);
  border-radius: 8px;
  font-size: var(--font-xs);
  font-weight: 600;
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
}

.tile-tag.ok {
  background: var(--success-bg);
  color: var(--success);
  border-color: var(--success-border);
}

.tile-tag.error {
  background: var(--error-bg);
  color: var(--error);
  border-color: var(--error-border);
}

.tile-tag.warn {
  background: var(--warning-bg);
  color: var(--warning);
  border-color: var(--warning-border);
}

/* ========== Enhanced Hero Section ========== */
.hero-card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 0;
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  margin-bottom: var(--space-8);
}

.hero-background {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.hero-gradient {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, 
    rgba(220,38,38,0.05) 0%, 
    rgba(185,28,28,0.02) 50%,
    transparent 100%);
}

.hero-pattern {
  position: absolute;
  inset: 0;
  background-image: 
    radial-gradient(circle at 20px 20px, rgba(220,38,38,0.08) 1px, transparent 1px);
  background-size: 40px 40px;
  opacity: 0.5;
}

.hero-content {
  position: relative;
  z-index: 2;
  padding: var(--space-8) var(--space-6);
}

@media (min-width: 768px) {
  .hero-content {
    padding: var(--space-10) var(--space-8);
  }
}

.hero-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}

.hero-text {
  flex: 1;
  min-width: 0;
}

.hero-greeting {
  display: block;
  color: var(--muted);
  font-size: var(--font-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-2);
}

.hero-title {
  margin: 0;
  font-size: var(--font-3xl);
  font-weight: 900;
  line-height: 1.2;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.hero-name {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-700) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-wave {
  font-size: var(--font-2xl);
  animation: wave 2s ease-in-out infinite;
}

@keyframes wave {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(20deg); }
  75% { transform: rotate(-10deg); }
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-active { background: var(--success); }
.status-pending { background: var(--warning); }
.status-lapsed { background: var(--error); }
.status-none { background: var(--muted); }

.hero-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: var(--font-lg);
  line-height: 1.5;
  max-width: 600px;
}

@media (min-width: 768px) {
  .hero-title {
    font-size: var(--font-4xl);
  }
}

/* ========== Enhanced Organization Section ========== */
.organization-showcase {
  margin-bottom: var(--space-8);
}

.org-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: var(--space-6);
  box-shadow: var(--shadow-lg);
  transition: all var(--transition-normal);
}

.org-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-xl);
  border-color: rgba(220,38,38,0.2);
}

.org-header {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.org-avatar {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-600) 100%);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.org-info {
  flex: 1;
  min-width: 0;
}

.org-name {
  margin: 0 0 var(--space-2);
  font-size: var(--font-xl);
  font-weight: 700;
  color: var(--fg);
}

.org-description {
  margin: 0;
  color: var(--muted);
  font-size: var(--font-sm);
  line-height: 1.5;
}

.org-actions {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
}

@media (min-width: 768px) {
  .org-header {
    gap: var(--space-5);
  }
  
  .org-card {
    padding: var(--space-8);
  }
}

/* ========== Enhanced Section Headers ========== */
.section-header {
  margin-bottom: var(--space-6);
}

.section-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0 0 var(--space-2);
  font-size: var(--font-2xl);
  font-weight: 800;
  color: var(--fg);
}

.section-icon {
  font-size: var(--font-xl);
}

.section-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: var(--font-base);
  line-height: 1.5;
}

/* ========== Overview Section ========== */
.overview-section {
  margin-bottom: var(--space-8);
}

.overview-grid {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .overview-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-5);
  }
}

@media (min-width: 1024px) {
  .overview-grid {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: var(--space-6);
  }
}

.overview-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-normal);
  opacity: 1;
  transform: translateY(0);
}

.overview-card.animate {
  animation: fadeInUp 0.5s var(--spring) both;
  animation-play-state: paused;
}

.overview-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: rgba(220,38,38,0.15);
}

.overview-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.overview-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.overview-icon-invoices {
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  color: white;
}

.overview-icon-tier {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: white;
}

.overview-icon-renewal {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
}

.overview-icon-org {
  background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
  color: white;
}

.overview-header h3 {
  margin: 0;
  font-size: var(--font-sm);
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.overview-value {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.overview-number {
  font-size: var(--font-3xl);
  font-weight: 800;
  color: var(--fg);
  line-height: 1;
}

.overview-label {
  font-size: var(--font-sm);
  color: var(--muted);
  font-weight: 500;
}

.overview-tier {
  font-size: var(--font-xl);
  font-weight: 700;
  color: var(--brand);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.overview-date {
  font-size: var(--font-lg);
  font-weight: 600;
  color: var(--fg);
}

.overview-org {
  font-size: var(--font-base);
  font-weight: 600;
  color: var(--fg);
  line-height: 1.3;
}

/* ========== Enhanced Badges ========== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-2) var(--space-3);
  border-radius: 999px;
  font-size: var(--font-xs);
  font-weight: 600;
  border: 1px solid transparent;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-ok {
  background: var(--success-bg);
  color: var(--success);
  border-color: var(--success-border);
}

.badge-warn {
  background: var(--warning-bg);
  color: var(--warning);
  border-color: var(--warning-border);
}

.badge-error {
  background: var(--error-bg);
  color: var(--error);
  border-color: var(--error-border);
}

.badge-muted {
  background: var(--surface);
  color: var(--muted);
  border-color: var(--border);
}

.badge-info {
  background: #eef2ff;
  color: #3730a3;
  border-color: #c7d2fe;
}

/* ========== Original Utilities ========== */
.mt-8 { margin-top: 8px }
.mt-12 { margin-top: 12px }
.mt-16 { margin-top: 16px }
.mt-24 { margin-top: 24px }
.mt-32 { margin-top: 32px }

.grid-2 { display: grid; gap: 12px; grid-template-columns: 1fr 1fr }
.grid-3 { display: grid; gap: 12px; grid-template-columns: 1fr 1fr 1fr }
.list-plain { margin: 0; padding: 0; list-style: none }
.kicker { color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-size: 12px }
.section-title { font-size: 18px; font-weight: 800; margin: 0 0 10px }
.visually-hidden { position: absolute!important; height: 1px; width: 1px; overflow: hidden; clip: rect(1px,1px,1px,1px); white-space: nowrap }

/* ========== Steps (onboarding) ========== */
.steps { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px }
.step { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--card) }
.step-cta { display: flex; gap: 8px; align-items: center }

/* ========== Directory search ========== */
.directory-search {
  background: var(--accent);
  border-radius: 16px;
  padding: 20px;
  margin: 20px 0;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-1);
}

.search-field { margin: 16px 0 }
.search-field .label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px }

/* ========== Segmented (register path) ========== */
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 6px 0 10px }
.segmented .seg {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--card) 92%, var(--accent));
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  user-select: none;
  font-weight: 700;
  box-shadow: var(--shadow-1);
  transition: border-color .15s, background .15s, box-shadow .15s, transform .02s;
}

.segmented .seg:active { transform: translateY(1px) }
.segmented .seg input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; margin: 0 }
.segmented .seg:hover { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 6%, var(--card)) }
.segmented .seg input:focus-visible + span { box-shadow: 0 0 0 4px var(--ring); border-radius: 10px; outline: 0 }
.segmented .seg input:checked + span { color: var(--fg); background: color-mix(in srgb, var(--brand) 10%, var(--card)); border-radius: 10px }

/* ========== Invoice helpers ========== */
.break-words { overflow-wrap: anywhere; word-break: break-word }

.invoice-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  column-gap: 12px;
  row-gap: 18px;
  flex-wrap: wrap;
}

.invoice-actions .actions-left { display: flex; gap: 10px; flex-wrap: wrap }
.invoice-actions .actions-right { display: flex; gap: 10px; align-items: center; margin-left: auto }
@media (max-width: 820px) { .invoice-actions .actions-right { margin-left: 0 } }

.file-input {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  background: var(--card);
  max-width: 100%;
}

/* Responsive table with safe overflow on small screens */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch }
.table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
}

.table th, .table td { padding: 10px; vertical-align: top }
.table thead tr { background: var(--accent) }
.t-right { text-align: right }

@media (max-width: 480px) {
  .table th:nth-child(2), .table th:nth-child(3), .table th:nth-child(4),
  .table td:nth-child(2), .table td:nth-child(3), .table td:nth-child(4) { white-space: nowrap }
}

/* Admin invoices: mobile cards vs desktop table */
.only-mobile { display: block }
.only-desktop { display: none }

@media (min-width: 768px) {
  .only-mobile { display: none }
  .only-desktop { display: block }
}

/* ========== Empty State ========== */
.empty-state {
  text-align: center;
  padding: var(--space-12) var(--space-6);
  color: var(--muted);
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: var(--space-4);
  opacity: 0.5;
}

.empty-state h3 {
  margin: 0 0 var(--space-2);
  font-size: var(--font-lg);
  font-weight: 600;
  color: var(--fg);
}

.empty-state p {
  margin: 0;
  font-size: var(--font-sm);
  line-height: 1.5;
}

/* ========== Enhanced Responsive Design ========== */
@media (max-width: 480px) {
  .hero-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-4);
  }
  
  .hero-actions {
    align-self: stretch;
    justify-content: space-between;
  }
  
  .hero-title {
    font-size: var(--font-2xl);
  }
  
  .org-actions {
    flex-direction: column;
  }
  
  .btn {
    width: 100%;
    justify-content: center;
  }
}

/* ========== Animation Performance ========== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .hero-wave {
    animation: none;
  }
}

/* ========== Dark Mode Adjustments ========== */
@media (prefers-color-scheme: dark) {
  .badge-info {
    background: #1e293b;
    color: #93c5fd;
    border-color: #334155;
  }
}

/* ========== Print Styles ========== */
@media print {
  .hero-background,
  .tile-background,
  .tile-pattern {
    display: none;
  }
  
  .hero-card,
  .org-card,
  .tile,
  .tile-enhanced,
  .overview-card {
    box-shadow: none;
    border: 1px solid #ccc;
  }
  
  .btn {
    background: transparent !important;
    color: #000 !important;
    border: 1px solid #ccc !important;
  }
}
/* Admin Invoice View (namespaced) */
.adm-inv { display: grid; gap: 16px; }
.adm-inv .muted { color: var(--muted, #6b7280); }
.adm-inv .help { color: var(--muted, #6b7280); font-size: 12px; }
.adm-inv .mt-8 { margin-top: 8px; }
.adm-inv .mt-16 { margin-top: 16px; }

.adm-inv__back { margin-top: 8px; }
.adm-inv__header { display: flex; align-items: center; gap: 12px; justify-content: space-between; }
.adm-inv__grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 900px) {
  .adm-inv__grid { grid-template-columns: 1.2fr 1fr; }
}
.adm-inv__card { padding: 16px; }

.adm-inv__actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.adm-inv__reject summary { cursor: pointer; color: #374151; }
.adm-inv__reject-body { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.adm-inv__void { margin-top: 12px; }
.adm-inv__advanced { margin-top: 16px; }
.adm-inv__advanced summary { cursor: pointer; color: #374151; }
.adm-inv__advanced-form { display: grid; gap: 8px; margin-top: 8px; }
.adm-inv__advanced-actions { display: flex; justify-content: flex-end; gap: 8px; }

.adm-inv .label { font-weight: 600; }
.adm-inv .input,
.adm-inv .textarea,
.adm-inv .select { border: 1px solid #d1d5db; border-radius: 8px; padding: 8px 10px; font: inherit; }
.adm-inv .input--small { padding: 6px 8px; font-size: 13px; }

.adm-inv__table th, .adm-inv__table td { vertical-align: middle; }
.adm-inv__row-actions { display: flex; gap: 6px; align-items: center; justify-content: flex-end; }

.adm-inv .btn { display: inline-flex; align-items: center; gap: 8px; border-radius: 8px; padding: 8px 12px; text-decoration: none; border: 1px solid transparent; cursor: pointer; }
.adm-inv .btn-small { padding: 6px 10px; font-size: 13px; }
.adm-inv .btn-primary { background: #2563eb; color: #fff; border-color: #2563eb; }
.adm-inv .btn-secondary { background: #fff; color: #374151; border-color: #d1d5db; }
.adm-inv .btn-danger { background: #ef4444; color: #fff; border-color: #ef4444; }

.adm-inv .badge { display: inline-block; padding: 4px 8px; border-radius: 999px; font-size: 12px; }
.adm-inv .badge-ok    { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.adm-inv .badge-warn  { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.adm-inv .badge-info  { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.adm-inv .badge-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.adm-inv .badge-muted { background: #f3f4f6; color: #374151; border: 1px solid #e5e7eb; }

.adm-inv .table-wrap { overflow: auto; }
.adm-inv .table { width: 100%; border-collapse: collapse; }
.adm-inv .table th, .adm-inv .table td { padding: 8px 10px; border-bottom: 1px solid #e5e7eb; text-align: left; }
.adm-inv .table .t-right { text-align: right; }
.adm-inv .link { color: #2563eb; text-decoration: none; }
.adm-inv .link:hover { text-decoration: underline; }
