/* =============================================================
   NOORPLAN — Design System
   Emerald (Pakistani) + Gold (German) + Navy on warm sand
   ============================================================= */

/* ---------- CSS Variables (light default) ---------- */
:root {
  --c-bg: #FAF7F0;
  --c-bg-alt: #F2EDE0;
  --c-bg-elevated: #FFFFFF;
  --c-bg-sunken: #E8E1CF;
  --c-border: #D9D1BB;
  --c-border-strong: #B8AE92;
  --c-text-primary: #1B2A20;
  --c-text-secondary: #5A6B5E;
  --c-text-tertiary: #8B968D;
  --c-text-inverse: #FAF7F0;
  --c-accent: #0F6B3E;
  --c-accent-hover: #0B5431;
  --c-accent-soft: #D4E8DC;
  --c-gold: #C99A1F;
  --c-gold-soft: #F5E8C2;
  --c-navy: #1B3A5C;
  --c-navy-soft: #D5E0EC;
  --c-success: #0F6B3E;
  --c-warning: #C97A0A;
  --c-warning-soft: #FAE6C5;
  --c-danger: #B8323C;
  --c-danger-soft: #F4D4D7;
  --c-info: #1B5A8C;
  --c-info-soft: #D6E5F1;

  --grad-hero: linear-gradient(135deg, #0F6B3E 0%, #1B5A4A 45%, #C99A1F 100%);
  --grad-progress: linear-gradient(90deg, #0F6B3E, #C99A1F);
  --grad-gold-emerald: linear-gradient(135deg, #0F6B3E 0%, #C99A1F 100%);

  --font-sans: "Segoe UI Variable", "Segoe UI", -apple-system, BlinkMacSystemFont,
               "Helvetica Neue", Arial, system-ui, sans-serif;
  --font-mono: "Cascadia Code", "Cascadia Mono", "Consolas", "SF Mono",
               "Liberation Mono", monospace;

  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
  --s-5: 24px; --s-6: 32px; --s-7: 48px; --s-8: 64px; --s-9: 96px;

  --r-sm: 6px; --r-md: 10px; --r-lg: 16px; --r-xl: 24px; --r-pill: 999px;

  --shadow-1: 0 1px 2px rgba(0,0,0,.04), 0 1px 3px rgba(0,0,0,.06);
  --shadow-2: 0 4px 12px rgba(0,0,0,.06), 0 2px 4px rgba(0,0,0,.04);
  --shadow-3: 0 12px 32px rgba(0,0,0,.10), 0 4px 8px rgba(0,0,0,.06);
  --shadow-glow: 0 0 0 1px var(--c-accent), 0 8px 24px rgba(15,107,62,.18);

  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
  --ease-in-out-cubic: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-out-back: cubic-bezier(0.34, 1.56, 0.64, 1);
  --d-fast: 150ms; --d-base: 250ms; --d-slow: 400ms; --d-slower: 700ms;
}

/* Dark mode */
[data-theme="dark"] {
  --c-bg: #0E1512;
  --c-bg-alt: #16201B;
  --c-bg-elevated: #1E2A23;
  --c-bg-sunken: #0A0F0C;
  --c-border: #2A3830;
  --c-border-strong: #3D5247;
  --c-text-primary: #ECE6D6;
  --c-text-secondary: #A5B0A8;
  --c-text-tertiary: #6F7B73;
  --c-text-inverse: #0E1512;
  --c-accent: #2EA968;
  --c-accent-hover: #3FC081;
  --c-accent-soft: #1A3329;
  --c-gold: #E8B842;
  --c-gold-soft: #3A2E15;
  --c-navy: #4A7BB5;
  --c-navy-soft: #1B2A40;
  --c-success: #2EA968;
  --c-warning: #E8A445;
  --c-warning-soft: #3D2E15;
  --c-danger: #E55C66;
  --c-danger-soft: #3D1F22;
  --c-info: #5A9BD4;
  --c-info-soft: #1B2A40;
  --shadow-1: 0 1px 2px rgba(0,0,0,.3), 0 1px 3px rgba(0,0,0,.2);
  --shadow-2: 0 4px 12px rgba(0,0,0,.4), 0 2px 4px rgba(0,0,0,.3);
  --shadow-3: 0 12px 32px rgba(0,0,0,.5), 0 4px 8px rgba(0,0,0,.4);
  --grad-hero: linear-gradient(135deg, #1A3329 0%, #16242E 45%, #3A2E15 100%);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font: 15px/1.6 var(--font-sans);
  background: var(--c-bg);
  color: var(--c-text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  transition: background var(--d-base) var(--ease-out-expo), color var(--d-base) var(--ease-out-expo);
}
button, input, select, textarea {
  font: inherit; color: inherit; background: none; border: none; outline: none;
}
button { cursor: pointer; }
a { color: var(--c-accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4, h5, h6 { font-weight: 700; line-height: 1.2; }
ul, ol { list-style: none; }
img, svg { display: block; max-width: 100%; }
[hidden] { display: none !important; }

/* Focus ring */
:focus-visible {
  outline: 2px solid var(--c-gold);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- Layout Shell ---------- */
.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  grid-template-rows: 64px 1fr;
  grid-template-areas:
    "topbar topbar"
    "sidebar main";
  min-height: 100vh;
}

.topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  padding: 0 var(--s-5);
  background: var(--c-bg-elevated);
  border-bottom: 1px solid var(--c-border);
  position: sticky; top: 0; z-index: 50;
  box-shadow: var(--shadow-1);
}
.topbar-brand {
  display: flex; align-items: center; gap: var(--s-2);
  font-weight: 700; font-size: 18px;
  color: var(--c-accent);
  margin-right: var(--s-6);
}
.topbar-brand .plane { color: var(--c-gold); transform: rotate(-30deg); }
.topbar-section { color: var(--c-text-secondary); font-size: 14px; font-weight: 500; }
.topbar-section strong { color: var(--c-text-primary); font-weight: 700; }
.topbar-spacer { flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: var(--s-2); }
.topbar-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px;
  border-radius: var(--r-md);
  color: var(--c-text-secondary);
  transition: background var(--d-fast) var(--ease-out-expo), color var(--d-fast);
}
.topbar-btn:hover { background: var(--c-bg-alt); color: var(--c-text-primary); }
.save-indicator {
  display: inline-flex; align-items: center; gap: var(--s-2);
  padding: var(--s-1) var(--s-3);
  font-size: 12px; color: var(--c-text-secondary);
  border-radius: var(--r-pill);
  background: var(--c-bg-alt);
}
.save-indicator .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--c-success);
  animation: pulse 2s var(--ease-in-out-cubic) infinite;
}
.save-indicator.saving .dot { background: var(--c-warning); animation: spin 1s linear infinite; }

.sidebar {
  grid-area: sidebar;
  background: var(--c-bg-alt);
  border-right: 1px solid var(--c-border);
  padding: var(--s-4) 0;
  position: sticky; top: 64px;
  height: calc(100vh - 64px);
  overflow-y: auto;
  display: flex; flex-direction: column;
}
.sidebar-progress {
  padding: 0 var(--s-4) var(--s-4);
  border-bottom: 1px solid var(--c-border);
  margin-bottom: var(--s-3);
}
.sidebar-progress-ring {
  display: flex; align-items: center; gap: var(--s-3);
  margin-bottom: var(--s-2);
}
.sidebar-progress-ring svg { flex-shrink: 0; }
.sidebar-progress-label { font-size: 12px; color: var(--c-text-secondary); font-weight: 500; }
.sidebar-progress-value { font-size: 18px; font-weight: 700; color: var(--c-accent); }
.sidebar-progress-bar {
  height: 6px; background: var(--c-bg-sunken); border-radius: var(--r-pill);
  overflow: hidden;
}
.sidebar-progress-bar-fill {
  height: 100%; background: var(--grad-progress);
  border-radius: var(--r-pill);
  transition: width var(--d-slow) var(--ease-out-expo);
}

.sidebar-nav { flex: 1; }
.sidebar-item {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-2) var(--s-4);
  color: var(--c-text-secondary);
  font-size: 14px; font-weight: 500;
  border-left: 3px solid transparent;
  transition: all var(--d-fast) var(--ease-out-expo);
  cursor: pointer;
  text-decoration: none;
}
.sidebar-item:hover { background: var(--c-bg-elevated); color: var(--c-text-primary); }
.sidebar-item.active {
  background: var(--c-accent-soft);
  color: var(--c-accent);
  border-left-color: var(--c-accent);
  font-weight: 700;
}
.sidebar-item .icon { width: 20px; height: 20px; flex-shrink: 0; }
.sidebar-item .badge {
  margin-left: auto;
  background: var(--c-bg-elevated);
  color: var(--c-text-secondary);
  font-size: 11px; font-weight: 700;
  padding: 1px var(--s-2);
  border-radius: var(--r-pill);
  min-width: 22px; text-align: center;
}
.sidebar-item.active .badge { background: var(--c-accent); color: var(--c-text-inverse); }

.sidebar-footer {
  border-top: 1px solid var(--c-border);
  padding: var(--s-3) var(--s-4);
  display: flex; gap: var(--s-1);
  justify-content: space-around;
}
.sidebar-footer button {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  border-radius: var(--r-md);
  color: var(--c-text-secondary);
  transition: all var(--d-fast);
}
.sidebar-footer button:hover { background: var(--c-bg-elevated); color: var(--c-text-primary); }
.sidebar-footer button.danger:hover { color: var(--c-danger); }

.main {
  grid-area: main;
  padding: var(--s-6) var(--s-7) var(--s-9);
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

/* ---------- Section base ---------- */
section {
  padding: var(--s-7) 0;
  border-bottom: 1px solid var(--c-border);
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 600ms var(--ease-out-expo), transform 600ms var(--ease-out-expo);
}
section.revealed { opacity: 1; transform: translateY(0); }
section:last-child { border-bottom: none; }

.section-header {
  margin-bottom: var(--s-6);
}
.section-eyebrow {
  display: inline-block;
  font-size: 12px; font-weight: 700;
  color: var(--c-accent);
  letter-spacing: 0.08em; text-transform: uppercase;
  margin-bottom: var(--s-2);
}
.section-title {
  font-size: 32px; line-height: 1.15;
  color: var(--c-text-primary);
  margin-bottom: var(--s-2);
}
.section-subtitle {
  font-size: 16px; color: var(--c-text-secondary);
  max-width: 720px;
}

/* ---------- Card ---------- */
.card {
  background: var(--c-bg-elevated);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  box-shadow: var(--shadow-1);
  transition: transform var(--d-base) var(--ease-out-expo), box-shadow var(--d-base), border-color var(--d-base);
}
.card:hover { box-shadow: var(--shadow-2); }
.card-lift:hover { transform: translateY(-4px); border-color: var(--c-border-strong); }
.card-title { font-size: 18px; font-weight: 700; margin-bottom: var(--s-1); color: var(--c-text-primary); }
.card-subtitle { font-size: 13px; color: var(--c-text-secondary); margin-bottom: var(--s-3); }
.card-body { font-size: 14px; color: var(--c-text-secondary); line-height: 1.6; }
.card-footer { margin-top: var(--s-4); padding-top: var(--s-3); border-top: 1px solid var(--c-border); display: flex; gap: var(--s-2); flex-wrap: wrap; }

/* Grid utilities */
.grid { display: grid; gap: var(--s-4); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.cols-12 { display: grid; grid-template-columns: repeat(12, 1fr); gap: var(--s-4); }
.col-4 { grid-column: span 4; }
.col-6 { grid-column: span 6; }
.col-8 { grid-column: span 8; }
.col-12 { grid-column: span 12; }

/* ---------- KPI cards ---------- */
.kpi-card {
  background: var(--c-bg-elevated);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  position: relative;
  overflow: hidden;
}
.kpi-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: var(--c-accent);
}
.kpi-card.gold::before { background: var(--c-gold); }
.kpi-card.navy::before { background: var(--c-navy); }
.kpi-card.danger::before { background: var(--c-danger); }
.kpi-label {
  font-size: 12px; font-weight: 700; color: var(--c-text-secondary);
  text-transform: uppercase; letter-spacing: 0.06em;
  margin-bottom: var(--s-2);
}
.kpi-value {
  font-size: 32px; font-weight: 700; color: var(--c-text-primary);
  font-variant-numeric: tabular-nums lining-nums;
  line-height: 1.1;
  margin-bottom: var(--s-1);
}
.kpi-delta {
  font-size: 13px; color: var(--c-text-tertiary);
  display: flex; align-items: center; gap: var(--s-1);
}
.kpi-delta.up { color: var(--c-success); }
.kpi-delta.down { color: var(--c-danger); }

/* ---------- Hero (dashboard) ---------- */
.hero {
  background: var(--grad-hero);
  border-radius: var(--r-xl);
  padding: var(--s-7) var(--s-6);
  color: var(--c-text-inverse);
  position: relative;
  overflow: hidden;
  margin-bottom: var(--s-6);
}
.hero-greeting { font-size: 14px; opacity: 0.9; margin-bottom: var(--s-2); }
.hero-title { font-size: 36px; font-weight: 700; line-height: 1.15; margin-bottom: var(--s-3); max-width: 720px; }
.hero-focus { font-size: 16px; opacity: 0.95; max-width: 720px; line-height: 1.6; }
.hero-pk-de { position: absolute; top: var(--s-5); right: var(--s-5); font-size: 12px; opacity: 0.7; }
.hero-pk-de .from { color: #fff; }
.hero-pk-de .to { color: var(--c-gold); }
.hero-plane {
  position: absolute; top: 60px; right: 80px;
  font-size: 48px; opacity: 0.4;
  animation: plane-fly 12s var(--ease-in-out-cubic) infinite;
}
@keyframes plane-fly {
  0% { transform: translate(-200px, 0) rotate(-15deg); opacity: 0; }
  10% { opacity: 0.4; }
  90% { opacity: 0.4; }
  100% { transform: translate(200px, 0) rotate(-15deg); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) { .hero-plane { animation: none; opacity: 0.3; } }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: var(--s-2);
  padding: var(--s-2) var(--s-4);
  border-radius: var(--r-md);
  font-size: 14px; font-weight: 600;
  transition: all var(--d-fast) var(--ease-out-expo);
  cursor: pointer; user-select: none;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--c-accent); color: var(--c-text-inverse); }
.btn-primary:hover { background: var(--c-accent-hover); }
.btn-gold { background: var(--c-gold); color: var(--c-text-inverse); }
.btn-gold:hover { filter: brightness(0.95); }
.btn-outline { background: transparent; color: var(--c-accent); border: 1px solid var(--c-accent); }
.btn-outline:hover { background: var(--c-accent-soft); }
.btn-ghost { background: var(--c-bg-alt); color: var(--c-text-primary); }
.btn-ghost:hover { background: var(--c-bg-sunken); }
.btn-danger { background: var(--c-danger); color: var(--c-text-inverse); }
.btn-danger:hover { filter: brightness(0.95); }
.btn-sm { padding: 6px var(--s-3); font-size: 12px; }
.btn-icon { padding: var(--s-2); }

/* ---------- Badges / Pills ---------- */
.badge {
  display: inline-flex; align-items: center; gap: var(--s-1);
  padding: 3px var(--s-2);
  font-size: 11px; font-weight: 700;
  border-radius: var(--r-pill);
  text-transform: uppercase; letter-spacing: 0.04em;
  white-space: nowrap;
}
.badge-success { background: var(--c-accent-soft); color: var(--c-accent); }
.badge-warning { background: var(--c-warning-soft); color: var(--c-warning); }
.badge-danger { background: var(--c-danger-soft); color: var(--c-danger); }
.badge-info { background: var(--c-info-soft); color: var(--c-info); }
.badge-gold { background: var(--c-gold-soft); color: var(--c-gold); }
.badge-navy { background: var(--c-navy-soft); color: var(--c-navy); }
.badge-neutral { background: var(--c-bg-sunken); color: var(--c-text-secondary); }

/* ---------- Form elements ---------- */
.input, .select, .textarea {
  width: 100%;
  padding: var(--s-2) var(--s-3);
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  font-size: 14px;
  color: var(--c-text-primary);
  transition: border-color var(--d-fast), box-shadow var(--d-fast);
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3px var(--c-accent-soft);
}
.textarea { min-height: 80px; resize: vertical; font-family: var(--font-sans); }
.input-prefix {
  display: flex; align-items: center; gap: var(--s-2);
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: 0 var(--s-3);
}
.input-prefix span { color: var(--c-text-secondary); font-size: 14px; }
.input-prefix .input { border: none; background: transparent; padding-left: 0; }
.field-group { display: flex; flex-direction: column; gap: var(--s-1); }
.field-label { font-size: 12px; font-weight: 700; color: var(--c-text-secondary); text-transform: uppercase; letter-spacing: 0.05em; }

/* Checkbox */
.checkbox {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  border: 2px solid var(--c-border-strong);
  border-radius: 5px;
  background: var(--c-bg-elevated);
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--d-fast) var(--ease-out-expo);
  position: relative;
}
.checkbox:hover { border-color: var(--c-accent); }
.checkbox.checked {
  background: var(--c-accent);
  border-color: var(--c-accent);
}
.checkbox.checked::after {
  content: '';
  width: 6px; height: 12px;
  border: solid var(--c-text-inverse);
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg) translate(-1px, -1px);
  animation: check-draw 300ms var(--ease-out-expo);
}
@keyframes check-draw {
  from { transform: rotate(45deg) translate(-1px, -1px) scale(0); }
  to { transform: rotate(45deg) translate(-1px, -1px) scale(1); }
}

/* Segmented control */
.segmented {
  display: inline-flex;
  background: var(--c-bg-sunken);
  border-radius: var(--r-md);
  padding: 2px;
  gap: 2px;
}
.segmented-item {
  padding: var(--s-1) var(--s-3);
  font-size: 13px; font-weight: 600;
  color: var(--c-text-secondary);
  border-radius: calc(var(--r-md) - 2px);
  cursor: pointer;
  transition: all var(--d-fast) var(--ease-out-expo);
}
.segmented-item.active {
  background: var(--c-bg-elevated);
  color: var(--c-accent);
  box-shadow: var(--shadow-1);
}
.segmented-item:hover:not(.active) { color: var(--c-text-primary); }

/* Toggle switch */
.toggle {
  position: relative;
  width: 44px; height: 24px;
  background: var(--c-bg-sunken);
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: background var(--d-base) var(--ease-out-expo);
  flex-shrink: 0;
}
.toggle::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 20px; height: 20px;
  background: var(--c-bg-elevated);
  border-radius: 50%;
  box-shadow: var(--shadow-1);
  transition: transform var(--d-base) var(--ease-out-back);
}
.toggle.on { background: var(--c-accent); }
.toggle.on::after { transform: translateX(20px); }

