:root {
  --bg: #f3f5f9; --panel: #ffffff; --panel-2: #f8fafc; --line: #e3e8ef; --line-2: #d3dae4;
  --text: #0f172a; --muted: #5b6678; --faint: #8a94a6;
  --accent: #1d4ed8; --accent-2: #2563eb; --accent-soft: #e8efff; --accent-text: #ffffff;
  --danger: #c62828; --danger-soft: #fdecec; --warn: #b45309; --warn-soft: #fff4e0; --ok: #15803d; --ok-soft: #e7f6ec;
  --side: #0f1b33; --side-text: #c9d3e6; --side-muted: #7f8ba3; --side-active: #1e3a8a; --side-hover: #18264a;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .06);
  --radius: 10px; --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1120; --panel: #111a2e; --panel-2: #0e1628; --line: #1f2a40; --line-2: #2a3752;
    --text: #e6ebf5; --muted: #9aa6bd; --faint: #6c7890;
    --accent: #3b82f6; --accent-2: #60a5fa; --accent-soft: #15254a; --accent-text: #ffffff;
    --danger: #f87171; --danger-soft: #3a1518; --warn: #fbbf24; --warn-soft: #33260b; --ok: #4ade80; --ok-soft: #0f2c1b;
    --side: #080e1c; --side-text: #c9d3e6; --side-muted: #6c7890; --side-active: #1e3a8a; --side-hover: #121c33;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1120; --panel: #111a2e; --panel-2: #0e1628; --line: #1f2a40; --line-2: #2a3752;
  --text: #e6ebf5; --muted: #9aa6bd; --faint: #6c7890;
  --accent: #3b82f6; --accent-2: #60a5fa; --accent-soft: #15254a; --accent-text: #ffffff;
  --danger: #f87171; --danger-soft: #3a1518; --warn: #fbbf24; --warn-soft: #33260b; --ok: #4ade80; --ok-soft: #0f2c1b;
  --side: #080e1c; --side-text: #c9d3e6; --side-muted: #6c7890; --side-active: #1e3a8a; --side-hover: #121c33;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
#app { height: 100%; }
.main { overflow: hidden; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
svg.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.hidden { display: none !important; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 8px; }
.wrap { flex-wrap: wrap; }
.stack > * + * { margin-top: 12px; }
.boot { display: grid; place-items: center; height: 100%; }
.boot-logo { width: 56px; height: 56px; border-radius: 14px; background: var(--accent); opacity: .25; animation: pulse 1.2s infinite alternate; }
@keyframes pulse { to { opacity: .6; } }

/* ---------- Knöpfe und Felder ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--panel); cursor: pointer; white-space: nowrap; font-weight: 500; }
.btn:hover { border-color: var(--accent-2); }
.btn:focus-visible, .icon-btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .nav-item:focus-visible, .list-item:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 1px; }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--panel-2); }
.btn.block { width: 100%; height: 42px; }
.btn[disabled] { opacity: .55; cursor: default; }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; border: 0; background: transparent; color: var(--muted); cursor: pointer; flex: none; }
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
.icon-btn.on { color: #e3a008; }
label.field { display: block; }
label.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
.input, select.input, textarea.input { width: 100%; height: 40px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--panel); }
textarea.input { height: auto; min-height: 90px; padding: 10px 12px; resize: vertical; }
.input:focus { border-color: var(--accent-2); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.input-group { display: flex; align-items: stretch; border: 1px solid var(--line-2); border-radius: 8px; background: var(--panel); }
.input-group:focus-within { border-color: var(--accent-2); box-shadow: 0 0 0 3px var(--accent-soft); }
.input-group .input { border: 0; box-shadow: none !important; background: transparent; }
.input-group .icon-btn { height: 38px; border-radius: 0; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.error { color: var(--danger); font-size: 14px; min-height: 20px; }
.meter { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.meter > div { height: 100%; width: 0; transition: width .2s; }
.lv0 { background: #dc2626; } .lv1 { background: #ea580c; } .lv2 { background: #ca8a04; } .lv3 { background: #16a34a; } .lv4 { background: #15803d; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.bad { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 600; }

/* ---------- Anmeldeseiten ---------- */
.auth { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(1200px 500px at 50% -10%, var(--accent-soft), transparent), var(--bg); }
.auth-card { width: 100%; max-width: 420px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px; box-shadow: var(--shadow); }
.auth-card.wide { max-width: 560px; }
.auth-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.auth-head img { width: 44px; height: 44px; }
.auth-head h1 { font-size: 21px; margin: 0; }
.auth-head p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.recovery-key { font-family: var(--mono); font-size: 17px; letter-spacing: .5px; padding: 14px; border-radius: 10px; background: var(--panel-2); border: 1px dashed var(--line-2); word-break: break-all; text-align: center; user-select: all; }
.note { padding: 12px 14px; border-radius: 10px; font-size: 14px; background: var(--accent-soft); }
.note.warn { background: var(--warn-soft); }
.note.bad { background: var(--danger-soft); }
.linkish { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; text-decoration: underline; }

/* ---------- Hauptlayout ---------- */
.shell { display: grid; grid-template-columns: 250px 1fr; height: 100%; }
.side { background: var(--side); color: var(--side-text); display: flex; flex-direction: column; min-height: 0; }
.side-head { display: flex; align-items: center; gap: 10px; padding: 16px 16px 12px; }
.side-head img { width: 30px; height: 30px; }
.side-head b { font-size: 17px; color: #fff; }
.side-scroll { overflow: auto; flex: 1; padding: 4px 8px 16px; }
.side-title { display: flex; align-items: center; justify-content: space-between; padding: 14px 10px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--side-muted); font-weight: 700; }
.side-title .icon-btn { width: 24px; height: 24px; color: var(--side-muted); }
.side-title .icon-btn:hover { background: var(--side-hover); color: #fff; }
.nav-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--side-text); cursor: pointer; text-align: left; font-size: 14px; }
.nav-item:hover { background: var(--side-hover); color: #fff; }
.nav-item.active { background: var(--side-active); color: #fff; }
.nav-item .count { margin-left: auto; font-size: 12px; color: var(--side-muted); }
.nav-item.active .count { color: #c7d2fe; }
.nav-item .caret { width: 16px; height: 16px; margin-left: -4px; opacity: .7; transition: transform .15s; }
.nav-item .caret.open { transform: rotate(90deg); }
.nav-item .nav-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.nav-sub { padding-left: 14px; }
.side-foot { padding: 10px 12px; border-top: 1px solid rgba(255,255,255,.06); display: flex; gap: 6px; }
.side-foot .icon-btn { color: var(--side-muted); }
.side-foot .icon-btn:hover { background: var(--side-hover); color: #fff; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.search { flex: 1; max-width: 560px; position: relative; }
.search svg { position: absolute; left: 11px; top: 11px; color: var(--faint); }
.search .input { padding-left: 36px; height: 40px; background: var(--panel-2); }
.lock-timer { font-size: 12px; color: var(--faint); white-space: nowrap; }
.menu-btn { display: none; }

.content { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(300px, 400px) 1fr; }
.list-pane { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; background: var(--panel); }
.list-head { padding: 14px 16px 10px; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); }
.list-head h2 { font-size: 16px; margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-head select { height: 32px; width: auto; padding: 0 8px; font-size: 13px; }
.list { overflow: auto; flex: 1; }
.list-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 16px; border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left; cursor: pointer; }
.list-item:hover { background: var(--panel-2); }
.list-item.active { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.list-item .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .s { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .star { color: #e3a008; }
.avatar { width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; font-weight: 700; color: #fff; flex: none; font-size: 15px; text-transform: uppercase; }
.avatar.big { width: 52px; height: 52px; border-radius: 12px; font-size: 22px; }
.c0 { background: #2563eb; } .c1 { background: #7c3aed; } .c2 { background: #db2777; } .c3 { background: #ea580c; } .c4 { background: #16a34a; } .c5 { background: #0891b2; } .c6 { background: #4f46e5; } .c7 { background: #64748b; }
.cr { background: #dc2626; } .co { background: #ea580c; } .cy { background: #ca8a04; } .cg { background: #16a34a; } .cb { background: #2563eb; } .cv { background: #7c3aed; }
.empty { padding: 40px 24px; text-align: center; color: var(--muted); }
.empty svg { width: 40px; height: 40px; color: var(--faint); margin-bottom: 8px; }

.detail { overflow: auto; min-height: 0; }
.detail-inner { max-width: 760px; margin: 0 auto; padding: 22px 24px 60px; }
.detail-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.detail-head h1 { margin: 0; font-size: 22px; word-break: break-word; }
.detail-head .crumbs { font-size: 13px; color: var(--muted); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card + .card { margin-top: 14px; }
.card-title { padding: 12px 16px; border-bottom: 1px solid var(--line); font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card-body { padding: 14px 16px; }
.frow { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); min-height: 56px; }
.frow:last-child { border-bottom: 0; }
.frow .k { font-size: 12px; color: var(--muted); font-weight: 500; }
.frow .v { word-break: break-all; }
.frow .v.secret { font-family: var(--mono); letter-spacing: .5px; }
.frow .v.pre { white-space: pre-wrap; word-break: break-word; }
.frow .actions { display: flex; gap: 2px; margin-left: auto; flex: none; }
.totp-ring { width: 22px; height: 22px; }
.totp-ring circle { fill: none; stroke-width: 3; }
.totp-code { font-family: var(--mono); font-size: 20px; letter-spacing: 2px; }
.meta { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; font-size: 13px; color: var(--muted); padding: 14px 16px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.form-grid { display: grid; gap: 14px; }
.form-grid .two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr auto auto; gap: 8px; align-items: end; }
.colors { display: flex; gap: 8px; }
.colors button { width: 26px; height: 26px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.colors button.sel { border-color: var(--text); }
.colors button.none { background: var(--panel-2); border: 1px dashed var(--line-2); }
.colors button.none.sel { border: 2px solid var(--text); }
.page { overflow: auto; min-height: 0; grid-column: 1 / -1; }
.page-inner { max-width: 900px; margin: 0 auto; padding: 24px 24px 60px; }
.page-inner h1 { font-size: 22px; margin: 0 0 4px; }
.page-inner > p.lead { color: var(--muted); margin: 0 0 18px; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .n { font-size: 26px; font-weight: 700; }
.stat .l { font-size: 13px; color: var(--muted); }
.score { display: flex; align-items: center; gap: 18px; }
.score-ring { width: 96px; height: 96px; flex: none; }
.score-ring circle { fill: none; stroke-width: 10; }
.score-ring text { font: 700 24px system-ui, sans-serif; fill: var(--text); }
.gen-out { font-family: var(--mono); font-size: 20px; padding: 16px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); word-break: break-all; min-height: 62px; }
.gen-out .d { color: var(--accent); } .gen-out .s { color: #db2777; }
input[type=range] { width: 100%; accent-color: var(--accent); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.table td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.ev-list .ev { display: flex; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.ev-list .ev:last-child { border-bottom: 0; }
.ev .dot { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; flex: none; background: var(--panel-2); color: var(--muted); }
.ev .dot.bad { background: var(--danger-soft); color: var(--danger); }
.ev .dot.ok { background: var(--ok-soft); color: var(--ok); }
.ev .dot.acc { background: var(--accent-soft); color: var(--accent); }
.qr { background: #fff; padding: 10px; border-radius: 10px; width: 200px; height: 200px; }
.qr svg, .qr img { width: 100%; height: 100%; display: block; }
.settings-grid { display: grid; gap: 14px; }
.set-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.set-row:last-child { border-bottom: 0; }
.set-wrap > .set-row:last-child { border-bottom: 1px solid var(--line); }
.set-row select { width: auto; min-width: 140px; }

/* ---------- Dialog und Meldungen ---------- */
.overlay { position: fixed; inset: 0; background: rgba(8, 13, 25, .55); display: grid; place-items: center; padding: 16px; z-index: 50; animation: fade .12s; }
@keyframes fade { from { opacity: 0; } }
.dialog { width: 100%; max-width: 480px; max-height: calc(100% - 32px); overflow: auto; background: var(--panel); border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.dialog.wide { max-width: 640px; }
.dialog-head { padding: 16px 18px 0; display: flex; align-items: center; gap: 8px; }
.dialog-head h3 { margin: 0; font-size: 17px; flex: 1; }
.dialog-body { padding: 14px 18px; }
.dialog-foot { padding: 0 18px 16px; display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: #0f172a; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: .18s; z-index: 60; max-width: calc(100% - 32px); box-shadow: 0 8px 24px rgba(0,0,0,.25); }
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.bad { background: var(--danger); }
.ctx { position: fixed; z-index: 55; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.2); padding: 4px; min-width: 190px; }
.ctx button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; background: transparent; border-radius: 6px; cursor: pointer; text-align: left; }
.ctx button:hover { background: var(--panel-2); }
.ctx button.danger { color: var(--danger); }

/* ---------- Handy ---------- */
.back-btn { display: none; }
.scrim { display: none; }
@media (max-width: 900px) {
  .content { grid-template-columns: 1fr; }
  .content.has-detail .list-pane { display: none; }
  .content:not(.has-detail) .detail { display: none; }
  .back-btn { display: inline-grid; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .shell.side-open .side { transform: none; }
  .shell.side-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 39; }
  .menu-btn { display: inline-grid; }
  .topbar { padding: 8px 10px; gap: 6px; }
  .topbar .btn .lbl, .lock-timer { display: none; }
  .topbar .btn { padding: 0 10px; }
  .detail-inner, .page-inner { padding: 16px 16px 60px; }
  .form-grid .two, .field-row { grid-template-columns: 1fr; }
  .auth-card { padding: 22px 18px; }
  .frow { padding: 10px 12px; }
  .table .hide-sm { display: none; }
}
@media print {
  body * { visibility: hidden; }
  .print-area, .print-area * { visibility: visible; }
  .print-area { position: absolute; inset: 0; padding: 40px; }
}
