/* LassZocken – Elternbereich (Dashboard auf Desktop, stapelbare Karten auf Smartphone) */

.parent-app { padding-bottom: var(--safe-bottom); }

.p-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: calc(10px + var(--safe-top)) calc(16px + var(--safe-right)) 10px calc(16px + var(--safe-left));
  background: var(--header-bg);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.p-header { flex-wrap: wrap; }
.p-nav { display: flex; gap: 4px; flex-wrap: wrap; }
@media (max-width: 560px) {
  .p-header .logo small { display: none; }
  .p-nav .btn { padding: 6px 8px; }
}
.p-nav .btn[aria-current="page"] { --btn-bg: var(--surface-3); --btn-line: var(--line-strong); }

.p-main {
  max-width: 1200px; margin: 0 auto;
  padding: var(--space-5) calc(16px + var(--safe-right)) var(--space-6) calc(16px + var(--safe-left));
  display: grid; gap: var(--space-5);
}

.view { display: grid; gap: var(--space-5); }
.view h1 { font-size: var(--fs-xl); font-weight: 800; }
.view h1:focus { outline: none; }
.card h2, .section-title { font-size: 1.1rem; font-weight: 750; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-3); }
.muted { color: var(--text-3); font-size: var(--fs-sm); }

/* ---------- Login ---------- */
.login-wrap { min-height: 80dvh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(420px, 100%); display: grid; gap: var(--space-4); padding: var(--space-5); }
.login-card .logo { justify-self: start; }

/* ---------- Gerade aktiv ---------- */
.active-card { border-color: rgba(74, 222, 128, 0.35); }
.active-list { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
.active-item {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: var(--space-3);
  padding: var(--space-3); border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line);
}
.active-item.long { border-color: rgba(255, 200, 87, 0.6); background: rgba(255, 200, 87, 0.07); }
.active-item .who { font-weight: 750; }
.active-item .what { font-size: var(--fs-sm); color: var(--text-2); }
.active-item .run { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 750; font-size: 1.1rem; }
.active-item .warn { grid-column: 1 / -1; color: var(--warn); font-size: var(--fs-sm); font-weight: 650; }
.mini-avatar { width: 40px; height: 40px; display: grid; place-items: center; background: var(--accent); clip-path: polygon(14% 0, 86% 0, 100% 14%, 100% 86%, 86% 100%, 14% 100%, 0 86%, 0 14%); }
.mini-avatar img { width: 70%; height: 70%; }

/* ---------- Toolbar ---------- */
.toolbar { display: grid; gap: var(--space-3); }
.segmented { display: inline-flex; padding: 4px; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.segmented .btn { --btn-line: transparent; --btn-bg: transparent; min-width: 84px; }
.segmented .btn[aria-pressed="true"] { --btn-bg: var(--brand); --btn-fg: var(--brand-ink); }
.segmented-sm { margin-left: auto; padding: 3px; gap: 2px; border-radius: 12px; }
.segmented-sm .btn { min-width: 0; padding-inline: 10px; }
.datenav { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: var(--space-2); }
.datenav h2 { font-size: 1.1rem; font-weight: 750; text-align: center; }
.datenav-extra { grid-column: 1 / -1; display: flex; gap: var(--space-2); justify-content: center; }
.datenav .input { width: auto; min-width: 150px; }
@media (min-width: 900px) {
  .datenav { grid-template-columns: auto minmax(16ch, 1fr) auto auto; }
  .datenav-extra { grid-column: auto; }
}
.filters { display: grid; gap: var(--space-3); grid-template-columns: 1fr 1fr; }
.filters .actions { grid-column: 1 / -1; display: flex; gap: var(--space-2); flex-wrap: wrap; }
@media (min-width: 900px) {
  .toolbar { grid-template-columns: auto 1fr; align-items: center; }
  .filters { grid-column: 1 / -1; grid-template-columns: 220px 220px 1fr; align-items: end; }
  .filters .actions { grid-column: auto; justify-content: flex-end; }
}

/* ---------- KPIs ---------- */
.kpi-grid { display: grid; gap: var(--space-3); grid-template-columns: repeat(2, 1fr); }
@media (min-width: 700px) { .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); } }
.kpi { padding: var(--space-4); border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); position: relative; overflow: hidden; }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--accent, var(--brand)); }
.kpi .label { font-size: var(--fs-xs); color: var(--text-3); font-weight: 650; text-transform: uppercase; letter-spacing: 0.06em; }
.kpi .value { font-size: 1.45rem; font-weight: 800; margin-top: 4px; line-height: 1.15; }
.kpi .sub { font-size: var(--fs-xs); color: var(--text-3); margin-top: 4px; }
.kpi-main { grid-column: 1 / -1; }
.kpi-over { border-color: var(--danger); }
.kpi-over .sub { color: var(--error-text); font-weight: 650; }
.active-item .quota-line { font-size: var(--fs-xs); color: var(--text-2); margin-top: 2px; }
.active-item .quota-line.over { color: var(--error-text); font-weight: 700; }
@media (min-width: 700px) { .kpi-main { grid-column: auto; } }

