:root {
  --ink: #14201c;
  --ink-muted: #5a6b64;
  --paper: #f3f6f4;
  --panel: #ffffff;
  --line: #d5ddd8;
  --accent: #0f6b4c;
  --accent-hover: #0b543c;
  --accent-soft: #e3f2ec;
  --danger: #9b2c2c;
  --danger-soft: #fde8e8;
  --warn: #8a5a00;
  --warn-soft: #fff4d6;
  --sidebar: #101a17;
  --sidebar-text: #d7e0db;
  --sidebar-active: #1e8f68;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 32, 28, 0.06), 0 8px 24px rgba(20, 32, 28, 0.06);
  --font: "DM Sans", system-ui, sans-serif;
  --display: "Instrument Serif", Georgia, serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, #dff0e8 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #e8eee9 0%, transparent 50%),
    var(--paper);
}

button,
input,
select {
  font: inherit;
}

.boot-status,
.center-msg {
  max-width: 40rem;
  margin: 4rem auto;
  padding: 0 1.5rem;
  text-align: center;
  color: var(--ink-muted);
}

.unauthorized {
  color: var(--danger);
  font-weight: 600;
}

/* Shell */
.shell {
  display: grid;
  grid-template-columns: 1fr 240px;
  min-height: 100vh;
}

.main {
  padding: 2rem 2.25rem 3rem;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.eyebrow {
  margin: 0 0 0.35rem;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 600;
}

.page-title {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(2rem, 3vw, 2.6rem);
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.signed-in {
  color: var(--ink-muted);
  font-size: 0.875rem;
  text-align: right;
}

.signed-in strong {
  color: var(--ink);
  font-weight: 600;
}

/* Right nav */
.side-nav {
  background: var(--sidebar);
  color: var(--sidebar-text);
  padding: 1.75rem 1rem;
  border-left: 1px solid #1c2a25;
}

.side-brand {
  font-family: var(--display);
  font-size: 1.35rem;
  color: #fff;
  padding: 0 0.65rem 1.5rem;
  border-bottom: 1px solid #24332d;
  margin-bottom: 1.25rem;
}

.side-brand span {
  display: block;
  font-family: var(--font);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8aa399;
  margin-top: 0.35rem;
}

.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0.7rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(30, 143, 104, 0.18);
  color: #fff;
}

.nav-item.active {
  box-shadow: inset 3px 0 0 var(--sidebar-active);
}

/* Panels */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
  margin-bottom: 1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.field label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.field input,
.field select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  background: #fff;
  color: var(--ink);
  min-width: 10rem;
}

.field input:focus,
.field select:focus {
  outline: 2px solid rgba(15, 107, 76, 0.25);
  border-color: var(--accent);
}

.toolbar-spacer {
  flex: 1;
}

.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0.55rem 0.9rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.875rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

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

.btn-secondary {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--accent-soft);
  border-color: #b7d0c4;
}

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: #f0c2c2;
}

.btn-danger:hover:not(:disabled) {
  background: #fad2d2;
}

.btn-sm {
  padding: 0.35rem 0.6rem;
  font-size: 0.78rem;
}

.spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.spinner.dark {
  border-color: rgba(20, 32, 28, 0.2);
  border-top-color: var(--accent);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Table */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table.accounts {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}

table.accounts th,
table.accounts td {
  text-align: left;
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  font-size: 0.875rem;
}

table.accounts th {
  background: #f7faf8;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 700;
}

table.accounts tbody tr:last-child td {
  border-bottom: 0;
}

table.accounts tbody tr:hover td {
  background: #f8fbf9;
}

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

.pill {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 600;
  margin: 0.1rem 0.2rem 0.1rem 0;
}

.pill.neutral {
  background: #eef1ef;
  color: var(--ink-muted);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
}

.status-badge::before {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: currentColor;
}

.status-active {
  background: var(--accent-soft);
  color: var(--accent);
}

.status-inactive {
  background: #eef1ef;
  color: var(--ink-muted);
}

.status-unauthorized {
  background: var(--danger-soft);
  color: var(--danger);
}

.status-pending {
  background: var(--warn-soft);
  color: var(--warn);
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.inline-select,
.scope-list {
  width: 100%;
}

.scope-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 9.5rem;
}

.scope-list label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  color: var(--ink);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  margin-top: 1rem;
  color: var(--ink-muted);
  font-size: 0.85rem;
}

.page-controls {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

/* Add user */
.add-panel {
  margin-top: 1.25rem;
}

.add-panel h3 {
  margin: 0 0 1rem;
  font-size: 1rem;
}

.add-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
  align-items: end;
}

.add-grid .scopes-field {
  grid-column: span 2;
}

.scope-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 1rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.scope-checks label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  color: var(--ink);
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16, 26, 23, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 50;
}

.modal {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(16, 26, 23, 0.25);
  padding: 1.35rem 1.4rem;
}

.modal h3 {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
}

.modal p {
  margin: 0 0 1rem;
  color: var(--ink-muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.password-box {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1rem;
}

.password-box input {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
  background: #f7faf8;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.copy-toast {
  font-size: 0.8rem;
  color: var(--accent);
  font-weight: 600;
  min-height: 1.2rem;
  margin-bottom: 0.75rem;
}

.empty-state {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--ink-muted);
}

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

  .side-nav {
    order: -1;
    border-left: 0;
    border-bottom: 1px solid #1c2a25;
    padding: 1rem;
  }

  .side-brand {
    border-bottom: 0;
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
  }

  .nav-list {
    display: flex;
    gap: 0.35rem;
  }

  .add-grid {
    grid-template-columns: 1fr 1fr;
  }

  .add-grid .scopes-field {
    grid-column: span 2;
  }
}

@media (max-width: 640px) {
  .main {
    padding: 1.25rem 1rem 2rem;
  }

  .add-grid {
    grid-template-columns: 1fr;
  }

  .add-grid .scopes-field {
    grid-column: span 1;
  }
}

/* Sign out sits at the bottom of the sidebar, away from navigation, so it
   is reachable from every state — including the "not approved" and token
   error screens, which otherwise have no way out. */
.side-nav {
  display: flex;
  flex-direction: column;
}

.side-footer {
  margin-top: auto;
  padding-top: 1.25rem;
  border-top: 1px solid #24332d;
}
