* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg-0: #0b0e13;
  --bg-1: #11151c;
  --bg-2: #161b24;
  --bg-3: #1e2532;
  --border: #232b3a;
  --text: #e6e9ef;
  --text-dim: #8a93a6;
  --accent: #4f8cff;
  --accent-hover: #6ba0ff;
  --green: #00d26a;
  --red: #ff5d6c;
  --amber: #f7c948;
}
html, body { height: 100%; }
body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg-0); color: var(--text);
}

/* === Login === */
.login-screen {
  height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at top, #1a2030, var(--bg-0));
}
.login-card {
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: 14px; padding: 32px; width: 360px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.login-brand { text-align: center; margin-bottom: 24px; }
.login-brand .brand-mark {
  width: 72px; height: 72px; margin: 0 auto 12px;
  background: white; border-radius: 16px; padding: 8px;
  object-fit: contain; display: block;
  box-shadow: 0 8px 24px rgba(79,140,255,0.4);
}
.login-brand h1 { font-size: 20px; font-weight: 600; }
.login-brand p { font-size: 13px; color: var(--text-dim); }

label { display: block; font-size: 12px; color: var(--text-dim); margin: 14px 0 4px; text-transform: uppercase; letter-spacing: 0.5px; }
input, select {
  width: 100%; background: var(--bg-0); border: 1px solid var(--border);
  color: var(--text); padding: 10px 12px; border-radius: 8px; font-size: 14px;
  font-family: inherit;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }

button {
  font-family: inherit; cursor: pointer; border: none;
  border-radius: 8px; font-size: 14px; font-weight: 500;
  padding: 10px 16px; transition: all 0.15s;
}
button.primary { background: var(--accent); color: white; width: 100%; margin-top: 16px; }
button.primary:hover { background: var(--accent-hover); }
button.primary:disabled { background: var(--bg-3); cursor: not-allowed; }
button.ghost { background: transparent; color: var(--text-dim); }
button.ghost:hover { background: var(--bg-2); color: var(--text); }
button.danger { background: transparent; color: var(--red); border: 1px solid var(--red); }
button.danger:hover { background: var(--red); color: white; }
button.small { padding: 6px 10px; font-size: 12px; }

.error { color: var(--red); font-size: 13px; margin-top: 12px; min-height: 18px; }

/* === App layout === */
.app { display: flex; height: 100vh; overflow: hidden; }
.sidebar {
  width: 240px; background: var(--bg-1); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.brand { padding: 18px; display: flex; gap: 10px; align-items: center; border-bottom: 1px solid var(--border); }
.brand-mark {
  width: 36px; height: 36px;
  background: white; border-radius: 9px; padding: 4px;
  object-fit: contain; display: block;
}
.brand-title { font-size: 14px; font-weight: 600; }
.brand-sub { font-size: 11px; color: var(--text-dim); }
.nav { flex: 1; padding: 8px; overflow-y: auto; }
.nav-item {
  display: block; padding: 10px 12px; margin: 2px 0;
  border-radius: 6px; color: var(--text-dim); text-decoration: none;
  font-size: 13px; cursor: pointer;
}
.nav-item:hover { background: var(--bg-2); color: var(--text); }
.nav-item.active { background: var(--bg-3); color: var(--text); }
.sidebar-bottom { padding: 12px; border-top: 1px solid var(--border); }
.sidebar-bottom button { width: 100%; }

.content { flex: 1; overflow-y: auto; padding: 28px 36px; }
.content h2 { font-size: 22px; font-weight: 600; margin-bottom: 18px; }
.content h3 { font-size: 15px; font-weight: 600; margin-bottom: 10px; }
.tab-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.tab-header h2 { margin: 0; }
.tab-header button { width: auto; margin: 0; padding: 8px 14px; }
.hint { color: var(--text-dim); font-size: 13px; margin-bottom: 14px; line-height: 1.5; }

/* === Tables === */
.table-wrap {
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: 10px; overflow: auto;
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead { background: var(--bg-2); }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--text-dim); font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg-2); }
.actions-cell { text-align: right; white-space: nowrap; }
.actions-cell button { margin-left: 6px; }
.pill {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 500;
}
.pill.green { background: rgba(0,210,106,0.15); color: var(--green); }
.pill.red { background: rgba(255,93,108,0.15); color: var(--red); }
.pill.gray { background: var(--bg-3); color: var(--text-dim); }

/* === Cards === */
.card {
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: 10px; padding: 20px; max-width: 540px; margin-bottom: 16px;
}
.card button { width: auto; }
.code-display {
  font-family: 'Consolas', 'Cascadia Mono', monospace;
  font-size: 28px; font-weight: 600; letter-spacing: 4px;
  background: var(--bg-0); border: 1px dashed var(--accent);
  padding: 16px; border-radius: 8px; text-align: center;
  color: var(--accent); margin: 12px 0;
}

/* === Modal === */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal-card {
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: 12px; padding: 24px; width: 480px; max-width: 90vw;
}
.modal-card h3 { margin-bottom: 14px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.modal-actions button { width: auto; margin: 0; }
.modal-card .checklist { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.modal-card .checklist label {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg-2); padding: 6px 10px; border-radius: 6px;
  cursor: pointer; margin: 0; text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--text);
}
.modal-card .checklist input { width: auto; margin: 0; }

#totp-qr { width: 200px; height: 200px; background: white; padding: 8px; border-radius: 8px; }
.enroll-result { margin-top: 16px; }

.dl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; max-width: 820px; }
@media (max-width: 720px) { .dl-grid { grid-template-columns: 1fr; } }
.dl-card {
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: 12px; padding: 22px;
  transition: border-color 0.2s, transform 0.2s;
}
.dl-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.dl-icon { font-size: 32px; margin-bottom: 8px; }
.dl-card h3 { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.dl-card p { color: var(--text-dim); font-size: 12px; line-height: 1.5; margin-bottom: 14px; min-height: 50px; }
a.dl-button {
  display: inline-block; background: var(--accent); color: white;
  padding: 9px 16px; border-radius: 7px; text-decoration: none;
  font-size: 13px; font-weight: 500; transition: background 0.15s;
}
a.dl-button:hover { background: var(--accent-hover); }
a.dl-button.disabled { background: var(--bg-3); color: var(--text-muted); cursor: not-allowed; pointer-events: none; }
.dl-meta { color: var(--text-muted); font-size: 11px; margin-top: 8px; }

.banner-warn {
  background: rgba(247, 201, 72, 0.15);
  border: 1px solid var(--amber);
  color: var(--amber);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 18px;
  font-size: 13px;
  font-weight: 500;
}
.feedback {
  margin-top: 12px; padding: 10px 14px;
  border-radius: 6px; font-size: 13px;
}
.feedback.ok { background: rgba(0,210,106,0.15); color: var(--green); border: 1px solid var(--green); }
.feedback.err { background: rgba(255,93,108,0.15); color: var(--red); border: 1px solid var(--red); }