/* ---------- Charts ---------- */
.charts-grid { display: grid; gap: var(--space-4); }
@media (min-width: 900px) { .charts-grid { grid-template-columns: 1fr 1fr; } .charts-grid .wide { grid-column: 1 / -1; } }

.hbars { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-3); }
.hbar-head { display: flex; justify-content: space-between; gap: var(--space-2); font-size: var(--fs-sm); margin-bottom: 6px; }
.hbar-label { display: inline-flex; align-items: center; gap: 8px; font-weight: 650; }
.hbar-value { font-weight: 750; font-variant-numeric: tabular-nums; }
.hbar-track { height: 14px; border-radius: 5px; background: var(--bg-2); overflow: hidden; }
.hbar-fill { display: block; height: 100%; border-radius: 5px; background: var(--accent); transition: width 0.4s ease; }

.donut-wrap { display: grid; gap: var(--space-4); align-items: center; grid-template-columns: 1fr; justify-items: center; }
@media (min-width: 480px) { .donut-wrap { grid-template-columns: 160px 1fr; justify-items: stretch; } }
.donut { width: 160px; height: 160px; }
.donut-track { fill: none; stroke: var(--bg-2); stroke-width: 22; }
.donut-seg { fill: none; stroke: var(--accent); stroke-width: 22; }
.donut-total { fill: var(--text); font-size: 20px; font-weight: 800; }
.donut-sub { fill: var(--text-3); font-size: 11px; }
.legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: var(--fs-sm); width: 100%; }
.legend li { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; }
.legend-value { color: var(--text-2); font-variant-numeric: tabular-nums; }
.legend-inline { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 8px; }
.legend-inline li { display: inline-flex; }

.columns { width: 100%; height: auto; max-height: 300px; }
.columns .grid { stroke: var(--line); stroke-width: 1; }
.columns .axis { fill: var(--text-3); font-size: 11px; }
.columns .col { fill: var(--accent); }
.columns .limit-mark { stroke: var(--text); stroke-width: 2; stroke-dasharray: 3 2; opacity: 0.7; }
.columns .trend-line { stroke: var(--text-2); stroke-width: 2; stroke-dasharray: 6 4; opacity: 0.85; }
.columns .trend-line[class*="theme-"] { stroke: var(--accent); opacity: 0.6; }
.lines .line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; }
.lines .dot { fill: var(--accent); }
.lines .dot.current { fill: var(--surface); stroke: var(--accent); stroke-width: 2; }
.swatch-limit { background: none !important; border-top: 2px dashed var(--text); height: 0 !important; align-self: center; }
.swatch-trend { background: none !important; border-top: 2px dashed var(--text-2); height: 0 !important; align-self: center; }

.chart-empty { display: grid; justify-items: center; gap: 6px; padding: var(--space-5) var(--space-3); color: var(--text-3); text-align: center; }
.chart-empty-icon { font-size: 1.8rem; opacity: 0.5; }

