/* =====================================================================
   VFL Dashboard · Apple-inspiriertes Design in Grün
   Hell- und Dunkelmodus folgen automatisch der Systemeinstellung.
   Layout: PC = Seitenleiste mit Text · Tablet = Icon-Leiste · Handy = untere Tab-Leiste
   ===================================================================== */
:root {
  /* Hell (Standard) */
  --bg: #f2f2f7;
  --panel: #ffffff;
  --panel-2: #f2f2f7;
  --panel-3: #e5e5ea;
  --glass: rgba(255, 255, 255, .78);
  --glass-strong: rgba(255, 255, 255, .9);
  --line: rgba(60, 60, 67, .12);
  --line-strong: rgba(60, 60, 67, .22);
  --text: #1c1c1e;
  --muted: #6e6e73;
  --accent: #1f9d48;          /* Apple-Grün, abgedunkelt für gute Lesbarkeit auf Weiß */
  --accent-bright: #34c759;   /* iOS systemGreen */
  --accent-text: #ffffff;
  --accent-tint: rgba(52, 199, 89, .14);
  --ok: #1f9d48;
  --warn: #c76a00;
  --err: #d70015;
  --gold: #b78a00;
  --link: #1f9d48;
  --code: #1f6f3a;
  --backdrop: rgba(0, 0, 0, .28);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .05);
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 6px 24px rgba(0, 0, 0, .06);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, .14);
  --radius: 16px;
  --radius-sm: 10px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI Variable Text", "Segoe UI", "Helvetica Neue", Inter, Roboto, Arial, sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, "Cascadia Code", Consolas, monospace;

  /* Layout-Maße (werden unten je Bildschirmbreite angepasst) */
  --side-w: 240px;
  --top-h: 60px;
  --bottom-h: 0px;
  --gutter: 24px;
  --sticky-top: calc(var(--top-h) + 16px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --panel: #1c1c1e;
    --panel-2: #2c2c2e;
    --panel-3: #3a3a3c;
    --glass: rgba(22, 22, 24, .78);
    --glass-strong: rgba(28, 28, 30, .94);
    --line: rgba(84, 84, 88, .45);
    --line-strong: rgba(120, 120, 128, .5);
    --text: #f5f5f7;
    --muted: #98989d;
    --accent: #30d158;
    --accent-bright: #30d158;
    --accent-text: #04210e;
    --accent-tint: rgba(48, 209, 88, .16);
    --ok: #30d158;
    --warn: #ffb340;
    --err: #ff6961;
    --gold: #ffd60a;
    --link: #30d158;
    --code: #7ee29a;
    --backdrop: rgba(0, 0, 0, .55);
    --shadow-sm: none;
    --shadow: 0 0 0 1px rgba(255, 255, 255, .04);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.47 var(--font); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body { -webkit-tap-highlight-color: transparent; overflow-x: hidden; }
body.center { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1200px 600px at 50% -10%, var(--accent-tint), transparent 70%), var(--bg); }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: var(--panel-2); color: var(--code); padding: 1px 6px; border-radius: 6px; font: 12.5px var(--mono); overflow-wrap: anywhere; }
h1 { font-size: 28px; font-weight: 700; letter-spacing: -.02em; margin: 10px 0 6px; }
h2 { font-size: 17px; font-weight: 600; letter-spacing: -.01em; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
[hidden] { display: none !important; }
::selection { background: var(--accent-tint); }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ico { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--accent-bright); outline-offset: 2px; }

/* ------------------------------------------------------------------ Seitenleiste */
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 20; width: var(--side-w); display: flex; flex-direction: column; gap: 4px;
  padding: 14px 12px 12px; background: var(--panel); border-right: 1px solid var(--line); overflow-y: auto; scrollbar-width: none; }
.sidebar::-webkit-scrollbar { display: none; }
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 8px 10px; }
.brand-txt { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-txt b { font-size: 15px; letter-spacing: -.01em; white-space: nowrap; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1 1 auto; min-height: 0; overflow-y: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav-group { font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); padding: 14px 10px 6px; }
.nav button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px 10px; border: 0; border-radius: 10px; background: none; color: var(--text);
  font: 500 14px var(--font); text-align: left; cursor: pointer; transition: background .15s, color .15s; }
