/* =========================================================================
   Application Manager — global styles
   Buildless, framework-free. Designed for a small internal tool:
   clean, quiet, readable. Light theme with an indigo accent.
   ========================================================================= */

:root {
  --bg: #f4f5f9;
  --surface: #ffffff;
  --border: #e3e5ee;
  --text: #1d2433;
  --text-muted: #626b7f;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef0fe;
  --danger: #b3261e;
  --danger-soft: #fdecea;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(23, 27, 43, 0.05), 0 8px 24px rgba(23, 27, 43, 0.07);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
          Arial, sans-serif;
}

* { box-sizing: border-box; }

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

body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(1200px 500px at 85% -10%, #e4e7ff 0%, transparent 60%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: var(--accent-soft);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

a { color: var(--accent); }

/* ------------------------------------------------------------------ */
/* Auth screens                                                        */
/* ------------------------------------------------------------------ */

.auth-layout {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 40px 36px 28px;
}

.brand { text-align: center; margin-bottom: 28px; }

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: linear-gradient(135deg, #6366f1, #4338ca);
  color: #fff;
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 0.5px;
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.35);
}

.brand h1 {
  font-size: 22px;
  margin: 16px 0 4px;
  letter-spacing: -0.01em;
}

.auth-subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 14.5px;
}

.field { margin-bottom: 16px; }

.field label {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  margin-bottom: 6px;
}

.field input {
  width: 100%;
  font: inherit;
  font-size: 15px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 13px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.18);
}

.field input:disabled { background: var(--bg); color: var(--text-muted); }

.hint {
  margin: 6px 0 0;
  font-size: 12.5px;
  color: var(--text-muted);
}

.form-error {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid #f3c2be;
  border-radius: 10px;
  padding: 10px 13px;
  font-size: 14px;
  margin: 0 0 16px;
}

.btn {
  font: inherit;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-primary {
  width: 100%;
  padding: 12px 16px;
  font-size: 15.5px;
  color: #fff;
  background: var(--accent);
  position: relative;
}

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

/* Busy spinner replaces the label while a request is in flight. */
.btn.is-busy .btn-label { visibility: hidden; }

.btn.is-busy::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.auth-footnote {
  margin: 22px 0 0;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-muted);
}

/* ------------------------------------------------------------------ */
/* Signed-in shell                                                     */
/* ------------------------------------------------------------------ */

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

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark-sm { width: 32px; height: 32px; border-radius: 9px; font-size: 13px; box-shadow: none; }

.topbar-title {
  font-weight: 700;
  font-size: 15.5px;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.tabs {
  display: flex;
  gap: 4px;
  margin-left: 18px;
  align-self: stretch;
  align-items: stretch;
}

.tabs a {
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tabs a:hover { color: var(--text); }

.tabs a.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.user-menu {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-email {
  font-size: 13.5px;
  color: var(--text-muted);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  border-radius: 999px;
  flex-shrink: 0;
}

.badge-admin { background: var(--accent-soft); color: var(--accent); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  padding: 7px 12px;
  font-size: 13.5px;
  border: 1px solid var(--border);
  border-radius: 9px;
  flex-shrink: 0;
}

.btn-ghost:hover { color: var(--text); background: var(--bg); }

.content {
  flex: 1;
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 20px 48px;
}

.content:focus { outline: none; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
}

.card h2 {
  margin: 0 0 10px;
  font-size: 20px;
  letter-spacing: -0.01em;
}

.card p { margin: 0; color: var(--text-muted); }

.hello { text-align: center; padding: 56px 32px; }

.hello-emoji { font-size: 44px; display: block; margin-bottom: 10px; }

.hello h2 { font-size: 26px; }

.hello p { max-width: 460px; margin: 0 auto; }

/* ------------------------------------------------------------------ */
/* Admin — invite form + user list                                     */
/* ------------------------------------------------------------------ */

.stack { display: flex; flex-direction: column; gap: 24px; }

.card-lede {
  margin: 0 0 4px;
  color: var(--text-muted);
  font-size: 14px;
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.card-header h2 { margin-bottom: 4px; }

.invite-form { margin-top: 16px; }

.invite-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

.invite-field { flex: 1; max-width: 420px; margin-bottom: 0; }

.btn-inline {
  width: auto;
  padding: 11px 20px;
  white-space: nowrap;
}

.form-success {
  background: #e7f6ec;
  color: #14652f;
  border: 1px solid #bfe5cb;
  border-radius: 10px;
  padding: 10px 13px;
  font-size: 14px;
  margin: 0 0 16px;
}

/* Busy state on non-primary buttons: keep the spinner visible. */
.btn.is-busy { position: relative; }

.btn-ghost.is-busy::after {
  border-color: rgba(79, 70, 229, 0.25);
  border-top-color: var(--accent);
}

.table-scroll { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
}

.data-table th {
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

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

.data-table tbody tr:hover { background: #fafbff; }

.cell-email {
  font-weight: 600;
  margin-right: 8px;
  word-break: break-all;
}

.cell-actions { text-align: right; white-space: nowrap; }

.btn-sm { padding: 5px 10px; font-size: 12.5px; }

.badge-status-active { background: #e7f6ec; color: #14652f; }
.badge-status-invited { background: #fff4e0; color: #8a5a00; }
.badge-status-warn { background: #fdecea; color: var(--danger); }
.badge-status-disabled { background: #eceef3; color: var(--text-muted); }

.table-placeholder {
  padding: 36px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14.5px;
}

.table-placeholder p { margin: 0 0 12px; }

.table-placeholder-error { color: var(--danger); }

.table-footer {
  display: flex;
  justify-content: center;
  padding-top: 14px;
}

.spinner {
  display: inline-block;
  vertical-align: -3px;
  width: 16px;
  height: 16px;
  margin-right: 6px;
  border: 2.5px solid rgba(79, 70, 229, 0.25);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ------------------------------------------------------------------ */
/* Small screens                                                       */
/* ------------------------------------------------------------------ */

@media (max-width: 560px) {
  .topbar-inner { padding: 0 12px; gap: 8px; }
  .topbar-title { display: none; }
  .user-email { display: none; }
  .auth-card { padding: 32px 24px 22px; }
  .card { padding: 22px 18px; }
  .invite-row { flex-direction: column; align-items: stretch; }
  .invite-field { max-width: none; }
  .btn-inline { width: 100%; }
  .card-header { flex-direction: column; }
  .card-header .btn { align-self: flex-start; }
}
