:root {
  --bg: #f3f5f9; --panel: #ffffff; --panel2: #f8fafc; --line: #e3e8ef; --text: #1b2333; --muted: #667085;
  --accent: #2563eb; --accent-2: #1d4ed8; --accent-soft: #e8efff; --danger: #d92d20; --danger-soft: #fee4e2;
  --ok: #12825a; --ok-soft: #dcfae6; --warn: #b54708; --warn-soft: #fef0c7;
  --radius: 10px; --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --side: 264px; --list: 380px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1117; --panel: #151b23; --panel2: #10151c; --line: #262f3b; --text: #e6edf3; --muted: #93a0b0;
    --accent: #4c8dff; --accent-2: #7aa8ff; --accent-soft: #16233b; --danger: #ff6b5e; --danger-soft: #3a1714;
    --ok: #3fcf8e; --ok-soft: #10291e; --warn: #f5a524; --warn-soft: #33250b; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1117; --panel: #151b23; --panel2: #10151c; --line: #262f3b; --text: #e6edf3; --muted: #93a0b0;
  --accent: #4c8dff; --accent-2: #7aa8ff; --accent-soft: #16233b; --danger: #ff6b5e; --danger-soft: #3a1714;
  --ok: #3fcf8e; --ok-soft: #10291e; --warn: #f5a524; --warn-soft: #33250b; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h2 { font-size: 18px; } h3 { font-size: 17px; } h4 { font-size: 15px; margin: 4px 0 8px; }
p { margin: 6px 0; }
.i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.i.big { width: 44px; height: 44px; stroke-width: 1.5; opacity: .45; }
.i.fav { color: #f5a524; fill: #f5a524; }
.muted { color: var(--muted); } .small { font-size: 13px; } .center { text-align: center; } .mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.grow { flex: 1; min-width: 0; } .ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.err { color: var(--danger); min-height: 1em; margin: 6px 0; font-size: 14px; }
.pre { white-space: pre-wrap; }
.linklike { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; }

/* Knöpfe und Felder */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 8px 14px; font-weight: 600; font-size: 14px; text-decoration: none; color: var(--text); white-space: nowrap; }
.btn:hover { background: var(--panel2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { color: var(--danger); }
.modal-foot .btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--accent); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.block { width: 100%; margin-top: 8px; padding: 11px; }
.btn:disabled { opacity: .6; cursor: default; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; border: 0; background: transparent; color: var(--muted); flex: none; }
.icon-btn:hover { background: var(--accent-soft); color: var(--accent); }
.icon-btn.fav-on { color: #f5a524; } .icon-btn.fav-on .i { fill: #f5a524; }
.input { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; background: var(--panel); outline: none; }
.input:focus, .search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.small { width: auto; padding: 5px 8px; font-size: 13px; }
.input.big { font-size: 18px; padding: 12px; }
textarea.input { resize: vertical; }
.field { display: block; margin: 10px 0; }
.field .label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.field .hint { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.three { display: grid; grid-template-columns: 1fr 1fr 160px; gap: 10px; margin-bottom: 10px; }
.pw-wrap { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.pw-wrap .input { border: 0; box-shadow: none !important; }
.pw-wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }
.checks { display: flex; gap: 14px; flex-wrap: wrap; margin: 8px 0; }
.cfield { display: grid; grid-template-columns: 1fr 1fr auto auto; gap: 6px; align-items: center; margin-bottom: 6px; }
.linkbox { display: flex; gap: 6px; align-items: center; margin-top: 8px; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); margin-left: 6px; vertical-align: 1px; }
.badge.ok, .badge.s-active { background: var(--ok-soft); color: var(--ok); }
.badge.s-invited { background: var(--warn-soft); color: var(--warn); }
.badge.s-disabled { background: var(--danger-soft); color: var(--danger); }

/* Stärke */
.meter { display: flex; align-items: center; gap: 10px; margin: 6px 0 2px; }
.meter .bar { flex: 1; height: 6px; background: var(--line); border-radius: 9px; overflow: hidden; }
.meter .bar span { display: block; height: 100%; width: 0; border-radius: 9px; transition: width .2s; }
.meter-label { font-size: 12px; color: var(--muted); min-width: 140px; }
.l0 .bar span { width: 10%; background: var(--danger); } .l1 .bar span { width: 30%; background: #f97316; } .l2 .bar span { width: 55%; background: #eab308; }
.l3 .bar span { width: 80%; background: #22c55e; } .l4 .bar span { width: 100%; background: var(--ok); }
.meter-inline { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin-top: 4px; }
.meter-inline span { width: 8px; height: 8px; border-radius: 9px; }
.meter-inline.l0 span { background: var(--danger); } .meter-inline.l1 span { background: #f97316; } .meter-inline.l2 span { background: #eab308; }
.meter-inline.l3 span { background: #22c55e; } .meter-inline.l4 span { background: var(--ok); }

/* Anmelden */
#app.boot { display: grid; place-items: center; height: 100%; }
#app.auth { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 420px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; box-shadow: var(--shadow); }
.auth-card h1 { font-size: 22px; margin: 18px 0 4px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand b { display: block; font-size: 17px; } .brand span { display: block; font-size: 13px; color: var(--muted); }
.logo { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; background: linear-gradient(135deg, #2563eb, #7c3aed); color: #fff; }
.logo .i { width: 20px; height: 20px; }
.brand.small .logo { width: 32px; height: 32px; } .brand.small .logo .i { width: 17px; height: 17px; }

/* Grundgerüst */
#app.shell { display: grid; overflow: hidden; height: 100vh; height: 100dvh; grid-template-columns: var(--side) var(--list) 1fr; grid-template-rows: 56px 1fr; grid-template-areas: "top top top" "side list detail"; }
.shell:has(> .page) { grid-template-columns: var(--side) 1fr; grid-template-areas: "top top" "side page"; }
.top { grid-area: top; display: flex; align-items: center; gap: 12px; padding: 0 14px; background: var(--panel); border-bottom: 1px solid var(--line); }
.search-wrap { flex: 1; min-width: 0; max-width: 560px; display: flex; align-items: center; gap: 8px; background: var(--panel2); border: 1px solid var(--line); border-radius: 9px; padding: 0 10px; color: var(--muted); margin-left: calc(var(--side) - 180px); }
.search { flex: 1; min-width: 0; width: 100%; border: 0; background: transparent; padding: 8px 0; outline: none; color: var(--text); }
.menu-wrap { position: relative; margin-left: auto; }
.me-btn { display: flex; align-items: center; gap: 8px; border: 0; background: transparent; padding: 4px 6px; border-radius: 8px; font-weight: 600; }
.me-btn:hover { background: var(--panel2); }
.menu { display: none; position: absolute; right: 0; top: 44px; min-width: 240px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 32px rgba(0,0,0,.15); padding: 6px; z-index: 30; }
.menu-wrap.open .menu { display: block; }
.menu button { display: flex; width: 100%; gap: 10px; align-items: center; border: 0; background: transparent; padding: 9px 10px; border-radius: 7px; text-align: left; }
.menu button:hover { background: var(--panel2); }
.menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu-head b, .menu-head span { display: block; } .menu-head span { font-size: 13px; color: var(--muted); }
.menu-head .badge { display: inline-block; margin: 4px 0 0; }
.mini { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; color: #fff; font-size: 12px; font-weight: 700; flex: none; text-transform: uppercase; }
.uchip { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; }
.uchip .mini { width: 20px; height: 20px; font-size: 10px; }

.side { grid-area: side; background: var(--panel); border-right: 1px solid var(--line); overflow-y: auto; padding: 10px 8px 24px; }
.nav { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: transparent; padding: 8px 10px; border-radius: 8px; text-align: left; color: var(--text); }
.nav:hover { background: var(--panel2); }
.nav.on, .vault-row.on .nav { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav .count { font-size: 12px; color: var(--muted); }
.nav.sub { font-size: 14px; padding-top: 6px; padding-bottom: 6px; }
.side-head { display: flex; align-items: center; justify-content: space-between; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 16px 10px 4px; }
.side-head .icon-btn { width: 26px; height: 26px; }
.vault-row { display: flex; align-items: center; }
.vault-row .nav { padding-left: 2px; }
.twisty { width: 22px; height: 22px; border: 0; background: transparent; display: grid; place-items: center; color: var(--muted); flex: none; padding: 0; }
.twisty .i { width: 14px; height: 14px; transition: transform .15s; } .twisty.open .i { transform: rotate(90deg); }
.side-tags { padding: 4px 8px; }

.list { grid-area: list; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.list-head { display: flex; align-items: center; gap: 8px; padding: 14px 14px 10px; border-bottom: 1px solid var(--line); }
.row-actions { display: flex; }
.sort { border: 1px solid var(--line); background: var(--panel); border-radius: 7px; padding: 4px 6px; font-size: 13px; }
.rows { overflow-y: auto; flex: 1; padding: 6px; }
.item-row { display: flex; align-items: center; gap: 12px; width: 100%; border: 0; background: transparent; padding: 9px 10px; border-radius: 9px; text-align: left; }
.item-row:hover { background: var(--panel2); }
.item-row.on { background: var(--accent-soft); }
.item-row .title { font-weight: 600; }
.item-row .sub { font-size: 13px; color: var(--muted); }
.avatar { width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; color: #fff; font-weight: 700; text-transform: uppercase; flex: none; }
.avatar.big { width: 48px; height: 48px; border-radius: 12px; font-size: 20px; }
.c0 { background: #2563eb; } .c1 { background: #7c3aed; } .c2 { background: #db2777; } .c3 { background: #ea580c; }
.c4 { background: #16a34a; } .c5 { background: #0891b2; } .c6 { background: #4f46e5; } .c7 { background: #ca8a04; }
.empty { display: grid; place-items: center; gap: 6px; text-align: center; padding: 48px 16px; color: var(--muted); }

.detail { grid-area: detail; overflow-y: auto; padding: 20px 24px 40px; min-width: 0; }
.detail > * { max-width: 760px; }
.empty-detail { display: grid; place-items: center; }
.detail-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
.page .card { padding: 14px 16px; }
.card-title { display: flex; align-items: center; gap: 8px; font-weight: 700; padding: 10px 0 6px; }
.card-title .count { margin-left: auto; }
.frow { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.frow:last-child { border-bottom: 0; }
.frow .k { font-size: 12px; font-weight: 600; color: var(--muted); }
.frow .v { word-break: break-all; }
.frow .actions { display: flex; }
.totp { font-size: 20px; letter-spacing: .06em; display: flex; align-items: center; gap: 10px; }
.ring { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; font-size: 11px; letter-spacing: 0; color: var(--muted);
  background: conic-gradient(var(--accent) calc(var(--p) * 360deg), var(--line) 0); position: relative; }
.ring::before { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--panel); }
.ring { isolation: isolate; } .ring::before { z-index: -1; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; }
.tag { border: 1px solid var(--line); background: var(--panel); border-radius: 99px; padding: 2px 10px; font-size: 13px; color: var(--accent); }
.tag.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.meta { display: grid; gap: 2px; margin: 4px 0 16px; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.detail-actions.sticky { position: sticky; bottom: -40px; background: var(--bg); padding: 12px 0; }
.notice { display: flex; align-items: center; gap: 10px; background: var(--warn-soft); color: var(--warn); border-radius: 9px; padding: 10px 12px; margin-bottom: 14px; }
.notice.ok { background: var(--ok-soft); color: var(--text); margin-top: 12px; }
.upload { margin: 8px 0; cursor: pointer; }
.edit .card { padding: 14px 16px; }

/* Seiten */
.page { grid-area: page; overflow-y: auto; min-width: 0; }
.page .list-head { background: var(--panel); position: sticky; top: 0; z-index: 2; }
.page-body { padding: 18px 24px 40px; max-width: 900px; }
.score-card { display: flex; align-items: center; gap: 18px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; }
.score { width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; font-size: 26px; font-weight: 800; color: #fff; flex: none; }
.score.good { background: var(--ok); } .score.mid { background: #eab308; } .score.bad { background: var(--danger); }
.count { font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 99px; background: var(--panel2); }
.count.bad { background: var(--danger-soft); color: var(--danger); } .count.mid { background: var(--warn-soft); color: var(--warn); }
.log { margin-top: 10px; }
.log-row { display: flex; gap: 14px; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.log-row.bad { background: var(--danger-soft); }
.log-time { width: 140px; flex: none; }
.user-card { display: flex; align-items: center; gap: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 8px; }
.members { display: grid; gap: 4px; }
.member { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.add-member { margin-top: 16px; }
.hist { display: grid; gap: 8px; }
.hist-row { display: flex; gap: 12px; align-items: flex-start; border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; }
.diff { font-size: 14px; word-break: break-all; }
.qr { display: grid; place-items: center; margin: 10px 0; } .qr img { background: #fff; padding: 8px; border-radius: 8px; }

/* Dialoge */
.modal-bg { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { width: 100%; max-width: 460px; max-height: 90vh; display: flex; flex-direction: column; background: var(--panel); border-radius: 14px; box-shadow: 0 24px 64px rgba(0,0,0,.3); }
.modal.wide { max-width: 680px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 8px; }
.modal-body { padding: 4px 18px 10px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; padding: 12px 18px 16px; border-top: 1px solid var(--line); }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: #111827; color: #fff; padding: 10px 16px; border-radius: 9px; font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; z-index: 60; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.bad { background: var(--danger); }

.only-mobile { display: none; }

/* Mittlere Bildschirme: Detail neben Liste schmaler */
@media (max-width: 1180px) { :root { --side: 230px; --list: 320px; } .search-wrap { margin-left: 0; } }

/* Handy: immer nur eine Spalte */
@media (max-width: 820px) {
  .only-mobile { display: inline-grid; } .hide-mobile { display: none !important; }
  #app.shell, .shell:has(> .page) { grid-template-columns: 1fr; grid-template-rows: 56px 1fr; grid-template-areas: "top" "main"; }
  .side, .list, .detail, .page { grid-area: main; }
  .shell.pane-side .list, .shell.pane-side .detail, .shell.pane-side .page { display: none; }
  .shell.pane-list .side, .shell.pane-list .detail { display: none; }
  .shell.pane-detail .side, .shell.pane-detail .list { display: none; }
  .shell.pane-detail .page, .shell.pane-list .page { display: block; }
  .shell.pane-list:has(> .page) .side, .shell.pane-detail:has(> .page) .side { display: none; }
  .top { gap: 6px; padding: 0 8px; min-width: 0; }
  .top .btn.primary { padding: 8px 10px; }
  .brand.small { flex: none; }
  .search-wrap { margin: 0; }
  .detail { padding: 14px 16px 40px; }
  .page-body { padding: 14px 16px 40px; }
  .two, .three { grid-template-columns: 1fr; }
  .cfield { grid-template-columns: 1fr 1fr auto; } .cfield .check { display: none; }
  .log-row { flex-direction: column; gap: 2px; } .log-time { width: auto; }
  .item-row { padding: 11px 10px; }
  .modal-bg { align-items: end; padding: 0; } .modal { max-width: none; border-radius: 16px 16px 0 0; max-height: 92vh; }
}
