/* ============================================================================
   APP LAYOUT · Sidebar + Main + Dashboard
   ============================================================================ */

/* --- Auth layout (full screen) --- */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr;
  background: var(--bg);
}
@media (min-width: 960px) {
  .auth-wrap { grid-template-columns: 1fr 1fr; }
}
.auth-hero {
  background: var(--ink);
  color: var(--bg);
  padding: var(--sp-8);
  display: flex; flex-direction: column; justify-content: space-between;
  min-height: 40vh;
  position: relative;
  overflow: hidden;
}
.auth-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(250, 248, 245, 0.08) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(250, 248, 245, 0.05) 0%, transparent 50%);
  pointer-events: none;
}
.auth-hero > * { position: relative; z-index: 1; }
.auth-hero .eyebrow { color: var(--ink-faint); }
.auth-hero h1 {
  color: var(--bg);
  font-size: clamp(2.5rem, 5vw, 4.5rem);
  font-style: italic;
  line-height: 1;
}
.auth-hero p { color: var(--ink-faint); max-width: 32ch; }
.auth-form-wrap {
  padding: var(--sp-8);
  display: flex; flex-direction: column; justify-content: center;
  min-height: 60vh;
}
.auth-form { max-width: 380px; margin: 0 auto; width: 100%; }
.auth-form h2 { font-size: 2rem; margin-bottom: var(--sp-2); }
.auth-form .sub { color: var(--ink-muted); margin-bottom: var(--sp-6); }

/* --- App shell --- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
}

/* Sidebar */
.sidebar {
  background: var(--ink);
  color: var(--bg);
  padding: var(--sp-6) 0;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  overflow-y: auto;
}
@media (max-width: 900px) {
  .sidebar {
    position: fixed; inset: 0 auto 0 0;
    width: 260px; height: 100vh;
    z-index: 800;
    transform: translateX(-100%);
    transition: transform var(--dur) var(--ease);
  }
  .sidebar.open { transform: translateX(0); }
}
.sidebar-brand {
  padding: 0 var(--sp-6) var(--sp-6);
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-brand .name {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-style: italic;
  line-height: 1;
}
.sidebar-brand .tag {
  font-size: 0.6875rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-top: var(--sp-2);
}
.sidebar-nav { padding: var(--sp-5) 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.nav-group { padding: var(--sp-4) var(--sp-6) var(--sp-2); font-size: 0.6875rem; letter-spacing: 0.18em; text-transform: uppercase; color: rgba(250,248,245,0.4); }
.nav-link {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 0.625rem var(--sp-6);
  color: rgba(250,248,245,0.7);
  font-size: 0.9375rem;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
  border-left: 2px solid transparent;
  cursor: pointer;
}
.nav-link:hover { color: var(--bg); background: rgba(255,255,255,0.04); text-decoration: none; }
.nav-link.active {
  color: var(--bg);
  background: rgba(255,255,255,0.12);
  border-left-color: var(--bg);
  font-weight: 500;
}
.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-footer {
  padding: var(--sp-5) var(--sp-6);
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: var(--small-size);
  color: rgba(250,248,245,0.5);
}
.sidebar-user {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) 0;
}
.sidebar-user .avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(255,255,255,0.1);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-serif); font-size: 1.125rem;
  color: var(--bg);
}

.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(26, 26, 26, 0.5);
  z-index: 790;
}
@media (max-width: 900px) {
  .sidebar-backdrop.show { display: block; }
}

/* --- Main --- */
.main-area {
  min-width: 0;
  display: flex; flex-direction: column;
}

.topbar {
  height: var(--topbar-h);
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  display: flex; align-items: center;
  padding: 0 var(--sp-6);
  position: sticky; top: 0; z-index: 100;
  gap: var(--sp-4);
}
@media (max-width: 640px) { .topbar { padding: 0 var(--sp-4); } }
.topbar .menu-toggle { display: none; }
@media (max-width: 900px) {
  .topbar .menu-toggle { display: inline-flex; }
}
.topbar .page-title {
  font-family: var(--font-serif);
  font-size: 1.375rem;
  flex: 1;
}
.topbar .actions { display: flex; gap: var(--sp-3); align-items: center; }
.global-search {
  position: relative;
  display: none;
}
@media (min-width: 720px) { .global-search { display: block; flex: 1; max-width: 360px; } }
.global-search input {
  width: 100%;
  padding: 0.5rem 0.875rem 0.5rem 2.25rem;
  background: var(--bg-alt);
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: var(--small-size);
  transition: border-color var(--dur) var(--ease);
}
.global-search input:focus { outline: none; border-color: var(--ink-faint); background: var(--bg-elev); }
.global-search svg {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; color: var(--ink-muted);
}

