/* Korkly Admin – gemeinsames Layout für Kunden-Admin und Super-Admin („Kellerfenster“).
   Dunkler Rahmen mit Logo und Navigation, die Arbeitsfläche liegt als helles Blatt darin.
   Gestaltet wird nur über die Variablen unten; Themes setzen andere Werte. */

@font-face { font-family: 'Inter'; src: url('inter-var.woff') format('woff'); font-weight: 400 700; font-style: normal; font-display: swap; }
@font-face { font-family: 'Unbounded'; src: url('unbounded-600.woff') format('woff'); font-weight: 600; font-style: normal; font-display: swap; }

:root {
  /* Marke */
  --brand: #0f1a17;          /* Rahmen, Primärbuttons */
  --brand-2: #17241f;        /* Flächen im Rahmen */
  --brand-line: #2e3b35;     /* Linien im Rahmen */
  --on-brand: #f2ede4;       /* Text im Rahmen */
  --on-brand-muted: #bdb7ab;
  --gold: #e8b86d;
  --gold-soft: #f3e6c9;

  /* Arbeitsfläche */
  --bg: #faf8f3;
  --surface: #ffffff;
  --text: #1a211e;
  --muted: #67665f;
  --border: #e2dbcf;
  --line: #f0ebe2;
  --focus: var(--brand);

  /* Status */
  --success: #1e5e36;  --success-bg: #e2efe5;
  --warning: #6e4500;  --warning-bg: var(--gold-soft);
  --danger: #8a1f33;   --danger-bg: #f5e1e3;
  --info: #1d4f7a;     --info-bg: #e3edf6;
  --online: #7cc48e;
  --env: var(--gold);

  /* Form */
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Unbounded', var(--font);
  --radius-sm: 10px;
  --radius: 18px;
  --radius-lg: 24px;
  --rail: 96px;
  --tabbar: 4.25rem;
  --content: 1100px;
}
.theme-staging { --env: #9fd4c9; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--brand); }
body { margin: 0; font: 400 1rem/1.5 var(--font); color: var(--text); background: var(--brand); }
a { color: var(--text); text-underline-offset: .2em; }
a:hover { color: var(--brand); }
h1, h2 { font-family: var(--font-display); font-weight: 600; margin: 0; color: var(--brand); }
h1 { font-size: 2rem; line-height: 1.15; letter-spacing: -.03em; }
h2 { font-size: 1.05rem; line-height: 1.3; letter-spacing: -.01em; }
p { margin: 0 0 .75rem; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: .75rem; z-index: 30; padding: .5rem 1rem; border-radius: var(--radius-sm); background: var(--gold); color: var(--brand); font-weight: 600; }
.skip:focus { left: .75rem; }
code { background: var(--line); padding: .1rem .35rem; border-radius: 4px; font-size: .9em; word-break: break-all; }
.icon { width: 1.25rem; height: 1.25rem; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.logo { display: block; height: 2.1rem; width: auto; fill: currentColor; }
.logo__y { fill: var(--gold); }

/* Rahmen ------------------------------------------------------------------------------ */
.banner { background: var(--gold); color: var(--brand); padding: .6rem 1rem; text-align: center; font-weight: 600; }
.banner form { display: inline; margin-left: .75rem; }
.app { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); grid-template-rows: auto 1fr; min-height: 100vh; min-height: 100dvh; padding: 0 .75rem .75rem 0; }

.topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: .75rem 1.25rem; padding: .875rem 1rem .875rem 1.5rem; color: var(--on-brand); --focus: var(--gold); }
.topbar a { color: inherit; text-decoration: none; }
.context { display: inline-flex; align-items: center; gap: .5rem; min-height: 2.5rem; padding: 0 1rem; border: 1px solid var(--brand-line); border-radius: 999px; background: var(--brand-2); font-size: .875rem; font-weight: 600; white-space: nowrap; }
.context::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: var(--online); }
.env { padding: .15rem .6rem; border-radius: 999px; background: var(--env); color: var(--brand); font-size: .75rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.spacer { flex: 1; }
.topbar .topbar__link { display: inline-flex; align-items: center; gap: .35rem; color: var(--gold); font-size: .875rem; }
.topbar__link .icon { width: 1rem; height: 1rem; }
.usermenu { display: flex; align-items: center; gap: .75rem; }
.user { display: flex; align-items: center; gap: .75rem; }
.user__text { display: flex; flex-direction: column; line-height: 1.2; text-align: right; font-size: .9rem; }
.user__text small { color: var(--on-brand-muted); font-size: .78rem; }
.avatar { display: grid; place-items: center; width: 2.5rem; height: 2.5rem; border-radius: 50%; background: var(--gold); color: var(--brand); font-size: .8rem; font-weight: 700; }
.topbar .btn--ghost { color: var(--on-brand); border-color: var(--brand-line); }
.topbar .btn--ghost:hover { background: var(--brand-2); }

/* Navigation: Icon-Leiste (Desktop), Tab-Leiste mit „Mehr“ (Mobil) */
.rail { padding: .25rem .5rem 1rem .625rem; --focus: var(--gold); }
.rail ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .25rem; }
.rail a, .rail summary { display: flex; flex-direction: column; align-items: center; gap: .3rem; padding: .5rem .25rem; border-radius: 14px; color: var(--on-brand-muted); font-size: .72rem; line-height: 1.2; text-align: center; text-decoration: none; cursor: pointer; }
.rail a:hover, .rail summary:hover { color: var(--on-brand); }
.rail__icon { display: grid; place-items: center; width: 2.75rem; height: 2.25rem; border-radius: 12px; transition: background-color .15s; }
.rail a:hover .rail__icon, .rail summary:hover .rail__icon { background: var(--brand-2); }
.rail a[aria-current="page"], .rail__more--active > summary { color: var(--gold); font-weight: 600; }
.rail a[aria-current="page"] .rail__icon, .rail__more--active > summary .rail__icon { background: var(--gold); color: var(--brand); }
.rail__more { display: none; }
.rail__more summary { list-style: none; }
.rail__more summary::-webkit-details-marker { display: none; }