/* ---------- Program Card ---------- */
.program-card {
  background: var(--c-bg-elevated);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: var(--s-4);
  position: relative;
  border-left: 4px solid var(--c-border);
  display: flex; flex-direction: column;
  transition: all var(--d-base) var(--ease-out-expo);
  cursor: pointer;
}
.program-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-3); }
.program-card.urgency-30 { border-left-color: var(--c-success); }
.program-card.urgency-7 { border-left-color: var(--c-warning); }
.program-card.urgency-now { border-left-color: var(--c-danger); animation: pulse-border 2s var(--ease-in-out-cubic) infinite; }
.program-card.urgency-past { border-left-color: var(--c-text-tertiary); opacity: 0.7; }
.program-card.primary { border-top: 3px solid var(--c-gold); }
@keyframes pulse-border {
  0%, 100% { box-shadow: 0 0 0 0 rgba(184, 50, 60, 0); }
  50% { box-shadow: 0 0 0 6px rgba(184, 50, 60, 0.15); }
}
.program-card-header {
  display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s-2);
  margin-bottom: var(--s-2);
}
.program-pills { display: flex; gap: 4px; flex-wrap: wrap; }
.program-title { font-size: 16px; font-weight: 700; color: var(--c-text-primary); margin-bottom: 4px; line-height: 1.3; }
.program-uni { font-size: 13px; color: var(--c-text-secondary); margin-bottom: var(--s-3); }
.program-meta {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: var(--s-2);
  margin-bottom: var(--s-3);
  padding: var(--s-2);
  background: var(--c-bg-alt);
  border-radius: var(--r-sm);
}
.program-meta-item { text-align: center; }
.program-meta-item .label { font-size: 10px; color: var(--c-text-tertiary); text-transform: uppercase; letter-spacing: 0.05em; }
.program-meta-item .value { font-size: 13px; font-weight: 700; color: var(--c-text-primary); }
.program-deadline {
  display: flex; align-items: center; gap: var(--s-2);
  margin-bottom: var(--s-3);
  font-size: 13px;
}
.program-fit-bar {
  height: 6px; background: var(--c-bg-sunken); border-radius: var(--r-pill);
  overflow: hidden; margin-bottom: var(--s-2);
}
.program-fit-fill { height: 100%; background: var(--grad-gold-emerald); border-radius: var(--r-pill); transition: width 1s var(--ease-out-expo); }
.program-fit-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--c-text-secondary); margin-bottom: var(--s-3); }