/* ---------- Tabelle ---------- */
.table-wrap { overflow-x: auto; }
.rtable { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.rtable th, .rtable td { padding: 10px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.rtable th { color: var(--text-3); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; white-space: nowrap; }
.rtable td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.rtable tr.voided td { color: var(--text-3); }
.rtable tr.voided .dur { text-decoration: line-through; }
.rtable .row-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.sort-btn { background: none; border: 0; color: inherit; font: inherit; text-transform: inherit; letter-spacing: inherit; cursor: pointer; padding: 4px; min-height: 32px; }
.cell-game { display: inline-flex; align-items: center; gap: 8px; }

@media (max-width: 760px) {
  .rtable thead { display: none; }
  .rtable, .rtable tbody, .rtable tr, .rtable td { display: block; width: 100%; }
  .rtable tr { padding: 12px 0; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px; }
  .rtable td { border: 0; padding: 2px 0; }
  .rtable td::before { content: attr(data-label); display: block; font-size: var(--fs-xs); color: var(--text-3); text-transform: uppercase; letter-spacing: 0.05em; }
  .rtable td.td-actions { grid-column: 1 / -1; }
  .rtable td.td-actions::before { display: none; }
  .rtable .row-actions { justify-content: flex-start; margin-top: 6px; }
}

.empty { text-align: center; padding: var(--space-5); color: var(--text-3); }

/* ---------- Audit ---------- */
details.card > summary { cursor: pointer; font-weight: 750; min-height: var(--tap); display: flex; align-items: center; }
.audit-list { list-style: none; margin: var(--space-3) 0 0; padding: 0; display: grid; gap: 8px; font-size: var(--fs-sm); }
.audit-list li { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line); }
.audit-list .when { color: var(--text-3); font-size: var(--fs-xs); }
.audit-list .diff { color: var(--text-2); font-family: var(--font-mono); font-size: var(--fs-xs); word-break: break-word; }

/* ---------- Verwaltung ---------- */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.tabs .btn[aria-selected="true"] { --btn-bg: var(--surface-3); --btn-line: var(--brand); }
.admin-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-3); }
.admin-row {
  display: grid; grid-template-columns: auto 1fr; gap: var(--space-3); align-items: center;
  padding: var(--space-3); border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line);
}
.admin-row.disabled { opacity: 0.6; }
.admin-row .title { font-weight: 750; }
.admin-row .meta { font-size: var(--fs-xs); color: var(--text-3); display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.admin-row .row-actions { grid-column: 1 / -1; display: flex; gap: 6px; flex-wrap: wrap; }
.child-badges { grid-column: 1 / -1; border-top: 1px solid var(--line); padding-top: var(--space-2); }
.child-badges > summary { cursor: pointer; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: var(--fs-sm); }
.child-badges .cb-title { font-weight: 750; }
.child-badges .cb-emojis { font-size: 1.1rem; letter-spacing: 1px; }
.child-badges .cb-streak { font-size: var(--fs-xs); }
.child-badges .p-badges { margin-top: var(--space-2); }
@media (min-width: 760px) {
  .admin-row { grid-template-columns: auto 1fr auto; }
  .admin-row .row-actions { grid-column: auto; justify-content: flex-end; }
}
.game-mini { width: 40px; height: 40px; display: grid; place-items: center; background: var(--accent); clip-path: polygon(12% 0, 88% 0, 100% 12%, 100% 88%, 88% 100%, 12% 100%, 0 88%, 0 12%); }
.game-mini img { width: 72%; height: 72%; }

.form-grid { display: grid; gap: var(--space-4); }
.sub-head { margin-top: var(--space-5); }
.sub-head h3 { font-size: var(--fs-md); }
.bonus-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); }
.bonus-list li { display: flex; align-items: center; gap: var(--space-3); padding: 8px 12px; border-radius: var(--radius-sm); background: var(--surface-2); flex-wrap: wrap; }
.bonus-list .amount { font-weight: 800; color: var(--ok); }
.bonus-list .why { color: var(--text-2); flex: 1 1 140px; }
.bonus-list .when { color: var(--text-3); font-size: var(--fs-xs); }
.bonus-list li.is-credit { outline: 1px dashed var(--ok); outline-offset: -1px; }
.chip-row { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: var(--space-2); }
.chip-row .btn[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.special-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.game-check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0 var(--space-3); }
.game-check-grid.all { opacity: 0.5; }
.game-check-grid .check { min-height: 40px; }
.limit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: var(--space-2); margin: var(--space-2) 0; }
.limit-day { display: grid; gap: 4px; }
.limit-day label { font-size: var(--fs-xs); font-weight: 700; color: var(--text-2); }
.limit-day .input { text-align: center; }
.limit-day .limit-preview { font-size: var(--fs-xs); color: var(--text-3); min-height: 1.2em; }
.limit-day.invalid .input { border-color: var(--danger); }
.limit-day.invalid .limit-preview { color: var(--error-text); }
@media (min-width: 640px) { .form-grid.cols-2 { grid-template-columns: 1fr 1fr; } }
.choice-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; inset: 0; }
.choice span {
  display: grid; place-items: center; min-width: var(--tap); min-height: var(--tap); padding: 6px;
  border-radius: var(--radius-sm); border: 2px solid var(--line-strong); background: var(--surface-2); cursor: pointer;
}
.choice input:checked + span { border-color: var(--focus-color); box-shadow: 0 0 0 2px color-mix(in srgb, var(--focus-color) 35%, transparent); }
.choice input:focus-visible + span { box-shadow: var(--focus); }
.choice .swatch-lg { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); }
.choice img { width: 30px; height: 30px; }
.choice .icon-bg { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 8px; background: var(--c-slate); }

