:root {
  --bg: #f6f7fb; --surface: #fff; --surface-2: #f0f1f7; --border: #e4e6ef;
  --text: #15172b; --muted: #6b7090; --accent: #6d5efc; --accent-2: #a45cff; --accent-text: #fff;
  --ok: #12a06b; --ok-bg: #e3f7ef; --bad: #e0344f; --bad-bg: #fde8ec; --warn-bg: #fff4de; --warn: #a96b00;
  --code-bg: #12142a; --code-text: #d7daf5;
  --shadow: 0 1px 2px rgba(20,22,50,.06), 0 8px 24px rgba(20,22,50,.06);
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0e1a; --surface: #161829; --surface-2: #1e2036; --border: #2a2d48;
    --text: #eceefb; --muted: #8e93b8; --ok-bg: #0f2e24; --bad-bg: #36141c; --warn-bg: #33270d; --warn: #f0b84a;
    --code-bg: #0a0b16; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.5 Inter, system-ui, sans-serif; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
code, pre, .mono { font-family: 'JetBrains Mono', ui-monospace, monospace; }
h1, h2, h3 { margin: 0; letter-spacing: -.02em; }
.muted { color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: 8px; justify-content: center; border: 1px solid var(--border); background: var(--surface); padding: 9px 16px; border-radius: 10px; cursor: pointer; font-weight: 500; transition: transform .08s, box-shadow .15s, background .15s; }
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .nav button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--accent-text); border: 0; box-shadow: 0 4px 14px rgba(109,94,252,.4); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 5px 11px; font-size: 13px; border-radius: 8px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }

/* forms */
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field label { font-weight: 500; font-size: 13.5px; }
.field .hint { font-size: 12.5px; color: var(--muted); }
input, select, textarea { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); }
textarea { min-height: 84px; resize: vertical; font-family: 'JetBrains Mono', monospace; font-size: 13px; }
.error { background: var(--bad-bg); color: var(--bad); padding: 10px 12px; border-radius: 10px; font-size: 13.5px; margin-bottom: 14px; }
.notice { background: var(--warn-bg); color: var(--warn); padding: 10px 12px; border-radius: 10px; font-size: 13.5px; margin-bottom: 14px; }

/* auth */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-hero { padding: 56px; color: #fff; background: radial-gradient(circle at 20% 10%, #8f6bff 0, transparent 45%), radial-gradient(circle at 90% 90%, #3f8cff 0, transparent 40%), #3a2bd6; display: flex; flex-direction: column; justify-content: space-between; gap: 32px; }
.auth-hero h1 { font-size: clamp(32px, 4vw, 48px); line-height: 1.08; max-width: 14ch; }
.auth-hero p { opacity: .85; max-width: 44ch; font-size: 17px; }
.points { display: grid; gap: 14px; padding: 0; margin: 0; list-style: none; }
.points li { display: flex; gap: 12px; align-items: flex-start; opacity: .95; }
.points svg { flex: none; margin-top: 3px; }
.auth-panel { display: grid; place-items: center; padding: 32px 24px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card h2 { font-size: 26px; margin-bottom: 6px; }
.auth-card .btn.primary { width: 100%; padding: 12px; margin-top: 4px; }
.switch { text-align: center; margin-top: 18px; font-size: 14px; }
.switch button { background: none; border: 0; color: var(--accent); font-weight: 600; cursor: pointer; padding: 0; }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; letter-spacing: -.02em; }
.logo { width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); display: grid; place-items: center; }
.auth-hero .logo { background: rgba(255,255,255,.2); }

