:root {
  --bg: #f5f6fa;
  --card: #ffffff;
  --text: #1c2130;
  --muted: #667085;
  --line: #e3e6ee;
  --accent: #4f7cff;
  --accent-text: #ffffff;
  --danger: #d6455d;
  --ok: #1f9d6a;
  --warn: #c98a12;
  --code-bg: #f0f2f7;
  --shadow: 0 1px 2px rgba(20, 30, 60, .06), 0 6px 20px rgba(20, 30, 60, .05);
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12151c; --card: #1a1f2a; --text: #e6e9f0; --muted: #98a2b3; --line: #2b3242;
    --accent: #6b93ff; --code-bg: #232a38; --shadow: 0 1px 2px rgba(0,0,0,.4);
  }
}
:root[data-theme="dark"] {
  --bg: #12151c; --card: #1a1f2a; --text: #e6e9f0; --muted: #98a2b3; --line: #2b3242;
  --accent: #6b93ff; --code-bg: #232a38; --shadow: 0 1px 2px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); min-height: 100vh; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); font-size: .92em; }
code { background: var(--code-bg); padding: 1px 5px; border-radius: 4px; word-break: break-all; }
pre { background: var(--code-bg); padding: 12px; border-radius: 8px; overflow: auto; font-family: var(--mono); font-size: .9em; }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 1.25rem 0 .5rem; }
p { margin: .5rem 0; }
.muted { color: var(--muted); }
.small { font-size: .88em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.25rem 0; }

.top { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--card); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 8px; }
.brand-lock { width: 18px; height: 18px; border-radius: 4px; background: var(--accent); display: inline-block; position: relative; }
.brand-lock::before { content: ""; position: absolute; left: 4px; top: -7px; width: 6px; height: 9px; border: 2px solid var(--accent); border-bottom: 0; border-radius: 6px 6px 0 0; }
.nav[hidden] { display: none; }
.nav { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.nav a { color: var(--muted); font-weight: 500; }
.nav a.active { color: var(--text); }

main { max-width: 980px; margin: 0 auto; padding: 24px 16px 60px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 18px; }
.card.center { max-width: 480px; margin: 40px auto; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 200px; }
.stack > * + * { margin-top: 10px; }

label { display: block; font-weight: 500; margin: 10px 0 4px; }
input[type=text], input[type=password], input[type=email], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--text); font: inherit;
}
textarea { font-family: var(--mono); font-size: .9em; min-height: 120px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.hint { color: var(--muted); font-size: .86em; margin-top: 3px; }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--text); font: inherit; font-weight: 500; cursor: pointer; }
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-sm { padding: 4px 9px; font-size: .86em; }
.btn-icon { padding: 4px 7px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs button { background: none; border: 0; padding: 10px 14px; font: inherit; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: .86em; }
td.actions { white-space: nowrap; text-align: right; }
.val { font-family: var(--mono); word-break: break-all; }
.val.masked { letter-spacing: 2px; color: var(--muted); }

.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .78em; background: var(--code-bg); color: var(--muted); }
.badge.ok { background: rgba(31,157,106,.15); color: var(--ok); }
.badge.warn { background: rgba(201,138,18,.15); color: var(--warn); }
.badge.danger { background: rgba(214,69,93,.15); color: var(--danger); }

.alert { padding: 10px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--code-bg); margin: 10px 0; }
.alert.warn { border-color: var(--warn); }
.alert.danger { border-color: var(--danger); }
.alert.ok { border-color: var(--ok); }

.list { list-style: none; padding: 0; margin: 0; }
.list li { display: flex; justify-content: space-between; align-items: center; padding: 12px 4px; border-bottom: 1px solid var(--line); gap: 12px; }
.list li:last-child { border-bottom: 0; }
.list a.title { font-weight: 600; color: var(--text); }

details { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; margin: 10px 0; }
summary { cursor: pointer; font-weight: 500; }
details[open] summary { margin-bottom: 8px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow); max-width: 90vw; z-index: 20; }
.toast.error { background: var(--danger); color: #fff; }

.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 10; padding: 16px; }
.modal { background: var(--card); border-radius: var(--radius); padding: 20px; max-width: 520px; width: 100%; box-shadow: var(--shadow); }

.step { display: flex; gap: 12px; margin: 10px 0; }
.step-n { flex: 0 0 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: .9em; }

@media (max-width: 600px) {
  .top { flex-direction: column; align-items: flex-start; gap: 8px; }
  td.actions { white-space: normal; }
  .hide-mobile { display: none; }
}
