/* ============================================================
   polish.css — Visuelle Politur (additiv, lädt zuletzt)
   ------------------------------------------------------------
   Fokus-States, Hover/Active-Mikrointeraktionen, Nav-Akzent,
   Scrollbar, Empty-States, Dark-Mode-Feinschliff, Tenant-Akzent.
   ============================================================ */

/* ── Lesbarkeit ─────────────────────────────────────────── */
body { font-size: 15px; line-height: 1.55; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
/* Sehr kleine Texte anheben (Mindestlesbarkeit ~12px) */
.de-num, .de-meta, .tv-card-meta, .al-meta, .rem-sub, .cp-sub, .ph-meta,
.an-sub, .an-k, .cd-act-meta, .sl-muted, .bk-hint, .en-ob-to {
  font-size: 12px !important;
}
.nav-section-label { font-size: 11.5px; }
/* Muted-Kontrast leicht erhöhen */
:root { --text-3: oklch(45% 0.012 256); }
[data-theme="dark"] { --text-3: oklch(70% 0.02 256); }
/* Eingaben gut lesbar */
.form-input, input, select, textarea { font-size: 14px; }

/* ── Konsistente Fokus-Sichtbarkeit (A11y) ──────────────── */
*:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}
.nav-item:focus-visible,
.btn:focus-visible { outline-offset: 1px; }

/* ── Sidebar-Brand: dezenter Mandanten-Akzent ───────────── */
.app-brand {
  position: relative;
}
.app-brand::after {
  content: "";
  position: absolute; left: var(--space-2); right: var(--space-2); bottom: -1px; height: 2px;
  background: linear-gradient(90deg, var(--brand), transparent 80%);
  opacity: .5; border-radius: 2px;
}

/* ── Sidebar-Lesbarkeit (überschreibt EAP-Dark-Sidebar-Annahme) ── */
.app-sidebar .nav-item { color: var(--text-2); }
.app-sidebar .nav-item:hover { background: var(--surface-2); color: var(--text); }
.app-sidebar .nav-item.active { background: color-mix(in srgb, var(--brand) 12%, transparent); color: var(--brand); }
.app-sidebar .nav-item .nav-ico { opacity: 1; }
.app-sidebar .nav-section-label { color: var(--text-3); }
.app-brand-name { color: var(--text); }
.app-brand-tag { color: var(--text-3); }

/* ── Aktiver Nav-Eintrag: Akzent-Leiste + Press ─────────── */
.nav-item { position: relative; transition: background var(--duration-fast), color var(--duration-fast), transform .08s; }
.nav-item:active { transform: scale(.985); }
.nav-item.active::before {
  content: "";
  position: absolute; left: -4px; top: 18%; bottom: 18%; width: 3px;
  background: var(--brand); border-radius: 3px;
}

/* ── Buttons: Press-Mikrointeraktion ────────────────────── */
.btn { transition: transform .1s var(--ease-out-expo), box-shadow var(--duration-fast), background var(--duration-fast), border-color var(--duration-fast); }
.btn:active { transform: translateY(0) scale(.97); }
.btn-primary { box-shadow: 0 1px 0 color-mix(in srgb, var(--brand) 40%, transparent); }
.btn-primary:hover { box-shadow: 0 4px 14px color-mix(in srgb, var(--brand) 35%, transparent); }

/* ── Klickbare Karten: einheitliches Lift ───────────────── */
.de-card, .ph-card, .tv-card, .cd-proj { transition: transform .14s var(--ease-out-expo), box-shadow .14s, border-color .14s; }
.kanban-card:hover, .sh-princ-card:hover { border-color: color-mix(in srgb, var(--brand) 45%, var(--border)); }

/* ── View-Wechsel: weicher Übergang ─────────────────────── */
.view:not(.hidden) { animation: viewIn .28s var(--ease-out-expo) both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ── Dezente Custom-Scrollbar ───────────────────────────── */
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: padding-box; }

/* ── Einheitliche Empty-States ──────────────────────────── */
.de-empty, .ph-empty, .tv-empty, .cd-empty, .an-empty {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}

/* ── Tabellen-Hover ─────────────────────────────────────── */
tbody tr { transition: background var(--duration-fast); }

/* ── Topbar: leichte Tiefe ──────────────────────────────── */
.app-topbar { backdrop-filter: saturate(1.1); }

/* ── Dark-Mode-Feinschliff ──────────────────────────────── */
[data-theme="dark"] .app-brand-logo,
[data-theme="dark"] .app-topbar { box-shadow: 0 1px 0 rgba(255, 255, 255, .03); }
[data-theme="dark"] .btn-primary:hover { box-shadow: 0 4px 18px color-mix(in srgb, var(--brand) 50%, transparent); }
[data-theme="dark"] *::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--border) 80%, #fff 6%); background-clip: padding-box; }

