/* ─── S5-8/S5-9 Design tokens — light default ────────────────────────────────── */
:root {
  --color-bg:               #f0f4f2;
  --color-surface:          #ffffff;
  --color-surface-elevated: #f7f9f8;
  --color-surface-input:    #ffffff;

  --color-border:           rgba(0, 80, 70, 0.20);
  --color-border-strong:    rgba(0, 80, 70, 0.35);

  --color-text-primary:     #111c1a;
  --color-text-secondary:   #2a3d38;
  --color-text-muted:       #5a7069;

  --color-accent:           #9a5f00; /* WCAG AA fix: #c47d00 csak 3.0:1 volt #f0f4f2-n; #9a5f00 ~4.6:1 */
  --color-accent-hover:     #7d4d00;
  --color-accent-2:         #007a6e;
  --color-accent-2-hover:   #005f56;

  --color-success:          #007a6e;
  --color-warning:          #c47d00;
  --color-danger:           #c0001a;

  --color-kpi-good:         #007a6e;
  --color-kpi-bad:          #c0001a;

  --color-chart-grid:       rgba(0, 0, 0, 0.08);
  --color-chart-tick:       #5a7069;

  /* Legacy extras (not in spec table but used in app) */
  --color-bg-alt:           #e8f0ec;
  --color-tooltip-bg:       var(--color-surface-elevated);
  --color-tooltip-border:   rgba(0, 122, 110, 0.45);
  --color-tooltip-text:     var(--color-text-secondary);
  --color-tooltip-muted:    var(--color-text-muted);

  /* S5-3: Forecast CI band — light mode */
  --color-ci-band:          rgba(0, 122, 110, 0.12);
  --color-ci-band-border:   rgba(0, 122, 110, 0.0); /* CI sáv szegélyt jelenleg nem használunk, transparent fallback */

  /* ─── S7-6: Chart adatpaletta (csoportok) — light mode ─────────────────── */
  /* WCAG AA: mind az 5 szín 4.5:1+ kontraszt arányt teljesít #f0f4f2 háttéren */
  --color-data-1:           #007a6e;   /* teal     — accent-2 alias */
  --color-data-2:           #a06500;   /* amber (darken: WCAG AA 5.32:1 on #f0f4f2) */
  --color-data-3:           #5a41c0;   /* indigo                   */
  --color-data-4:           #b5344a;   /* crimson                  */
  --color-data-5:           #2e7d32;   /* forest                   */

  /* ─── S7-6: Chip multi-select tokenek ──────────────────────────────────── */
  --chip-bg-inactive:       var(--color-surface-elevated);
  --chip-bg-active:         color-mix(in srgb, var(--color-accent-2) 18%, var(--color-surface));
  --chip-border-inactive:   var(--color-border);
  --chip-border-active:     var(--color-accent-2);
  --chip-text-inactive:     var(--color-text-secondary);
  --chip-text-active:       var(--color-accent-2);

  /* ─── S7-6: Modal tokenek ──────────────────────────────────────────────── */
  --modal-backdrop-bg:      rgba(0, 0, 0, 0.55);
  --modal-box-max-width:    600px;
  --modal-box-radius:       16px;
}

/* ─── Explicit dark theme ───────────────────────────────────────────────────── */
[data-theme="dark"] {
  --color-bg:               #0b1513;
  --color-surface:          #0b201d;
  --color-surface-elevated: #0b0f10;
  --color-surface-input:    #060f0d;

  --color-border:           rgba(125, 226, 209, 0.25);
  --color-border-strong:    rgba(125, 226, 209, 0.20);

  --color-text-primary:     #f7f7ee;
  --color-text-secondary:   #e9f2ef;
  --color-text-muted:       #b7c3bf;

  --color-accent:           #f4b942;
  --color-accent-hover:     #ffc95a;
  --color-accent-2:         #7de2d1;
  --color-accent-2-hover:   #9df0e3;

  --color-success:          #7de2d1;
  --color-warning:          #f4b942;
  --color-danger:           #ff8f8f;

  --color-kpi-good:         #7de2d1;
  --color-kpi-bad:          #ff8f8f;

  --color-chart-grid:       rgba(255, 255, 255, 0.06);
  --color-chart-tick:       #b7c3bf;

  /* Legacy extras */
  --color-bg-alt:           #102523;
  --color-tooltip-bg:       var(--color-surface-elevated);
  --color-tooltip-border:   rgba(125, 226, 209, 0.45);
  --color-tooltip-text:     var(--color-text-secondary);
  --color-tooltip-muted:    var(--color-text-muted);

  /* S5-3: Forecast CI band — dark mode */
  --color-ci-band:          rgba(125, 226, 209, 0.10);
  --color-ci-band-border:   rgba(125, 226, 209, 0.0); /* CI sáv szegélyt jelenleg nem használunk, transparent fallback */

  /* ─── S7-6: Chart adatpaletta — dark mode (10:1+ kontraszt #0b1513 háttéren) */
  --color-data-1:           #7de2d1;   /* teal light  */
  --color-data-2:           #f4b942;   /* amber light */
  --color-data-3:           #a78bfa;   /* indigo light */
  --color-data-4:           #ff8f8f;   /* rose light  */
  --color-data-5:           #86efac;   /* sage light  */

  /* ─── S7-6: Chip dark mode ──────────────────────────────────────────────── */
  --chip-bg-inactive:       #1d2a27;
  --chip-bg-active:         color-mix(in srgb, var(--color-accent-2) 22%, var(--color-surface));
  --chip-border-inactive:   #2f3f3a;
  --chip-border-active:     var(--color-accent-2);
  --chip-text-inactive:     #b7c3bf;
  --chip-text-active:       var(--color-accent-2);

  /* ─── S7-6: Modal dark mode ─────────────────────────────────────────────── */
  --modal-backdrop-bg:      rgba(0, 0, 0, 0.75);
}