/* ---------- Filters bar ---------- */
.filters-bar {
  display: flex; flex-wrap: wrap; gap: var(--s-3);
  align-items: center;
  padding: var(--s-3) var(--s-4);
  background: var(--c-bg-elevated);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  margin-bottom: var(--s-5);
  position: sticky; top: 64px; z-index: 10;
  box-shadow: var(--shadow-1);
}
.filter-chip {
  padding: var(--s-1) var(--s-3);
  font-size: 12px; font-weight: 600;
  background: var(--c-bg-alt);
  color: var(--c-text-secondary);
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: all var(--d-fast);
  border: 1px solid transparent;
}
.filter-chip:hover { background: var(--c-accent-soft); color: var(--c-accent); }
.filter-chip.active { background: var(--c-accent); color: var(--c-text-inverse); }

/* ---------- Cost calculator ---------- */
.cost-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-5);
  align-items: start;
}
.cost-summary {
  position: sticky; top: 80px;
  background: var(--c-bg-elevated);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  box-shadow: var(--shadow-2);
}
.cost-total {
  font-size: 40px; font-weight: 700; color: var(--c-accent);
  font-variant-numeric: tabular-nums lining-nums;
  line-height: 1.1;
  margin-bottom: var(--s-1);
  transition: color var(--d-base);
}
.cost-total-eur { font-size: 16px; color: var(--c-text-secondary); font-weight: 500; }
.cost-bar { display: flex; height: 12px; border-radius: var(--r-pill); overflow: hidden; margin: var(--s-4) 0; }
.cost-bar-seg { transition: width var(--d-slow) var(--ease-out-expo); }
.cost-legend { display: flex; flex-direction: column; gap: var(--s-1); }
.cost-legend-item { display: flex; align-items: center; gap: var(--s-2); font-size: 12px; }
.cost-legend-color { width: 12px; height: 12px; border-radius: 3px; }
.cost-legend-name { flex: 1; color: var(--c-text-secondary); }
.cost-legend-value { font-weight: 700; color: var(--c-text-primary); font-variant-numeric: tabular-nums; }

