/* trainedup. Wallet – Look des bisherigen Wallets (#292929 / #81FE58), mobile first. White Label: Farben nur über die Tokens in :root */
:root {
  --bg: #292929; --surface: #333333; --surface-2: #3a3a3a; --line: #444444;
  --text: #F3F4F6; --muted: #aaaaaa; --soft: #e0e0e0;
  --accent: #81FE58; --accent-hover: #9dff7e; --on-accent: #292929;
  --ok: #66bb6a; --warn: #ffb74d; --danger: #ff6b6b; --info: #64b5f6;
  /* Fälligkeits-Ampel (App\Support\StatusTone): violett ≤ 1 Monat, blau ≤ 2 Monate */
  --soon: #b388ff; --due: #64b5f6;
  /* abgeleitete Farben – White Label setzt alle Tokens über App\Support\WalletTheme (gleiche Namen) */
  --head-bg: rgba(41,41,41,.96); --line-hover: #666; --hover: rgba(255,255,255,.08); --focus-ring: rgba(129,254,88,.2); --camera-frame: rgba(129,254,88,.7);
  --on-danger: #fff; --on-warn: #222;
  --ok-bg: rgba(76,175,80,.15); --ok-border: rgba(76,175,80,.3); --ok-text: #a5d6a7;
  --warn-bg: rgba(255,183,77,.12); --warn-border: rgba(255,183,77,.35); --warn-text: #ffcc80;
  --danger-bg: rgba(255,76,76,.15); --danger-border: rgba(255,76,76,.3); --danger-text: #ff8a8a; --danger-soft: #ffb3b3;
  --info-bg: rgba(100,181,246,.12); --info-border: rgba(100,181,246,.35); --info-text: #90caf9;
  --radius: 8px; --radius-lg: 14px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 16px; line-height: 1.5; min-height: 100vh; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; line-height: 1.25; }
img, svg { max-width: 100%; }
.wrap { max-width: 800px; margin: 0 auto; padding: 0 15px 96px; }
.hidden, [hidden] { display: none !important; }

/* Kopfzeile */
.w-head { position: sticky; top: 0; z-index: 10; background: var(--head-bg); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); }
.w-head .in { max-width: 800px; margin: 0 auto; padding: 12px 15px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.w-head .logo img { height: 30px; width: auto; display: block; }
.w-head .tenant { font-size: 12px; color: var(--muted); }
/* ohne Anmeldung fehlt das Profil-Symbol rechts: Logo mittig, Sprachwahl (falls vorhanden) bleibt rechts */
.w-head.is-guest .in { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); }
.w-head.is-guest .logo { grid-column: 2; }
.w-head.is-guest .lang-switch { grid-column: 3; justify-self: end; justify-content: flex-end; margin: 0; }
.avatar { position: relative; }
.avatar > button { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font-weight: 700; cursor: pointer; font: inherit; font-weight: 700; }
.avatar > button:hover, .avatar > button[aria-expanded="true"] { border-color: var(--accent); }
.avatar .menu { position: absolute; right: 0; top: 48px; min-width: 230px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 10px 30px rgba(0,0,0,.35); padding: 8px; }
.avatar .menu .who { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; font-size: 14px; }
.avatar .menu .who small { display: block; color: var(--muted); }
.avatar .menu a, .avatar .menu button { display: block; width: 100%; text-align: left; padding: 9px 10px; border-radius: 6px; color: var(--text); text-decoration: none; background: none; border: 0; font: inherit; font-size: 15px; cursor: pointer; }
.avatar .menu a:hover, .avatar .menu button:hover { background: var(--surface-2); }
.avatar .menu .logout { color: var(--danger); }

/* Tabs */
.tabs { display: flex; gap: 4px; margin: 16px 0; border-bottom: 1px solid var(--line); }
.tabs a { padding: 10px 14px; color: var(--muted); text-decoration: none; font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }
.tabs .count { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 6px; border-radius: 99px; background: var(--danger); color: var(--on-danger); font-size: 12px; text-align: center; }