/* ─── OS-level dark fallback (no explicit [data-theme]) ─────────────────────── */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --color-bg:               #0b1513;
    --color-surface:          #0b201d;
    --color-surface-elevated: #0b0f10;
    --color-surface-input:    #060f0d;

    --color-border:           rgba(125, 226, 209, 0.25);
    --color-border-strong:    rgba(125, 226, 209, 0.20);

    --color-text-primary:     #f7f7ee;
    --color-text-secondary:   #e9f2ef;
    --color-text-muted:       #b7c3bf;

    --color-accent:           #f4b942;
    --color-accent-hover:     #ffc95a;
    --color-accent-2:         #7de2d1;
    --color-accent-2-hover:   #9df0e3;

    --color-success:          #7de2d1;
    --color-warning:          #f4b942;
    --color-danger:           #ff8f8f;

    --color-kpi-good:         #7de2d1;
    --color-kpi-bad:          #ff8f8f;

    --color-chart-grid:       rgba(255, 255, 255, 0.06);
    --color-chart-tick:       #b7c3bf;

    /* Legacy extras */
    --color-bg-alt:           #102523;
    --color-tooltip-bg:       var(--color-surface-elevated);
    --color-tooltip-border:   rgba(125, 226, 209, 0.45);
    --color-tooltip-text:     var(--color-text-secondary);
    --color-tooltip-muted:    var(--color-text-muted);

    /* S5-3: Forecast CI band — OS dark fallback */
    --color-ci-band:          rgba(125, 226, 209, 0.10);
    --color-ci-band-border:   rgba(125, 226, 209, 0.0); /* CI sáv szegélyt jelenleg nem használunk, transparent fallback */

    /* ─── S7-6: Chart adatpaletta + chip — OS dark fallback ─────────────── */
    --color-data-1:           #7de2d1;
    --color-data-2:           #f4b942;
    --color-data-3:           #a78bfa;
    --color-data-4:           #ff8f8f;
    --color-data-5:           #86efac;
    --chip-bg-inactive:       #1d2a27;
    --chip-bg-active:         color-mix(in srgb, #7de2d1 22%, #0b201d);
    --chip-border-inactive:   #2f3f3a;
    --chip-border-active:     #7de2d1;
    --chip-text-inactive:     #b7c3bf;
    --chip-text-active:       #7de2d1;

    /* ─── S7-6: Modal — OS dark fallback ────────────────────────────────── */
    --modal-backdrop-bg:      rgba(0, 0, 0, 0.75);
  }
}

/* ─── Backward-compat alias tokens ──────────────────────────────────────────── */
:root,
[data-theme] {
  --bg-1:     var(--color-bg);
  --bg-2:     var(--color-bg-alt);
  --card:     var(--color-surface);
  --text:     var(--color-text-primary);
  --muted:    var(--color-text-muted);
  --border:   var(--color-border);
  --accent:   var(--color-accent);
  --accent-2: var(--color-accent-2);
  /* Old name aliases for incremental migration */
  --color-text:        var(--color-text-primary);
  --color-surface-alt: var(--color-surface-input);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--color-text);
  font-family: "Space Grotesk", sans-serif;
  overflow-x: hidden;
  transition: background 0.3s ease, color 0.3s ease;
}

/* ─── Light body background ─────────────────────────────────────────────────── */
:root body,
[data-theme="light"] body {
  background:
    radial-gradient(circle at 20% 10%, #c8e6e0 0%, transparent 35%),
    radial-gradient(circle at 90% 90%, #f5ddb0 0%, transparent 30%),
    linear-gradient(130deg, var(--color-bg), var(--color-bg-alt));
}

/* ─── Dark body background ──────────────────────────────────────────────────── */
[data-theme="dark"] body {
  background:
    radial-gradient(circle at 20% 10%, #1a3f39 0%, transparent 35%),
    radial-gradient(circle at 90% 90%, #402914 0%, transparent 30%),
    linear-gradient(130deg, var(--color-bg), var(--color-bg-alt));
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) body {
    background:
      radial-gradient(circle at 20% 10%, #1a3f39 0%, transparent 35%),
      radial-gradient(circle at 90% 90%, #402914 0%, transparent 30%),
      linear-gradient(130deg, var(--color-bg), var(--color-bg-alt));
  }
}

.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: repeating-radial-gradient(circle at 0 0, transparent 0, rgba(0, 0, 0, 0.02) 1px, transparent 2px);
}

[data-theme="dark"] .noise,
:root:not([data-theme]) .noise {
  background-image: repeating-radial-gradient(circle at 0 0, transparent 0, rgba(255, 255, 255, 0.02) 1px, transparent 2px);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .noise {
    background-image: repeating-radial-gradient(circle at 0 0, transparent 0, rgba(255, 255, 255, 0.02) 1px, transparent 2px);
  }
}

.app-shell {
  width: min(100%, 1920px);
  max-width: none;
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(20px, 2vw, 32px) clamp(14px, 2vw, 28px) 40px;
}

.hero {
  animation: slide-in 550ms ease-out both;
  margin-bottom: clamp(18px, 2vw, 28px);
  position: relative;
}

/* ─── Theme toggle button ───────────────────────────────────────────────────── */
.theme-toggle-btn {
  position: absolute;
  top: 0;
  right: 0;
  min-width: 44px;
  min-height: 44px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  color: var(--color-text);
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  z-index: 5;
}

.theme-toggle-btn:hover {
  transform: scale(1.08);
  background: var(--color-surface-alt);
  border-color: var(--color-accent-2);
}

.theme-toggle-btn:active {
  transform: scale(0.96);
}

/* ─── Fullscreen panel ──────────────────────────────────────────────────────── */
.panel.fullscreen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  border-radius: 0;
  overflow-y: auto;
  grid-column: unset !important;
}

.body-fullscreen {
  overflow: hidden;
}

/* ─── Fullscreen button ─────────────────────────────────────────────────────── */
.fullscreen-btn {
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 4px 8px;
  line-height: 1;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  flex-shrink: 0;
}

.fullscreen-btn:hover {
  color: var(--color-accent-2);
  border-color: var(--color-accent-2);
  background: color-mix(in srgb, var(--color-accent-2) 10%, transparent);
}

.fullscreen-btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.theme-toggle-btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* ─── S6-2 Export gomb ───────────────────────────────────────────────────────── */
.btn-export {
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  color: var(--color-text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  /* Touch-target ≥44×44px */
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.btn-export svg {
  display: block;
  width: 16px;
  height: 16px;
  pointer-events: none;
}

.btn-export:hover {
  color: var(--color-accent);
  border-color: var(--color-accent);
  background: color-mix(in srgb, var(--color-accent) 10%, transparent);
}

.btn-export:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.btn-export:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ─── S6-2 Export format menü ────────────────────────────────────────────────── */
.export-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 200;
  background: var(--color-surface-elevated);
  border: 1px solid var(--color-border-strong);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  min-width: 96px;
  overflow: hidden;
}

.export-menu-item {
  background: transparent;
  border: none;
  color: var(--color-text-secondary);
  cursor: pointer;
  font-size: 0.85rem;
  font-family: inherit;
  font-weight: 500;
  padding: 0.55rem 1.1rem;
  text-align: left;
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
}

.export-menu-item:hover {
  background: color-mix(in srgb, var(--color-accent) 12%, transparent);
  color: var(--color-accent);
}

.export-menu-item:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: -2px;
}

.panel-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  flex-shrink: 0;
}

/* ─── S5-10 panel size grid (infrastructure) ─────────────────────────────────
   Requires CSS Grid 12-col parent. Per-panel size toggles (S5-10) will use these.
   Backend model needed before enabling user persistence — see blocker note. */
.panel-size-s  { grid-column: span 3; }
.panel-size-m  { grid-column: span 4; }
.panel-size-l  { grid-column: span 6; }
.panel-size-xl { grid-column: span 12; }

.kicker {
  font-family: "IBM Plex Mono", monospace;
  letter-spacing: 0.18em;
  color: var(--color-accent-2);
  margin: 0;
  font-size: 12px;
}

h1 {
  margin: 8px 0 6px;
  font-size: clamp(2rem, 5vw, 3.5rem);
}

.subtitle {
  color: var(--color-text-muted);
  margin: 0;
  max-width: 760px;
}

.panel-grid {
  margin-top: 28px;
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: start;
}

.panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 14px;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  padding: 18px;
  animation: rise 600ms ease both;
  transition: box-shadow 200ms ease, background 0.3s ease, border-color 0.3s ease;
  min-width: 0;
}

.panel:hover {
  box-shadow: 0 4px 20px rgba(125, 226, 209, 0.07);
}

.auth-panel {
  max-width: 460px;
}

.auth-form {
  display: grid;
  gap: 10px;
}

.auth-form label {
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  color: var(--color-text-muted);
}

.auth-form input {
  width: 100%;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--color-surface-alt);
  color: var(--color-text);
}

