:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --text: #1c1b22;
  --muted: #6b6a75;
  --border: #e3e2ea;
  --accent: #5b4bdb;
  --accent-text: #ffffff;
  --accent-soft: #ecebfd;
  --ok-bg: #e7f6ec; --ok-text: #1d6b3a;
  --warn-bg: #fff5dd; --warn-text: #7a5300;
  --error-bg: #fde8e8; --error-text: #9b1c1c;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 20, 40, .06), 0 4px 16px rgba(20, 20, 40, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121117; --surface: #1c1b24; --text: #ecebf3; --muted: #9d9cab; --border: #2e2d3a;
    --accent: #8c7ff5; --accent-text: #120f2a; --accent-soft: #2a2645;
    --ok-bg: #163322; --ok-text: #8fe0ab; --warn-bg: #3a2e10; --warn-text: #f3cf7a;
    --error-bg: #3d1717; --error-text: #f5a3a3;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
h1 { font-size: 1.6rem; margin: 0 0 1rem; line-height: 1.2; display: flex; align-items: center; gap: .5rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
code, .mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .9em; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: .75rem 1.5rem; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: inline-flex; align-items: center; gap: .55rem; font-weight: 650; color: var(--text); text-decoration: none; }
.brand.big { font-size: 1.05rem; margin-bottom: 1.25rem; }
.brand-mark { width: 22px; height: 22px; border-radius: 6px; background: url(/static/icon.svg) center/cover; }
.topnav { display: flex; align-items: center; gap: 1.1rem; flex-wrap: wrap; }
.topnav a { color: var(--text); text-decoration: none; }
.topnav a:hover { color: var(--accent); }

main { max-width: 960px; margin: 0 auto; padding: 2rem 1.5rem 4rem; }
main.wide { max-width: 1200px; }
main.center { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.25rem 1.4rem; box-shadow: var(--shadow); margin-bottom: 1.25rem; min-width: 0;
}
.card.narrow { max-width: 440px; width: 100%; margin: 0 auto 1.25rem; }
.card.highlight { border-color: var(--accent); }
.card.danger { border-color: var(--error-bg); }
.empty { text-align: center; padding: 2.5rem; }
.pagehead { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.pagehead h1 { margin: 0; }

.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem 1.25rem; }
.grid2 > .card { margin-bottom: 0; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; }
.grid4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; }
.align-end { display: flex; align-items: flex-end; }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.row { display: flex; gap: .75rem; align-items: flex-end; flex-wrap: wrap; }
.row input:not([type=file]) { flex: 1; min-width: 200px; }
.inline { display: inline; margin: 0; }

label { display: flex; flex-direction: column; gap: .3rem; font-weight: 550; font-size: .92rem; }
label.radio, label.check { flex-direction: row; align-items: center; gap: .5rem; font-weight: 400; }
input, select {
  font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: .55rem .7rem; width: 100%;
}
input[type=radio], input[type=checkbox] { width: auto; accent-color: var(--accent); }
input[type=color] { padding: .2rem; height: 2.4rem; }
input[type=file] { background: transparent; border-style: dashed; }
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input[readonly] { color: var(--muted); }
fieldset { border: 1px solid var(--border); border-radius: 8px; padding: .75rem 1rem; display: flex; flex-direction: column; gap: .5rem; }
legend { font-weight: 600; padding: 0 .3rem; }
[hidden] { display: none !important; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  background: var(--accent); color: var(--accent-text); border: 1px solid transparent;
  border-radius: 8px; padding: .55rem 1rem; white-space: nowrap;
}
.btn:hover { filter: brightness(1.08); }
.btn.secondary { background: var(--accent-soft); color: var(--text); }
.btn.danger { background: var(--error-text); color: var(--surface); }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--text); cursor: pointer; text-align: left; }
.linklike:hover { color: var(--accent); }
.danger-text { color: var(--error-text); }

.flash { border-radius: 8px; padding: .7rem 1rem; margin-bottom: 1rem; font-weight: 500; }
main.center > .flash { max-width: 440px; width: 100%; margin-left: auto; margin-right: auto; }
.flash-ok { background: var(--ok-bg); color: var(--ok-text); }
.flash-warn { background: var(--warn-bg); color: var(--warn-text); }
.flash-error { background: var(--error-bg); color: var(--error-text); }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.badge { display: inline-block; font-size: .72rem; font-weight: 600; padding: .1rem .45rem; border-radius: 99px; background: var(--accent-soft); color: var(--text); }

/* App-Kacheln */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1rem; }
.tile {
  display: flex; gap: .9rem; align-items: center; text-decoration: none; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.1rem; box-shadow: var(--shadow); transition: border-color .15s, transform .15s;
}
.tile:hover { border-color: var(--accent); transform: translateY(-1px); }
.tile.disabled { opacity: .6; pointer-events: none; }
.tile-icon {
  --c: #5b4bdb; flex: none; width: 48px; height: 48px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--c); color: #fff; font-weight: 700; font-size: 1.15rem; text-transform: uppercase;
}
.tile-icon.sm { width: 28px; height: 28px; border-radius: 7px; font-size: .8rem; vertical-align: middle; }
.tile-body { display: flex; flex-direction: column; min-width: 0; }
.tile-name { font-weight: 650; }
.tile-desc { color: var(--muted); font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Tabellen */
.card:has(> .table) { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: .6rem .5rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: .8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.table tr:last-child td { border-bottom: 0; }
tr.inactive td { color: var(--muted); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.list { list-style: none; padding: 0; margin: 0 0 1rem; display: flex; flex-direction: column; gap: .5rem; }
.list li { display: flex; flex-direction: column; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .5rem 1rem; }

.menu { position: relative; }
.menu summary { cursor: pointer; color: var(--accent); list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu-body {
  position: absolute; right: 0; z-index: 5; min-width: 240px; display: flex; flex-direction: column; gap: .6rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: .8rem 1rem; box-shadow: var(--shadow);
}
.menu-body form { margin: 0; }

/* 2FA */
.steps { padding-left: 1.2rem; display: flex; flex-direction: column; gap: .75rem; }
.qr { background: #fff; border-radius: 8px; padding: .5rem; width: max-content; margin: .5rem 0; }
.qr svg { display: block; width: 200px; height: 200px; }
.secret { word-break: break-all; font-size: 1rem; letter-spacing: .05em; }
.codes { list-style: none; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; }
.codes code { display: block; text-align: center; padding: .4rem; background: var(--bg); border-radius: 6px; font-size: 1rem; }
details summary { cursor: pointer; }

@media (max-width: 600px) {
  .topbar { padding: .75rem 1rem; }
  main { padding: 1.25rem 1rem 3rem; }
  .card { padding: 1rem; }
  .table th:nth-child(n+5), .table td:nth-child(n+5):not(:last-child) { display: none; }
}