/* Karten */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px; margin-bottom: 12px; }
.card h3 { font-size: 17px; }
.card .meta { color: var(--muted); font-size: 14px; margin-top: 4px; }
.card.history { opacity: .7; }
.cert { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: start; }
.cert .qr { width: 96px; height: 96px; background: #fff; border-radius: 8px; padding: 4px; }
.cert .qr img { display: block; width: 100%; height: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.state { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; margin-top: 6px; }
.state::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.state.valid::before { background: var(--ok); } .state.expiring::before, .state.submitted::before { background: var(--warn); }
.state.expired::before, .state.overdue::before, .state.rejected::before, .state.revoked::before { background: var(--danger); }
.state.info::before { background: var(--info); }
.state.ok::before { background: var(--ok); } .state.soon::before { background: var(--soon); } .state.due::before { background: var(--due); }
.state.danger::before { background: var(--danger); } .state.warn::before { background: var(--warn); } .state.neutral::before, .state.muted::before { background: var(--muted); }
.folder-title { margin: 20px 0 8px; font-size: 13px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.req .note { margin-top: 8px; padding: 8px 10px; border-radius: 6px; background: var(--danger-bg); border: 1px solid var(--danger-border); color: var(--danger-soft); font-size: 14px; }
.empty { text-align: center; color: var(--muted); padding: 32px 12px; }

/* Buttons & Formulare */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 16px; border-radius: 4px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn:hover { border-color: var(--line-hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.btn.danger { color: var(--danger); }
.btn.block { width: 100%; }
.btn svg { width: 18px; height: 18px; }
.field { margin-bottom: 14px; }
.field label { display: block; margin-bottom: 6px; font-size: 14px; font-weight: 600; color: var(--soft); }
.field input, .field select, .field textarea { width: 100%; padding: 12px; font-size: 16px; border-radius: 4px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font-family: inherit; }
.field input:focus, .field select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus-ring); }
.field .hint { font-size: 13px; color: var(--muted); margin-top: 4px; }
.field .error { font-size: 13px; color: var(--danger-text); margin-top: 4px; }
.field.has-error input { border-color: var(--danger); }
.pin-input { letter-spacing: .5em; text-align: center; font-size: 24px !important; font-weight: 700; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; margin: 10px 0; }
.check input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--accent); flex: 0 0 auto; }
.flash { padding: 12px 14px; border-radius: 6px; margin: 12px 0; font-size: 15px; border: 1px solid; }
.flash.success { background: var(--ok-bg); border-color: var(--ok-border); color: var(--ok-text); }
.flash.error { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger-text); }
.flash.warning { background: var(--warn-bg); border-color: var(--warn-border); color: var(--warn-text); }
.flash.info { background: var(--info-bg); border-color: var(--info-border); color: var(--info-text); }

/* Login */
.login { max-width: 420px; margin: 32px auto 0; }
.login .brand { text-align: center; margin-bottom: 24px; }
.login .brand img { height: 44px; }
.login .brand p { color: var(--muted); margin: 10px 0 0; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: var(--surface); border-radius: 8px; margin-bottom: 16px; }
.seg a { text-align: center; padding: 10px; border-radius: 6px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: 15px; }
.seg a[aria-current="page"] { background: var(--surface-2); color: var(--text); }
.links { text-align: center; margin-top: 16px; font-size: 14px; }
.links a { color: var(--muted); }