.cost-line { display: flex; justify-content: space-between; align-items: center; padding: var(--s-2) 0; border-bottom: 1px solid var(--c-border); }
.cost-line:last-child { border-bottom: none; }
.cost-line-label { font-size: 13px; color: var(--c-text-secondary); display: flex; align-items: center; gap: var(--s-2); }
.cost-line-value { font-size: 14px; font-weight: 700; color: var(--c-text-primary); font-variant-numeric: tabular-nums; }

/* ---------- Timeline / Gantt ---------- */
.gantt {
  background: var(--c-bg-elevated);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: var(--s-4);
  overflow-x: auto;
  margin-bottom: var(--s-4);
}
.gantt-header {
  display: grid;
  grid-template-columns: 200px 1fr;
  margin-bottom: var(--s-3);
}
.gantt-months {
  display: flex; gap: 0;
  font-size: 11px; color: var(--c-text-secondary);
  text-transform: uppercase; letter-spacing: 0.05em;
  font-weight: 600;
}
.gantt-month { flex: 1; text-align: left; padding-left: var(--s-2); border-left: 1px solid var(--c-border); }
.gantt-month:first-child { border-left: none; }
.gantt-row {
  display: grid;
  grid-template-columns: 200px 1fr;
  margin-bottom: var(--s-2);
  align-items: center;
  min-height: 36px;
}
.gantt-row-name { font-size: 13px; font-weight: 600; color: var(--c-text-primary); padding-right: var(--s-2); }
.gantt-row-track {
  position: relative;
  height: 28px;
  background: var(--c-bg-sunken);
  border-radius: var(--r-sm);
}
.gantt-bar {
  position: absolute;
  height: 100%;
  border-radius: var(--r-sm);
  display: flex; align-items: center; padding: 0 var(--s-2);
  font-size: 11px; color: #fff; font-weight: 600;
  cursor: pointer;
  transition: transform var(--d-fast) var(--ease-out-expo), filter var(--d-fast);
  transform-origin: left;
  animation: bar-grow 700ms var(--ease-out-quart) backwards;
}
.gantt-bar:hover { transform: scaleY(1.1); filter: brightness(1.1); z-index: 2; }
.gantt-bar.milestone { width: 12px !important; min-width: 12px; border-radius: 50%; }
@keyframes bar-grow {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}
.gantt-bar.todo { opacity: 0.5; }
.gantt-bar.in-progress { opacity: 0.8; box-shadow: 0 0 0 2px rgba(255,255,255,0.4); }
.gantt-bar.done { opacity: 1; }
.gantt-today {
  position: absolute;
  top: -4px; bottom: -4px;
  width: 2px;
  background: var(--c-danger);
  z-index: 3;
}
.gantt-today::after {
  content: 'TODAY';
  position: absolute; top: -16px; left: -22px;
  background: var(--c-danger); color: #fff;
  padding: 2px var(--s-2); border-radius: 4px;
  font-size: 10px; font-weight: 700;
}

