/* =====================================================================
   AbiKarten · Finance Overview — Styles
   Dunkles, ruhiges internes Cockpit. Farbe nur als Semantik:
   Grün = Einnahmen/Profit, Rot = Ausgaben. Sonst Hairlines und Ruhe.
   ===================================================================== */

:root {
  /* Fläche — fast schwarz mit leicht bläulichem Unterton (Marken-Echo) */
  --bg:        oklch(15.5% 0.012 262);
  --bg-raise:  oklch(18.5% 0.014 262);
  --surface:   oklch(20.5% 0.015 262);

  /* Text */
  --ink:       oklch(93% 0.008 255);
  --muted:     oklch(69% 0.015 258);
  --faint:     oklch(60% 0.015 258);

  /* Linien */
  --line:      oklch(80% 0.02 262 / 0.10);
  --line-strong: oklch(80% 0.02 262 / 0.18);

  /* Semantik */
  --pos:       oklch(77% 0.115 155);
  --pos-soft:  oklch(77% 0.115 155 / 0.12);
  --neg:       oklch(69% 0.105 22);
  --neg-soft:  oklch(69% 0.105 22 / 0.12);

  /* Geometrie & Motion */
  --r-sm: 8px;
  --r-md: 14px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);   /* kräftiges Ease-out */
  --t-fast: 150ms;
  --t-med: 200ms;

  /* Z-Skala */
  --z-backdrop: 40;
  --z-panel: 50;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI",
               system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Zahlen immer mit Tabular Figures */
.num { font-variant-numeric: tabular-nums; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-align: inherit;
}

:focus-visible {
  outline: 2px solid oklch(70% 0.06 262 / 0.8);
  outline-offset: 3px;
  border-radius: var(--r-sm);
}

/* ------------------------------------------------------------------ */
/* Kopfzeile                                                           */
/* ------------------------------------------------------------------ */

.top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
  padding: 28px clamp(20px, 5vw, 56px) 0;
}

.top p { margin: 0; }

.top-brand {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--muted);
}

.top-sep { color: var(--faint); margin: 0 2px; }

.top-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--faint);
}

.badge-demo {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 2px 9px;
}

/* ------------------------------------------------------------------ */
/* Bühne                                                               */
/* ------------------------------------------------------------------ */

.stage {
  flex: 1;
  width: min(920px, 100%);
  margin: 0 auto;
  padding: clamp(40px, 9vh, 96px) clamp(20px, 5vw, 56px) 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Profit — die eine große Zahl */

.profit {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 28px 16px;
  border-radius: var(--r-md);
  transition: background-color var(--t-fast) var(--ease),
              transform var(--t-fast) var(--ease);
}

.profit:hover { background: var(--bg-raise); }
.profit:active { transform: scale(0.99); }

.profit-label {
  font-size: 14px;
  color: var(--muted);
}

.profit-value {
  font-size: clamp(3.25rem, 10vw, 5.25rem);
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.05;
  color: var(--pos);
}

.profit-value.is-neg { color: var(--neg); }

.profit-sub {
  font-size: 13px;
  color: var(--faint);
  text-align: center;
}
.profit-sub .pos { color: var(--pos); }
.profit-sub .neg { color: var(--neg); }

/* Entwicklungskurve — bewusst dezent */

.trend {
  width: min(560px, 100%);
  margin: clamp(28px, 5vh, 44px) 0 0;
}

.trend svg {
  display: block;
  width: 100%;
  height: 64px;
  overflow: visible;
}

.trend-caption {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--faint);
}

/* Kennzahlen */

.kpis {
  width: 100%;
  margin-top: clamp(40px, 8vh, 72px);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.kpi {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 20px 22px 18px;
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  transition: border-color var(--t-fast) var(--ease),
              background-color var(--t-fast) var(--ease),
              transform var(--t-fast) var(--ease);
}

.kpi:hover {
  border-color: var(--line-strong);
  background: var(--surface);
}

.kpi:active { transform: scale(0.985); }

.kpi-label {
  font-size: 13px;
  color: var(--muted);
}

.kpi-value {
  font-size: 26px;
  font-weight: 620;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.kpi-value.pos { color: var(--pos); }
.kpi-value.neg { color: var(--neg); }

.kpi-sub {
  font-size: 12.5px;
  color: var(--faint);
}

/* ------------------------------------------------------------------ */
/* Fußzeile                                                            */
/* ------------------------------------------------------------------ */

.foot {
  padding: 0 clamp(20px, 5vw, 56px) 24px;
}

.foot p {
  margin: 0;
  font-size: 12px;
  color: var(--faint);
}

.foot code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
  color: var(--muted);
}

/* ------------------------------------------------------------------ */
/* Detail-Panel                                                        */
/* ------------------------------------------------------------------ */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-backdrop);
  background: oklch(10% 0.01 262 / 0.55);
  opacity: 0;
  transition: opacity var(--t-fast) var(--ease);
}

.backdrop.open { opacity: 1; }

.panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-panel);
  width: min(440px, 100%);
  display: flex;
  flex-direction: column;
  background: var(--bg-raise);
  border-left: 1px solid var(--line);
  transform: translateX(100%);
  transition: transform var(--t-med) var(--ease);
}

.panel.open { transform: translateX(0); }

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 24px 24px 16px;
}

.panel-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.005em;
}

.panel-sum {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--muted);
}
.panel-sum .pos { color: var(--pos); }
.panel-sum .neg { color: var(--neg); }

.panel-close {
  flex: none;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  color: var(--muted);
  transition: background-color var(--t-fast) var(--ease),
              color var(--t-fast) var(--ease);
}

.panel-close:hover { background: var(--surface); color: var(--ink); }
.panel-close:active { transform: scale(0.94); }

/* Filter-Chips */

.panel-filters {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 24px 14px;
  border-bottom: 1px solid var(--line);
}

.panel-filters:empty { display: none; }

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 11px;
  transition: border-color var(--t-fast) var(--ease),
              color var(--t-fast) var(--ease),
              background-color var(--t-fast) var(--ease);
}

.chip:hover { border-color: var(--line-strong); color: var(--ink); }

.chip[aria-pressed="true"] {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--line-strong);
}

/* Positionsliste */

.panel-list {
  flex: 1;
  overflow-y: auto;
  margin: 0;
  padding: 8px 12px 20px;
  list-style: none;
}

.row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 11px 12px;
  border-radius: var(--r-sm);
}

.row + .row { border-top: 1px solid var(--line); }

.row-main { min-width: 0; }

.row-name {
  display: block;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12px;
  color: var(--faint);
  margin-top: 2px;
}

.row-amount {
  flex: none;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}
.row-amount.pos { color: var(--pos); }
.row-amount.neg { color: var(--neg); }
.row-amount.plain { color: var(--ink); }

.row-note { font-size: 11.5px; color: var(--faint); text-align: right; }

.tag {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 1px 7px;
}

.empty {
  padding: 32px 12px;
  font-size: 13px;
  color: var(--faint);
  text-align: center;
}

/* ------------------------------------------------------------------ */
/* Responsive                                                          */
/* ------------------------------------------------------------------ */

@media (max-width: 680px) {
  .stage { padding-top: clamp(28px, 6vh, 48px); }
  .kpis { grid-template-columns: 1fr; }
  .panel { width: 100%; border-left: 0; }
}

/* ------------------------------------------------------------------ */
/* Reduzierte Bewegung                                                 */
/* ------------------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
  .profit:active, .kpi:active, .panel-close:active { transform: none; }
}