.auth-form button,
.secondary {
  margin-top: 10px;
  border: 1px solid var(--color-accent-2);
  border-radius: 10px;
  background: linear-gradient(120deg, rgba(125, 226, 209, 0.25), rgba(244, 185, 66, 0.2));
  color: var(--color-text);
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
}

.secondary {
  width: 100%;
  margin-top: 6px;
}

.secondary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.hidden {
  display: none;
}

.panel:nth-child(2) { animation-delay: 80ms; }
.panel:nth-child(3) { animation-delay: 130ms; }
.panel:nth-child(4) { animation-delay: 180ms; }

.panel.wide {
  grid-column: 1 / -1;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Status dot */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-text-muted);
  flex-shrink: 0;
}
.status-dot.ok    { background: var(--color-success); box-shadow: 0 0 6px rgba(125, 226, 209, 0.7); animation: pulse-dot 2s ease infinite; }
.status-dot.warn  { background: var(--color-accent); box-shadow: 0 0 6px rgba(244, 185, 66, 0.7); animation: pulse-dot 1.5s ease infinite; }
.status-dot.error { background: var(--color-danger); box-shadow: 0 0 6px rgba(255, 143, 143, 0.7); }

/* Chart containers */
.chart-wrap {
  position: relative;
  min-height: 220px;
}

.donut-wrap {
  max-height: 240px;
}

/* Location split row */
.locations-row {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 20px;
  align-items: center;
}

/* Loading shimmer */
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
.loading-value {
  display: inline-block;
  width: 80px;
  height: 1.6rem;
  border-radius: 6px;
  background: linear-gradient(90deg, rgba(0,0,0,0.04) 25%, rgba(0,0,0,0.10) 50%, rgba(0,0,0,0.04) 75%);
  background-size: 400px 100%;
  animation: shimmer 1.2s ease infinite;
}

[data-theme="dark"] .loading-value,
:root:not([data-theme]) .loading-value {
  background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.1) 50%, rgba(255,255,255,0.04) 75%);
  background-size: 400px 100%;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .loading-value {
    background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.1) 50%, rgba(255,255,255,0.04) 75%);
    background-size: 400px 100%;
  }
}

.controls .control-row {
  display: grid;
  grid-template-columns: auto minmax(120px, 180px) auto minmax(220px, 1fr) auto minmax(150px, 180px) auto minmax(150px, 180px) auto;
  gap: 10px;
  align-items: center;
}

.controls label {
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  color: var(--color-text-muted);
}

.controls select,
.controls input,
.controls button {
  width: 100%;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--color-surface-alt);
  color: var(--color-text);
}

.controls button {
  border-color: var(--color-accent);
  background: linear-gradient(120deg, rgba(244, 185, 66, 0.2), rgba(125, 226, 209, 0.2));
  font-weight: 700;
  cursor: pointer;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.kpi-box {
  position: relative;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 16px 14px 14px;
  background: var(--color-surface-alt);
  overflow: hidden;
  transition: transform 150ms ease, box-shadow 150ms ease;
}

.kpi-box::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: linear-gradient(90deg, var(--color-accent-2), var(--color-accent));
  border-radius: 12px 12px 0 0;
}

.kpi-box:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(125, 226, 209, 0.1);
}

.kpi-box .kpi-label {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0 6px;
}

