/* ═══════════════════════════════════════════════════════════════════════════
   CONDUXA — Design System v3.0
   Direkt von Landing Page abgeleitet · Dark + Light Mode · Mobile-First
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Fonts (identisch Landing) ────────────────────────────────────────────── */
/* Fonts via <link> in base.html */

/* ── Dark Mode (Default — wie Landing) ────────────────────────────────────── */
:root,
[data-theme="dark"] {
  /* Exakt Landing Page Werte */
  --bg:           #0a0a0a;
  --surface:      #111111;
  --border:       #1f1f1f;
  --border-light: #2a2a2a;
  --text:         #ededed;
  --text-muted:   #888888;
  --text-dim:     #555555;
  --accent:       #3b82f6;
  --accent-glow:  rgba(59,130,246,0.15);
  --green:        #22c55e;
  --swiss-red:    #C8102E;

  /* App-spezifisch (abgeleitet) */
  --bg-elevated:  #161616;
  --bg-input:     #0d0d0d;
  --bg-overlay:   #1a1a1a;
  --border-strong:#3a3a3a;
  --text-primary: #ededed;   /* = --text */
  --text-secondary:#888888;  /* = --text-muted */
  --accent-blue:  #3b82f6;   /* = --accent */
  --accent-grad:  linear-gradient(135deg, #60a5fa 0%, #a78bfa 100%);

  /* Status */
  --status-green:  #22c55e;
  --status-yellow: #f59e0b;
  --status-red:    #ef4444;
  --status-blue:   #3b82f6;
  --status-green-bg:  rgba(34,197,94,0.08);
  --status-yellow-bg: rgba(245,158,11,0.08);
  --status-red-bg:    rgba(239,68,68,0.08);
  --status-blue-bg:   rgba(59,130,246,0.08);

  /* Sidebar Toggle */
  --theme-toggle-icon: '☀';
}

/* ── Light Mode ────────────────────────────────────────────────────────────── */
[data-theme="light"] {
  --bg:           #f8f9fa;
  --surface:      #ffffff;
  --border:       #e5e7eb;
  --border-light: #d1d5db;
  --text:         #111827;
  --text-muted:   #6b7280;
  --text-dim:     #9ca3af;
  --accent:       #2563eb;
  --accent-glow:  rgba(37,99,235,0.08);
  --green:        #16a34a;
  --swiss-red:    #C8102E;

  --bg-elevated:  #f3f4f6;
  --bg-input:     #ffffff;
  --bg-overlay:   #e5e7eb;
  --border-strong:#9ca3af;
  --text-primary: #111827;
  --text-secondary:#6b7280;
  --accent-blue:  #2563eb;
  --accent-grad:  linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);

  --status-green:  #16a34a;
  --status-yellow: #d97706;
  --status-red:    #dc2626;
  --status-blue:   #2563eb;
  --status-green-bg:  rgba(22,163,74,0.08);
  --status-yellow-bg: rgba(217,119,6,0.08);
  --status-red-bg:    rgba(220,38,38,0.08);
  --status-blue-bg:   rgba(37,99,235,0.08);

  --theme-toggle-icon: '☾';
}

/* System preference fallback */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg: #f8f9fa; --surface: #ffffff; --border: #e5e7eb;
    --border-light: #d1d5db; --text: #111827; --text-muted: #6b7280;
    --text-dim: #9ca3af; --accent: #2563eb; --accent-glow: rgba(37,99,235,0.08);
    --bg-elevated: #f3f4f6; --bg-input: #ffffff; --text-primary: #111827;
    --text-secondary: #6b7280; --accent-blue: #2563eb;
    --accent-grad: linear-gradient(135deg,#3b82f6,#8b5cf6);
    --status-green: #16a34a; --status-yellow: #d97706; --status-red: #dc2626;
    --status-blue: #2563eb;
    --status-green-bg: rgba(22,163,74,.08); --status-yellow-bg: rgba(217,119,6,.08);
    --status-red-bg: rgba(220,38,38,.08); --status-blue-bg: rgba(37,99,235,.08);
  }
}

/* ── Layout Variablen ─────────────────────────────────────────────────────── */
:root {
  --sidebar-width:  220px;
  --topbar-height:  56px;
  --content-pad:    1.5rem;
  --font-sans:      'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:      'IBM Plex Mono', 'Fira Code', monospace;
  --radius-sm:  4px;
  --radius-md:  6px;
  --radius-lg:  10px;
  --radius-xl:  14px;
  --shadow-sm:  0 1px 3px rgba(0,0,0,.3);
  --shadow-md:  0 4px 12px rgba(0,0,0,.4);
  --shadow-lg:  0 8px 32px rgba(0,0,0,.5);
  /* Light mode shadows */
}
[data-theme="light"] {
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,.1);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.15);
}