/* Kamera */
.camera { position: relative; background: #000; border-radius: var(--radius-lg); overflow: hidden; aspect-ratio: 3 / 4; display: flex; align-items: center; justify-content: center; }
.camera video, .camera img, .camera canvas { width: 100%; height: 100%; object-fit: contain; display: block; }
.camera .frame { position: absolute; inset: 8%; border: 2px dashed var(--camera-frame); border-radius: 12px; pointer-events: none; }
.camera .msg { position: absolute; inset: auto 0 0 0; padding: 12px; background: rgba(0,0,0,.6); color: #f3f4f6; font-size: 14px; text-align: center; }
/* uploads (no live camera): compact box with the hint until a preview exists, so the pick buttons stay in view */
.camera.idle { aspect-ratio: auto; background: var(--surface-2); }
.camera.idle .msg { position: static; background: none; color: var(--text); }
.shutter { width: 72px; height: 72px; border-radius: 50%; border: 4px solid var(--accent); background: #fff; cursor: pointer; margin: 16px auto 0; display: block; }
.shutter:disabled { opacity: .4; }

/* Teilen-Dialog */
dialog.sheet { border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); color: var(--text); padding: 20px; width: min(420px, calc(100vw - 30px)); }
dialog.sheet::backdrop { background: rgba(0,0,0,.6); }
/* Rückfrage- und Hinweisfenster (layouts/wallet.php, WalletDialog in wallet.js) statt window.confirm()/alert() */
dialog.confirm-sheet h3 { margin: 0 0 8px; }
dialog.confirm-sheet .meta { margin: 0; overflow-wrap: anywhere; }
dialog.confirm-sheet .actions { margin-top: 18px; }
dialog.confirm-sheet .actions .btn { flex: 1 1 140px; }
.btn.danger-solid { background: var(--danger); border-color: var(--danger); color: var(--on-danger); }
dialog.sheet .url { word-break: break-all; padding: 10px; border-radius: 6px; background: var(--surface-2); font-size: 14px; margin: 10px 0; }

/* Installationshinweis, Offline-Banner, Fuß */
.install { position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 20; display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--accent); box-shadow: 0 10px 30px rgba(0,0,0,.4); font-size: 14px; }
.install p { margin: 0; flex: 1; }
.offline-banner { background: var(--warn); color: var(--on-warn); text-align: center; font-size: 14px; font-weight: 600; padding: 6px; }
.w-foot { text-align: center; font-size: 13px; color: var(--muted); padding: 24px 15px; }
.w-foot a { color: var(--muted); margin: 0 8px; }
.share-page { max-width: 520px; margin: 32px auto; }
.big-state { font-size: 22px; font-weight: 700; margin: 12px 0; }
.demo-bar { background: var(--accent); color: var(--on-accent); text-align: center; font-size: 14px; padding: 6px 12px; }
.demo-bar a { color: var(--on-accent); font-weight: 700; margin-left: 8px; }

.w-head .lang-switch { display: flex; flex-wrap: wrap; margin: 0 0 0 auto; gap: 4px 10px; font-size: .85rem; }
.w-head .lang-switch a { color: inherit; opacity: .75; text-decoration: none; }
.w-head .lang-switch a[aria-current] { opacity: 1; font-weight: 600; text-decoration: underline; }

/* Rückmeldungen als Toast (partials/flash.php + wallet.js): unten rechts, Smartphone unten volle Breite, über dem
   Installationshinweis; schwebend mit deckendem Grund (die Inline-Farben oben sind halbtransparent) */
.flash .flash-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.flash-stack.is-toast { position: fixed; right: 20px; bottom: 20px; z-index: 30; display: flex; flex-direction: column; gap: 10px; width: min(420px, calc(100vw - 40px)); pointer-events: none; }
.flash-stack.is-toast .flash { pointer-events: auto; margin: 0; display: flex; align-items: center; gap: 10px; background: var(--surface-2); color: var(--text); border: 1px solid var(--line); border-left: 4px solid var(--info); box-shadow: 0 12px 32px rgba(0, 0, 0, .45); animation: toast-in .22s ease-out; }
.flash-stack.is-toast .flash.success { border-left-color: var(--ok); }
.flash-stack.is-toast .flash.error { border-left-color: var(--danger); }
.flash-stack.is-toast .flash.warning { border-left-color: var(--warn); }
.flash-close { flex: 0 0 auto; width: 32px; height: 32px; margin: -6px -8px -6px 0; display: grid; place-items: center; border: 0; border-radius: var(--radius); background: transparent; color: var(--muted); font-size: 22px; line-height: 1; cursor: pointer; }
.flash-close:hover { background: var(--hover); color: var(--text); }
.flash-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.flash.is-leaving { opacity: 0; transform: translateY(8px); transition: opacity .2s ease, transform .2s ease; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (max-width: 600px) { .flash-stack.is-toast { left: 12px; right: 12px; bottom: 12px; width: auto; } }
body:has(.install:not([hidden])) .flash-stack.is-toast { bottom: 96px; }
@media (prefers-reduced-motion: reduce) { .flash-stack.is-toast .flash { animation: none; } .flash.is-leaving { transition: none; } }


/* White Label: Logo des Mandanten im Kopf (beliebiges Seitenverhältnis), neutrales Wallet-Symbol auf der Anmeldung */
.w-head .logo.is-tenant img { height: 36px; width: auto; max-width: min(220px, 60vw); object-fit: contain; }
.wallet-symbol { display: block; margin: 0 auto; width: 72px; height: 72px; }
.wallet-symbol .ws-back { fill: var(--muted); } .wallet-symbol .ws-doc { fill: var(--accent); }
.wallet-symbol .ws-line { fill: var(--bg); } .wallet-symbol .ws-front { fill: var(--text); }

/* Jahresfilter + Sortierung der Listen (wallet/_list_tools.php, wallet.js) */
.list-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin: 4px 0 12px; }
.list-tools .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.list-tools .chip { min-height: 32px; padding: 4px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.list-tools .chip[aria-pressed="true"] { background: var(--surface-2); color: var(--text); border-color: var(--line-hover); }
.list-tools .sort { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.list-tools .sort select { min-height: 32px; padding: 4px 8px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-size: 14px; }
.list-tools [data-list-empty] { flex-basis: 100%; margin: 0; }
