:root {
  --bg: #f3f5f8; --panel: #ffffff; --border: #dde2ea; --text: #1c2431; --muted: #6b7684;
  --primary: #1d4ed8; --primary-h: #1e40af; --danger: #c0392b; --ok: #15803d; --warn: #b45309;
  --side: #0f172a; --side-text: #cbd5e1; --side-active: #1e293b; --radius: 10px;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--primary); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0 0 .6em; font-weight: 600; }
h1 { font-size: 22px; } h2 { font-size: 18px; } h3 { font-size: 15px; }
p { margin: 0 0 .8em; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); }
.hidden { display: none !important; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grow { flex: 1; }
.mt { margin-top: 12px; } .mb { margin-bottom: 12px; }

/* Layout */
.center { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; width: 100%; max-width: 420px; box-shadow: 0 8px 30px rgba(15, 23, 42, .06); }
.card.wide { max-width: 560px; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; margin-bottom: 18px; }
.logo svg { width: 28px; height: 28px; }

.shell { display: grid; grid-template-columns: 250px 1fr; height: 100vh; }
.sidebar { background: var(--side); color: var(--side-text); display: flex; flex-direction: column; overflow: hidden; }
.sidebar .logo { color: #fff; padding: 16px 16px 8px; margin: 0; }
.sidebar .nav { flex: 1; overflow-y: auto; padding: 8px; }
.sidebar .nav-title { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #94a3b8; padding: 12px 8px 4px; }
.vault-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; cursor: pointer; color: var(--side-text); }
.vault-item:hover { background: #1e293b88; }
.vault-item.active { background: var(--side-active); color: #fff; }
.vault-item .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vault-item .cnt { font-size: 11px; color: #94a3b8; }
.sidebar .foot { padding: 12px; border-top: 1px solid #1e293b; font-size: 13px; }
.sidebar .foot .who { color: #fff; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.sidebar .foot .row { margin-top: 8px; }
.sidebar .btn-side { background: transparent; border: 1px solid #334155; color: var(--side-text); border-radius: 6px; padding: 5px 8px; font-size: 12px; }
.sidebar .btn-side:hover { background: #1e293b; color: #fff; }

.main { display: flex; flex-direction: column; overflow: hidden; }
.topbar { display: flex; align-items: center; gap: 10px; padding: 12px 20px; background: var(--panel); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.topbar h2 { margin: 0; font-size: 17px; flex: 1; min-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.content { flex: 1; overflow: auto; padding: 20px; }
.split { display: grid; grid-template-columns: minmax(260px, 380px) 1fr; gap: 20px; height: 100%; }
.list { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow-y: auto; }
.entry { padding: 10px 14px; border-bottom: 1px solid var(--border); cursor: pointer; }
.entry:hover { background: #f8fafc; }
.entry.active { background: #eef2ff; }
.entry .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry .u { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.detail { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; overflow-y: auto; }
.empty { color: var(--muted); text-align: center; padding: 40px 20px; }

/* Felder */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=password], input[type=number], input[type=url], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: #fff; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px #1d4ed822; }
textarea { min-height: 90px; resize: vertical; }
.val { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: #f8fafc; min-height: 38px; word-break: break-all; }
.val .v { flex: 1; font-family: var(--mono); }
.val .v.plain { font-family: inherit; white-space: pre-wrap; word-break: break-word; }
.val a { word-break: break-all; }
.inline { display: flex; gap: 6px; }
.inline input { flex: 1; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border); background: #fff; font-weight: 500; white-space: nowrap; }
.btn:hover { background: #f1f5f9; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-h); }
.btn.danger { color: var(--danger); border-color: #f1c4bf; }
.btn.danger:hover { background: #fdf2f1; }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn.icon { padding: 5px 7px; font-size: 13px; line-height: 1; }
.btn.block { width: 100%; justify-content: center; }

/* Badges / Tags */
.badge { display: inline-block; padding: 2px 7px; border-radius: 999px; font-size: 11px; font-weight: 600; background: #e2e8f0; color: #334155; }
.badge.admin { background: #fde68a; color: #78350f; }
.badge.write { background: #bfdbfe; color: #1e3a8a; }
.badge.read { background: #e2e8f0; color: #334155; }
.badge.ok { background: #bbf7d0; color: #14532d; }
.badge.warn { background: #fed7aa; color: #7c2d12; }
.badge.off { background: #fecaca; color: #7f1d1d; }

/* Tabellen */
table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: #f8fafc; }
tr:last-child td { border-bottom: 0; }
.tbl-wrap { overflow-x: auto; }

/* Meldungen */
.alert { padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; font-size: 13px; }
.alert.error { background: #fdecea; color: #7f1d1d; border: 1px solid #f5c2bd; }
.alert.info { background: #eff6ff; color: #1e3a8a; border: 1px solid #bfdbfe; }
.alert.warn { background: #fff7ed; color: #7c2d12; border: 1px solid #fed7aa; }
.alert.ok { background: #f0fdf4; color: #14532d; border: 1px solid #bbf7d0; }
#toasts { position: fixed; bottom: 16px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: #1c2431; color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.2); font-size: 13px; animation: fade .2s; }
.toast.error { background: var(--danger); }
.toast.ok { background: var(--ok); }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,.55); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.modal { background: var(--panel); border-radius: var(--radius); width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto; padding: 22px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal.wide { max-width: 720px; }
.modal h2 { margin-bottom: 14px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* Stärke */
.meter { height: 6px; border-radius: 3px; background: #e2e8f0; overflow: hidden; margin-top: 6px; }
.meter i { display: block; height: 100%; width: 0; transition: width .2s; }
.totp-code { font-family: var(--mono); font-size: 20px; letter-spacing: 2px; }
.totp-bar { height: 3px; background: var(--primary); transition: width 1s linear; }

.section { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; max-width: 900px; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 6px 12px; font-size: 13px; }
code.box { display: block; padding: 8px 10px; background: #f1f5f9; border-radius: 6px; font-family: var(--mono); font-size: 12px; word-break: break-all; }
.gen-opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin: 8px 0; }
.gen-opts label { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.progress { font-size: 13px; color: var(--muted); }

.menu-btn { display: none; font-size: 18px; padding: 6px 10px; }
.back-btn { display: none; margin-bottom: 10px; }
.nav-backdrop { display: none; }

@media (max-width: 800px) {
  html { -webkit-text-size-adjust: 100%; }
  body { font-size: 15px; }
  input[type=text], input[type=password], input[type=number], input[type=url], select, textarea { font-size: 16px; padding: 10px 12px; }
  .btn { padding: 10px 14px; min-height: 42px; }
  .btn.sm { padding: 8px 12px; min-height: 38px; font-size: 13px; }
  .btn.icon { min-height: 36px; min-width: 36px; padding: 6px 8px; }
  .menu-btn { display: inline-flex; }
  .shell { display: block; height: auto; min-height: 100vh; }
  .sidebar { position: fixed; top: 0; left: 0; bottom: 0; width: min(84vw, 320px); z-index: 60; transform: translateX(-100%); transition: transform .2s ease; box-shadow: 0 0 40px rgba(0,0,0,.4); }
  .sidebar.open { transform: translateX(0); }
  .nav-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 55; }
  .vault-item { padding: 12px 12px; font-size: 15px; }
  .main { min-height: 100vh; }
  .topbar { position: sticky; top: 0; z-index: 20; padding: 10px 12px; gap: 8px; }
  .topbar h2 { font-size: 16px; min-width: 0; }
  .topbar .w200 { width: 100%; order: 10; }
  .content { padding: 12px; }
  .split { display: block; height: auto; }
  .list { max-height: none; margin-bottom: 12px; }
  .entry { padding: 14px 14px; }
  .split.has-sel .list { display: none; }
  .split:not(.has-sel) .detail { display: none; }
  .detail { padding: 14px; }
  .back-btn { display: inline-flex; }
  .val { flex-wrap: wrap; }
  .val .v { min-width: 0; flex-basis: 100%; }
  .modal-bg { padding: 0; align-items: flex-end; }
  .modal { max-width: none; max-height: 100vh; border-radius: 14px 14px 0 0; padding: 18px 16px 24px; }
  .modal .actions { position: sticky; bottom: 0; background: var(--panel); padding-top: 10px; }
  .gen-opts { grid-template-columns: 1fr 1fr; }
  .section { padding: 14px; }
  .kv { grid-template-columns: 1fr; }
  th, td { padding: 8px 8px; font-size: 13px; }
  .card { padding: 22px 18px; }
  .center { padding: 12px; align-items: flex-start; padding-top: 24px; }
  .qr-row { flex-direction: column; align-items: center; }
  #toasts { left: 12px; right: 12px; bottom: 12px; }
}