/* ---------- Document checklist ---------- */
.doc-group { margin-bottom: var(--s-4); }
.doc-group-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: var(--s-3) var(--s-4);
  background: var(--c-bg-elevated);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md) var(--r-md) 0 0;
  cursor: pointer;
  transition: background var(--d-fast);
}
.doc-group-header:hover { background: var(--c-bg-alt); }
.doc-group-body {
  background: var(--c-bg-elevated);
  border: 1px solid var(--c-border);
  border-top: none;
  border-radius: 0 0 var(--r-md) var(--r-md);
}
.doc-row {
  display: grid;
  grid-template-columns: 30px 1fr auto auto;
  gap: var(--s-3);
  align-items: center;
  padding: var(--s-3) var(--s-4);
  border-top: 1px solid var(--c-border);
  transition: background var(--d-fast);
}
.doc-row:first-child { border-top: none; }
.doc-row:hover { background: var(--c-bg-alt); }
.doc-row.done .doc-name { text-decoration: line-through; color: var(--c-text-tertiary); }
.doc-name { font-size: 14px; font-weight: 500; color: var(--c-text-primary); }
.doc-meta { display: flex; gap: var(--s-2); align-items: center; font-size: 12px; color: var(--c-text-secondary); }
.doc-meta .cost { font-weight: 700; color: var(--c-text-primary); font-variant-numeric: tabular-nums; }

