:root {
  --bg: #0e1015;
  --card: #171a21;
  --card2: #1d212b;
  --line: #262b37;
  --text: #e8ebf2;
  --muted: #8b93a5;
  --accent: #4f7cff;
  --accent2: #3b63d8;
  --green: #34c07c;
  --red: #e05555;
  --amber: #e0a83c;
}

* { box-sizing: border-box; margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.center { text-align: center; padding: 24px 0; }
.err { color: var(--red); margin-top: 10px; font-size: 14px; }
.hint { color: var(--muted); font-size: 13px; margin-top: 14px; line-height: 1.6; }

/* ---------- login ---------- */

#view-login {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px;
}

.login-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 34px 32px; width: 100%; max-width: 380px;
  text-align: center;
}
.login-card h1 { font-size: 22px; letter-spacing: .04em; }
.login-card form { margin-top: 22px; text-align: left; }
.login-card label { display: block; margin-bottom: 14px; font-size: 13px; color: var(--muted); }

input, textarea {
  width: 100%; margin-top: 5px; padding: 10px 12px;
  background: var(--card2); border: 1px solid var(--line); border-radius: 8px;
  color: var(--text); font: inherit; outline: none;
}
input:focus, textarea:focus { border-color: var(--accent); }

/* ---------- header ---------- */

header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px; border-bottom: 1px solid var(--line);
  background: var(--card);
}
.brand { display: flex; gap: 12px; align-items: center; }
.brand b { font-size: 16px; letter-spacing: .03em; }
.brand .muted { display: block; font-size: 12.5px; }
.hdr-actions { display: flex; gap: 10px; align-items: center; }

.logo-shield {
  width: 42px; height: 42px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #7a5cff);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2 4 5v6c0 5 3.4 9.4 8 11 4.6-1.6 8-6 8-11V5l-8-3z'/%3E%3C/svg%3E") center/contain no-repeat, #4f7cff;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2 4 5v6c0 5 3.4 9.4 8 11 4.6-1.6 8-6 8-11V5l-8-3z'/%3E%3C/svg%3E") center/contain no-repeat, #4f7cff;
  background-clip: text; -webkit-background-clip: text; color: var(--accent);
}
.logo-shield.small { width: 34px; height: 34px; }

/* ---------- layout ---------- */

main { max-width: 1080px; margin: 0 auto; padding: 22px; }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px;
}

.table-card { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { text-align: left; padding: 13px 16px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: 12.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(79,124,255,.05); }
td .name { font-weight: 600; }
td .mono { font-family: ui-monospace, Menlo, monospace; font-size: 13px; }

/* ---------- buttons & chips ---------- */

.btn {
  border: 1px solid var(--line); background: var(--card2); color: var(--text);
  border-radius: 8px; padding: 9px 16px; font: inherit; cursor: pointer;
  transition: background .12s, border-color .12s;
}
.btn:hover { border-color: var(--accent); }
.btn.wide { width: 100%; }
.btn.primary { background: var(--accent); border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { background: var(--accent2); }
.btn.ghost { background: transparent; }
.btn.danger { color: #ff8d8d; }
.btn.danger:hover { border-color: var(--red); }
.btn:disabled { opacity: .5; cursor: wait; }

.chip {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600;
}
.chip.green { background: rgba(52,192,124,.15); color: var(--green); }
.chip.red { background: rgba(224,85,85,.15); color: var(--red); }
.chip.grey { background: rgba(139,147,165,.15); color: var(--muted); }
.chip.amber { background: rgba(224,168,60,.15); color: var(--amber); }
.chip.on { background: rgba(52,192,124,.15); color: var(--green); }
.chip.off { background: rgba(224,85,85,.15); color: var(--red); }

.row { display: flex; }
.gap { gap: 10px; }

/* ---------- dialogs ---------- */

dialog {
  background: var(--card); color: var(--text);
  border: 1px solid var(--line); border-radius: 14px;
  padding: 24px; width: min(480px, 92vw);
}
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog h2 { font-size: 18px; margin-bottom: 8px; }
dialog form label { display: block; margin: 14px 0 0; font-size: 13px; color: var(--muted); }
dialog .row { margin-top: 18px; }

#qr-holder { display: flex; justify-content: center; padding: 14px 0; }
#qr-holder img { border-radius: 10px; }

#key-link {
  font-family: ui-monospace, Menlo, monospace; font-size: 12.5px;
  min-height: 84px; resize: none; white-space: nowrap;
}

/* ---------- toasts ---------- */

#toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 99; }
.toast {
  background: var(--card2); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  padding: 10px 16px; border-radius: 8px; font-size: 14px; max-width: 340px;
  animation: slide .18s ease-out;
}
.toast.err { border-left-color: var(--red); }
.toast.ok { border-left-color: var(--green); }
@keyframes slide { from { transform: translateY(8px); opacity: 0; } }

/* ---------- responsive ---------- */

@media (max-width: 640px) {
  header { padding: 12px; flex-wrap: wrap; }
  main { padding: 14px; }
  .toolbar { flex-wrap: wrap; }
}