.nav button .ico { color: var(--muted); transition: color .15s; }
.nav button:hover { background: var(--panel-2); }
.nav button.active { background: var(--accent-tint); color: var(--accent); font-weight: 600; }
.nav button.active .ico { color: var(--accent); }
.side-user { display: flex; align-items: center; gap: 10px; margin-top: auto; padding: 12px 8px 4px; border-top: 1px solid var(--line); min-width: 0; }
.side-user img, .sheet-user img { width: 30px; height: 30px; border-radius: 50%; flex: none; }
.side-name { flex: 1; min-width: 0; font-weight: 500; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; flex: none; border: 0; border-radius: 10px; background: none; color: var(--muted); cursor: pointer;
  transition: background .15s, color .15s; }
.icon-btn:hover { background: var(--panel-2); color: var(--text); }

/* ------------------------------------------------------------------ Hauptbereich & Kopfleiste (Milchglas) */
.main { margin-left: var(--side-w); min-width: 0; min-height: 100vh; min-height: 100dvh; }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; gap: 12px; align-items: center; height: var(--top-h); padding: 0 var(--gutter);
  background: var(--glass); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); border-bottom: 1px solid var(--line); }
.topbar h1 { margin: 0; font-size: 21px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-logo { display: none !important; }
.status { display: flex; gap: 8px; margin-left: auto; flex: none; }

.content { padding: 20px var(--gutter) calc(32px + var(--bottom-h)); max-width: 1560px; margin: 0 auto; }
.tab { display: none; animation: fade .25s ease; }
.tab.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------------ Untere Tab-Leiste & „Mehr“-Blatt (nur Handy) */
.bottombar { display: none; }
.sheet-backdrop { position: fixed; inset: 0; z-index: 45; background: var(--backdrop); display: flex; align-items: flex-end; justify-content: center; animation: fadein .2s ease; }
@keyframes fadein { from { opacity: 0; } }
.sheet { width: 100%; max-width: 560px; max-height: 88vh; max-height: 88dvh; overflow-y: auto; overscroll-behavior: contain; background: var(--glass-strong);
  backdrop-filter: saturate(180%) blur(24px); -webkit-backdrop-filter: saturate(180%) blur(24px); border-radius: 22px 22px 0 0; box-shadow: var(--shadow-lg);
  padding: 8px 16px calc(16px + var(--safe-b)); animation: sheet-up .32s cubic-bezier(.2, .9, .3, 1); }
@keyframes sheet-up { from { transform: translateY(40%); opacity: .4; } }
.sheet-head { position: relative; display: flex; align-items: center; gap: 10px; padding: 14px 0 6px; }
.sheet-grab { position: absolute; top: 0; left: 50%; width: 38px; height: 5px; margin-left: -19px; border-radius: 99px; background: var(--line-strong); }
.sheet-user { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.sheet-user b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-body .nav-group { padding: 14px 4px 8px; }
.sheet-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.sheet-grid button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 76px; padding: 10px 4px; border: 0;
  border-radius: 14px; background: var(--panel); color: var(--text); font: 500 12.5px var(--font); cursor: pointer; box-shadow: var(--shadow-sm); text-align: center; }
.sheet-grid button .ico { width: 24px; height: 24px; color: var(--accent); }
.sheet-grid button.active { background: var(--accent-tint); color: var(--accent); font-weight: 600; box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 40%, transparent); }
.sheet-logout { width: 100%; margin-top: 16px; color: var(--err); }
body.sheet-lock { overflow: hidden; }