.page-content {
  padding: var(--sp-7) var(--sp-6);
  flex: 1;
  max-width: var(--max-content);
  width: 100%;
  margin: 0 auto;
}
@media (max-width: 640px) { .page-content { padding: var(--sp-5) var(--sp-4); } }

/* --- Page header (editorial) --- */
.page-head {
  margin-bottom: var(--sp-7);
  padding-bottom: var(--sp-5);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: var(--sp-5);
  flex-wrap: wrap;
}
.page-head .left { max-width: 60ch; }
.page-head .eyebrow { margin-bottom: var(--sp-3); }
.page-head h1 { margin: 0; }
.page-head .desc { color: var(--ink-muted); margin-top: var(--sp-3); max-width: 52ch; }

/* --- KPI cards (dashboard) --- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--sp-4);
  margin-bottom: var(--sp-7);
}
.kpi {
  padding: var(--sp-6);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg-elev);
  position: relative;
  overflow: hidden;
  transition: border-color var(--dur) var(--ease);
}
.kpi:hover { border-color: var(--ink-faint); }
.kpi .kpi-label {
  font-size: var(--eyebrow-size);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: var(--sp-4);
}
.kpi .kpi-value {
  font-family: var(--font-serif);
  font-size: 2.75rem;
  line-height: 1;
  font-weight: 400;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.kpi .kpi-sub {
  font-size: var(--small-size);
  color: var(--ink-muted);
  margin-top: var(--sp-3);
}

/* --- Two-column layout --- */
.two-col {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--sp-6);
}
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }

/* Section heading (editorial) */
.section-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: var(--sp-5);
  padding-bottom: var(--sp-3);
  border-bottom: 1px solid var(--line);
}
.section-head h2 {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-style: italic;
}
.section-head a { font-size: var(--small-size); color: var(--ink-muted); }
.section-head a:hover { color: var(--ink); }

/* --- Activity timeline --- */
.timeline { display: flex; flex-direction: column; gap: var(--sp-4); }
.timeline-item {
  display: flex; gap: var(--sp-4);
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--line-soft);
}
.timeline-item:last-child { border-bottom: 0; }
.timeline-item .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ink);
  margin-top: 8px;
  flex-shrink: 0;
}
.timeline-item .meta { font-size: var(--small-size); color: var(--ink-muted); }

/* --- Kanban (pipeline) --- */
.kanban {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--sp-4);
}
@media (min-width: 900px) {
  .kanban {
    display: flex;
    gap: var(--sp-4);
    overflow-x: auto;
    padding-bottom: var(--sp-3);
  }
  .kanban-col { min-width: 280px; width: 280px; flex-shrink: 0; }
}
.kanban-col {
  background: var(--bg-alt);
  border-radius: var(--radius-lg);
  padding: var(--sp-4);
  display: flex; flex-direction: column;
  max-height: calc(100vh - 200px);
}
.kanban-col-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: var(--sp-4);
  padding-bottom: var(--sp-2);
}
.kanban-col-head .title {
  font-size: var(--eyebrow-size);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 500;
}
.kanban-col-head .count {
  font-size: var(--small-size);
  color: var(--ink-muted);
}
.kanban-cards { display: flex; flex-direction: column; gap: var(--sp-3); overflow-y: auto; flex: 1; padding-right: 2px; }
.kanban-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--sp-4);
  cursor: grab;
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.kanban-card:hover { border-color: var(--ink-faint); transform: translateY(-1px); }
.kanban-card.dragging { opacity: 0.5; transform: scale(0.98); }
.kanban-card .title { font-size: var(--body-size); font-weight: 500; margin-bottom: var(--sp-2); }
.kanban-card .client { font-size: var(--small-size); color: var(--ink-muted); }
.kanban-card .value { font-family: var(--font-serif); font-size: 1.25rem; margin-top: var(--sp-3); }
.kanban-col.drop-target { background: var(--line-soft); }

