:root {
  --bg: #0a0e14;
  --panel: #121822;
  --panel-2: #171f2c;
  --border: #232d3d;
  --text: #e6eaf0;
  --text-dim: #8b96a8;
  --text-faint: #5b6579;
  --accent: #4ea1ff;
  --accent-dim: #2b6cb0;
  --success: #3fb950;
  --success-bg: rgba(63, 185, 80, 0.14);
  --danger: #f85149;
  --danger-bg: rgba(248, 81, 73, 0.14);
  --warning: #d29922;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
}

body {
  min-height: 100vh;
}

a { color: var(--accent); }

/* ---- centered auth card (login/setup) ---- */

.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.auth-brand-mark {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent);
}

.auth-brand-name {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.auth-card h1 {
  font-size: 22px;
  margin: 4px 0 22px;
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.field input {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 15px;
  font-family: var(--font-body);
  transition: border-color 0.15s;
}

.field input:focus {
  outline: none;
  border-color: var(--accent);
}

.field input[data-mono] {
  font-family: var(--font-mono);
  letter-spacing: 0.08em;
}

.field small {
  display: block;
  margin-top: 6px;
  color: var(--text-faint);
  font-size: 12.5px;
}

button {
  font-family: var(--font-body);
  cursor: pointer;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 14.5px;
  font-weight: 600;
  transition: filter 0.12s, transform 0.05s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #051019; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:disabled { opacity: 0.5; cursor: default; }
.btn-secondary { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--text-faint); }
.btn-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid transparent; }
.btn-danger:hover { border-color: var(--danger); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 10px; font-size: 13px; border-radius: 6px; }

.auth-error {
  background: var(--danger-bg);
  color: var(--danger);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13.5px;
  margin-bottom: 16px;
  display: none;
}
.auth-error.visible { display: block; }

.auth-footnote {
  margin-top: 20px;
  font-size: 13px;
  color: var(--text-faint);
  text-align: center;
}

.qr-wrap {
  background: #fff;
  border-radius: 10px;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}
.qr-wrap img { display: block; width: 200px; height: 200px; }

.secret-display {
  font-family: var(--font-mono);
  font-size: 13.5px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  word-break: break-all;
  margin-bottom: 16px;
  color: var(--text-dim);
}

.step-indicator {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
}
.step-indicator span {
  height: 3px;
  flex: 1;
  border-radius: 2px;
  background: var(--border);
}
.step-indicator span.done { background: var(--accent); }

/* ---- dashboard shell ---- */

.dash-shell {
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px 24px 80px;
}

.dash-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.dash-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.dash-title h1 {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px;
  margin-bottom: 22px;
}

.card h2 {
  font-size: 15px;
  margin: 0 0 16px;
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.create-form {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  align-items: end;
}
.create-form .field { margin-bottom: 0; }
.create-form .field.span-2 { grid-column: span 2; }

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.search-input {
  flex: 1;
  max-width: 320px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  color: var(--text);
  font-size: 14px;
}
.search-input:focus { outline: none; border-color: var(--accent); }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

thead th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  font-weight: 600;
  padding: 0 12px 10px;
  border-bottom: 1px solid var(--border);
}

tbody td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:hover { background: var(--panel-2); }
tbody tr:last-child td { border-bottom: none; }

.key-cell {
  font-family: var(--font-mono);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: var(--text);
}
.key-cell:hover { color: var(--accent); }
.key-copy-icon { color: var(--text-faint); font-size: 12px; }

.pill {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
}
.pill-enabled { background: var(--success-bg); color: var(--success); }
.pill-disabled { background: var(--danger-bg); color: var(--danger); }

.muted { color: var(--text-faint); }
.mono { font-family: var(--font-mono); font-size: 13px; }

.row-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.empty-state {
  padding: 40px 0;
  text-align: center;
  color: var(--text-faint);
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
  z-index: 100;
}
.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(-6px);
}

/* ---- confirm modal ---- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 7, 12, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.modal-backdrop.visible { display: flex; }

.modal-card {
  width: 100%;
  max-width: 360px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px;
}
.modal-card h3 { margin: 0 0 10px; font-size: 16px; }
.modal-card p { margin: 0 0 20px; color: var(--text-dim); font-size: 14px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

.dash-loading, .auth-loading {
  text-align: center;
  color: var(--text-faint);
  padding: 60px 0;
}