.kpi-box .value {
  margin: 0;
  font-size: clamp(0.95rem, 1vw + 0.25rem, 1.25rem);
  font-weight: 700;
  color: var(--color-accent);
  line-height: 1.2;
  white-space: nowrap;
  overflow: visible;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.kpi-box .value .kpi-unit {
  font-size: 0.75em;
  color: var(--color-text-muted);
  margin-left: 0.25em;
  font-weight: 500;
}
.kpi-box { padding: 14px 12px 12px; }

.delta {
  margin: 5px 0 0;
  font-size: 11px;
  font-family: "IBM Plex Mono", monospace;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.delta.positive { color: var(--color-kpi-good); }
.delta.negative { color: var(--color-kpi-bad); }

.value {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-text);
}

.meta {
  margin: 6px 0 0;
  color: var(--color-text-muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
}

.delta.info {
  color: var(--color-text-muted);
}

.visitor-ticket-breakdown {
  margin-top: 1rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: var(--color-surface-alt);
}

.visitor-ticket-breakdown-title {
  margin: 0 0 0.65rem;
  color: var(--color-text);
  font-size: 0.92rem;
  font-weight: 600;
}

.visitor-ticket-breakdown-total {
  margin-top: 0.75rem;
}

@keyframes slide-in {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

/* ─── Breakpoint referencia (S6-3 / S6-4) ───────────────────────────────────
   --bp-mobile:  480px   (≤480px  — mobile only, hamburger drawer)
   --bp-phablet: 767px   (481–767px — phablet, 2×2 KPI)
   --bp-tablet:  1023px  (768–1023px — tablet, 2 col panel-grid)
   --bp-desktop: 1024px  (≥1024px — desktop, jelenlegi 4 col)
   Minimum eszközméret: 375px (iPhone SE 2/3 baseline).
   ─────────────────────────────────────────────────────────────────────────── */

/* ─── Tablet (768–1023px): 2 oszlop panel-grid, 4 col KPI ──────────────── */
@media (max-width: 1023px) {
  .panel-grid,
  .tab-pane.panel-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .app-shell {
    width: 100%;
    padding-inline: 16px;
  }

  .controls .control-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kpi-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .locations-row {
    grid-template-columns: 1fr;
  }

  .data-table { font-size: 0.875rem; }
  .data-table th, .data-table td { padding: 9px 12px; }
}

/* ─── Phablet + Mobile (≤767px): 1 oszlop panel-grid, 2×2 KPI ──────────── */
@media (max-width: 767px) {
  .panel-grid,
  .tab-pane.panel-grid {
    grid-template-columns: 1fr;
  }

  .panel.wide {
    grid-column: auto;
  }

  .controls .control-row {
    grid-template-columns: 1fr;
  }

  .app-shell {
    padding-inline: 12px;
  }

  .tabs-nav {
    gap: 8px;
  }

  .tab-btn {
    flex: 1 1 calc(50% - 8px);
    text-align: center;
    bottom: 0;
    border-bottom: 1px solid var(--color-border);
    border-radius: 8px;
  }

  .tab-btn.active {
    border-bottom-color: var(--color-border);
  }

  .panel {
    padding: 14px;
  }

  .panel-header {
    align-items: flex-start;
  }

  .toggle-group {
    flex-wrap: wrap;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kpi-box .value,
  .value {
    font-size: 1.3rem;
    white-space: normal;
  }

  .data-table {
    font-size: 0.82rem;
  }

  .data-table th, .data-table td { padding: 8px 10px; }
  .data-table td.text-cell { max-width: 180px; }
}

/* ─── Mobile only (≤480px): 1 col, hamburger, fix chart height ──────────── */
@media (max-width: 480px) {
  .app-shell {
    padding-inline: 8px;
  }

  .panel {
    padding: 12px 10px;
    border-radius: 10px;
  }

  /* Panel size toggle (S/M/L/XL) mobilon nem értelmes — 1 col override */
  .panel-size-s,
  .panel-size-m,
  .panel-size-l,
  .panel-size-xl {
    grid-column: span 1 !important;
  }

  .panel-header {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  /* Toggle gombok (Mennyiség/Bevétel/Összes) — kisebb, wrappelhető */
  .toggle-btn {
    font-size: 0.72rem;
    padding: 0.35rem 0.6rem;
  }

  /* ─── KPI grid: 1 oszlop, delta jobb oldalon ────────────────────────── */
  .kpi-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .kpi-box {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    align-items: start;
    padding: 12px;
  }

  .kpi-box .kpi-label {
    grid-column: 1;
    grid-row: 1;
  }

  .kpi-box .value {
    grid-column: 1;
    grid-row: 2;
    font-size: 1.3rem;
    white-space: normal;
  }

  .kpi-box .delta {
    grid-column: 2;
    grid-row: 1 / 3;
    align-self: center;
    margin: 0;
    padding-left: 8px;
  }

  /* ─── Chart wrap: fix 280px magasság mobilon ─────────────────────────── */
  .chart-wrap {
    min-height: 280px !important;
    height: 280px;
    max-height: 280px;
  }

  /* Páros-chart (pairs-chart): kicsivel több hely kell a 15 terméknek */
  #panel-pairs .chart-wrap {
    height: 360px;
    max-height: 360px;
  }

  /* ─── WCAG 2.5.5: ≥44×44px touch targets ────────────────────────────── */
  .tab-btn {
    min-height: 44px;
    padding: 12px 16px;
  }

  .toggle-btn {
    min-height: 44px;
    padding: 10px 14px;
    font-size: 0.75rem;
  }

  .fullscreen-btn {
    min-width: 44px;
    min-height: 44px;
    padding: 10px;
    font-size: 1.1rem;
  }

  .auth-form button,
  .secondary {
    padding: 14px 16px;
    min-height: 44px;
  }

  .profile-toggle-item {
    padding: 14px 16px;
    min-height: 44px;
  }

  .controls select,
  .controls input,
  .controls button {
    padding: 12px 14px;
    min-height: 44px;
  }

  /* ─── Hamburger bekapcsolása, tabs-nav kikapcsolása ─────────────────── */
  .hamburger-btn {
    display: flex;
    position: absolute;
    top: 0;
    right: 56px; /* theme toggle (44px) + 12px rés */
  }

  .tabs-nav {
    display: none;
  }
}

/* Mobile: table horizontal scroll */
.data-table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

option {
  background: var(--color-surface-elevated);
  color: var(--color-text-primary);
}

/* ─── Profile toggle list: 1 col ≤767px ─────────────────────────────────────── */
@media (max-width: 767px) {
  .profile-toggle-list {
    grid-template-columns: 1fr;
  }
}

/* ─── Panel header with toggle controls ─────────────────────────────────────── */
.panel-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.panel-header h2 {
  margin: 0;
  flex: 1 1 auto;
}

.toggle-group {
  display: flex;
  gap: 0.375rem;
}

.toggle-btn {
  background: rgba(125, 226, 209, 0.1);
  border: 1px solid rgba(125, 226, 209, 0.35);
  color: var(--color-text-muted);
  border-radius: 4px;
  padding: 0.3rem 0.75rem;
  font-size: 0.78rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.toggle-btn:hover {
  background: rgba(125, 226, 209, 0.2);
  color: var(--color-accent);
}

.toggle-btn.active {
  background: rgba(125, 226, 209, 0.3);
  border-color: rgba(125, 226, 209, 0.8);
  color: var(--color-accent-2);
}

/* ─── Panel shell (tab container) ────────────────────────────────────────────── */
.panel-shell {
  margin-top: 28px;
}

/* ─── Tab navigation ─────────────────────────────────────────────────────────── */
.tabs-nav {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 0;
  margin-bottom: 0;
  flex-wrap: wrap;
}

.tab-btn {
  background: transparent;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  color: var(--color-text-muted);
  padding: 0.55rem 1.1rem;
  font-size: 0.88rem;
  font-family: "Space Grotesk", sans-serif;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  position: relative;
  bottom: -1px;
}

.tab-btn:hover {
  background: rgba(125, 226, 209, 0.08);
  color: var(--color-text);
}

.tab-btn.active {
  background: var(--color-surface);
  border-color: var(--color-border);
  border-bottom-color: transparent;
  color: var(--color-accent-2);
}

/* ─── Tab pane ───────────────────────────────────────────────────────────────── */
.tab-pane {
  display: none;
}

.tab-pane.panel-grid {
  gap: 16px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  padding-top: 16px;
}

.tab-pane:not(.panel-grid).active {
  display: block;
  padding-top: 16px;
}

.tab-pane.panel-grid.active {
  display: grid;
}

/* ─── Data table (user list, ticket breakdown) ──────────────────────────────── */
.data-table-scroll {
  position: relative;
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  border-radius: 8px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  line-height: 1.45;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}

.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--color-bg);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.78rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 2px solid var(--color-border);
}

.data-table td {
  color: var(--color-text);
}

.data-table tbody tr:hover {
  background: rgba(125, 226, 209, 0.08);
}

/* Numerikus oszlopok: tabular-nums + jobbra igazítás + nowrap */
.data-table th.num,
.data-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  min-width: 90px;
}

/* Fesztivál nap oszlop: nowrap + min-width */
.data-table th.col-day,
.data-table td.col-day {
  white-space: nowrap;
  min-width: 140px;
  color: var(--color-text);
}

/* Hosszabb szöveges cella: max-width + ellipsis + cursor-help (title tooltip) */
.data-table td.text-cell {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: help;
}

/* data-table responsive már a 1023px + 767px blokkokban van definiálva (S6-4) */

.data-table tfoot th {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  color: var(--color-text);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-top: 2px solid var(--color-border);
  background: rgba(125, 226, 209, 0.06);
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-admin   { background: rgba(244,185,66,0.2);   color: var(--color-accent); border: 1px solid rgba(244,185,66,0.4); }
.badge-operator{ background: rgba(80,190,230,0.2);   color: #50bed6; border: 1px solid rgba(80,190,230,0.4); }
.badge-viewer  { background: rgba(125,226,209,0.15); color: var(--color-accent-2); border: 1px solid rgba(125,226,209,0.3); }

/* ─── Profile toggle list ────────────────────────────────────────────────────── */
.profile-toggle-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
}

.profile-toggle-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  -webkit-user-select: none;
  user-select: none;
}

.profile-toggle-item:hover {
  border-color: rgba(125, 226, 209, 0.5);
  background: rgba(125, 226, 209, 0.06);
}

.profile-toggle-item input[type="checkbox"] {
  accent-color: var(--color-accent-2);
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  cursor: pointer;
}

.profile-toggle-item span {
  font-size: 0.88rem;
  color: var(--color-text);
}

/* ─── Form select (inside auth-form) ─────────────────────────────────────────── */
.form-select {
  width: 100%;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--color-surface-alt);
  color: var(--color-text);
  font-family: "Space Grotesk", sans-serif;
}

/* ─── S4-2 LIVE dashboard: event window banner + sync health badge ─────────── */
.event-banner {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 10px 16px;
  margin-bottom: 12px;
  background: linear-gradient(90deg, rgba(125, 226, 209, 0.15), rgba(244, 185, 66, 0.10));
  border: 1px solid var(--color-accent-2);
  border-radius: 10px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 13px;
  color: var(--color-text);
}
.event-banner .label-live {
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--color-accent-2);
}
.event-banner .festival-day { color: var(--color-text); }
.event-banner .server-time  { color: var(--color-text-muted); }
.event-banner .next-sync    { color: var(--color-text-muted); margin-left: auto; }
.event-banner .archive-toggle {
  font-size: 11px;
  padding: 4px 10px;
  margin: 0;
}