/* ── Toast: Eintritt etwas lebendiger ───────────────────── */
.toast-item { box-shadow: 0 8px 28px rgba(15, 23, 42, .22); }

@media (prefers-reduced-motion: reduce) {
  .view:not(.hidden) { animation: none; }
}

/* ============================================================
   MOBILE — voll funktionsfähige Mini-Version (≤ 640px)
   ============================================================ */
@media (max-width: 640px) {
  /* Topbar darf umbrechen, damit keine Bedienelemente abgeschnitten werden */
  .app-topbar { flex-wrap: wrap; padding: 10px 12px; gap: 8px; row-gap: 8px; position: sticky; top: 0; }
  .app-topbar .topbar-title { order: 0; font-size: 15px; flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .app-topbar .sidebar-toggle { order: -1; }
  .app-topbar .header-actions { order: 2; width: 100%; flex-wrap: wrap; justify-content: flex-start; gap: 6px; }

  /* Bedienelemente kompakter, alle bleiben erreichbar */
  .off-wrap { order: 1; }
  .off-pill, .lang-btn, .rem-btn, .off-install { font-size: 11px; }
  .lang-btn { padding: 5px 9px; }
  .header-actions .btn-sm { padding: 6px 9px; }

  /* Inhalt */
  .app-content { padding: 14px 12px 64px; }

  /* Layouts auf eine Spalte */
  .de-grid3, .de-grid2, .de-two, .cd-cols, .al-grid2,
  .form-row-3, .form-row-2, .an-kpis, .an-grid,
  .ph-list, .de-list, .tv-cols { grid-template-columns: 1fr !important; }
  .de-totals, .cd-kpis { max-width: none; }

  /* Modals: nahezu vollflächig, weniger Rand */
  .modal-overlay { padding: 8px; align-items: flex-start; }
  .modal, .modal.wide { max-width: 100% !important; padding: 18px 16px; border-radius: 14px; max-height: 94vh; }
  .modal-title { font-size: 17px; }

  /* Tabellen horizontal scrollbar statt Überlauf */
  .de-items, .card { overflow-x: auto; }

  /* Overlays/Panels an den Viewport anpassen */
  .cp-overlay { padding-top: 8vh; }
  .cp-box { width: 94vw; }
  .rem-panel { position: fixed; left: 8px; right: 8px; top: auto; width: auto; max-width: none; }

  /* Touch-Targets vergrößern */
  .nav-item { padding: 13px 12px; }
  .btn { min-height: 40px; }
  .de-i, .form-input, input, select, textarea { font-size: 16px; } /* verhindert iOS-Zoom */

  /* Offline-Banner über der unteren Kante, nicht überdeckend */
  .off-banner { font-size: 12px; padding: 8px 12px; }
}

/* Sehr schmale Geräte */
@media (max-width: 380px) {
  .app-topbar .topbar-title { display: none; }
  .lang-btn { padding: 5px 7px; }
}

/* ============================================================
   AWARD POLISH — Africa-first
   ------------------------------------------------------------
   Letzte Handwerks-Schicht: premium Tiefe, finanztaugliche
   Typografie und Ergonomie für den ersten Einsatz in Afrika.
   Leitgedanken:
   • Sonnenlicht-Lesbarkeit (hoher Kontrast, klare Hierarchie)
   • Mobile-first & touch (große Ziele, taktiles Feedback)
   • Performance (CSS-only, 0 Webfonts → schnell bei wenig Bandbreite)
   • Warme, premium Identität ohne Klischee (Mandanten-Akzent)
   ============================================================ */

/* Native Controls (Scrollbars, Date-Picker) folgen dem Theme */
:root { color-scheme: light; }
[data-theme="dark"] { color-scheme: dark; }

/* ── Apple-/SF-Style Vektor-Icons — gestochen scharf bei jeder DPI/Zoom ──
      Vektor statt Emoji: konsistent über alle Plattformen, kein Bitmap-Blur. */
.nav-ico { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; }
.nav-ico svg,
.icon-btn svg {
  display: block; fill: none; stroke: currentColor;
  stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
  shape-rendering: geometricPrecision;
}
.nav-ico svg { width: 20px; height: 20px; }
.nav-item.active .nav-ico svg { stroke-width: 1.95; }
.icon-btn { padding: 8px; line-height: 0; }
.icon-btn svg { width: 18px; height: 18px; stroke-width: 1.85; }
.app-topbar .icon-btn:hover svg { stroke: var(--brand); }

/* Inline-Icons (window.Icon) — saubere optische Ausrichtung im Text/Button */
.ico { flex-shrink: 0; }
:where(h1,h2,h3,h4,span,div,label) > .ico { vertical-align: -.16em; }
.btn > .ico:first-child { margin-right: 1px; }
/* Icon+Text-Buttons/Chips sauber zentrieren (gemischte Module) */
.mdm-tab, .sh-vw, .sh-filter-btn, .sh-save-view, .sh-reset-btn, .sh-sync-badge,
.de-grouptog, .sh-bulk-act, .ph-tab, .de-chip, .set-tenant-btn {
  display: inline-flex; align-items: center; gap: 6px;
}
.sh-search-ic { display: inline-flex; align-items: center; }

/* ── Sunlit Atmosphere — dezente, mandanten-getönte Wärme im Canvas.
      Liegt hinter dem Inhalt (z-index:-1), kostet keine Scroll-Repaints. ── */
body::before {
  content: "";
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(1100px 620px at 100% -8%, color-mix(in srgb, var(--brand) 9%, transparent), transparent 62%),
    radial-gradient(820px 520px at -6% 4%, color-mix(in srgb, var(--accent, var(--brand)) 7%, transparent), transparent 56%);
}
[data-theme="dark"] body::before {
  background:
    radial-gradient(1100px 620px at 100% -8%, color-mix(in srgb, var(--brand) 16%, transparent), transparent 60%),
    radial-gradient(820px 520px at -6% 4%, color-mix(in srgb, var(--accent, var(--brand)) 10%, transparent), transparent 55%);
}

/* ── Finanz-Typografie: tabellarische Ziffern, damit Zahlen/Beträge
      sauber untereinander stehen (Kennzeichen polierter B2B-Software). ── */
.ph-kpi-val, .ph-pstats strong, .ph-tabn, .ph-chipn,
.tb-kpi-val, .set-kv strong, .de-totals, .de-line,
.kc-val, .sh-kpi-val, .an-k, .an-val, .cd-kpi-val {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* ── Brand-getönte Textauswahl ── */
::selection { background: color-mix(in srgb, var(--brand) 24%, transparent); }

/* ── Sidebar: ruhige Tiefe + taktile Navigation ── */
.app-sidebar {
  background:
    linear-gradient(180deg, var(--surface), color-mix(in srgb, var(--surface) 88%, var(--surface-2)));
}
.app-brand-logo { box-shadow: 0 6px 16px color-mix(in srgb, var(--brand) 32%, transparent); }
.nav-item:hover { transform: translateX(2px); }
.nav-item.active { font-weight: 700; }
.nav-item.active::before { box-shadow: 0 0 12px color-mix(in srgb, var(--brand) 55%, transparent); }

/* ── Topbar: klare Trennung beim Scrollen, leichte Glas-Tiefe ── */
.app-topbar {
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: saturate(1.3) blur(10px);
  -webkit-backdrop-filter: saturate(1.3) blur(10px);
}

/* ── Primär-Buttons: feiner Top-Sheen für Dimensionalität (tenant-treu) ── */
.btn-primary {
  background-image: linear-gradient(180deg, color-mix(in srgb, #fff 16%, transparent), transparent 70%);
}

/* ── Karten: einheitliches Lift auch für die neuen Views ── */
.set-card, .ph-pcard, .ph-kpi { transition: transform .14s var(--ease-out-expo), box-shadow .14s var(--ease-out-expo), border-color .14s; }
.ph-kpi:hover, .set-card:hover { box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--brand) 22%, var(--border)); }

/* KPI-Icon-Chip leicht mandanten-getönt */
.ph-kpi-ico { background: color-mix(in srgb, var(--brand) 9%, var(--surface-2)); }

/* ── Kontrast-Feinschliff für Sonnenlicht (helles Theme) ── */
:root { --text-2: oklch(38% 0.012 256); }
/* Dark Mode: dunkler --text-2-Wert würde sonst von :root oben geerbt
   und macht die inaktiven Sidebar-Labels unlesbar (1.7:1). Anheben auf AA. */
[data-theme="dark"] { --text-2: oklch(76% 0.02 256); }

/* ── Africa-first Ergonomie: großzügige Touch-Ziele auf Mobilgeräten ── */
@media (max-width: 640px) {
  .btn { min-height: 44px; }
  .btn-sm { min-height: 38px; }
  .ph-tab, .sh-tab, .set-seg-btn { min-height: 42px; }
  .ph-pactions .btn { flex: 1; }
  .ph-kpis { grid-template-columns: 1fr 1fr; }
}

/* ── Atmosphäre auf großen Screens etwas weiter ziehen ── */
@media (min-width: 1400px) {
  .app-content { padding-left: clamp(24px, 3vw, 56px); padding-right: clamp(24px, 3vw, 56px); }
}