/* shell */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--border); padding: 22px 14px; display: flex; flex-direction: column; gap: 22px; position: sticky; top: 0; height: 100vh; }
.side .brand { padding: 0 8px; }
.nav { display: grid; gap: 4px; }
.nav button { display: flex; gap: 11px; align-items: center; padding: 10px 12px; border: 0; background: none; border-radius: 10px; cursor: pointer; color: var(--muted); font-weight: 500; text-align: left; }
.nav button:hover { background: var(--surface-2); color: var(--text); }
.nav button[aria-current="page"] { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.side .me { margin-top: auto; padding: 12px; border-radius: 12px; background: var(--surface-2); font-size: 13px; display: grid; gap: 8px; }
.side .me b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
main { padding: 36px clamp(18px, 4vw, 48px) 80px; max-width: 1080px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 26px; flex-wrap: wrap; }
.page-head h1 { font-size: 26px; }
.page-head p { margin: 4px 0 0; color: var(--muted); max-width: 60ch; }

/* cards & lists */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.list { display: grid; gap: 12px; }
.item { padding: 18px 20px; display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.item-main { min-width: 0; display: grid; gap: 6px; flex: 1 1 280px; }
.item-title { font-weight: 600; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.item-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-size: 12px; padding: 2px 9px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); font-family: 'JetBrains Mono', monospace; }
.badge { font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 99px; text-transform: uppercase; letter-spacing: .04em; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.off { background: var(--surface-2); color: var(--muted); }
.avatar { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); flex: none; }
.row { display: flex; gap: 14px; align-items: center; min-width: 0; flex: 1 1 280px; }
.empty { text-align: center; padding: 56px 24px; display: grid; gap: 10px; justify-items: center; }
.empty .avatar { width: 56px; height: 56px; border-radius: 16px; }
.empty p { margin: 0; color: var(--muted); max-width: 40ch; }

/* table */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 12px 18px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
td.wrap { white-space: normal; max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
th { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
tr:last-child td { border-bottom: 0; }

/* code */
.code { position: relative; background: var(--code-bg); color: var(--code-text); border-radius: 12px; overflow: hidden; }
.code pre { margin: 0; padding: 18px 20px; overflow-x: auto; font-size: 13px; line-height: 1.65; }
.code .copy { position: absolute; top: 10px; right: 10px; background: rgba(255,255,255,.1); border: 0; color: #d7daf5; }
.code .copy:hover { background: rgba(255,255,255,.2); }
.tabs { display: flex; gap: 4px; margin-bottom: 12px; }
.tabs button { border: 0; background: none; padding: 7px 14px; border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 500; }
.tabs button[aria-selected="true"] { background: var(--surface-2); color: var(--text); }
.steps { display: grid; gap: 22px; counter-reset: s; }
.step { display: grid; grid-template-columns: 34px 1fr; gap: 16px; }
.step::before { counter-increment: s; content: counter(s); width: 34px; height: 34px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; font-weight: 600; }
.step h3 { font-size: 16px; margin-bottom: 4px; }
.step p { margin: 0 0 12px; color: var(--muted); }
.step code.inline, p code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-size: 12.5px; }
.pad { padding: 22px 24px; }

/* modal */
.overlay { position: fixed; inset: 0; background: rgba(8,9,24,.55); backdrop-filter: blur(3px); display: grid; place-items: center; padding: 20px; z-index: 50; animation: fade .15s; overflow-y: auto; }
.modal { width: 100%; max-width: 480px; padding: 26px; animation: pop .18s; max-height: 100%; overflow-y: auto; }
.modal h2 { font-size: 20px; margin-bottom: 4px; }
.modal > p { margin: 0 0 20px; color: var(--muted); font-size: 14px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.keybox { display: flex; gap: 8px; align-items: center; background: var(--code-bg); color: #b7f5d6; padding: 12px 14px; border-radius: 10px; word-break: break-all; font-size: 13px; margin-bottom: 14px; }
.keybox span { flex: 1; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0 18px; }
.toggle { width: 42px; height: 24px; border-radius: 99px; border: 0; background: var(--border); position: relative; cursor: pointer; flex: none; transition: background .15s; }
.toggle::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; }
.toggle[aria-checked="true"] { background: var(--accent); }
.toggle[aria-checked="true"]::after { transform: translateX(18px); }

#toasts { position: fixed; bottom: 20px; right: 20px; display: grid; gap: 8px; z-index: 100; }
.toast { background: var(--text); color: var(--bg); padding: 11px 16px; border-radius: 10px; box-shadow: var(--shadow); animation: pop .18s; font-size: 14px; }
.toast.bad { background: var(--bad); color: #fff; }
.spin { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: rot .6s linear infinite; }
.loading { display: grid; place-items: center; padding: 60px; color: var(--muted); }
@keyframes rot { to { transform: rotate(360deg); } }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; }
  .auth-hero { padding: 28px 24px; }
  .auth-hero .points { display: none; }
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px 14px; gap: 8px 14px; }
  .nav { grid-auto-flow: column; overflow-x: auto; order: 3; width: 100%; }
  .nav button { padding: 8px 12px; white-space: nowrap; }
  .side .me { margin: 0 0 0 auto; padding: 6px 10px; grid-auto-flow: column; align-items: center; }
  .side .me b { display: none; }
  main { padding-top: 24px; }
}