/* ---------- Applications table ---------- */
.apps-table {
  width: 100%;
  background: var(--c-bg-elevated);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  overflow: hidden;
  border-collapse: collapse;
}
.apps-table th {
  background: var(--c-bg-alt);
  padding: var(--s-3) var(--s-4);
  text-align: left;
  font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--c-text-secondary);
  border-bottom: 1px solid var(--c-border);
}
.apps-table td {
  padding: var(--s-3) var(--s-4);
  font-size: 13px;
  border-bottom: 1px solid var(--c-border);
  vertical-align: middle;
}
.apps-table tr:last-child td { border-bottom: none; }
.apps-table tr:hover td { background: var(--c-bg-alt); }

/* ---------- Funding ---------- */
.funding-grid {
  display: grid; grid-template-columns: 2fr 1fr; gap: var(--s-5);
  align-items: start;
}
.funding-source {
  background: var(--c-bg-elevated);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: var(--s-3) var(--s-4);
  display: flex; align-items: center; gap: var(--s-3);
  margin-bottom: var(--s-2);
}
.funding-source .icon {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: var(--c-bg-alt);
  border-radius: var(--r-md);
  color: var(--c-accent); flex-shrink: 0;
}
.funding-source .label { flex: 1; font-size: 14px; font-weight: 600; color: var(--c-text-primary); }
.funding-source .amount { font-size: 14px; font-weight: 700; color: var(--c-text-primary); font-variant-numeric: tabular-nums; min-width: 100px; text-align: right; }
.funding-source .delete { color: var(--c-text-tertiary); padding: var(--s-1); }
.funding-source .delete:hover { color: var(--c-danger); }