.sync-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  margin-left: 10px;
  border-radius: 999px;
  background: rgba(125, 226, 209, 0.08);
  border: 1px solid var(--color-border);
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  color: var(--color-text-muted);
  cursor: help;
  position: relative;
  vertical-align: middle;
}
.sync-badge .status-dot {
  width: 8px;
  height: 8px;
  margin: 0;
}
.sync-badge:hover .sync-badge-tooltip,
.sync-badge:focus .sync-badge-tooltip,
.sync-badge:focus-within .sync-badge-tooltip {
  display: block;
}
.sync-badge-tooltip {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 10px 12px;
  min-width: 260px;
  z-index: 20;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  color: var(--color-text);
  white-space: pre-line;
  text-align: left;
  font-size: 11px;
  line-height: 1.5;
}

/* Mobile + phablet — banner stackelés és badge tooltip bal oldalra */
@media (max-width: 767px) {
  .event-banner {
    flex-wrap: wrap;
    font-size: 11px;
    padding: 8px 12px;
    gap: 0.5rem;
  }
  .event-banner .next-sync {
    margin-left: 0;
    flex-basis: 100%;
  }
  .event-banner .archive-toggle {
    flex-basis: 100%;
    text-align: center;
  }
  .sync-badge {
    margin-left: 6px;
    font-size: 10px;
  }
  .sync-badge-tooltip {
    right: auto;
    left: 0;
    min-width: auto;
    max-width: 90vw;
  }
}

/* ─── Phablet (481–767px): event-banner font finomítás ─────────────────────── */
@media (min-width: 481px) and (max-width: 767px) {
  .event-banner {
    font-size: 12px;
    padding: 9px 14px;
  }
}

/* ─── Globális focus-visible token (S6-4 / WCAG 2.4.7) ─────────────────────── */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ─── Hamburger gomb ─────────────────────────────────────────────────────────── */
.hamburger-btn {
  display: none; /* desktop + phablet: rejtett; mobilon .hamburger-btn { display: flex } */
  min-width: 44px;
  min-height: 44px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
  padding: 10px;
  transition: background 0.15s, border-color 0.15s;
}

