:root {
  --bg: #0f1419;
  --panel: #161c24;
  --panel2: #1d2530;
  --line: #2a3441;
  --text: #e6edf3;
  --muted: #8b98a8;
  --accent: #3ecf8e;
  --accent-ink: #06231a;
  --danger: #ff6b6b;
  --warn: #f5a623;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body, #app { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
.hidden { display: none !important; }

/* ---------- auth ---------- */
.auth-wrap { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.auth-card {
  width: 100%; max-width: 420px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 28px; display: grid; gap: 14px;
}
.auth-card h1 { margin: 0; font-size: 22px; }
.auth-card p { margin: 0; color: var(--muted); }
.logo { width: 44px; height: 44px; }

/* ---------- form controls ---------- */
label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
input[type="text"], input[type="password"], input[type="url"], input[type="search"],
input[type="number"], textarea, select {
  width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; color: var(--text); outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { min-height: 96px; resize: vertical; }
.btn {
  border: 1px solid var(--line); background: var(--panel2); border-radius: 8px;
  padding: 9px 14px; cursor: pointer; color: var(--text);
}
.btn:hover { border-color: #3b4a5c; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.danger { color: var(--danger); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .6; cursor: default; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.check { display: flex; gap: 8px; align-items: center; color: var(--text); font-size: 14px; }
.check input { width: auto; }
.msg { font-size: 13px; min-height: 18px; color: var(--muted); }
.msg.err { color: var(--danger); }
.msg.ok { color: var(--accent); }
.note { font-size: 13px; color: var(--warn); }

/* ---------- strength meter ---------- */
.meter { height: 5px; border-radius: 3px; background: var(--line); overflow: hidden; }
.meter > span { display: block; height: 100%; width: 0; transition: width .2s; }
.meter.s1 > span { width: 25%; background: var(--danger); }
.meter.s2 > span { width: 50%; background: var(--warn); }
.meter.s3 > span { width: 75%; background: #9bd36b; }
.meter.s4 > span { width: 100%; background: var(--accent); }

/* ---------- vault layout ---------- */
.shell { height: 100%; display: grid; grid-template-rows: auto 1fr auto; }
.topbar {
  display: flex; gap: 10px; align-items: center; padding: 10px 14px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.topbar .brand { display: flex; gap: 8px; align-items: center; font-weight: 600; }
.topbar .brand img { width: 24px; height: 24px; }
.main { display: grid; grid-template-columns: 340px 1fr; min-height: 0; }
.list-pane { border-right: 1px solid var(--line); display: grid; grid-template-rows: auto auto 1fr; min-height: 0; }
.list-tools { padding: 10px; display: grid; gap: 8px; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 10px 8px; }
.chip {
  border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; font-size: 12px;
  background: transparent; color: var(--muted); cursor: pointer;
}
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.entries { overflow: auto; min-height: 0; }
.entry {
  display: grid; gap: 2px; padding: 10px 14px; border-bottom: 1px solid var(--line);
  cursor: pointer; background: transparent; width: 100%; text-align: left; border-left: 0; border-right: 0; border-top: 0;
}
.entry:hover { background: var(--panel); }
.entry.sel { background: var(--panel2); box-shadow: inset 3px 0 0 var(--accent); }
.entry .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry .u { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { padding: 28px; color: var(--muted); text-align: center; }
.detail-pane { overflow: auto; padding: 22px; min-height: 0; min-width: 0; }
.detail { max-width: 640px; display: grid; gap: 14px; min-width: 0; }
.field { min-width: 0; }
.detail h2 { margin: 0; font-size: 22px; overflow-wrap: anywhere; }
.field { display: grid; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.field .k { font-size: 12px; color: var(--muted); }
.field .v { overflow-wrap: anywhere; white-space: pre-wrap; }
.field .v.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.statusbar { padding: 6px 14px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); background: var(--panel); }
.statusbar.err { color: var(--danger); }
.back { display: none; }

/* ---------- dialogs ---------- */
dialog {
  background: var(--panel); color: var(--text); border: 1px solid var(--line);
  border-radius: 14px; padding: 0; width: min(520px, 94vw); max-height: 90vh;
}
dialog::backdrop { background: rgba(0, 0, 0, .6); }
.dlg { padding: 20px; display: grid; gap: 14px; }
.dlg h3 { margin: 0; }
.dlg h4 { margin: 8px 0 0; font-size: 14px; color: var(--muted); font-weight: 600; }
.sep { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.gen-out { font-family: ui-monospace, Menlo, Consolas, monospace; word-break: break-all; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }

/* ---------- mobile ---------- */
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; gap: 6px; padding: 8px 10px; }
  .topbar .brand span { display: none; }
  .topbar .grow { display: none; }
  .main { grid-template-columns: minmax(0, 1fr); }
  .list-pane { border-right: 0; }
  .detail-pane { display: none; }
  .main.show-detail .list-pane { display: none; }
  .main.show-detail .detail-pane { display: block; padding: 16px; }
  .back { display: inline-block; }
}