/* ── Reset ────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background .2s, color .2s;
}
a { color: var(--accent); text-decoration: none; }
a:hover { opacity: .85; }
img { max-width: 100%; }

/* ═══════════════════════════════════════════════════════════════════════════
   APP LAYOUT
   ═══════════════════════════════════════════════════════════════════════════ */
.app-body {
  display: flex;
  min-height: 100vh;
}

.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  margin-left: var(--sidebar-width);
  transition: margin-left .25s ease;
}

/* ═══════════════════════════════════════════════════════════════════════════
   SIDEBAR
   ═══════════════════════════════════════════════════════════════════════════ */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 200;
  overflow: hidden;
  transition: transform .25s ease;
}

/* Logo — identisch Landing Nav */
.sidebar__logo {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  padding: 0 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar__logo-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.3px;
}

.sidebar__logo-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

[data-theme="dark"] .sidebar__logo-dot {
  box-shadow: 0 0 8px var(--accent);
}

.sidebar__logo-name {
  font-family: var(--font-sans);
}

/* Projekt-Kontext */
.sidebar__project {
  padding: 0.65rem 1rem;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar__project-label {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-bottom: 0.2rem;
}

.sidebar__project-code {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--accent);
  font-weight: 500;
}

.sidebar__project-name {
  font-size: 0.73rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Nav */
.sidebar__nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.4rem 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.sidebar__section-label {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  letter-spacing: 0.14em;
  color: var(--text-dim);
  text-transform: uppercase;
  padding: 0.8rem 1rem 0.25rem;
}

.sidebar__link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.42rem 1rem;
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: 0;
  border-left: 2px solid transparent;
  transition: background .1s, color .1s, border-color .1s;
}

.sidebar__link:hover {
  background: var(--bg-elevated);
  color: var(--text);
  opacity: 1;
}

.sidebar__link--active {
  color: var(--accent);
  background: var(--accent-glow);
  border-left-color: var(--accent);
  font-weight: 500;
}

.sidebar__icon {
  width: 16px;
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-dim);
  flex-shrink: 0;
}

.sidebar__link--active .sidebar__icon,
.sidebar__link:hover .sidebar__icon {
  color: inherit;
}

/* User Footer */
.sidebar__footer {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.sidebar__user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-grad);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.sidebar__user-info { flex: 1; min-width: 0; }