.hamburger-btn:hover {
  border-color: var(--color-accent-2);
  background: var(--color-surface-elevated);
}

.hamburger-btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.hamburger-icon span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--color-text-primary);
  border-radius: 2px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

/* Hamburger → X animáció (aria-expanded="true" esetén) */
.hamburger-btn[aria-expanded="true"] .hamburger-icon span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.hamburger-btn[aria-expanded="true"] .hamburger-icon span:nth-child(2) {
  opacity: 0;
}
.hamburger-btn[aria-expanded="true"] .hamburger-icon span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* ─── Mobile drawer ──────────────────────────────────────────────────────────── */
.mobile-drawer {
  position: fixed;
  top: 0;
  left: 0;
  width: min(280px, 80vw);
  height: 100vh;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  z-index: 1000;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}

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

.drawer-close-btn {
  align-self: flex-end;
  min-width: 44px;
  min-height: 44px;
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  color: var(--color-text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, border-color 0.15s;
  margin-bottom: 8px;
}

.drawer-close-btn:hover {
  color: var(--color-text-primary);
  border-color: var(--color-accent-2);
}

.drawer-close-btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.drawer-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.drawer-tab-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--color-text-muted);
  padding: 12px 16px;
  font-size: 0.95rem;
  font-family: "Space Grotesk", sans-serif;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  min-height: 44px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.drawer-tab-btn:hover {
  background: rgba(125, 226, 209, 0.08);
  color: var(--color-text-primary);
}

.drawer-tab-btn.active {
  background: rgba(125, 226, 209, 0.15);
  border-color: var(--color-accent-2);
  color: var(--color-accent-2);
}

.drawer-tab-btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* ─── Drawer overlay ─────────────────────────────────────────────────────────── */
.drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
}

.drawer-overlay.active {
  display: block;
}

/* ─── prefers-reduced-motion: animáció nélkül ───────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .mobile-drawer {
    transition: none;
  }
  .hamburger-icon span {
    transition: none;
  }
  .nav-drawer,
  .hamburger-btn,
  .panel {
    transition: none !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   S7-6: Pult-csoport kezelés panel
   ══════════════════════════════════════════════════════════════════════════════ */

/* 2 oszlopos elrendezés */
.groups-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 1rem;
}

.groups-col-title {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin: 0 0 10px;
}

/* Csoport card */
.group-card {
  background: var(--color-surface-elevated);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 10px;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
  position: relative;
}

.group-card:hover {
  box-shadow: 0 4px 16px rgba(125, 226, 209, 0.09);
  border-color: var(--color-border-strong);
}

.group-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.group-card-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-text-primary);
  margin: 0;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Member-szám badge */
.group-member-badge {
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  font-weight: 500;
  color: var(--color-text-muted);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 99px;
  padding: 2px 8px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Akció ikonok (edit + delete) */
.group-card-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.group-icon-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--color-text-muted);
  cursor: pointer;
  min-width: 44px;   /* WCAG 2.5.5 — min touch target */
  min-height: 44px;  /* WCAG 2.5.5 — min touch target */
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.group-icon-btn:hover {
  background: color-mix(in srgb, var(--color-accent-2) 12%, transparent);
  border-color: var(--color-accent-2);
  color: var(--color-accent-2);
}

.group-icon-btn.delete:hover {
  background: color-mix(in srgb, var(--color-danger) 12%, transparent);
  border-color: var(--color-danger);
  color: var(--color-danger);
}

.group-icon-btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* Member pult chip-ek preview (max 3 + "...") */
.group-member-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
}

.group-member-chip {
  font-size: 11px;
  color: var(--color-text-muted);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 99px;
  padding: 2px 8px;
  white-space: nowrap;
}

.group-member-more {
  font-size: 11px;
  color: var(--color-text-muted);
  padding: 2px 4px;
  align-self: center;
}

/* Üres állapot */
.group-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 28px 16px;
  text-align: center;
  color: var(--color-text-muted);
  border: 1px dashed var(--color-border-strong);
  border-radius: 12px;
}

.group-empty-icon {
  font-size: 2rem;
  opacity: 0.6;
}

.group-empty-state p {
  margin: 0;
  font-size: 0.9rem;
}

/* Primary gomb (új) */
.btn-primary {
  background: linear-gradient(120deg, var(--color-accent-2), var(--color-accent));
  border: none;
  border-radius: 10px;
  color: #fff;
  cursor: pointer;
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  padding: 10px 18px;
  min-height: 40px;
  transition: opacity 0.15s, transform 0.1s;
  white-space: nowrap;
}

.btn-primary:hover {
  opacity: 0.9;
}

.btn-primary:active {
  transform: scale(0.97);
}

.btn-primary:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.btn-primary.btn-sm {
  font-size: 0.82rem;
  padding: 8px 14px;
  min-height: 34px;
}

/* Secondary gomb */
.btn-secondary {
  background: transparent;
  border: 1px solid var(--color-border-strong);
  border-radius: 10px;
  color: var(--color-text-secondary);
  cursor: pointer;
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 10px 18px;
  min-height: 40px;
  transition: background 0.15s, border-color 0.15s;
}

.btn-secondary:hover {
  background: color-mix(in srgb, var(--color-accent-2) 8%, transparent);
  border-color: var(--color-accent-2);
}

.btn-secondary:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   S7-6: Csoport modal
   ══════════════════════════════════════════════════════════════════════════════ */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--modal-backdrop-bg);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  animation: modal-fade-in 0.18s ease both;
}

.modal-backdrop.hidden {
  display: none;
}

@keyframes modal-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-box {
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--modal-box-radius);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
  max-width: var(--modal-box-max-width);
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  animation: modal-slide-in 0.2s ease both;
}

@keyframes modal-slide-in {
  from { transform: translateY(12px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .modal-backdrop,
  .modal-box {
    animation: none;
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.05rem;
}

.modal-close-btn {
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 1.3rem;
  min-width: 36px;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, border-color 0.15s;
  flex-shrink: 0;
  line-height: 1;
}

.modal-close-btn:hover {
  color: var(--color-text-primary);
  border-color: var(--color-accent-2);
}

.modal-close-btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* Form mezők a modal-ban */
.form-field {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: 6px;
}

.required-mark {
  color: var(--color-danger);
  margin-left: 2px;
}

.form-input {
  width: 100%;
  background: var(--color-surface-input);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  color: var(--color-text-primary);
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.9rem;
  padding: 10px 12px;
  transition: border-color 0.15s;
  box-sizing: border-box;
}

.form-input:focus {
  outline: none;
  border-color: var(--color-accent-2);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-accent-2) 20%, transparent);
}

.form-hint {
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  color: var(--color-text-muted);
  margin: 4px 0 0;
}

.form-error {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  color: var(--color-danger);
  margin: 6px 0 0;
}

/* Globális checkbox sor */
.form-check-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--color-text-secondary);
  min-height: 36px;
}