.funding-summary {
  background: var(--c-bg-elevated);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  position: sticky; top: 80px;
  text-align: center;
}
.funding-ring { display: inline-block; margin-bottom: var(--s-3); }
.funding-pct { font-size: 36px; font-weight: 700; color: var(--c-accent); font-variant-numeric: tabular-nums; }
.funding-pct-label { font-size: 13px; color: var(--c-text-secondary); margin-bottom: var(--s-3); }
.funding-gap { font-size: 14px; font-weight: 600; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  opacity: 0; visibility: hidden;
  transition: opacity var(--d-base), visibility var(--d-base);
}
.modal-backdrop.open { opacity: 1; visibility: visible; }
.modal {
  background: var(--c-bg-elevated);
  border-radius: var(--r-xl);
  max-width: 640px; width: calc(100% - var(--s-5));
  max-height: 80vh; overflow-y: auto;
  padding: var(--s-6);
  box-shadow: var(--shadow-3);
  transform: scale(0.95) translateY(20px);
  transition: transform var(--d-base) var(--ease-out-back);
}
.modal-backdrop.open .modal { transform: scale(1) translateY(0); }
.modal-title { font-size: 20px; font-weight: 700; margin-bottom: var(--s-3); color: var(--c-text-primary); }
.modal-body { font-size: 14px; color: var(--c-text-secondary); line-height: 1.6; margin-bottom: var(--s-4); }
.modal-footer { display: flex; justify-content: flex-end; gap: var(--s-2); }

/* ---------- Toast ---------- */
.toast-host {
  position: fixed; bottom: var(--s-5); left: 50%; transform: translateX(-50%);
  z-index: 200; display: flex; flex-direction: column; gap: var(--s-2);
  pointer-events: none;
}
.toast {
  background: var(--c-text-primary);
  color: var(--c-text-inverse);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-3);
  animation: toast-in 280ms var(--ease-out-back), toast-out 280ms var(--ease-in-out-cubic) 2.5s forwards;
  display: flex; align-items: center; gap: var(--s-2);
  max-width: 400px;
}
.toast.success { background: var(--c-success); }
.toast.warning { background: var(--c-warning); color: var(--c-text-primary); }
.toast.danger { background: var(--c-danger); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateY(20px); }
}

/* ---------- Path picker ---------- */
.path-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: var(--s-4); }
.path-card {
  background: var(--c-bg-elevated);
  border: 2px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  cursor: pointer;
  transition: all var(--d-base) var(--ease-out-expo);
  position: relative;
}
.path-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); }
.path-card.selected { border-color: var(--c-accent); background: var(--c-accent-soft); }
.path-card.selected::before {
  content: '✓';
  position: absolute; top: var(--s-3); right: var(--s-3);
  width: 24px; height: 24px;
  background: var(--c-accent); color: var(--c-text-inverse);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}
.path-icon { font-size: 36px; margin-bottom: var(--s-2); }
.path-title { font-size: 20px; font-weight: 700; margin-bottom: var(--s-1); }
.path-subtitle { font-size: 13px; color: var(--c-text-secondary); margin-bottom: var(--s-3); }
.path-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s-2); margin-top: var(--s-3); }
.path-stat { padding: var(--s-2); background: var(--c-bg-alt); border-radius: var(--r-sm); }
.path-stat .v { font-size: 18px; font-weight: 700; color: var(--c-accent); }
.path-stat .l { font-size: 11px; color: var(--c-text-secondary); text-transform: uppercase; letter-spacing: 0.05em; }

/* ---------- Quick actions (dashboard) ---------- */
.quick-actions {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--s-3);
}
.quick-action {
  background: var(--c-bg-elevated);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: var(--s-4);
  display: flex; flex-direction: column; gap: var(--s-1);
  text-decoration: none;
  color: inherit;
  transition: all var(--d-base) var(--ease-out-expo);
  cursor: pointer;
}
.quick-action:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); border-color: var(--c-accent); text-decoration: none; }
.quick-action .icon { color: var(--c-accent); }
.quick-action .title { font-size: 14px; font-weight: 600; color: var(--c-text-primary); }
.quick-action .desc { font-size: 12px; color: var(--c-text-secondary); }

