:root {
  --bg: #0f0f12;
  --surface: #18181c;
  --border: #2a2a2e;
  --text: #e4e4e7;
  --text-muted: #a1a1aa;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --error: #f87171;
  --error-bg: rgba(248, 113, 113, 0.12);
  --radius: 8px;
  --font: "DM Sans", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Login page ────────────────────────────────────────── */

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
}

.login-card h1 {
  margin: 0 0 0.25rem;
  font-size: 1.5rem;
  font-weight: 600;
}

.login-subtitle {
  margin: 0 0 1.5rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.login-form label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.login-form input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  margin-bottom: 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 1rem;
}

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

.login-form button {
  width: 100%;
  padding: 0.65rem 1rem;
  margin-top: 0.5rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
}

.login-form button:hover {
  background: var(--accent-hover);
}

.alert {
  padding: 0.65rem 0.85rem;
  margin-bottom: 1rem;
  border-radius: 6px;
  font-size: 0.9rem;
}

.alert-error {
  background: var(--error-bg);
  color: var(--error);
}

.alert-success {
  background: rgba(74, 222, 128, 0.12);
  color: #4ade80;
}

.text-link {
  color: var(--accent-hover);
  text-decoration: none;
  font-size: 0.875rem;
}

.text-link:hover {
  text-decoration: underline;
}

/* ── Dashboard shell ───────────────────────────────────── */

.dashboard-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.dashboard-header h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-email {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ── Buttons ───────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.9rem;
  text-decoration: none;
  cursor: pointer;
  border: none;
  font-family: var(--font);
}

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
}

.btn-outline {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-outline:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

.btn-accent {
  background: var(--accent);
  color: white;
}

.btn-accent:hover {
  background: var(--accent-hover);
}

.btn-danger {
  background: #dc3545;
  color: white;
}

.btn-danger:hover {
  background: #bb2d3b;
}

.card-danger {
  border: 1px solid #dc354540;
}

/* ── Dashboard main & card grid ────────────────────────── */

.dashboard-main {
  flex: 1;
  padding: 1.5rem;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
}

@media (max-width: 768px) {
  .card-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Summary cards (dashboard) ─────────────────────────── */

.summary-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 2.5rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s;
}

.summary-card:hover {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.04);
}

.summary-count {
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1;
  color: var(--accent-hover);
}

.summary-label {
  font-size: 0.9rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}


/* ── Cards ─────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.card-header h2 {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.card-count {
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--surface);
  padding: 0.15rem 0.55rem;
  border-radius: 12px;
  font-weight: 500;
}

.card-toolbar {
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border);
}

.card-body {
  padding: 0;
}

.card-body > .empty-state {
  margin: 0;
  border: none;
  border-radius: 0;
}

/* ── Search ────────────────────────────────────────────── */

.search-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--font);
}

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

.search-input::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}

/* ── Data tables ───────────────────────────────────────── */

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 0.65rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}

.data-table th {
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.text-muted {
  color: var(--text-muted);
}

.text-right {
  text-align: right;
}

/* ── Empty state ───────────────────────────────────────── */

.empty-state {
  color: var(--text-muted);
  padding: 2rem;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
}

/* ── Role badges & overview ────────────────────────────── */

.role-overview-group {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

.role-overview-group:last-child {
  border-bottom: none;
}

.role-overview-domain {
  margin: 0 0 0.4rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.role-overview-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.role-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.78rem;
  padding: 0.2rem 0.5rem;
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent-hover);
  border-radius: 4px;
}

.role-domain-inline {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-right: 0.1rem;
}

.role-overview-entry {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.role-overview-entry:last-child {
  margin-bottom: 0;
}

.role-user-list {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.role-user-link {
  color: var(--accent-hover);
  text-decoration: none;
}

.role-user-link:hover {
  text-decoration: underline;
}

.role-badge-removable {
  padding-right: 0.3rem;
}

.role-remove-form {
  display: inline;
  margin: 0;
  padding: 0;
}

.role-remove-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  padding: 0 0.15rem;
  opacity: 0.5;
}

.role-remove-btn:hover {
  color: var(--error);
  opacity: 1;
}

/* ── User-roles page ───────────────────────────────────── */

.user-roles-container {
  max-width: 640px;
  margin: auto;
}

.user-roles-header {
  margin-bottom: 1.25rem;
}

.user-roles-header h2 {
  margin: 0 0 0.25rem;
  font-size: 1.25rem;
  font-weight: 600;
}

.user-id {
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--surface);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}

.user-roles-container .card {
  margin-bottom: 1rem;
}

.role-manage-group {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

.role-manage-group:last-child {
  border-bottom: none;
}

/* ── Add-role form ─────────────────────────────────────── */

.add-role-form {
  padding: 0;
}

.form-row {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
}

.form-field {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.form-field label {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

.form-input {
  padding: 0.5rem 0.65rem;
  font-size: 0.875rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--font);
}

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

.form-input::placeholder {
  color: var(--text-muted);
  opacity: 0.5;
}

.form-field-action {
  flex: 0;
}

/* ── Select inputs (dropdowns) ────────────────────────── */

select.form-input {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23a1a1aa' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.65rem center;
  padding-right: 2rem;
  cursor: pointer;
}

select.form-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Banned badge ─────────────────────────────────────── */

.badge-banned {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.5rem;
  background: var(--error-bg);
  color: var(--error);
  border-radius: 4px;
  vertical-align: middle;
  margin-left: 0.35rem;
}

/* ── Danger zone items ───────────────────────────────── */

.danger-zone-item {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

.danger-zone-item:last-child {
  border-bottom: none;
}

/* ── Domain roles list (detail page) ──────────────────── */

.domain-roles-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.75rem 1rem;
}