.danger-zone { border-color: rgba(255, 107, 107, 0.45); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: var(--fs-sm); }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; overflow-wrap: anywhere; min-width: 0; }
.prose { display: grid; gap: var(--space-3); font-size: var(--fs-sm); color: var(--text-2); max-width: 75ch; }
.prose ul { margin: 0; padding-left: 1.2em; display: grid; gap: 4px; }
code { font-family: var(--font-mono); font-size: 0.9em; background: var(--bg-2); padding: 1px 6px; border-radius: 6px; }
.offset-choice { display: grid; gap: 6px; padding: 10px; border-radius: var(--radius-sm); background: rgba(255, 200, 87, 0.08); border: 1px solid rgba(255, 200, 87, 0.4); }
.form-error { color: var(--error-text); font-weight: 600; font-size: var(--fs-sm); min-height: 1.2em; }

/* Abzeichen: Hinweise oben in der Übersicht, Sammlung je Kind */
.badge-alerts { display: grid; gap: var(--space-2); }
.badge-alerts:empty { display: none; }
.badge-alert { align-items: center; flex-wrap: wrap; }
.badge-alert .text { flex: 1 1 220px; }
.badge-alert .alert-actions { display: flex; gap: 6px; }
#ach-card > summary { gap: 8px; flex-wrap: wrap; }
.ach-summary { font-weight: 800; font-size: var(--fs-md); }
.ach-child { margin-top: var(--space-4); }
.ach-child h3 { display: flex; align-items: center; gap: 8px; color: var(--accent); }
.ach-child > p { margin: 2px 0 var(--space-2); font-size: var(--fs-sm); }
.p-badges { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: var(--space-2); }
.p-badges li { position: relative; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line); display: grid; gap: 3px; align-content: start; }
.p-badges .emoji { font-size: 1.6rem; line-height: 1; }
.p-badges .t { font-weight: 750; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.p-badges .d { font-size: var(--fs-xs); color: var(--text-3); }
.p-badges li.locked .emoji { filter: grayscale(1); opacity: 0.35; }
.p-badges li.locked :is(.t, .d) { opacity: 0.7; }
.p-badges li.earned {
  border: 2px solid var(--warn);
  background: linear-gradient(160deg, color-mix(in srgb, var(--warn) 22%, var(--surface-2)), var(--surface-2) 70%);
}
.p-badges .got {
  position: absolute; top: 8px; right: 8px; padding: 1px 7px; border-radius: 999px;
  background: var(--warn); color: var(--warn-ink); font-size: var(--fs-xs); font-weight: 800;
}
.p-badges li.earned .when { color: var(--text-2); font-weight: 650; }
.p-badges .bar { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.p-badges .bar span { display: block; height: 100%; background: var(--warn); }