.form-check {
  width: 16px;
  height: 16px;
  accent-color: var(--color-accent-2);
  cursor: pointer;
  flex-shrink: 0;
}

/* Chip keresőmező */
.chip-search {
  margin-bottom: 8px;
}

/* Chip scroll-lista */
.chip-scroll-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 200px;
  overflow-y: auto;
  padding: 10px;
  background: var(--color-surface-elevated);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  margin-bottom: 6px;
}

.chip-scroll-list:focus-within {
  border-color: var(--color-accent-2);
}

/* Egyedi pult chip */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--chip-bg-inactive);
  border: 1px solid var(--chip-border-inactive);
  border-radius: 99px;
  color: var(--chip-text-inactive);
  cursor: pointer;
  font-size: 12px;
  font-family: "Space Grotesk", sans-serif;
  font-weight: 500;
  padding: 5px 10px;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  user-select: none;
  min-height: 32px;
}

.chip:hover {
  border-color: var(--color-accent-2);
  background: color-mix(in srgb, var(--color-accent-2) 8%, var(--chip-bg-inactive));
}

.chip.active {
  background: var(--chip-bg-active);
  border-color: var(--chip-border-active);
  color: var(--chip-text-active);
  font-weight: 600;
}

.chip.active::before {
  content: '✓';
  font-size: 10px;
  flex-shrink: 0;
}

.chip.hidden {
  display: none;
}

.chip:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* Modal footer akciók */
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   S7-8: Csoport-bevétel panel
   ══════════════════════════════════════════════════════════════════════════════ */

/* KPI sáv */
.group-kpi-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}

/* Egy csoport KPI mini-csempéje */
.group-kpi-chip {
  background: var(--color-surface-elevated);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 12px 16px;
  min-width: 160px;
  flex: 1;
  position: relative;
  overflow: hidden;
  transition: box-shadow 0.15s;
}

/* Bal oldali color accent sáv (csoportszín) */
.group-kpi-chip::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  border-radius: 12px 0 0 12px;
  background: var(--chip-color, var(--color-data-1));
}

.group-kpi-chip:hover {
  box-shadow: 0 4px 16px rgba(125, 226, 209, 0.09);
}

.group-kpi-chip .group-kpi-label {
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-text-muted);
  margin: 0 0 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.group-kpi-chip .group-kpi-value {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--color-accent);
  font-variant-numeric: tabular-nums;
  margin: 0 0 2px;
}

.group-kpi-chip .group-kpi-meta {
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  color: var(--color-text-muted);
  margin: 0;
}

/* Multi-select dropdown wrapper */
.multi-select-wrap {
  position: relative;
}

.multi-select-trigger {
  cursor: pointer;
  text-align: left;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 200px;
  padding: 8px 12px;
  background: var(--color-surface-input);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  transition: border-color 0.15s;
}

.multi-select-trigger:hover,
.multi-select-trigger[aria-expanded="true"] {
  border-color: var(--color-accent-2);
}

.multi-select-trigger:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* Legördülő listbox */
.multi-select-listbox {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 300;
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  padding: 6px;
  min-width: 220px;
  max-height: 280px;
  overflow-y: auto;
}

.multi-select-listbox.hidden {
  display: none;
}

.multi-select-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 0.87rem;
  color: var(--color-text-secondary);
  transition: background 0.1s;
}

.multi-select-option:hover {
  background: color-mix(in srgb, var(--color-accent-2) 10%, transparent);
}

.multi-select-option.selected {
  color: var(--color-accent-2);
  font-weight: 600;
}

.multi-select-option .option-swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.multi-select-count {
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  color: var(--color-text-muted);
  background: var(--color-surface-elevated);
  border-radius: 99px;
  padding: 1px 6px;
}

/* Maximálva (5 csoport): további opciókon disabled megjelenés */
.multi-select-option.max-reached:not(.selected) {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* Toast értesítések (S7-7) */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  color: var(--color-text-primary);
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.9rem;
  padding: 12px 18px;
  pointer-events: auto;
  animation: toast-in 0.22s ease both;
  max-width: 340px;
}

.toast.toast-success {
  border-left: 4px solid var(--color-success);
}

.toast.toast-error {
  border-left: 4px solid var(--color-danger);
}

.toast.toast-info {
  border-left: 4px solid var(--color-accent-2);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Csoport-bevétel: üres állapot */
.group-revenue-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 40px 16px;
  text-align: center;
  color: var(--color-text-muted);
  border: 1px dashed var(--color-border-strong);
  border-radius: 12px;
  margin-top: 1rem;
}

.group-revenue-empty.hidden {
  display: none;
}

/* Chart canvas: fix magasság */
#group-revenue-chart {
  min-height: 350px;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   S7-7 + S7-8: Reszponzív
   ══════════════════════════════════════════════════════════════════════════════ */

/* Tablet */
@media (max-width: 1023px) {
  .group-kpi-chip {
    min-width: 130px;
  }

  .multi-select-trigger {
    min-width: 160px;
  }
}

/* Phablet */
@media (max-width: 767px) {
  .groups-two-col {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .group-kpi-strip {
    flex-direction: column;
  }

  .group-kpi-chip {
    min-width: unset;
    width: 100%;
  }
}

/* Mobile */
@media (max-width: 480px) {
  /* Modal: bottom-sheet stílus */
  .modal-backdrop {
    padding: 0;
    align-items: flex-end;
  }
  .modal-box {
    max-width: none;
    width: 100%;
    max-height: 92vh;
    border-radius: 16px 16px 0 0;
    padding: 20px 16px;
  }
  .chip-scroll-list {
    max-height: 140px;
  }
  /* Akciók: full-width gombok */
  .modal-actions {
    flex-direction: column-reverse;
    gap: 8px;
  }
  .modal-actions .btn-primary,
  .modal-actions .btn-secondary {
    width: 100%;
    min-height: 44px;
  }
  /* Csoport ikonok: nagyobb touch area */
  .group-icon-btn {
    min-width: 44px;
    min-height: 44px;
  }
  /* Multi-select trigger: full-width */
  .multi-select-trigger {
    min-width: unset;
    width: 100%;
  }
  /* S7-8: chart min-height mobilon */
  #group-revenue-chart {
    min-height: 280px;
  }
  /* Toast: teljes szélességű mobilon */
  .toast-container {
    bottom: 16px;
    right: 12px;
    left: 12px;
  }
  .toast {
    max-width: none;
  }
}