/* --- Calendar --- */
.cal {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.cal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--line);
}
.cal-head h3 { font-family: var(--font-serif); font-size: 1.5rem; font-style: italic; }
.cal-nav { display: flex; gap: var(--sp-2); }
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}
.cal-day-header {
  padding: var(--sp-3) var(--sp-2);
  text-align: center;
  font-size: var(--eyebrow-size);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-muted);
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line-soft);
}
.cal-day-header:last-child { border-right: 0; }
.cal-day {
  min-height: 100px;
  border-right: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  padding: var(--sp-2);
  background: var(--bg-elev);
  transition: background var(--dur-fast) var(--ease);
  cursor: pointer;
}
@media (max-width: 640px) { .cal-day { min-height: 70px; } }
.cal-day:hover { background: var(--bg-alt); }
.cal-day:nth-child(7n) { border-right: 0; }
.cal-day.other-month { background: var(--bg); color: var(--ink-faint); }
.cal-day.today .num { background: var(--ink); color: var(--bg); }
.cal-day .num {
  font-family: var(--font-serif);
  font-size: 1.125rem;
  width: 26px; height: 26px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: var(--sp-2);
}
.cal-event {
  display: block;
  font-size: 0.6875rem;
  padding: 2px 6px;
  margin-bottom: 2px;
  background: var(--ink);
  color: var(--bg);
  border-radius: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-event.completed { background: var(--success); }
.cal-event.canceled { background: var(--ink-faint); text-decoration: line-through; }

/* --- Detail drawer --- */
.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 100%;
  max-width: 520px;
  background: var(--bg);
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform var(--dur-slow) var(--ease-out);
  z-index: 850;
  overflow-y: auto;
  display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer-head {
  padding: var(--sp-5) var(--sp-6);
  border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center;
  position: sticky; top: 0; background: var(--bg);
  z-index: 1;
}
.drawer-head h2 { font-size: 1.5rem; }
.drawer-body { padding: var(--sp-6); flex: 1; }
.drawer-foot {
  padding: var(--sp-4) var(--sp-6);
  border-top: 1px solid var(--line);
  display: flex; justify-content: flex-end; gap: var(--sp-3);
}

/* --- Tabs --- */
.tabs { display: flex; gap: var(--sp-2); border-bottom: 1px solid var(--line); margin-bottom: var(--sp-5); }
.tab {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 2px solid transparent;
  font-size: var(--small-size);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-muted);
  cursor: pointer;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.tab.active { color: var(--ink); border-color: var(--ink); }
.tab:hover { color: var(--ink); }

/* --- Invoice preview --- */
.invoice-preview {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  padding: var(--sp-7);
  font-family: var(--font-sans);
  min-height: 600px;
}
.invoice-preview h1 { font-family: var(--font-serif); font-size: 3rem; margin-bottom: var(--sp-2); }
.invoice-preview .num-label { font-size: var(--eyebrow-size); color: var(--ink-muted); letter-spacing: 0.14em; text-transform: uppercase; }

/* Status dots */
.status-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: var(--sp-2);
  vertical-align: middle;
}
.status-draft    { background: var(--ink-faint); }
.status-sent     { background: var(--info); }
.status-paid     { background: var(--success); }
.status-overdue  { background: var(--danger); }
.status-partial  { background: var(--warn); }
.status-canceled { background: var(--ink-faint); }

/* AI panel */
.ai-panel {
  background: linear-gradient(135deg, var(--bg-alt) 0%, var(--bg) 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--sp-6);
}
.ai-panel .ai-label {
  font-size: var(--eyebrow-size);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: var(--sp-3);
  display: flex; align-items: center; gap: var(--sp-2);
}
.ai-panel .ai-content {
  white-space: pre-wrap;
  line-height: 1.7;
  font-size: var(--body-size);
}
.ai-mode-badge {
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  padding: 2px 8px;
  background: var(--ink);
  color: var(--bg);
  border-radius: 2px;
  text-transform: uppercase;
}