/* ---------- Deadlines list ---------- */
.deadline-list { display: flex; flex-direction: column; gap: var(--s-2); }
.deadline-row {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  background: var(--c-bg-elevated);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  transition: all var(--d-base) var(--ease-out-expo);
}
.deadline-row:hover { transform: translateX(4px); border-left: 4px solid var(--c-accent); }
.deadline-date { font-size: 12px; color: var(--c-text-tertiary); font-weight: 600; min-width: 80px; }
.deadline-name { flex: 1; font-size: 14px; color: var(--c-text-primary); }
.deadline-urgency { padding: 2px var(--s-2); border-radius: var(--r-pill); font-size: 11px; font-weight: 700; }
.deadline-urgency.soon { background: var(--c-warning-soft); color: var(--c-warning); }
.deadline-urgency.urgent { background: var(--c-danger-soft); color: var(--c-danger); animation: pulse 1.5s var(--ease-in-out-cubic) infinite; }
.deadline-urgency.ok { background: var(--c-accent-soft); color: var(--c-accent); }
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* ---------- Animations (entrance) ---------- */
.fade-in { opacity: 0; transform: translateY(16px); transition: opacity 600ms var(--ease-out-expo), transform 600ms var(--ease-out-expo); }
.fade-in.revealed { opacity: 1; transform: translateY(0); }
.stagger > * { opacity: 0; transform: translateY(16px); }
.stagger.revealed > *:nth-child(1) { animation: fade-in-up 500ms 0ms var(--ease-out-expo) forwards; }
.stagger.revealed > *:nth-child(2) { animation: fade-in-up 500ms 60ms var(--ease-out-expo) forwards; }
.stagger.revealed > *:nth-child(3) { animation: fade-in-up 500ms 120ms var(--ease-out-expo) forwards; }
.stagger.revealed > *:nth-child(4) { animation: fade-in-up 500ms 180ms var(--ease-out-expo) forwards; }
.stagger.revealed > *:nth-child(5) { animation: fade-in-up 500ms 240ms var(--ease-out-expo) forwards; }
.stagger.revealed > *:nth-child(6) { animation: fade-in-up 500ms 300ms var(--ease-out-expo) forwards; }
.stagger.revealed > *:nth-child(7) { animation: fade-in-up 500ms 360ms var(--ease-out-expo) forwards; }
.stagger.revealed > *:nth-child(8) { animation: fade-in-up 500ms 420ms var(--ease-out-expo) forwards; }
@keyframes fade-in-up {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .hero-plane { animation: none !important; }
  .program-card.urgency-now { animation: none !important; }
  .deadline-urgency.urgent { animation: none !important; }
}

/* ---------- Print ---------- */
@media print {
  .sidebar, .topbar, .modal-backdrop, .toast-host, .filters-bar, .btn { display: none !important; }
  body { background: #fff; color: #000; font: 11pt/1.4 Georgia, serif; }
  .main { max-width: 100%; padding: 0; }
  section { page-break-inside: avoid; padding: var(--s-4) 0; }
  .card, .kpi-card, .program-card { box-shadow: none; border: 1px solid #ccc; }
  a[href]::after { content: " (" attr(href) ")"; font-size: 9pt; color: #555; }
  .gantt-bar { background: #333 !important; color: #fff !important; }
  h1, h2, h3 { color: #000; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .cost-grid { grid-template-columns: 1fr; }
  .cost-summary { position: static; }
  .funding-grid { grid-template-columns: 1fr; }
  .funding-summary { position: static; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; grid-template-areas: "topbar" "main"; }
  .sidebar { display: none; }
  .main { padding: var(--s-4); }
  .section-title { font-size: 24px; }
  .hero { padding: var(--s-5); }
  .hero-title { font-size: 24px; }
  .gantt { font-size: 12px; }
  .doc-row { grid-template-columns: 24px 1fr; }
  .doc-meta { grid-column: 2; }
  .apps-table { font-size: 12px; }
  .apps-table th:nth-child(3), .apps-table td:nth-child(3),
  .apps-table th:nth-child(5), .apps-table td:nth-child(5) { display: none; }
  .topbar-section { display: none; }
}
@media (max-width: 600px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .kpi-value { font-size: 24px; }
  .topbar-brand span { display: none; }
  .path-grid { grid-template-columns: 1fr; }
  .filters-bar { padding: var(--s-2); }
}

/* ---------- Utilities ---------- */
.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-1 { margin-top: var(--s-1); } .mt-2 { margin-top: var(--s-2); } .mt-3 { margin-top: var(--s-3); } .mt-4 { margin-top: var(--s-4); } .mt-5 { margin-top: var(--s-5); } .mt-6 { margin-top: var(--s-6); }
.mb-1 { margin-bottom: var(--s-1); } .mb-2 { margin-bottom: var(--s-2); } .mb-3 { margin-bottom: var(--s-3); } .mb-4 { margin-bottom: var(--s-4); } .mb-5 { margin-bottom: var(--s-5); } .mb-6 { margin-bottom: var(--s-6); }
.flex { display: flex; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: var(--s-1); } .gap-2 { gap: var(--s-2); } .gap-3 { gap: var(--s-3); } .gap-4 { gap: var(--s-4); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.text-secondary { color: var(--c-text-secondary); }
.text-tertiary { color: var(--c-text-tertiary); }
.text-accent { color: var(--c-accent); }
.text-gold { color: var(--c-gold); }
.text-danger { color: var(--c-danger); }
.text-warning { color: var(--c-warning); }
.text-success { color: var(--c-success); }
.fw-700 { font-weight: 700; }
.fw-600 { font-weight: 600; }
.fw-500 { font-weight: 500; }
.tabular { font-variant-numeric: tabular-nums lining-nums; }
.uppercase { text-transform: uppercase; letter-spacing: 0.05em; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.w-100 { width: 100%; }
.muted { color: var(--c-text-secondary); font-style: italic; }
