:root {
  --bg: #0d1117;
  --panel: #161b22;
  --border: #30363d;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #5b6ee1;
  --accent-hover: #4a5dd0;
  --error: #f87171;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

main {
  max-width: 420px;
  margin: 0 auto;
  padding: 80px 24px 24px;
}

h1 {
  font-size: 24px;
  font-weight: 600;
  margin: 0 0 8px;
}

.hint {
  color: var(--muted);
  margin: 0 0 24px;
}

form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

input[type="email"], input[type="text"] {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font: inherit;
  padding: 10px 12px;
}

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

#code-input {
  font-size: 20px;
  letter-spacing: 6px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

button {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 6px;
  font: inherit;
  font-weight: 500;
  padding: 10px 16px;
  cursor: pointer;
}

button:hover { background: var(--accent-hover); }
button:disabled { opacity: 0.6; cursor: not-allowed; }

button.link {
  background: none;
  color: var(--muted);
  padding: 4px 0;
  font-size: 13px;
}
button.link:hover { color: var(--text); }

#google-button {
  background: white;
  color: #1f1f1f;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  border-radius: 8px;
  border: 1px solid #d2d2d2;
  font-weight: 500;
  width: 100%;
  justify-content: center;
}

#google-button:hover {
  background: #f8f9fa;
  border-color: #c2c2c2;
}

#google-button .g-icon {
  display: inline-flex;
  align-items: center;
}

.error {
  color: var(--error);
  font-size: 13px;
  margin: 8px 0 0;
}

#dashboard-list {
  list-style: none;
  padding: 0;
  margin: 0 0 24px;
}

#dashboard-list li {
  margin-bottom: 8px;
}

.dashboard-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.dashboard-link {
  flex: 1;
  display: block;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
}

.dashboard-link:hover {
  border-color: var(--accent);
}

.dashboard-name { font-weight: 500; }
.dashboard-role { color: var(--muted); font-size: 12px; margin-top: 2px; }

.manage-button {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 14px;
  font-size: 13px;
  white-space: nowrap;
}
.manage-button:hover {
  border-color: var(--accent);
  background: var(--panel);
}

/* ── Permissions modal ────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal[hidden] { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
}

.modal-panel {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  width: min(480px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  overflow-y: auto;
  padding: 20px 24px 24px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
}

.modal-panel header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 4px;
}
.modal-panel h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}
.modal-close {
  background: transparent;
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
  padding: 0 4px;
  border: none;
}
.modal-close:hover { color: var(--text); background: transparent; }

.permissions-list {
  list-style: none;
  padding: 0;
  margin: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.permission-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.permission-meta { min-width: 0; }
.permission-email {
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.permission-role {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}
.role-owner { color: #f0b429; }
.permission-locked {
  color: var(--muted);
  font-size: 12px;
}
button.link.danger { color: var(--error); }
button.link.danger:hover { color: #f87171; text-decoration: underline; }

#grant-form {
  margin-top: 8px;
  margin-bottom: 0;
  gap: 8px;
}
.grant-row {
  display: flex;
  gap: 8px;
}
.grant-row input { flex: 1; }
.grant-row button { white-space: nowrap; }