/* ─── S8-15: What-if szekció ─────────────────────────────────────────────── */

.forecast-whatif-section {
  border-top: 1px solid var(--color-border);
  margin-top: 1.5rem;
}

/* Toggle fejléc sáv */
.whatif-toggle-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0 8px;
  cursor: pointer;
  user-select: none;
}

.whatif-toggle-label {
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-text-secondary);
}

.whatif-toggle-btn {
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 0.75rem;
  min-width: 80px;
  min-height: 32px;
  padding: 4px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  white-space: nowrap;
}

.whatif-toggle-btn:hover {
  border-color: var(--color-accent-2);
  color: var(--color-accent-2);
  background: color-mix(in srgb, var(--color-accent-2) 8%, transparent);
}

.whatif-toggle-btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* Nyíl ikon forgása expanded-kor */
.whatif-toggle-btn[aria-expanded="true"] .whatif-toggle-icon {
  transform: rotate(180deg);
}

.whatif-toggle-icon {
  display: inline-block;
  transition: transform 0.2s ease;
}

@media (prefers-reduced-motion: reduce) {
  .whatif-toggle-icon {
    transition: none;
  }
}

/* Összecsukt törzs */
.whatif-body {
  padding-bottom: 16px;
}

.whatif-body.hidden {
  display: none;
}

/* Slider sor */
.whatif-slider-row {
  margin-bottom: 16px;
}

.whatif-slider-label-text {
  display: block;
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: 10px;
}

/* Slider + szélső értékek sor */
.whatif-slider-track {
  display: flex;
  align-items: center;
  gap: 10px;
}

.whatif-range-min,
.whatif-range-max {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  color: var(--color-text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* HTML5 range input stílus */
.whatif-slider {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 4px;
  border-radius: 99px;
  background: var(--color-border-strong);
  outline: none;
  cursor: pointer;
  /* Az aktív (bal) rész: JS állítja inline style-lal,
     linear-gradient(to right, --color-accent-2 N%, --color-border-strong N%) */
  transition: opacity 0.15s;
}

@media (prefers-reduced-motion: reduce) {
  .whatif-slider {
    transition: none;
  }
}

.whatif-slider:hover {
  opacity: 0.9;
}

/* Thumb — WebKit */
.whatif-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--color-accent);
  border: 3px solid var(--color-surface);
  box-shadow: 0 0 0 2px var(--color-accent-2);
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.1s;
}

.whatif-slider::-webkit-slider-thumb:hover {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent-2) 40%, transparent);
  transform: scale(1.1);
}

.whatif-slider:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 3px var(--color-accent);
}

@media (prefers-reduced-motion: reduce) {
  .whatif-slider::-webkit-slider-thumb {
    transition: none;
  }
}

/* Thumb — Firefox */
.whatif-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--color-accent);
  border: 3px solid var(--color-surface);
  box-shadow: 0 0 0 2px var(--color-accent-2);
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.1s;
}

.whatif-slider::-moz-range-thumb:hover {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent-2) 40%, transparent);
  transform: scale(1.1);
}

@media (prefers-reduced-motion: reduce) {
  .whatif-slider::-moz-range-thumb {
    transition: none;
  }
}

/* Slider aktuális értéke és visitor szám */
.whatif-slider-value-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
}

.whatif-slider-display {
  font-family: "IBM Plex Mono", monospace;
  font-size: 1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--color-accent);
  min-width: 60px;
  text-align: center;
}

.whatif-visitor-count {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

/* Eredmény info doboz */
.whatif-info-box {
  background: var(--color-surface-elevated);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 14px 18px;
}

.whatif-info-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.whatif-info-row:last-of-type {
  margin-bottom: 0;
}

.whatif-info-label {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  color: var(--color-text-muted);
  min-width: 190px;
  flex-shrink: 0;
}

.whatif-info-value {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.9rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--color-text-secondary);
}

/* Delta szöveg: pozitív = zöld, negatív = piros, nulla = muted */
.whatif-info-delta {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-muted);
}

.whatif-info-delta.positive {
  color: var(--color-success);
}

.whatif-info-delta.negative {
  color: var(--color-danger);
}

/* Reset gomb */
.whatif-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--color-border);
}

.btn-whatif-reset {
  background: transparent;
  border: 1px solid var(--color-border-strong);
  border-radius: 10px;
  color: var(--color-text-muted);
  cursor: pointer;
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 16px;
  min-height: 36px;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  white-space: nowrap;
}

.btn-whatif-reset:hover {
  color: var(--color-text-secondary);
  border-color: var(--color-accent-2);
  background: color-mix(in srgb, var(--color-accent-2) 8%, transparent);
}

.btn-whatif-reset:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* Disabled állapot (ha nincs baseline adat) */
.btn-whatif-reset:disabled,
.whatif-slider:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* ─── S8-15: Reszponzív — what-if ────────────────────────────────────────── */

/* Tablet (768–1023px) */
@media (max-width: 1023px) {
  .kpi-tooltip-content {
    max-width: 220px;
  }
}

/* Phablet (481–767px) */
@media (max-width: 767px) {
  .whatif-slider-track {
    gap: 6px;
  }

  .whatif-info-label {
    min-width: unset;
    width: 100%;
    margin-bottom: 2px;
  }

  .whatif-info-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }
}

/* Mobile (≤480px) */
@media (max-width: 480px) {
  .whatif-slider-track {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
  }

  .whatif-range-min,
  .whatif-range-max {
    display: none;
  }

  .whatif-slider {
    width: 100%;
  }

  .whatif-slider-value-row {
    flex-direction: column;
    gap: 2px;
  }

  .whatif-actions {
    justify-content: stretch;
  }

  .btn-whatif-reset {
    width: 100%;
    min-height: 44px;
    text-align: center;
  }
}
