:root {
  --bg: #0e1116;
  --surface: #171b22;
  --surface-2: #1f242d;
  --border: #2a313c;
  --text: #e6e9ef;
  --muted: #8b95a5;
  --primary: #25d366;
  --primary-ink: #04210f;
  --danger: #ef4444;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; }

.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; font-size: 1.1rem; }
.brand .logo { color: var(--primary); }
.plain { text-decoration: none; display: flex; align-items: center; gap: .5rem; }

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--border);
  background: var(--surface); position: sticky; top: 0; z-index: 5;
}
.container { max-width: 960px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }
.container.narrow { max-width: 520px; }

h2 { font-size: 1.1rem; margin: 0; }
.muted { color: var(--muted); }
section { margin-top: 2.25rem; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: .9rem; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  padding: .5rem .9rem; border-radius: 9px; font-size: .9rem; font-weight: 600;
  cursor: pointer; text-decoration: none; transition: .15s; white-space: nowrap;
}
.btn:hover { border-color: #3a4454; }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: transparent; }
.btn.small { padding: .35rem .6rem; font-size: .8rem; }
.btn.danger { color: #fff; background: transparent; border-color: #5a2b2b; }
.btn.danger:hover { background: var(--danger); border-color: var(--danger); }
.btn.block { width: 100%; margin-top: .75rem; }

input[type=text], input[type=password] {
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  padding: .5rem .7rem; border-radius: 9px; font-size: .9rem; min-width: 220px;
}
input:focus { outline: none; border-color: var(--primary); }
form.inline { display: flex; gap: .5rem; flex-wrap: wrap; }

.tbl { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.tbl th, .tbl td { text-align: left; padding: .7rem .85rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl th { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--surface-2); }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr.revoked { opacity: .5; }
.row-actions { display: flex; gap: .4rem; justify-content: flex-end; }
.row-actions form { margin: 0; }

.pill { display: inline-block; padding: .2rem .6rem; border-radius: 999px; font-size: .78rem; font-weight: 600; }
.pill.green { background: rgba(37,211,102,.15); color: #4ade80; }
.pill.amber { background: rgba(245,158,11,.15); color: #fbbf24; }
.pill.red { background: rgba(239,68,68,.15); color: #f87171; }
.pill.gray { background: var(--surface-2); color: var(--muted); }

.empty { color: var(--muted); padding: 1.25rem; background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }

.alert { padding: .75rem 1rem; border-radius: 9px; margin-bottom: 1rem; }
.alert.error { background: rgba(239,68,68,.12); color: #fca5a5; border: 1px solid #5a2b2b; }
.alert.ok { background: rgba(37,211,102,.12); color: #86efac; border: 1px solid #1e5b36; }

.keybox { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.newkey { background: var(--bg); padding: .5rem .7rem; border-radius: 8px; border: 1px solid var(--border); word-break: break-all; flex: 1; min-width: 240px; }

.code-block { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; overflow-x: auto; white-space: pre; font-family: ui-monospace, Menlo, monospace; font-size: .82rem; color: #cbd5e1; }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1.25rem; }
.login-card { width: 100%; max-width: 340px; text-align: center; }
.login-card .brand { justify-content: center; font-size: 1.4rem; }
.login-card label { display: block; text-align: left; font-size: .8rem; color: var(--muted); margin: 1rem 0 .3rem; }
.login-card input { width: 100%; }

/* qr */
.qr-card { text-align: center; }
.qrbox { display: grid; place-items: center; min-height: 300px; margin: 1rem 0; }
.qrbox img { background: #fff; padding: 10px; border-radius: 12px; }
.qr-loading, .qr-done { color: var(--muted); }
.qr-done { font-size: 4rem; color: var(--primary); }
.status { font-weight: 600; }
.status.connecting { color: #fbbf24; }
.status.ok { color: #4ade80; }

@media (max-width: 560px) {
  input[type=text] { min-width: 0; flex: 1; }
  .section-head { align-items: stretch; }
  .section-head .inline { width: 100%; }
}
