:root {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1e222b;
  --border: #2a2f3a;
  --text: #e8eaed;
  --muted: #9aa4b2;
  --accent: #5b8def;
  --green: #3fb950;
  --amber: #d9a441;
  --red: #e5534b;
  --gray: #6e7681;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body.centered {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* --- app shell: left sidebar + content --- */

.app-layout {
  display: flex;
  min-height: 100vh;
  align-items: stretch;
}

.sidebar {
  width: 260px;
  flex: 0 0 260px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 6px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.sidebar-logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.sidebar-title { font-weight: 600; font-size: 14px; }
.sidebar-subtitle { font-size: 12px; color: var(--muted); }

.sidebar-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }

.nav-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  margin-bottom: 2px;
}
.nav-item:hover { background: var(--surface-2); }
.nav-item.active { background: rgba(91,141,239,0.15); }
.nav-item.active .nav-label { color: var(--accent); }
.nav-label { font-size: 14px; font-weight: 500; }
.nav-desc { font-size: 11.5px; color: var(--muted); line-height: 1.3; }

.nav-group { margin: 10px 0 2px; }
.nav-group-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 8px 12px 4px;
}
.nav-item.nav-sub { padding-left: 20px; }

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  margin-top: 12px;
}
.who { font-size: 13px; word-break: break-all; }
.who-name { color: var(--text); font-weight: 600; }
.who-email { color: var(--muted); font-size: 11.5px; margin-bottom: 2px; }
.role-badge {
  display: inline-block;
  margin: 6px 0 8px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  background: var(--surface-2);
  color: var(--muted);
}

.link-button {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  padding: 0;
  text-decoration: underline;
}

.content {
  flex: 1;
  min-width: 0;
  padding: 36px 40px 64px;
  max-width: 980px;
}

.page-intro { color: var(--muted); font-size: 14px; margin: -10px 0 24px; max-width: 640px; }

h1 { font-size: 22px; margin-bottom: 20px; }

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

.login-card { width: 380px; text-align: center; }
.login-card h1 { font-size: 20px; }

label {
  display: block;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--muted);
}

input, select, textarea {
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}

textarea { resize: vertical; }

button, .button {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 10px 18px;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
}
button:hover, .button:hover { filter: brightness(1.08); }

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.table th, .table td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.table th { color: var(--muted); font-weight: 500; background: var(--surface-2); }
.table tr:last-child td { border-bottom: none; }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.status-pending { background: rgba(217,164,65,0.18); color: var(--amber); }
.status-approved { background: rgba(91,141,239,0.18); color: var(--accent); }
.status-granted { background: rgba(63,185,80,0.18); color: var(--green); }
.status-rejected { background: rgba(229,83,75,0.18); color: var(--red); }
.status-grant_failed { background: rgba(229,83,75,0.18); color: var(--red); }
.status-revoked { background: rgba(110,118,129,0.18); color: var(--gray); }
.status-revoke_failed { background: rgba(229,83,75,0.18); color: var(--red); }

.dev-badge { background: rgba(217,164,65,0.18); color: var(--amber); padding: 8px 12px; border-radius: 6px; font-size: 12px; margin-bottom: 16px; }

.flash { padding: 10px 14px; border-radius: 6px; font-size: 14px; margin-bottom: 16px; }
.flash.error { background: rgba(229,83,75,0.15); color: var(--red); }
.flash.success { background: rgba(63,185,80,0.15); color: var(--green); }

.muted { color: var(--muted); font-size: 13px; }

.request-card { margin-bottom: 14px; }
.request-head { margin-bottom: 6px; }
.reason { margin: 8px 0; color: var(--text); }
.actions { display: flex; gap: 12px; margin-top: 14px; }
.actions form { display: flex; gap: 8px; }
.actions input { width: 200px; margin-top: 0; }
button.approve { background: var(--green); }
button.reject { background: var(--red); }

.actions-inline { display: flex; gap: 6px; margin-top: 0; }
.actions-inline form { display: flex; gap: 4px; }
.actions-inline input {
  width: 110px;
  margin-top: 0;
  padding: 6px 8px;
  font-size: 12px;
}
.actions-inline button {
  padding: 6px 10px;
  font-size: 12px;
}
.table td, .table th { white-space: nowrap; }
.table td:nth-child(8) { white-space: normal; max-width: 220px; }

/* --- polish: motion, hover feedback, witty status copy --- */

@media (prefers-reduced-motion: no-preference) {
  .nav-item, .card, button, .button, .badge, .flash {
    transition: background-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease, filter 0.15s ease;
  }
  .card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.25); }
  .request-card:hover { transform: translateY(-1px); }
  button:active, .button:active { transform: scale(0.97); }
  .nav-item:hover { transform: translateX(2px); }

  @keyframes pulse-soft {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.55; }
  }
  @keyframes bounce-emoji {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-2px); }
  }
  @keyframes pop-in {
    0% { transform: scale(0.6); opacity: 0; }
    70% { transform: scale(1.08); opacity: 1; }
    100% { transform: scale(1); }
  }
  @keyframes shake-soft {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-3px); }
    40% { transform: translateX(3px); }
    60% { transform: translateX(-2px); }
    80% { transform: translateX(2px); }
  }
  @keyframes slide-fade-in {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
  }

  .badge.status-pending { animation: pulse-soft 1.8s ease-in-out infinite; }
  .badge.status-granted { animation: pop-in 0.4s ease; }
  .badge.status-rejected { animation: shake-soft 0.4s ease; }
  .badge.status-grant_failed { animation: shake-soft 0.4s ease; }
  .badge.status-revoke_failed { animation: shake-soft 0.4s ease; }
  .flash { animation: slide-fade-in 0.25s ease; }
  .flash.success::before { content: "🎉 "; }
  .flash.error::before { content: "😬 "; }
}

.status-cell { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.requesting-as { font-size: 13px; margin: 0 0 18px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }

.status-note {
  font-size: 11.5px;
  color: var(--muted);
  max-width: 240px;
  line-height: 1.35;
}
.table td .status-note { white-space: normal; }

/* --- GCP users & roles, command log, command receipt --- */

.card-title { font-size: 15px; margin: 0 0 14px; }

.inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px;
}
.inline-form label { margin-bottom: 0; flex: 1 1 180px; }
.inline-form button { height: 38px; }

.access-table { margin-top: 24px; }

.role-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.role-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 6px 3px 10px;
  font-size: 12px;
  white-space: nowrap;
}
.chip-form { display: inline-flex; margin: 0; }
.chip-remove {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 2px 4px;
}
.chip-remove:hover { color: var(--red); }

.terminal {
  background: #0a0c10;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.7;
  margin: 20px 0;
  overflow-x: auto;
}
.terminal .cmd-line {
  color: #e8eaed;
  margin-bottom: 10px;
  white-space: pre-wrap;
  word-break: break-all;
}
.terminal .cmd-line::before { content: "$ "; color: var(--accent); }
.terminal .step { color: #9aa4b2; white-space: pre-wrap; }
.terminal .step::before { content: "→ "; }
.terminal .step.done::before { content: "✓ "; color: var(--green); }
.terminal .step.failed { color: var(--red); }
.terminal .step.failed::before { content: ""; }

.preview-command {
  margin: 10px 0;
  font-size: 12.5px;
}
.preview-command code {
  display: inline-block;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--text);
  word-break: break-all;
}
.table .preview-command { max-width: 320px; white-space: normal; }