.sheet { min-width: 0; background: var(--bg); border-radius: var(--radius-lg); padding: 2rem 2.5rem 2.75rem; }
.sheet > * { max-width: var(--content); }

/* Seitenkopf, Karten, Raster -------------------------------------------------------- */
.page-header { margin-bottom: 1.5rem; }
.page-header__row { display: flex; gap: 1rem; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; }
.page-header p { margin: .35rem 0 0; }
.page-header .back { display: inline-block; margin-bottom: .5rem; font-size: .9rem; color: var(--muted); text-decoration: none; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.card { background: var(--surface); border: 1px solid transparent; border-radius: var(--radius); padding: 1.25rem 1.4rem; margin-bottom: 1rem; }
.card--danger { border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.card--warning { border-color: color-mix(in srgb, var(--warning) 30%, transparent); }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 2.25rem; margin-bottom: .75rem; flex-wrap: wrap; }
.card__head .btn { min-height: 2.25rem; padding: .25rem .85rem; font-size: .85rem; }
.grid { display: grid; gap: 1rem; margin-bottom: 1rem; }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid > .card { margin-bottom: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat { display: flex; flex-direction: column; gap: 1rem; padding: 1.35rem 1.4rem; background: var(--surface); border: 1px solid transparent; border-radius: var(--radius); color: var(--text); text-decoration: none; }
.stat__label { color: var(--muted); font-size: .9rem; }
.stat__value { font-family: var(--font-display); font-size: 2.25rem; font-weight: 600; line-height: 1; letter-spacing: -.02em; color: var(--brand); }
.stat--danger .stat__value { color: var(--danger); }
.stat--success .stat__value { color: var(--success); }
.stat--warning .stat__value { color: var(--warning); }
.stat--featured { background: var(--brand); }
.stat--featured .stat__label { color: var(--on-brand-muted); }
.stat--featured .stat__value { color: var(--gold); }
a.stat:hover { border-color: var(--gold); color: inherit; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: .45rem 1.25rem; margin: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; overflow-wrap: anywhere; }
.empty { text-align: center; padding: 2rem 1rem; }
.empty__title { font-weight: 600; font-size: 1.05rem; }

/* Tabellen ----------------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: .75rem .5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table th { font-size: .8rem; color: var(--muted); font-weight: 600; }
.table .num { text-align: right; white-space: nowrap; }
.table .actions-col { text-align: right; white-space: nowrap; }
.table .thumb { width: 44px; height: 44px; object-fit: cover; border-radius: var(--radius-sm); display: block; background: var(--line); }
.pagination { display: flex; justify-content: space-between; align-items: center; margin-top: 1rem; }

/* Badges & Hinweise -------------------------------------------------------------------- */
.badge { display: inline-block; padding: .15rem .6rem; border-radius: 999px; font-size: .8rem; font-weight: 600; background: var(--line); color: var(--text); white-space: nowrap; }
.badge--success { background: var(--success-bg); color: var(--success); }
.badge--warning { background: var(--warning-bg); color: var(--warning); }
.badge--danger { background: var(--danger-bg); color: var(--danger); }
.badge--info { background: var(--info-bg); color: var(--info); }
.notice { border-radius: 14px; padding: .85rem 1.1rem; margin-bottom: 1rem; background: var(--surface); }
.notice ul { margin: .25rem 0 0 1.2rem; padding: 0; }
.notice a { font-weight: 600; }
.notice--info { background: var(--info-bg); color: var(--info); }
.notice--success { background: var(--success-bg); color: var(--success); }
.notice--warning { background: var(--warning-bg); color: var(--warning); }
.notice--danger { background: var(--danger-bg); color: var(--danger); }
.notice--info a, .notice--success a, .notice--warning a, .notice--danger a { color: inherit; }

/* Buttons ------------------------------------------------------------------------------ */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 2.75rem; padding: .5rem 1.1rem; border-radius: 12px; border: 1px solid transparent; font: inherit; font-size: .95rem; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap; transition: background-color .15s, border-color .15s; }
.btn .icon { width: 1.1rem; height: 1.1rem; }
.btn--primary { background: var(--brand); color: var(--gold); }
.btn--primary:hover { background: var(--brand-2); color: var(--gold); }
.btn--secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn--secondary:hover { border-color: var(--brand); }
.btn--danger { background: var(--surface); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.btn--danger:hover { background: var(--danger-bg); color: var(--danger); }
.btn--ghost { background: transparent; color: inherit; border-color: var(--border); }
.btn--ghost:hover { border-color: var(--brand); }
form.inline { display: inline; }

/* Formulare ---------------------------------------------------------------------------- */
.form { max-width: 720px; }
.field { margin-bottom: 1rem; }
.field > label { display: block; font-weight: 600; margin-bottom: .35rem; }
.field input:not([type="checkbox"]), .field select, .field textarea, .filterbar input, .filterbar select, .copybox input {
  width: 100%; min-height: 2.75rem; padding: .55rem .75rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); font: inherit; color: inherit;
}
.field textarea { min-height: 6rem; resize: vertical; }
.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible, .filterbar input:focus-visible { border-color: var(--brand); }
.field--error input, .field--error select, .field--error textarea { border-color: var(--danger); }
.field .hint { color: var(--muted); font-size: .88rem; margin: .35rem 0 0; }
.field .error { color: var(--danger); font-size: .9rem; margin: .35rem 0 0; font-weight: 600; }
.field--check { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.field--check input { width: 1.2rem; height: 1.2rem; accent-color: var(--brand); }
.field--check label { font-weight: 500; margin: 0; }
.field--check .hint, .field--check .error { flex-basis: 100%; }
.req { color: var(--danger); }
.preview { display: block; max-width: 180px; max-height: 180px; border-radius: var(--radius-sm); margin-bottom: .5rem; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0 1rem; }
.fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: .85rem 1.1rem 0; margin: 0 0 1rem; background: var(--surface); }
.fieldset legend { font-weight: 700; padding: 0 .35rem; }
.form__actions { display: flex; gap: .5rem; margin-top: 1.25rem; flex-wrap: wrap; }
.filterbar { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.filterbar input { flex: 1 1 220px; width: auto; }
.filterbar select { width: auto; }
.copybox { display: flex; gap: .5rem; }
.copybox input { font-family: ui-monospace, monospace; font-size: .85rem; }
.totp-setup { display: grid; grid-template-columns: auto 1fr; gap: 1.5rem; align-items: start; margin-bottom: 1rem; }
.totp-setup ol { margin-top: 0; padding-left: 1.2rem; }
.qr { display: block; width: 220px; max-width: 100%; height: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; }
.codes { columns: 2; font-family: ui-monospace, monospace; padding-left: 1.2rem; }
pre.log { background: var(--brand); color: var(--on-brand); padding: 1rem; border-radius: var(--radius-sm); overflow: auto; font-size: .82rem; line-height: 1.45; max-height: 60vh; }

/* Login & Co. -------------------------------------------------------------------------- */
body.auth { display: grid; place-items: center; min-height: 100vh; min-height: 100dvh; padding: 1.5rem 1rem; }
.auth__inner { width: 100%; max-width: 26rem; display: flex; flex-direction: column; align-items: center; gap: 1.5rem; }
.auth__brand { display: flex; align-items: center; gap: .75rem; color: var(--on-brand); }
.auth__brand .logo { height: 2.6rem; }
.auth-box { width: 100%; background: var(--bg); border-radius: var(--radius-lg); padding: 2rem; }
.auth-box__app { color: var(--muted); font-size: .9rem; margin-bottom: .35rem; }
.auth-box h1 { font-size: 1.5rem; margin-bottom: 1.25rem; }
.auth-box .btn--primary { width: 100%; }

/* Mobil: Tab-Leiste unten, Blatt fast randlos ------------------------------------------- */
@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); padding: 0 .5rem calc(var(--tabbar) + env(safe-area-inset-bottom)); }
  .topbar { gap: .5rem; padding: .75rem .5rem .625rem; }
  .logo { height: 1.75rem; }
  .context { min-height: 2.25rem; padding: 0 .75rem; font-size: .8rem; }
  .topbar .topbar__link, .user__text { display: none; }
  .avatar { width: 2.25rem; height: 2.25rem; }
  .topbar .btn--ghost { min-height: 2.25rem; padding: .35rem .6rem; }
  .topbar .btn__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

  .rail { position: fixed; inset: auto 0 0; z-index: 20; display: flex; background: var(--brand); border-top: 1px solid var(--brand-line); padding: .35rem .5rem calc(.35rem + env(safe-area-inset-bottom)); }
  .rail > ul { flex: 4; flex-direction: row; gap: 0; }
  .rail > ul > li { flex: 1; }
  .rail__item--extra { display: none; }
  .rail__more { display: block; flex: 1; }
  .rail__more ul { position: fixed; left: .5rem; right: .5rem; bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + .5rem); padding: .5rem; border: 1px solid var(--brand-line); border-radius: var(--radius); background: var(--brand-2); box-shadow: 0 12px 32px rgb(0 0 0 / .35); }
  .rail__more ul a { flex-direction: row; justify-content: flex-start; gap: .75rem; padding: .5rem .75rem; font-size: .95rem; }
  .rail__more ul .rail__icon { width: 2.25rem; }

  .sheet { border-radius: 22px 22px 0 0; padding: 1.4rem 1.1rem 2rem; }
  h1 { font-size: 1.6rem; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .625rem; }
  .stat { padding: 1rem 1.1rem; gap: .75rem; }
  .stat--featured { grid-column: 1 / -1; flex-direction: row; align-items: flex-end; justify-content: space-between; }
  .stat__value { font-size: 1.9rem; }
  .grid--2, .grid--3 { grid-template-columns: 1fr; }
  .page-header .actions .btn { flex: 1 1 auto; }
  .totp-setup { grid-template-columns: 1fr; }
  .qr { margin: 0 auto; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { border-bottom: 1px solid var(--line); padding: .6rem 0; }
  .table tr:last-child { border-bottom: 0; }
  .table td { border: 0; padding: .2rem 0; text-align: left !important; }
  .table td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: .85rem; }
  .table td.actions-col::before, .table td.thumb-col::before { content: ""; }
  .codes { columns: 1; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