/* Chart */
.chart { height: 240px; }
.chart svg { width: 100%; height: 100%; }

/* Print (invoice pdf trigger fallback) */
@media print {
  .sidebar, .topbar, .drawer, .btn, .modal-backdrop { display: none !important; }
  .page-content { padding: 0; }
}

/* ============================================================================
   MOBILE FIXES & OVERFLOW PROTECTION
   ============================================================================ */
html, body { overflow-x: hidden; max-width: 100vw; }
.main-area { min-width: 0; max-width: 100vw; overflow-x: hidden; }
.page-content { max-width: 100%; overflow-x: hidden; }
.page-content iframe { max-width: 100%; }
.two-col > * { min-width: 0; max-width: 100%; }
.card iframe { width: 100%; max-width: 100%; }
.table { max-width: 100%; }

/* table overflow wrap helper */
.card.card-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

@media (max-width: 640px) {
  .page-head { flex-direction: column; align-items: stretch; gap: var(--sp-3); }
  .page-head .row { flex-wrap: wrap; gap: var(--sp-2); }
  .page-head h1 { font-size: 2.25rem; }

  .topbar { flex-wrap: nowrap; padding: 0 var(--sp-3); gap: var(--sp-2); height: auto; min-height: var(--topbar-h); }
  .topbar .page-title { font-size: 1.125rem; flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .global-search { display: none !important; }
  .topbar .actions { flex-shrink: 0; }

  .kpi-grid { grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
  .kpi { padding: var(--sp-4); }
  .kpi .kpi-value { font-size: 1.75rem; }

  .two-col { grid-template-columns: 1fr !important; gap: var(--sp-4); }
  .card { padding: var(--sp-4); }
  .form-row-2 { grid-template-columns: 1fr !important; }

  .table { font-size: 0.85rem; }
  .table th, .table td { padding: var(--sp-2) var(--sp-3); }
  .section-head { flex-wrap: wrap; gap: var(--sp-2); }
  .section-head h2 { font-size: 1.25rem; }

  iframe { height: 400px !important; }

  .drawer { max-width: 100vw; }
}

@media (max-width: 380px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .page-content { padding: var(--sp-4) var(--sp-3); }
}

/* ============ DRAWER Z-INDEX FIX (backdrop below drawer) ============ */
#drawer-container .modal-backdrop { z-index: 840; }
.drawer { z-index: 860; }

/* ============ SIDEBAR SCROLL FIX ============ */
@media (min-width: 901px) {
  .app {
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: 100vh;
    height: 100vh;
    max-height: 100vh;
  }
  .sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    max-height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
  }
  .main-area {
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
  }
  .topbar { position: sticky; top: 0; z-index: 100; }
  .sidebar::-webkit-scrollbar { width: 6px; }
  .sidebar::-webkit-scrollbar-thumb { background: rgba(250,248,245,0.15); border-radius: 3px; }
  .sidebar::-webkit-scrollbar-thumb:hover { background: rgba(250,248,245,0.3); }
}

/* ============ TOTALS BLOCK (used in offer detail) ============ */
.totals-block {
  margin-top: var(--sp-4);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  max-width: 360px;
  margin-left: auto;
}
.totals-block .grand { font-weight: 600; }

/* ============ MOBILE OPTIMIERUNG v13 ============ */

/* Modal: volle Breite auf kleinen Screens */
@media (max-width: 640px) {
  .modal { max-width: calc(100vw - 24px) !important; max-height: 90vh; margin: 5vh 12px; }
  .modal .modal-body { max-height: 70vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .modal .modal-foot { flex-wrap: wrap; gap: var(--sp-2); }
  .modal .modal-foot .row { flex-wrap: wrap; gap: var(--sp-2); }
  .modal .modal-foot .btn { flex: 1 0 auto; min-width: 100px; }

  /* Form-Grid auf mobile: 1 Spalte */
  .form-grid { grid-template-columns: 1fr !important; }
  .form-grid > .field[style*="grid-column"] { grid-column: 1 / -1 !important; }

  /* Buttons in page-head: kleiner und wrapping */
  .page-head .btn { font-size: 0.8rem; padding: 6px 10px; }

  /* Tabellen: horizontales Scrollen */
  .card-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .card-table-wrap .table { min-width: 600px; }

  /* Tabs: scrollbar statt wrap */
  .tabs { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; gap: 0; }
  .tabs .tab { flex-shrink: 0; white-space: nowrap; font-size: 0.85rem; padding: var(--sp-2) var(--sp-3); }

  /* Row-between: stacking auf sehr kleinen Screens */
  .card-flat .row-between { flex-wrap: wrap; gap: var(--sp-2); }

  /* Notifications dropdown: volle Breite */
  .notif-dropdown { width: calc(100vw - 24px) !important; right: -40px !important; }

  /* Offer items Grid im Create-Modal */
  div[style*="grid-template-columns: 1fr 80px 100px"] {
    grid-template-columns: 1fr !important;
    gap: var(--sp-2) !important;
  }

  /* Statistics Charts: kleinere Höhe */
  div[style*="height: 120px"] { height: 80px !important; }
  div[style*="height: 140px"] { height: 100px !important; }

  /* Global search overlay: mobilfreundlich */
  .gsearch-box { max-width: calc(100vw - 24px) !important; margin: 0 12px; border-radius: 12px; }
  .gsearch-input { font-size: 16px !important; } /* Prevents iOS zoom */
}

/* Kleine Tablets: 2-spaltig bleibt, aber enger */
@media (min-width: 641px) and (max-width: 900px) {
  .modal { max-width: 90vw; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: var(--sp-3); }
}

/* Touch targets: mindestens 44px */
@media (pointer: coarse) {
  .btn-sm { min-height: 36px; }
  .icon-btn { min-width: 36px; min-height: 36px; }
  .nav-link { min-height: 44px; display: flex; align-items: center; }
  .table td, .table th { padding: var(--sp-3); }
  .card-flat { padding: var(--sp-3); }
  input, select, textarea { min-height: 40px; font-size: 16px; } /* Prevents iOS zoom */
}

/* ============ SETUP WIZARD ============ */
.setup-wizard {
  max-width: 560px; margin: 0 auto; padding: var(--sp-6);
  min-height: 100vh; display: flex; flex-direction: column; justify-content: center;
}
.wizard-head { text-align: center; margin-bottom: var(--sp-6); }
.wizard-head h1 { font-family: var(--font-serif); font-size: clamp(2rem, 5vw, 3rem); margin-bottom: var(--sp-3); }
.wizard-head p { color: var(--ink-muted); font-family: var(--font-serif); font-style: italic; }
.wizard-steps { display: flex; gap: var(--sp-2); margin-bottom: var(--sp-5); justify-content: center; }
.wizard-step-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--line); transition: background 0.3s; }
.wizard-step-dot.active { background: var(--ink); }
.wizard-step-dot.done { background: var(--success); }
.wizard-card { background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--sp-6); }
.wizard-card h2 { font-family: var(--font-serif); font-size: 1.5rem; margin-bottom: var(--sp-2); }
.wizard-card .desc { color: var(--ink-muted); margin-bottom: var(--sp-5); font-size: var(--small-size); }
.wizard-foot { display: flex; justify-content: space-between; margin-top: var(--sp-5); }
.wizard-error { background: var(--danger-bg); color: var(--danger); padding: var(--sp-3); border-radius: var(--radius); margin-bottom: var(--sp-3); }