/* ------------------------------------------------------------------ Raster & Karten */
.grid { display: grid; gap: 16px; margin-bottom: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }
.grid.two > .card { margin-bottom: 0; }
.grid.cards { grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); }
.card { background: var(--panel); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; min-width: 0; box-shadow: var(--shadow); }
.card > h2:not(:first-child) { margin-top: 22px; }
.card.narrow { max-width: 420px; width: 100%; text-align: center; padding: 36px 32px; box-shadow: var(--shadow-lg); }
.card-head { display: flex; gap: 10px 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.row { display: flex; gap: 8px; align-items: center; }
.row.between { justify-content: space-between; }
.row.center { justify-content: center; margin-top: 12px; }
.row.wrap { flex-wrap: wrap; }
.row.between.wrap { gap: 10px 12px; margin-bottom: 12px; }
.row.between.wrap > h2 { margin: 0; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.grow { flex: 1 1 200px; }

/* ------------------------------------------------------------------ Kennzahlen */
.stat { background: var(--panel); border-radius: var(--radius); padding: 16px 18px; min-width: 0; box-shadow: var(--shadow); transition: transform .2s, box-shadow .2s; }
.stat:hover { transform: translateY(-1px); }
.stat .label { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.stat .value { font-size: 22px; font-weight: 700; letter-spacing: -.02em; margin-top: 6px; overflow-wrap: break-word; font-variant-numeric: tabular-nums; line-height: 1.25; }
.stat .sub { color: var(--muted); font-size: 13px; margin-top: 2px; overflow-wrap: anywhere; }
.stat.hero { grid-column: span 2; display: flex; gap: 16px; align-items: center; background: linear-gradient(135deg, color-mix(in srgb, var(--accent-bright) 16%, var(--panel)), var(--panel) 70%); }
.stat.hero .hero-face { width: 56px; height: 56px; border-radius: 14px; image-rendering: pixelated; flex: none; background: var(--panel-2); box-shadow: var(--shadow-sm); }
.stat.hero .hero-main { min-width: 0; }
.stat.hero .value { font-size: 24px; margin-top: 2px; }
.bar { height: 6px; background: var(--panel-3); border-radius: 99px; margin-top: 12px; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent-bright), var(--accent)); transition: width .6s cubic-bezier(.2, .8, .2, 1); }
.bar.food > i { background: linear-gradient(90deg, #ffcc00, #ff9500); }
.bar.xp > i { background: linear-gradient(90deg, #a8e063, #56ab2f); }

/* ------------------------------------------------------------------ Elemente */
.logo { display: inline-grid; place-items: center; width: 72px; height: 72px; border-radius: 22px; color: #fff; flex: none;
  background: linear-gradient(145deg, #4cd964 0%, #1f9d48 100%); font-weight: 800; font-size: 22px; letter-spacing: .04em;
  box-shadow: 0 8px 24px rgba(31, 157, 72, .35), inset 0 1px 0 rgba(255, 255, 255, .35); }
.logo.sm { width: 32px; height: 32px; border-radius: 9px; font-size: 11px; box-shadow: 0 2px 6px rgba(31, 157, 72, .35), inset 0 1px 0 rgba(255, 255, 255, .3); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 999px; background: var(--panel-2); font-size: 12.5px; font-weight: 500; color: var(--muted);
  white-space: nowrap; max-width: 220px; overflow: hidden; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .9; flex: none; }
.pill-k::after { content: ":"; }
.pill-v { overflow: hidden; text-overflow: ellipsis; }
.pill.ok { color: var(--ok); background: var(--accent-tint); }
.pill.ok::before { box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }
.pill.err { color: var(--err); background: color-mix(in srgb, var(--err) 12%, transparent); }
.pill.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--panel-2); border-radius: 8px; padding: 3px 9px; font-size: 12.5px; color: var(--text); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--accent); color: var(--accent-text); border: 0;
  border-radius: var(--radius-sm); padding: 9px 16px; font: 600 14px var(--font); cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: filter .15s, transform .1s, background .2s; box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.btn:hover { filter: brightness(1.06); text-decoration: none; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.sm { padding: 6px 12px; font-size: 13px; border-radius: 9px; }
.btn.ghost { background: var(--panel-2); color: var(--accent); box-shadow: none; }
.btn.ghost:hover { background: var(--panel-3); filter: none; }
.btn.danger { background: #ff3b30; color: #fff; }
.btn.discord { margin: 20px 0 8px; padding: 12px 22px; font-size: 15px; width: 100%; background: #5865f2; color: #fff; border-radius: 12px; }
.btn .ico { width: 18px; height: 18px; }

input, select, textarea { background: var(--panel-2); border: 1px solid transparent; color: var(--text); border-radius: var(--radius-sm); padding: 8px 12px;
  font: 14px var(--font); min-width: 0; transition: box-shadow .15s, border-color .15s, background .15s; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
input[type="number"] { width: 110px; }
input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; }
input:focus, select:focus, textarea:focus { outline: none; background: var(--panel); border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-tint); }
input[type="checkbox"] { accent-color: var(--accent-bright); width: 16px; height: 16px; }
label { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); font-size: 14px; }
label.check { cursor: pointer; color: var(--text); }
#send-text { width: 100%; font-family: var(--mono); }

/* ------------------------------------------------------------------ Tabellen */
.table-wrap { overflow: auto; max-height: 560px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); -webkit-overflow-scrolling: touch; }
.table-wrap.tall { max-height: 72vh; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
th { position: sticky; top: 0; z-index: 1; background: var(--glass); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; }
tbody tr { transition: background .12s; }
tbody tr:hover td { background: color-mix(in srgb, var(--accent-bright) 5%, transparent); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.pos { color: var(--ok); font-weight: 600; }
td.neg { color: var(--err); font-weight: 600; }
span.pos { color: var(--ok); font-weight: 600; }
span.neg { color: var(--err); font-weight: 600; }
td.wrap { white-space: pre-wrap; overflow-wrap: anywhere; max-width: 480px; color: var(--muted); font-size: 13px; }
td.nowrap { white-space: nowrap; }
.ok { color: var(--ok); }
.err { color: var(--err); }
.warnc { color: var(--warn); }
.empty { text-align: center; color: var(--muted); padding: 28px; }
.res { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; font-size: 12px; font-weight: 800; }
.res.ok { background: var(--accent-tint); }
.res.err { background: color-mix(in srgb, var(--err) 12%, transparent); }

/* ------------------------------------------------------------------ Chat */
.log { height: 65vh; overflow-y: auto; font: 13px/1.55 var(--mono); background: var(--panel-2); border-radius: 12px; padding: 12px 14px; overscroll-behavior: contain; }
.log .line { padding: 2px 0; overflow-wrap: anywhere; }
.log .t { color: var(--muted); margin-right: 10px; font-size: 12px; }
.log .system { color: #8e44ad; }
.log .whisper { color: #d6336c; }
@media (prefers-color-scheme: dark) { .log .system { color: #c9a7ff; } .log .whisper { color: #ff8fc1; } }

/* ------------------------------------------------------------------ Steuerung */
.dpad { display: grid; grid-template-columns: repeat(3, minmax(0, 130px)); gap: 8px; margin: 14px 0; }
.dpad .btn { padding: 12px 10px; }
.result { background: var(--panel-2); border-radius: 12px; padding: 12px 14px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 240px; overflow: auto; font: 12.5px var(--mono); }
.result.ok { box-shadow: inset 3px 0 0 var(--ok); }
.result.err { box-shadow: inset 3px 0 0 var(--err); }

/* iOS-Schalter */
.switch { position: relative; display: inline-block; width: 46px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--panel-3); border-radius: 999px; cursor: pointer; transition: background .25s; }
.switch span::before { content: ""; position: absolute; width: 24px; height: 24px; left: 2px; top: 2px; background: #fff; border-radius: 50%;
  box-shadow: 0 3px 8px rgba(0, 0, 0, .15), 0 1px 1px rgba(0, 0, 0, .16); transition: transform .25s cubic-bezier(.3, 1.3, .6, 1); }
.switch input:checked + span { background: var(--accent-bright); }
.switch input:checked + span::before { transform: translateX(18px); }
.switch input:focus-visible + span { box-shadow: 0 0 0 4px var(--accent-tint); }
.switch input:disabled + span { opacity: .5; cursor: not-allowed; }

.dl-buttons { margin: 16px 0 12px; }
.btn.disabled { opacity: .45; pointer-events: none; }
ol.steps { margin: 0; padding-left: 22px; display: grid; gap: 8px; }
ol.steps li::marker { color: var(--accent); font-weight: 700; }

/* Toast (Milchglas, unten mittig) */
.toast { position: fixed; bottom: calc(24px + var(--bottom-h)); left: calc(50% + var(--side-w) / 2); transform: translateX(-50%); width: max-content; max-width: min(460px, calc(100vw - 32px)); z-index: 60;
  background: var(--glass-strong); backdrop-filter: saturate(180%) blur(24px); -webkit-backdrop-filter: saturate(180%) blur(24px);
  color: var(--text); border-radius: 14px; padding: 12px 18px; box-shadow: var(--shadow-lg); font-weight: 500; border: 1px solid var(--line);
  animation: toast .35s cubic-bezier(.2, .9, .3, 1.2); }
.toast::before { content: "ℹ︎"; margin-right: 8px; color: var(--muted); }
.toast.ok::before { content: "✓"; color: var(--ok); font-weight: 700; }
.toast.err::before { content: "!"; color: #fff; background: var(--err); border-radius: 50%; display: inline-grid; place-items: center; width: 18px; height: 18px; font-size: 12px; font-weight: 800; }
@keyframes toast { from { opacity: 0; transform: translate(-50%, 12px) scale(.96); } to { opacity: 1; transform: translate(-50%, 0) scale(1); } }

/* Login */
.login h1 { margin-top: 18px; }
.login p { margin: 6px 0; }

/* Scrollbalken dezent */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 99px; border: 3px solid transparent; background-clip: content-box; }

/* =====================================================================
   Tablet (761–1279 px): Seitenleiste nur mit Icons
   ===================================================================== */
@media (max-width: 1279px) {
  :root { --side-w: 72px; --gutter: 20px; }
  .sidebar { padding: 12px 10px; align-items: center; }
  .brand { padding: 4px 0 8px; }
  .brand-txt, .nav .lbl, .side-name { display: none; }
  .nav { width: 100%; align-items: center; }
  .nav .nav-group { width: 28px; height: 1px; padding: 0; margin: 10px 0; background: var(--line-strong); font-size: 0; }
  .nav .nav-group:first-child { display: none; }
  .nav button { justify-content: center; width: 48px; height: 44px; padding: 0; }
  .nav button .ico { width: 22px; height: 22px; }
  .side-user { flex-direction: column; padding: 10px 0 0; gap: 6px; }
}

/* =====================================================================
   Handy (≤ 760 px): untere Tab-Leiste, Tabellen als Karten, größere Ziele
   ===================================================================== */
@media (max-width: 760px) {
  :root { --side-w: 0px; --top-h: 52px; --gutter: 12px; --bottom-h: calc(58px + var(--safe-b)); --sticky-top: calc(var(--top-h) + 10px); }
  .sidebar { display: none; }
  .main { margin-left: 0; }
  .topbar { gap: 10px; padding: 0 14px; }
  .topbar-logo { display: inline-grid !important; width: 28px; height: 28px; font-size: 9.5px; border-radius: 8px; }
  .topbar h1 { font-size: 18px; }
  .status { gap: 6px; }
  .pill { padding: 4px 9px; font-size: 12px; max-width: 120px; }
  #pill-mod .pill-v, #pill-world .pill-k { display: none; }
  #pill-mod .pill-k::after { content: none; }

  .bottombar { position: fixed; inset: auto 0 0 0; z-index: 30; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); height: var(--bottom-h);
    padding: 0 4px var(--safe-b); background: var(--glass); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-top: 1px solid var(--line); }
  .bottombar button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-width: 0; border: 0; background: none;
    color: var(--muted); font: 500 10.5px var(--font); cursor: pointer; padding: 6px 0 4px; }
  .bottombar button span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .bottombar button .ico { width: 24px; height: 24px; }
  .bottombar button.active { color: var(--accent); font-weight: 600; }

  .content { padding-top: 12px; }
  .card { padding: 16px 14px; border-radius: 14px; margin-bottom: 12px; }
  .grid { gap: 12px; margin-bottom: 12px; }
  .grid.cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 12px 14px; border-radius: 14px; }
  .stat .label { font-size: 11px; }
  .stat .value { font-size: 17px; }
  .stat .sub { font-size: 12px; }
  .stat.hero { grid-column: 1 / -1; }
  .stat.hero .value { font-size: 20px; }
  .stat:hover { transform: none; }

  /* iOS zoomt bei Schrift < 16 px in Eingabefeldern – daher 16 px */
  input, select, textarea { font-size: 16px; padding: 9px 12px; }
  input[type="checkbox"] { width: 20px; height: 20px; }
  .btn { padding: 11px 16px; }
  .btn.sm { padding: 9px 13px; font-size: 14px; }
  label.check { min-height: 36px; }
  .row.wrap > .grow { flex-basis: 100%; }
  .row.wrap > select { flex: 1 1 140px; }
  .row.between.wrap > .row.wrap { width: 100%; }
  .row.wrap > .btn { flex: 1 1 auto; }
  #form-connect .btn { width: 100%; }

  .table-wrap, .table-wrap.tall { max-height: none; border-radius: 12px; }
  .table-wrap.tall { max-height: 70vh; }
  th, td { padding: 9px 12px; }
  table { font-size: 14px; }
  td.wrap { max-width: none; }

  /* Spalten ausblenden, die am Handy nur Platz kosten */
  .t-tablist th:nth-child(n+3), .t-tablist td:nth-child(n+3) { display: none; }
  .t-members th:nth-child(1), .t-members td:nth-child(1), .t-members th:nth-child(3), .t-members td:nth-child(3), .t-members th:nth-child(6), .t-members td:nth-child(6) { display: none; }
  .t-members th, .t-members td { padding-left: 10px; padding-right: 10px; }
  .t-members td:nth-child(2) { overflow-wrap: anywhere; }
  .t-members th:nth-child(5) { white-space: normal; }

  /* Allgemeine Karten-Tabelle: jede Zeile eine Karte, Spaltenname links */
  table.responsive thead, table.cards-sm thead { display: none; }
  table.responsive, table.responsive tbody, table.responsive tr,
  table.cards-sm, table.cards-sm tbody, table.cards-sm tr { display: block; width: 100%; }
  table.responsive tr { padding: 10px 14px; border-bottom: 1px solid var(--line); }
  table.responsive tr:last-child { border-bottom: 0; }
  table.responsive td { display: block; padding: 4px 0; border: 0; text-align: left; max-width: none; }
  table.responsive td::before { content: attr(data-label); display: block; color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; line-height: 1.6; }
  table.responsive td[data-label=""] { display: block; padding-top: 8px; }
  table.responsive td[data-label=""]::before { content: none; }
  table.responsive td.empty, table.cards-sm td.empty { display: block; padding: 24px 0; text-align: center; }
  table.responsive td.empty::before { content: none; }
  table.responsive tbody tr:hover td, table.cards-sm tbody tr:hover td { background: none; }

  /* Kontoauszug: Spieler + Betrag oben, Aktion und Datum darunter */
  table.cards-sm tr { display: grid; gap: 2px 12px; padding: 11px 14px; border-bottom: 1px solid var(--line); }
  table.cards-sm tr:last-child { border-bottom: 0; }
  table.cards-sm td { display: block; padding: 0; border: 0; max-width: none; text-align: left; }
  .t-bank tr { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "player amount" "action date"; }
  .t-bank .c-date { grid-area: date; text-align: right; color: var(--muted); font-size: 12.5px; }
  .t-bank .c-player { grid-area: player; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
  .t-bank .c-action { grid-area: action; color: var(--muted); font-size: 13px; }
  .t-bank .c-amount { grid-area: amount; text-align: right; font-size: 16px; }
  .t-bank .c-raw { display: none; }
  /* Aktions-Log: Ergebnis + Aktion oben, Quelle/Schritt + Zeit darunter, Details unten */
  .t-actions tr { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "res type time" "res meta meta" "res detail detail"; }
  .t-actions .c-res { grid-area: res; padding-top: 1px; }
  .t-actions .c-type { grid-area: type; font-weight: 600; overflow-wrap: anywhere; }
  .t-actions .c-time { grid-area: time; color: var(--muted); font-size: 12.5px; }
  .t-actions .c-source { grid-area: meta; color: var(--muted); font-size: 13px; }
  .t-actions .c-stage { display: none; }
  .t-actions .c-detail { grid-area: detail; font-size: 12.5px; }
  .t-actions .c-detail:empty { display: none; }

  /* Module: Name + Schalter oben, Status/Art/Auslöser als Zeile, dann letzter Lauf und Fehler */
  .t-modules tr { grid-template-columns: auto auto minmax(0, 1fr) auto; grid-template-areas: "name name name toggle" "status kind trigger trigger" "last last last last" "error error error error" "run run run run"; gap: 6px 10px; }
  .t-modules .c-toggle { grid-area: toggle; }
  .t-modules .c-name { grid-area: name; min-width: 0; overflow-wrap: anywhere; }
  .t-modules .c-status { grid-area: status; font-weight: 600; font-size: 13px; }
  .t-modules .c-kind { grid-area: kind; }
  .t-modules .c-trigger { grid-area: trigger; font-size: 13px; align-self: center; }
  .t-modules .c-last { grid-area: last; font-size: 13px; white-space: normal; }
  .t-modules .c-last-l { display: inline; color: var(--muted); }
  .t-modules .c-error { grid-area: error; font-size: 12.5px; }
  .t-modules .c-error.none { display: none; }
  .t-modules .c-run { grid-area: run; }
  .t-modules .c-run:empty { display: none; }
  .t-modules .c-run .btn { width: 100%; }

  .log { height: calc(100vh - 290px); height: calc(100dvh - var(--top-h) - var(--bottom-h) - 230px); min-height: 280px; padding: 10px 12px; font-size: 12.5px; }
  .dpad { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dpad .btn { padding: 14px 6px; }
  .toast { left: 50%; }
  h2 { font-size: 16px; }
}
@media (max-width: 380px) {
  .grid.cards { grid-template-columns: minmax(0, 1fr); }
  .stat.hero { grid-column: auto; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
.c-stage-inline { display: none; }
@media (max-width: 760px) { .t-actions .c-stage-inline { display: inline; } }
.tag { display: inline-block; padding: 1px 8px; border-radius: 6px; background: var(--panel-2); font-size: 12.5px; font-weight: 500; }
.c-last-l { display: none; }

/* ------------------------------------------------------------------ Fehler-Log */
.nav-badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--err); color: #fff;
  font-size: 11.5px; font-weight: 700; display: inline-grid; place-items: center; font-variant-numeric: tabular-nums; }
.nav-badge[hidden] { display: none; }
.err-toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.err-toolbar select { flex: 0 1 200px; }
.err-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; margin: 12px 0; }
.err-btns { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.err-list { display: grid; gap: 6px; }
.err-item { border: 1px solid var(--line); border-radius: 12px; background: var(--panel); overflow: hidden; }
.err-item[open] { box-shadow: var(--shadow); }
.err-item summary { display: flex; align-items: center; gap: 10px; padding: 10px 12px; cursor: pointer; list-style: none; min-width: 0; }
.err-item summary::-webkit-details-marker { display: none; }
.err-item summary:hover { background: var(--panel-2); }
.err-lvl { flex: none; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 3px 7px; border-radius: 6px; }
.lvl-error .err-lvl { color: var(--err); background: color-mix(in srgb, var(--err) 13%, transparent); }
.lvl-warn .err-lvl { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }
.lvl-error { border-left: 3px solid var(--err); }
.lvl-warn { border-left: 3px solid var(--warn); }
.err-main { display: grid; min-width: 0; flex: 1; }
.err-scope { font-size: 12px; color: var(--muted); font-weight: 600; }
.err-msg { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.err-item[open] .err-msg { white-space: normal; overflow-wrap: anywhere; }
.err-n { flex: none; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--panel-2); font-variant-numeric: tabular-nums; }
.err-when { flex: none; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.err-body { display: grid; gap: 8px; padding: 4px 12px 12px; justify-items: start; }
.err-pre { width: 100%; margin: 0; max-height: 360px; overflow: auto; background: var(--panel-2); border-radius: 10px; padding: 10px 12px; font: 12px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.err-hint { margin: 14px 0 0; }
.offscreen { position: fixed; left: -9999px; top: 0; opacity: 0; }
@media (max-width: 1279px) { .nav .nav-badge { position: absolute; top: 2px; right: 6px; margin: 0; } .nav button { position: relative; } }
@media (max-width: 760px) {
  .err-toolbar select { flex: 1 1 45%; }
  .err-when { display: none; }
  .err-item summary { padding: 10px; gap: 8px; }
}

/* ------------------------------------------------------------------ Verknüpfungen + Zugänge */
body:not(.is-admin) [data-admin] { display: none !important; }
.m-link { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text); white-space: nowrap; margin-right: 6px; }
.m-link.inline { display: none; margin-top: 2px; font-size: 12px; color: var(--muted); white-space: normal; }
.c-link { white-space: nowrap; }
.portal-badge { font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 2px 6px; border-radius: 6px; background: var(--panel-2); color: var(--muted); flex: none; }
.portal-badge.user { background: var(--accent-tint); color: var(--accent); }
.portal-badge.admin { background: color-mix(in srgb, #0a84ff 15%, transparent); color: #0a6cd8; }
.portal-badge.owner { background: color-mix(in srgb, var(--gold) 18%, transparent); color: var(--gold); }
@media (prefers-color-scheme: dark) { .portal-badge.admin { color: #64b0ff; } }
.access-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.access-form select, .access-form input { flex: 1 1 200px; }
.access-form #access-role { flex: 0 1 130px; }
.access-preview { display: flex; align-items: center; gap: 10px; margin-top: 10px; padding: 8px 12px; background: var(--panel-2); border-radius: 10px; }
.access-list { display: grid; gap: 6px; }
.acc-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; min-width: 0; }
.acc-ava { width: 36px; height: 36px; border-radius: 50%; flex: none; object-fit: cover; }
.acc-ava.letter { display: inline-grid; place-items: center; background: var(--panel-3); color: var(--muted); font-weight: 700; }
.acc-main { display: grid; min-width: 0; flex: 1; }
.acc-main b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-main .small { overflow-wrap: anywhere; }
.acc-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.danger-text { color: var(--err) !important; }
@media (max-width: 760px) {
  .m-link.inline { display: flex; flex-wrap: wrap; overflow-wrap: normal; word-break: normal; }
  .acc-row { flex-wrap: wrap; }
  .acc-actions { width: 100%; justify-content: flex-start; }
  .access-form #access-role, .access-form .btn { flex: 1 1 45%; }
}

/* ------------------------------------------------------------------ Web-App installieren */
.install-banner { display: flex; align-items: center; gap: 12px; padding: 10px 8px 10px 12px; margin-bottom: 12px;
  background: var(--panel); border-radius: 14px; box-shadow: var(--shadow); }
.install-banner[hidden] { display: none; }
.install-banner img { width: 40px; height: 40px; border-radius: 10px; flex: none; }
.install-banner .ib-txt { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.3; }
.install-banner .ib-txt span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.install-banner .btn { flex: none; }
.app-card { display: flex; align-items: flex-start; gap: 16px; }
.app-card > img { width: 56px; height: 56px; border-radius: 14px; flex: none; }
.app-card-txt { flex: 1; min-width: 0; }
.app-card-txt h2 { margin-top: 0; }
.app-steps { margin-top: 10px !important; }
.app-steps:empty { display: none; }
.app-card > .btn { flex: none; align-self: center; }
@media (max-width: 760px) {
  .app-card { flex-wrap: wrap; }
  .app-card > img { width: 44px; height: 44px; border-radius: 11px; }
  .app-card-txt { flex-basis: calc(100% - 60px); }
  .app-card > .btn { width: 100%; }
}
/* Installierte App: Statusleiste/Notch oben berücksichtigen */
@media (display-mode: standalone) {
  .topbar { padding-top: env(safe-area-inset-top, 0px); height: calc(var(--top-h) + env(safe-area-inset-top, 0px)); }
}