.sidebar__user-email {
  font-size: 0.68rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar__user-role {
  font-family: var(--font-mono);
  font-size: 0.56rem;
  color: var(--text-dim);
}

.sidebar__footer-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.sidebar__footer-btn {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 0.85rem;
  text-decoration: none;
  transition: background .1s, color .1s;
  cursor: pointer;
  background: none;
  border: none;
}

.sidebar__footer-btn:hover {
  background: var(--bg-elevated);
  color: var(--text);
  opacity: 1;
}

/* Theme Toggle Button */
.theme-toggle {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 0.8rem;
  cursor: pointer;
  background: none;
  border: 1px solid var(--border);
  transition: all .1s;
}

.theme-toggle:hover {
  background: var(--bg-elevated);
  color: var(--text);
  border-color: var(--border-light);
}

/* ═══════════════════════════════════════════════════════════════════════════
   TOPBAR
   ═══════════════════════════════════════════════════════════════════════════ */
.topbar {
  height: var(--topbar-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  gap: 0.75rem;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar__toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.3rem 0.4rem;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  line-height: 1;
  transition: background .1s, color .1s;
  flex-shrink: 0;
}

.topbar__toggle:hover {
  background: var(--bg-elevated);
  color: var(--text);
}

.topbar__breadcrumb {
  flex: 1;
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
  overflow: hidden;
}

.topbar__breadcrumb a {
  color: var(--text-muted);
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.topbar__breadcrumb a:hover { color: var(--text); opacity: 1; }

.topbar__sep { color: var(--text-dim); font-size: 0.7rem; flex-shrink: 0; }

.topbar__current {
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════════════════
   CONTENT
   ═══════════════════════════════════════════════════════════════════════════ */
.app-content {
  flex: 1;
  padding: var(--content-pad);
}

.page-header {
  margin-bottom: 1.5rem;
}

.page-title {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: var(--text);
}

.page-subtitle {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-top: 0.2rem;
  font-family: var(--font-mono);
}

/* Section */
.section { margin-bottom: 2rem; }

.section-title {
  font-size: 0.6rem;
  font-family: var(--font-mono);
  letter-spacing: 0.12em;
  color: var(--text-dim);
  text-transform: uppercase;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

/* ═══════════════════════════════════════════════════════════════════════════
   BUTTONS — identisch Landing
   ═══════════════════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 1rem;
  font-size: 0.8rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: opacity .15s, background .15s, border-color .15s;
  white-space: nowrap;
  font-family: var(--font-sans);
  line-height: 1.4;
}

.btn:hover { opacity: .88; }

.btn--primary {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

.btn--primary:hover {
  opacity: .88;
  color: var(--bg);
}

.btn--accent {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn--secondary {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border-light);
}

.btn--secondary:hover {
  border-color: var(--border-strong);
  color: var(--text);
  opacity: 1;
}

.btn--ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}

.btn--ghost:hover {
  background: var(--bg-elevated);
  color: var(--text);
  opacity: 1;
}

.btn--danger {
  background: transparent;
  color: var(--status-red);
  border-color: var(--status-red);
}

.btn--danger:hover {
  background: var(--status-red-bg);
  opacity: 1;
}

.btn--sm  { padding: 0.32rem 0.7rem; font-size: 0.73rem; }
.btn--lg  { padding: 0.65rem 1.25rem; font-size: 0.9rem; }

/* ═══════════════════════════════════════════════════════════════════════════
   CARDS
   ═══════════════════════════════════════════════════════════════════════════ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  transition: background .15s;
}

.card:hover { background: var(--bg-elevated); }

.card__label {
  font-size: 0.6rem;
  font-family: var(--font-mono);
  letter-spacing: 0.12em;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-bottom: 0.4rem;
}

.card__value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
}

.card__sub {
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-top: 0.2rem;
  font-family: var(--font-mono);
}

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 2rem;
}

.kpi-card {
  background: var(--surface);
  padding: 1.1rem 1.25rem;
  transition: background .15s;
}

.kpi-card:hover { background: var(--bg-elevated); }

.kpi-card__label {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-bottom: 0.4rem;
}

.kpi-card__value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  font-family: var(--font-mono);
  letter-spacing: -0.5px;
  line-height: 1.1;
}

.kpi-card__sub {
  font-size: 0.68rem;
  color: var(--text-dim);
  margin-top: 0.2rem;
}

.kpi-card--accent .kpi-card__value { color: var(--accent); }
.kpi-card--green .kpi-card__value  { color: var(--status-green); }
.kpi-card--amber .kpi-card__value  { color: var(--status-yellow); }
.kpi-card--red   .kpi-card__value  { color: var(--status-red); }

/* ═══════════════════════════════════════════════════════════════════════════
   TABLES — Landing Feature Grid Stil
   ═══════════════════════════════════════════════════════════════════════════ */
.table-wrap {
  background: var(--border);  /* grid lines via background gap */
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  overflow-x: auto;
}

table, .table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  background: var(--surface);
}

thead th {
  background: var(--bg-elevated);
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 500;
  padding: 0.65rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}

tbody tr:last-child { border-bottom: none; }

tbody tr:hover { background: var(--bg-elevated); }

tbody td {
  padding: 0.62rem 1rem;
  color: var(--text-muted);
  vertical-align: middle;
}

tbody td strong { color: var(--text); font-weight: 500; }

tbody td:first-child {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-dim);
}

tfoot td {
  padding: 0.62rem 1rem;
  background: var(--bg-elevated);
  font-size: 0.78rem;
  border-top: 1px solid var(--border-light);
  color: var(--text-muted);
}

/* ═══════════════════════════════════════════════════════════════════════════
   BADGES — Landing Stil
   ═══════════════════════════════════════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 500;
  font-family: var(--font-mono);
  white-space: nowrap;
}

.badge::before { content: '●'; font-size: 0.42rem; }

.badge--green  { background: var(--status-green-bg);  color: var(--status-green); }
.badge--yellow { background: var(--status-yellow-bg); color: var(--status-yellow); }
.badge--red    { background: var(--status-red-bg);    color: var(--status-red); }
.badge--blue   { background: var(--status-blue-bg);   color: var(--status-blue); }
.badge--gray   { background: var(--bg-elevated); border: 1px solid var(--border); color: var(--text-dim); }

/* Legacy */
.status-active, .status-paid   { display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .55rem; border-radius: 999px; font-size: .65rem; font-weight: 500; font-family: var(--font-mono); background: var(--status-green-bg); color: var(--status-green); }
.status-approved                { display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .55rem; border-radius: 999px; font-size: .65rem; font-weight: 500; font-family: var(--font-mono); background: var(--status-blue-bg);  color: var(--status-blue); }
.status-pending                 { display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .55rem; border-radius: 999px; font-size: .65rem; font-weight: 500; font-family: var(--font-mono); background: var(--status-yellow-bg); color: var(--status-yellow); }

/* ═══════════════════════════════════════════════════════════════════════════
   FORMS
   ═══════════════════════════════════════════════════════════════════════════ */
.form-group { margin-bottom: 1rem; }

label, .form-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-bottom: 0.35rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="search"],
select,
textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  padding: 0.5rem 0.75rem;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
  -webkit-appearance: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

input::placeholder, textarea::placeholder { color: var(--text-dim); }

select {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23555' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2rem;
}

textarea { resize: vertical; min-height: 80px; }

.form-control { }
.form-control--sm { font-size: 0.73rem; padding: 0.35rem 0.6rem; }

/* ═══════════════════════════════════════════════════════════════════════════
   ALERTS & BANNERS
   ═══════════════════════════════════════════════════════════════════════════ */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.78rem;
  margin-bottom: 1rem;
  border: 1px solid;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.alert--warning { background: var(--status-yellow-bg); border-color: rgba(245,158,11,.2); color: var(--status-yellow); }
.alert--error   { background: var(--status-red-bg);    border-color: rgba(239,68,68,.2);  color: var(--status-red); }
.alert--info    { background: var(--status-blue-bg);   border-color: rgba(59,130,246,.2); color: var(--status-blue); }
.alert--success { background: var(--status-green-bg);  border-color: rgba(34,197,94,.2);  color: var(--status-green); }

.plan-locked-banner {
  background: var(--status-yellow-bg);
  border: 1px solid rgba(245,158,11,.2);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  color: var(--status-yellow);
  font-size: 0.78rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ═══════════════════════════════════════════════════════════════════════════
   VALIDATION ERRORS (Sprint 29)
   ═══════════════════════════════════════════════════════════════════════════ */
.validation-error {
  background: var(--status-red-bg);
  border: 1px solid rgba(239,68,68,.2);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.78rem;
}

.validation-error__list { margin: 0; padding: 0 0 0 1rem; color: var(--status-red); }
.validation-error__item { margin-bottom: 0.2rem; }
.form-field--error input,
.form-field--error select,
.form-field--error textarea { border-color: var(--status-red); }
.form-field__error-msg { color: var(--status-red); font-size: 0.68rem; margin-top: .2rem; font-family: var(--font-mono); }

/* ═══════════════════════════════════════════════════════════════════════════
   CONTEXT BANNER (Sprint 28)
   ═══════════════════════════════════════════════════════════════════════════ */
.ctx-banner {
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  padding: 0.38rem var(--content-pad);
  font-size: 0.7rem;
  margin: calc(-1 * var(--content-pad));
  margin-bottom: 1.25rem;
}

.ctx-banner__inner { display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; }
.ctx-banner__item { display: flex; align-items: center; gap: .2rem; }
.ctx-banner__item--link { color: var(--accent); }
.ctx-banner__item--link:hover { opacity: .8; }
.ctx-banner__item--current { color: var(--text-muted); font-weight: 500; }
.ctx-banner__sep { color: var(--text-dim); font-size: .62rem; }
@media print { .ctx-banner { display: none; } }

/* ═══════════════════════════════════════════════════════════════════════════
   MODAL
   ═══════════════════════════════════════════════════════════════════════════ */
.modal { position: fixed; inset: 0; z-index: 300; display: flex; align-items: center; justify-content: center; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(4px); }
.modal__box { position: relative; background: var(--surface); border: 1px solid var(--border-light); border-radius: var(--radius-xl); padding: 2rem; max-width: 420px; width: 90%; text-align: center; box-shadow: var(--shadow-lg); }
.modal__icon { font-size: 2rem; margin-bottom: .75rem; }
.modal__title { font-size: 1.1rem; font-weight: 600; margin-bottom: .5rem; }
.modal__body { font-size: .82rem; color: var(--text-muted); margin-bottom: 1.5rem; }
.modal__actions { display: flex; gap: .5rem; justify-content: center; }

/* ═══════════════════════════════════════════════════════════════════════════
   WORKFLOW TIMELINE
   ═══════════════════════════════════════════════════════════════════════════ */
.timeline {
  display: flex;
  align-items: center;
  padding: 1rem 0;
  overflow-x: auto;
}

.timeline__step {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-width: 75px;
  position: relative;
}

.timeline__step::before {
  content: '';
  position: absolute;
  top: 13px;
  left: calc(-50% + 13px);
  right: calc(50% + 13px);
  height: 1px;
  background: var(--border-light);
}

.timeline__step:first-child::before { display: none; }

.timeline__dot {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border-light);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.62rem; font-family: var(--font-mono);
  color: var(--text-dim);
  position: relative; z-index: 1;
}

.timeline__step--active .timeline__dot {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.timeline__step--done .timeline__dot {
  background: var(--status-green);
  border-color: var(--status-green);
  color: #fff;
}

.timeline__step--done::before  { background: var(--status-green); }
.timeline__step--active::before { background: var(--status-green); }

.timeline__label {
  font-size: 0.6rem; color: var(--text-dim);
  margin-top: 0.35rem; text-align: center; white-space: nowrap;
}
.timeline__step--active .timeline__label { color: var(--accent); }
.timeline__step--done .timeline__label { color: var(--status-green); }

/* ═══════════════════════════════════════════════════════════════════════════
   GLOSSAR (Sprint 28)
   ═══════════════════════════════════════════════════════════════════════════ */
.glossar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; margin-top: 1.5rem; }
.glossar-card { background: var(--surface); padding: 1.25rem 1.5rem; transition: background .15s; }
.glossar-card:hover { background: var(--bg-elevated); }
.glossar-card__term { font-weight: 600; font-size: .88rem; color: var(--text); margin-bottom: .2rem; }
.glossar-card__norm { font-family: var(--font-mono); font-size: .62rem; color: var(--accent); margin-bottom: .5rem; letter-spacing: .05em; }
.glossar-card__def { font-size: .78rem; color: var(--text-muted); line-height: 1.65; }

/* ═══════════════════════════════════════════════════════════════════════════
   GANTT FARBEN (Sprint 28)
   ═══════════════════════════════════════════════════════════════════════════ */
.gantt-bar--bkp-1 { background: var(--accent) !important; }
.gantt-bar--bkp-2 { background: var(--status-green) !important; }
.gantt-bar--bkp-3 { background: var(--status-yellow) !important; }
.gantt-bar--bkp-4 { background: var(--status-red) !important; }
.gantt-bar--bkp-5 { background: #8b5cf6 !important; }
.gantt-bar--bkp-6 { background: #06b6d4 !important; }
.gantt-bar--bkp-7 { background: #f97316 !important; }
.gantt-bar--bkp-8 { background: #84cc16 !important; }
.gantt-bar--bkp-9 { background: #ec4899 !important; }

/* ═══════════════════════════════════════════════════════════════════════════
   UTILITY
   ═══════════════════════════════════════════════════════════════════════════ */
.text-mono     { font-family: var(--font-mono); }
.text-muted    { color: var(--text-muted); }
.text-dim      { color: var(--text-dim); }
.text-accent   { color: var(--accent); }
.text-green    { color: var(--status-green); }
.text-red      { color: var(--status-red); }
.text-yellow   { color: var(--status-yellow); }
.text-right    { text-align: right; }
.text-sm       { font-size: .75rem; }
.text-xs       { font-size: .65rem; }
.mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; } .mb-2 { margin-bottom: 1rem; } .mb-3 { margin-bottom: 1.5rem; }
.flex { display: flex; } .flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: .5rem; } .gap-2 { gap: 1rem; }
.items-center { align-items: center; }
.w-full { width: 100%; }

/* ═══════════════════════════════════════════════════════════════════════════
   MOBILE — Bottom Navigation
   ═══════════════════════════════════════════════════════════════════════════ */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 0.5rem 0 calc(0.5rem + env(safe-area-inset-bottom));
  z-index: 200;
}

.mobile-nav__items {
  display: flex;
  justify-content: space-around;
}

.mobile-nav__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.4rem 0.75rem;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.58rem;
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
  transition: color .1s;
  border-radius: var(--radius-sm);
}

.mobile-nav__item:hover,
.mobile-nav__item--active {
  color: var(--accent);
  opacity: 1;
}

.mobile-nav__icon { font-size: 1.1rem; line-height: 1; }

/* Mobile Overlay für Sidebar */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 150;
  backdrop-filter: blur(2px);
}

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE BREAKPOINTS
   ═══════════════════════════════════════════════════════════════════════════ */

/* Tablet (768px–1024px) */
@media (max-width: 1024px) {
  :root { --sidebar-width: 200px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Mobile (< 768px) */
@media (max-width: 767px) {
  :root {
    --content-pad: 1rem;
    --topbar-height: 52px;
  }

  /* Sidebar wird Drawer */
  .sidebar {
    transform: translateX(-100%);
    width: 280px;
    box-shadow: var(--shadow-lg);
  }

  .sidebar--open {
    transform: translateX(0);
  }

  .sidebar-overlay {
    display: block;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s;
  }

  .sidebar--open ~ .sidebar-overlay {
    opacity: 1;
    pointer-events: auto;
  }

  /* App main: kein margin */
  .app-main {
    margin-left: 0;
  }

  /* Mobile Bottom Nav */
  .mobile-nav { display: block; }

  /* Content Padding für Bottom Nav */
  .app-content {
    padding-bottom: calc(4rem + env(safe-area-inset-bottom));
  }

  /* Page Title kleiner */
  .page-title { font-size: 1.15rem; }

  /* KPI Cards 2-spaltig */
  .kpi-grid { grid-template-columns: 1fr 1fr; }

  /* Topbar: kein Breadcrumb-Overflow */
  .topbar__breadcrumb {
    font-size: 0.72rem;
  }

  /* Tabellen scrollbar */
  .table-wrap { border-radius: var(--radius-md); }

  /* Buttons full-width in manchen Kontexten */
  .btn--block { width: 100%; justify-content: center; }
}

/* Sehr kleines Mobile (< 380px) */
@media (max-width: 380px) {
  .kpi-grid { grid-template-columns: 1fr; }
  :root { --content-pad: 0.75rem; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   PRINT
   ═══════════════════════════════════════════════════════════════════════════ */
@media print {
  .sidebar, .topbar, .mobile-nav, .ctx-banner, .topbar__toggle,
  .btn--primary, .btn--secondary, .btn--ghost { display: none !important; }
  .app-main { margin-left: 0 !important; }
  body { background: #fff !important; color: #000 !important; }
  .card, .table-wrap { border-color: #ccc !important; }
  .kpi-card__value { color: #000 !important; }
}


/* ═══════════════════════════════════════════════════════════════════════════
   DARK MODE OVERRIDES — Dashboard + Legacy Components
   Überschreibt alle hardcodierten hellen Inline-Styles
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── KPI Cards Dashboard ──────────────────────────────────────────────────── */
.kpi-card,
.stat-card,
[class*="kpi"],
.dashboard-card {
  background: var(--surface) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}

/* ── Quick-Link Cards (Dashboard Module-Grid) ─────────────────────────────── */
.quick-link,
.module-card,
.quick-actions a,
.quick-actions div,
.action-card,
[class*="quick"],
[class*="module"] {
  background: var(--surface) !important;
  border-color: var(--border) !important;
  color: var(--text) !important;
}

.quick-link:hover,
.module-card:hover,
.action-card:hover {
  background: var(--bg-elevated) !important;
  border-color: var(--border-light) !important;
}

.quick-link span,
.module-card span,
.action-card span {
  color: var(--text-muted) !important;
}

/* ── SIA 112 Phasenbalken ─────────────────────────────────────────────────── */
.sia-bar,
.phase-bar,
[class*="sia"],
[class*="phase"] {
  background: var(--bg-elevated) !important;
  border-color: var(--border) !important;
  color: var(--text) !important;
}

.sia-bar__fill,
.phase-bar__fill,
.progress-fill {
  background: var(--accent) !important;
}

/* ── Alle weissen/hellen Hintergründe fixen ───────────────────────────────── */
.white-bg,
.bg-white,
.card-white,
[style*="background: white"],
[style*="background:#fff"],
[style*="background: #fff"],
[style*="background-color: white"],
[style*="background-color:#fff"],
[style*="background-color: #fff"] {
  background: var(--surface) !important;
  color: var(--text) !important;
}

/* ── Text auf dunklem Hintergrund ─────────────────────────────────────────── */
[style*="color: #"],
[style*="color:#"] {
  /* Nur wenn sehr dunkel — via Kontrast nicht überschreibbar, daher gezielt */
}

/* ── Projekt-Code Farbe ───────────────────────────────────────────────────── */
.sidebar__project-code,
[class*="project-code"],
[class*="proj-code"] {
  color: var(--accent) !important;
}

/* ── Dashboard spezifisch: KPI Werte ─────────────────────────────────────── */
.kpi-value,
.stat-value,
.dashboard-value,
[class*="kpi-val"],
[class*="stat-val"] {
  color: var(--text) !important;
}

/* Orange Akzent → Blau umleiten ──────────────────────────────────────────── */
[style*="color: #f97316"],
[style*="color:#f97316"],
[style*="color: orange"],
[style*="background: #f97316"],
[style*="background:#f97316"] {
  color: var(--accent) !important;
  background: transparent !important;
}

/* ── Topbar Aktionen ──────────────────────────────────────────────────────── */
.topbar__actions .btn,
.topbar__actions a {
  background: var(--text) !important;
  color: var(--bg) !important;
  border-color: var(--text) !important;
}

.topbar__actions .btn:hover,
.topbar__actions a:hover {
  opacity: .85 !important;
}

/* ── Tabellen in Legacy-Templates ────────────────────────────────────────── */
.table,
table {
  background: var(--surface) !important;
}

th {
  background: var(--bg-elevated) !important;
  color: var(--text-dim) !important;
}

/* ── Formulare ────────────────────────────────────────────────────────────── */
.form-control,
input,
select,
textarea {
  background: var(--bg-input) !important;
  color: var(--text) !important;
  border-color: var(--border-light) !important;
}

.form-control:focus,
input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 2px var(--accent-glow) !important;
  outline: none !important;
}

/* ── Scrollbar Dark Mode ──────────────────────────────────────────────────── */
[data-theme="dark"] ::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

[data-theme="dark"] ::-webkit-scrollbar-track {
  background: var(--bg);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 3px;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
  background: var(--border-strong, #3a3a3a);
}

/* ── Light Mode: sicherstellen dass alles hell bleibt ─────────────────────── */
[data-theme="light"] .sidebar {
  background: var(--surface) !important;
}

[data-theme="light"] .topbar {
  background: var(--surface) !important;
}

[data-theme="light"] .kpi-card {
  background: var(--surface) !important;
  border-color: var(--border) !important;
}

[data-theme="light"] table {
  background: var(--surface) !important;
}

[data-theme="light"] th {
  background: var(--bg-elevated) !important;
}

/* ── Dashboard Quick-Link Grid ────────────────────────────────────────────── */
.dashboard-grid,
.quicklinks,
.quick-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)) !important;
  gap: 1px !important;
  background: var(--border) !important;
  border: 1px solid var(--border) !important;
  border-radius: 10px !important;
  overflow: hidden !important;
}

/* ── Spezifische Legacy-Klassen aus altem CSS ─────────────────────────────── */
.main-content {
  background: transparent !important;
}

.content-header {
  background: transparent !important;
  border-bottom: 1px solid var(--border) !important;
  color: var(--text) !important;
}

.breadcrumb {
  background: transparent !important;
  color: var(--text-muted) !important;
}

.breadcrumb a {
  color: var(--text-muted) !important;
}

.breadcrumb-sep {
  color: var(--text-dim) !important;
}

/* ── Badges / Status Pills legacy ────────────────────────────────────────── */
.status-badge,
.pill,
.tag {
  font-family: var(--font-mono) !important;
  font-size: .65rem !important;
}

/* ── Alerts legacy ────────────────────────────────────────────────────────── */
.alert,
.banner,
.notification {
  border-radius: 6px !important;
}

/* ── Footer / Legal Links ─────────────────────────────────────────────────── */
footer,
.page-footer,
.footer-links {
  background: transparent !important;
  border-top: 1px solid var(--border) !important;
  color: var(--text-dim) !important;
}

footer a,
.footer-links a {
  color: var(--text-dim) !important;
}

footer a:hover,
.footer-links a:hover {
  color: var(--text-muted) !important;
}


/* ═══════════════════════════════════════════════════════════════════════════
   MOBILE OPTIMIERUNGEN — iPhone / Android
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 767px) {

  /* ── Tabellen: horizontal scrollbar statt Overflow ─────────────────── */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  table {
    min-width: 500px;
  }

  /* Erste Spalte sticky damit Kontext bleibt */
  tbody td:first-child,
  thead th:first-child {
    position: sticky;
    left: 0;
    background: var(--surface);
    z-index: 1;
  }

  thead th:first-child {
    background: var(--bg-elevated);
  }

  /* ── Topbar Breadcrumb: kompakter ───────────────────────────────────── */
  .topbar__breadcrumb {
    font-size: .7rem;
    overflow: hidden;
  }

  /* Nur letzte Ebene zeigen auf sehr kleinen Screens */
  .topbar__breadcrumb a:not(:last-of-type) {
    display: none;
  }

  .topbar__breadcrumb .topbar__sep:not(:last-of-type) {
    display: none;
  }

  /* ── Filter-Zeile: untereinander ────────────────────────────────────── */
  .page-header.flex-between {
    flex-direction: column;
    align-items: flex-start;
    gap: .75rem;
  }

  .page-header .flex {
    flex-direction: column;
    width: 100%;
    gap: .5rem;
  }

  .page-header select,
  .page-header input[type="search"],
  .page-header .form-select,
  .page-header .form-input {
    width: 100% !important;
  }

  /* ── KI-Assistent: Single Column ────────────────────────────────────── */
  .assistant-layout,
  [class*="assistant"] .grid,
  [class*="chat-layout"] {
    display: flex !important;
    flex-direction: column !important;
  }

  /* Chat-Bereich volle Breite */
  .chat-panel,
  .assistant-chat,
  [class*="chat-panel"] {
    width: 100% !important;
    min-width: 0 !important;
  }

  /* Context-Panel ausblenden oder nach unten */
  .context-panel,
  .assistant-context,
  [class*="context-panel"] {
    width: 100% !important;
    order: 2;
  }

  /* ── Bottom Nav: immer 5 Punkte sichtbar ────────────────────────────── */
  .mobile-nav__items {
    justify-content: space-evenly;
  }

  .mobile-nav__item {
    flex: 1;
    padding: .4rem .25rem;
    font-size: .55rem;
  }

  /* ── Sidebar Overlay: stärker abdunkeln ─────────────────────────────── */
  .sidebar-overlay {
    background: rgba(0, 0, 0, .65) !important;
    backdrop-filter: blur(3px);
  }

  /* ── Content Padding anpassen ───────────────────────────────────────── */
  .app-content {
    padding: .875rem;
    padding-bottom: calc(5rem + env(safe-area-inset-bottom));
  }

  /* ── KPI Grid: 2 Spalten ────────────────────────────────────────────── */
  .kpi-grid {
    grid-template-columns: 1fr 1fr !important;
  }

  /* ── Formulare: volle Breite ────────────────────────────────────────── */
  .form-row,
  [style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* ── Page Title kleiner ─────────────────────────────────────────────── */
  .page-title {
    font-size: 1.1rem;
  }

  /* ── Buttons: touch-freundlicher ────────────────────────────────────── */
  .btn {
    min-height: 38px;
    padding: .5rem 1rem;
  }

  .btn--sm {
    min-height: 32px;
    padding: .4rem .75rem;
  }

  /* ── Topbar kompakter ───────────────────────────────────────────────── */
  .topbar {
    padding: 0 .875rem;
    gap: .5rem;
  }

  /* ── Quick Action Grid: 4 Spalten auf Mobile ────────────────────────── */
  .qa-grid {
    grid-template-columns: repeat(4, 1fr) !important;
  }

  .qa-link {
    padding: .75rem .25rem !important;
    font-size: .65rem !important;
  }

  .qa-icon {
    font-size: 1.1rem !important;
  }

  /* ── Cards: kein Padding-Overflow ───────────────────────────────────── */
  .card,
  .dash-section {
    border-radius: 8px;
  }

  /* ── Ctx Banner anpassen ────────────────────────────────────────────── */
  .ctx-banner {
    padding: .35rem .875rem;
    font-size: .65rem;
  }

  /* ── Modal: volle Breite ────────────────────────────────────────────── */
  .modal__box {
    width: 95%;
    padding: 1.5rem 1rem;
  }

  /* ── Invoice Detail: Stack Layout ───────────────────────────────────── */
  .invoice-layout,
  .detail-grid,
  [class*="detail-layout"] {
    grid-template-columns: 1fr !important;
  }

  /* ── Timeline: kompakter ────────────────────────────────────────────── */
  .timeline {
    padding: .5rem 0;
  }

  .timeline__dot {
    width: 22px;
    height: 22px;
    font-size: .55rem;
  }

  .timeline__label {
    font-size: .55rem;
  }

  /* ── Projektstatus-Zeilen: wrappen ──────────────────────────────────── */
  .project-row,
  tbody tr {
    position: relative;
  }

}

/* ── Sehr kleines Mobile: < 380px ──────────────────────────────────────── */
@media (max-width: 380px) {
  .kpi-grid {
    grid-template-columns: 1fr !important;
  }

  .qa-grid {
    grid-template-columns: repeat(3, 1fr) !important;
  }

  .app-content {
    padding: .65rem;
  }
}

/* ── Safe Area Insets (iPhone Notch/HomeBar) ───────────────────────────── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .mobile-nav {
    padding-bottom: calc(.5rem + env(safe-area-inset-bottom));
  }

  .app-content {
    padding-bottom: calc(4.5rem + env(safe-area-inset-bottom));
  }
}