/* ============ DRUCK / PRINT ============ */
@media print {
  /* Verstecke Navigation, Topbar, Sidebar */
  .sidebar, .topbar, .pwa-install-banner, .notif-dropdown,
  .gsearch-overlay, .modal-backdrop, .drawer,
  .page-head .btn, .page-head .row > .btn,
  .nav-link, .nav-group, #quick-new-btn { display: none !important; }

  /* App-Layout: volle Breite */
  .app { display: block !important; }
  .main-area { margin: 0 !important; padding: 0 !important; height: auto !important; overflow: visible !important; }
  .page-content { padding: 0 !important; }

  /* Karten: kein Schatten, dünner Rand */
  .card { box-shadow: none !important; border: 1px solid #ddd !important; break-inside: avoid; }
  .card-flat { box-shadow: none !important; }

  /* Tabellen: lesbar */
  .table { width: 100% !important; min-width: 0 !important; font-size: 11px !important; }
  .table th, .table td { padding: 4px 8px !important; border: 1px solid #ddd !important; }

  /* KPIs: inline, kompakter */
  .kpi-grid { display: flex !important; flex-wrap: wrap !important; gap: 12px !important; }
  .kpi { border: 1px solid #ddd !important; padding: 8px 12px !important; flex: 1 1 120px !important; }

  /* Badges: Outline statt Farbe */
  .badge { border: 1px solid currentColor !important; background: transparent !important; }

  /* Font: schwarz auf weiß */
  body, .app, .main-area, .page-content { background: white !important; color: black !important; }
  * { color: black !important; }

  /* Links: URL anzeigen */
  a[href]:after { content: " (" attr(href) ")"; font-size: 9px; color: #666 !important; }
  a.btn:after, a.nav-link:after, a.back-link:after { content: none !important; }

  /* Seitenumbruch */
  .page-head { break-after: avoid; }
  .two-col { display: block !important; }
  .two-col > * { break-inside: avoid; margin-bottom: 16px; }

  /* Statistik-Charts: nicht drucken (sind CSS-basiert, sehen im Druck kaputt aus) */
  .kpi-grid + .two-col div[style*="height: 120px"],
  .kpi-grid + .two-col div[style*="height: 140px"] { display: none !important; }
}

/* ============ INLINE HELP ============ */
.help-tip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--bg-alt); color: var(--ink-muted);
  font-size: 11px; font-weight: 600; cursor: help;
  border: 1px solid var(--line); flex-shrink: 0;
  position: relative;
}
.help-tip:hover { background: var(--ink); color: var(--bg); }
.help-tip .help-text {
  display: none; position: absolute; bottom: calc(100% + 8px); left: 50%;
  transform: translateX(-50%); width: 260px; max-width: 80vw;
  background: var(--ink); color: var(--bg); padding: 10px 14px;
  border-radius: 8px; font-size: 12px; font-weight: 400; line-height: 1.5;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15); z-index: 200;
  pointer-events: none; text-align: left;
}
.help-tip .help-text::after {
  content: ''; position: absolute; top: 100%; left: 50%;
  transform: translateX(-50%); border: 6px solid transparent;
  border-top-color: var(--ink);
}
.help-tip:hover .help-text { display: block; }
@media (max-width: 640px) {
  .help-tip .help-text { width: 220px; left: auto; right: -10px; transform: none; }
  .help-tip .help-text::after { left: auto; right: 14px; }
}

/* ============ MOBILE: Horizontal-Scroll-Fix v25 ============ */
@media (max-width: 640px) {
  /* Page head: buttons wrappen */
  .page-head { flex-direction: column !important; align-items: flex-start !important; gap: var(--sp-3) !important; }
  .page-head .row { flex-wrap: wrap !important; gap: var(--sp-2) !important; width: 100% !important; }
  .page-head .left { width: 100% !important; }

  /* Alle row-Elemente wrappen */
  .row { flex-wrap: wrap !important; }

  /* Body + HTML: absolut kein horizontales Scrollen */
  html, body, .app, .main-area, .page-content, #page-content {
    max-width: 100vw !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
  }

  /* KPI-Grid: 2 statt 4 Spalten */
  .kpi-grid { grid-template-columns: repeat(2, 1fr) !important; gap: var(--sp-3) !important; }

  /* Two-col: single column */
  .two-col { grid-template-columns: 1fr !important; }

  /* Drawer: volle Breite */
  .drawer { width: 100vw !important; max-width: 100vw !important; }

  /* Cards: kein Overflow */
  .card, .card-flat { max-width: 100% !important; box-sizing: border-box !important; overflow-wrap: break-word !important; word-break: break-word !important; }

  /* Mono/code: umbrechen statt overflow */
  .mono, code, pre { word-break: break-all !important; overflow-wrap: break-word !important; }

  /* Stack-LG spacing reduzieren */
  .stack-lg { gap: var(--sp-4) !important; }
}
