:root {
  --bg: #f6f6f3;
  --surface: #ffffff;
  --text: #1d1d1b;
  --muted: #6b6b66;
  --line: #e2e1dc;
  --accent: #2f5d8a;
  --accent-text: #ffffff;
  --ok: #2e7d4f;
  --warn: #9a6a00;
  --bad: #b3261e;
  --radius: 10px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141413;
    --surface: #1e1e1c;
    --text: #ececea;
    --muted: #a3a39d;
    --line: #34332f;
    --accent: #7fa8d1;
    --accent-text: #0f1720;
    --ok: #6cc28f;
    --warn: #e0b54d;
    --bad: #f08a80;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0 0 1rem; font-weight: 650; }
h2 { font-size: 1.1rem; margin: 1.75rem 0 .75rem; font-weight: 600; }
.card h2 { margin-top: 0; }

.top {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .75rem 1.25rem; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; color: var(--text); text-decoration: none; }
.top nav { display: flex; gap: .25rem; flex-wrap: wrap; flex: 1; }
.top nav a { padding: .35rem .7rem; border-radius: 8px; color: var(--text); text-decoration: none; }
.top nav a[aria-current="page"] { background: var(--bg); font-weight: 600; }
.logout { margin: 0; }

main { max-width: 1040px; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }
main.narrow { max-width: 460px; padding-top: 3rem; }

.head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.head h1 { margin: 0; }

.cards { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; }

.accounts { list-style: none; padding: 0; margin: 0 0 1rem; }
.accounts li { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem;
  padding: .6rem 0; border-top: 1px solid var(--line); }
.accounts li:first-child { border-top: 0; }
.accounts form { margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.actions form { margin: 0; }

.stack { display: flex; flex-direction: column; gap: .9rem; }
label { display: flex; flex-direction: column; gap: .3rem; font-weight: 500; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: .6rem .7rem; width: 100%;
}
textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .95rem; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

button, .button {
  display: inline-block; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; text-align: center;
  background: var(--accent); color: var(--accent-text); border: 1px solid var(--accent);
  border-radius: 8px; padding: .55rem 1rem;
}
button.secondary, .button.secondary { background: transparent; color: var(--accent); }
button.danger { background: transparent; color: var(--bad); border-color: var(--bad); }
button.small { padding: .3rem .7rem; font-size: .9rem; }
button.link { background: none; border: 0; color: var(--muted); padding: 0; font-weight: 500; }

.badge { display: inline-block; font-size: .85rem; font-weight: 600; padding: .1rem .55rem; border-radius: 999px;
  border: 1px solid currentColor; margin: 0 0 .5rem; }
.badge.ok { color: var(--ok); }
.badge.warn { color: var(--warn); }
.badge.bad { color: var(--bad); }
.badge.muted { color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.error { color: var(--bad); font-weight: 500; }
.note { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: .75rem; }
.center { text-align: center; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .05em; word-break: break-all; }

.qr { display: flex; justify-content: center; margin: 1rem 0; }
.qr svg { width: min(280px, 80vw); height: auto; background: #fff; padding: 6px; border-radius: 8px; }
.code { font: 700 2rem/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .15em; text-align: center;
  padding: 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.cancel { margin-top: 1.5rem; }
.spinner { display: inline-block; width: .9em; height: .9em; border: 2px solid var(--line);
  border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: .5rem .7rem; border-top: 1px solid var(--line); vertical-align: top; }
thead th { border-top: 0; font-weight: 600; color: var(--muted); font-size: .875rem; }
table.small td { font-size: .875rem; }
@media (max-width: 560px) { table { display: block; overflow-x: auto; } }

.search { display: flex; gap: .5rem; margin-bottom: 1rem; }
.search input { flex: 1; }
.tree, .hits { list-style: none; padding: 0; margin: 0; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); }
.tree li, .hits li { padding: .5rem .8rem; border-top: 1px solid var(--line); }
.tree li:first-child, .hits li:first-child { border-top: 0; }
.tree .depth-1 { padding-left: 2rem; }
.tree .depth-2 { padding-left: 3.2rem; }
.tree .depth-3 { padding-left: 4.4rem; }
.tree .depth-4 { padding-left: 5.6rem; }
.tree .depth-5, .tree .depth-6 { padding-left: 6.8rem; }
.tree .small { margin-left: .5rem; }
mark { background: color-mix(in srgb, var(--warn) 30%, transparent); color: inherit; }
.crumbs { margin: 0 0 .5rem; font-size: .9rem; }

.prose { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.25rem;
  overflow-wrap: anywhere; }
.prose pre { background: var(--bg); padding: .75rem; border-radius: 8px; overflow-x: auto; }
.prose code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92em; }
.prose img { max-width: 100%; }
.prose blockquote { margin: 0; padding-left: 1rem; border-left: 3px solid var(--line); color: var(--muted); }
