/* ctg-portal — ClubTech brand system.
   Tokens mirror the ClubTech style guide (Figma CTG-Landing-Pages v2):
   near-monochrome slate palette, Albert Sans w/ -0.04em tracking, pill
   buttons, 24px cards, glass floating navbar. No framework. */

:root {
  /* ---- Color ---- */
  --ctg-background: #fcfcfc;          /* page */
  --ctg-foreground: #020617;          /* dark surface / primary button */
  --ctg-primary-foreground: #f8fafc;  /* text on dark */
  --ctg-secondary: #f1f5f9;           /* secondary button / card / muted */
  --ctg-muted: #f1f5f9;
  --ctg-border: #e2e8f0;

  --ctg-text-heading: #262626;
  --ctg-text-body: #515151;
  --ctg-text-subtle: #6e6e6e;
  --ctg-nav-link: #334155;
  --ctg-white: #ffffff;

  /* Semantic states (app-side extension of the brand: kept quiet & tinted) */
  --ctg-ok-bg: #f0fdf4;   --ctg-ok-border: #bbf7d0;   --ctg-ok-text: #166534;
  --ctg-warn-bg: #fffbeb; --ctg-warn-border: #fde68a; --ctg-warn-text: #92400e;
  --ctg-danger: #b91c1c;  --ctg-danger-hover: #991b1b;
  --ctg-danger-bg: #fef2f2; --ctg-danger-border: #fecaca;

  /* Glass navbar */
  --ctg-glass-bg: rgba(215, 215, 215, 0.56);
  --ctg-glass-border: rgba(255, 255, 255, 0.2);
  --ctg-glass-blur: 60px;

  /* ---- Typography ---- */
  --ctg-font: "Albert Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --ctg-tracking: -0.04em;
  --ctg-tracking-button: 0;

  /* ---- Radius ---- */
  --ctg-radius-card: 24px;
  --ctg-radius-inner: 14px;
  --ctg-radius-pill: 9999px;
  --ctg-radius-navbar: 100px;

  /* ---- Layout ---- */
  --ctg-content-max: 1186px;
  --ctg-pad-x: clamp(16px, 4vw, 32px);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: var(--ctg-font);
  font-weight: 500;
  font-size: 16px;
  line-height: 1.5;
  letter-spacing: var(--ctg-tracking);
  background: var(--ctg-background);
  color: var(--ctg-text-body);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5 {
  color: var(--ctg-text-heading);
  letter-spacing: var(--ctg-tracking);
  font-weight: 600;
}

a { color: var(--ctg-text-heading); }
a:hover { color: var(--ctg-foreground); }

:focus-visible {
  outline: 2px solid var(--ctg-foreground);
  outline-offset: 2px;
  border-radius: 4px;
}

::selection { background: var(--ctg-foreground); color: var(--ctg-primary-foreground); }

/* ── Glass floating navbar ───────────────────────────────────────────── */
.topbar-wrap {
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 12px var(--ctg-pad-x) 0;
}
.topbar {
  max-width: var(--ctg-content-max);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  padding: 8px 8px 8px 22px;
  border-radius: var(--ctg-radius-navbar);
  background: var(--ctg-glass-bg);
  border: 1px solid var(--ctg-glass-border);
  backdrop-filter: blur(var(--ctg-glass-blur));
  -webkit-backdrop-filter: blur(var(--ctg-glass-blur));
}
.brand {
  font-weight: 600;
  font-size: 20px;
  letter-spacing: var(--ctg-tracking);
  text-decoration: none;
  color: var(--ctg-foreground);
  white-space: nowrap;
}
.brand .brand-suffix { color: var(--ctg-text-body); font-weight: 500; }
.session { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.who {
  color: var(--ctg-nav-link);
  font-size: 14px;
  font-weight: 600;
  padding: 0 10px;
}

/* ── Page frame ──────────────────────────────────────────────────────── */
.wrap {
  flex: 1;
  width: 100%;
  max-width: var(--ctg-content-max);
  margin: 0 auto;
  padding: 40px var(--ctg-pad-x) 80px;
}

/* ── Footer ──────────────────────────────────────────────────────────── */
.footer {
  background: var(--ctg-white);
  border-top: 1px solid var(--ctg-border);
  padding: 48px var(--ctg-pad-x) 24px;
  text-align: center;
  margin-top: 64px;
}
.footer-wordmark {
  font-weight: 600;
  font-size: clamp(44px, 8vw, 80px);
  line-height: 1;
  letter-spacing: var(--ctg-tracking);
  color: var(--ctg-text-heading);
  user-select: none;
}
.footer-copy { color: var(--ctg-text-body); font-size: 14px; margin: 16px 0 0; }

/* ── Buttons — fully rounded pills ───────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 80px;
  min-height: 40px;
  padding: 8px 18px;
  border-radius: var(--ctg-radius-pill);
  border: 0;
  cursor: pointer;
  font-family: var(--ctg-font);
  font-size: 14px;
  line-height: 24px;
  font-weight: 600;
  letter-spacing: var(--ctg-tracking-button);
  text-decoration: none;
  background: var(--ctg-secondary);
  color: var(--ctg-foreground);
  transition: background-color .15s ease, color .15s ease, box-shadow .15s ease;
}
.btn:hover { background: var(--ctg-border); color: var(--ctg-foreground); }
.btn:active { background: #cbd5e1; }

.btn-primary { background: var(--ctg-foreground); color: var(--ctg-primary-foreground); }
.btn-primary:hover { background: #1e293b; color: var(--ctg-primary-foreground); }
.btn-primary:active { background: #0f172a; }

.btn-quiet { background: transparent; min-width: 0; }
.btn-quiet:hover { background: var(--ctg-secondary); }

.btn-danger { background: var(--ctg-danger); color: #ffffff; }
.btn-danger:hover { background: var(--ctg-danger-hover); color: #ffffff; }

.btn-wide { display: flex; width: 100%; min-height: 51px; }

/* Small pills for dense table rows */
table.grid .btn { min-height: 32px; padding: 3px 14px; min-width: 0; }

/* ── Banners & flash messages ────────────────────────────────────────── */
.staff-banner {
  background: var(--ctg-secondary);
  border: 1px solid var(--ctg-border);
  color: var(--ctg-nav-link);
  border-radius: var(--ctg-radius-inner);
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 24px;
}

.flash {
  border-radius: var(--ctg-radius-inner);
  padding: 12px 16px;
  margin-bottom: 20px;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid;
}
.flash-ok    { background: var(--ctg-ok-bg); border-color: var(--ctg-ok-border); color: var(--ctg-ok-text); }
.flash-warn  { background: var(--ctg-warn-bg); border-color: var(--ctg-warn-border); color: var(--ctg-warn-text); }
.flash-error { background: var(--ctg-danger-bg); border-color: var(--ctg-danger-border); color: var(--ctg-danger); }

/* ── Dashboard feature cards ─────────────────────────────────────────── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(21rem, 100%), 1fr));
  gap: 28px;
}
.card {
  background: var(--ctg-muted);
  border-radius: var(--ctg-radius-card);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.card-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.card-head h2 {
  margin: 0;
  font-size: 22px;
  line-height: 29px;
  font-weight: 600;
}
.card-icon {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--ctg-radius-pill);
  background: var(--ctg-white);
  border: 1px solid var(--ctg-border);
  color: var(--ctg-text-heading);
}
.card-icon svg { width: 18px; height: 18px; }

.tenant-select {
  font-family: var(--ctg-font);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--ctg-foreground);
  padding: 6px 14px;
  border: 1px solid var(--ctg-border);
  border-radius: var(--ctg-radius-pill);
  background: var(--ctg-white);
  cursor: pointer;
}
.tenant-chip {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--ctg-text-body);
  background: var(--ctg-white);
  border: 1px solid var(--ctg-border);
  border-radius: var(--ctg-radius-pill);
  padding: 3px 12px;
  white-space: nowrap;
}

/* Stats area (states driven by data-state, injected by dashboard.js) */
.card-stats { min-height: 44px; font-size: 14px; }
.card-stats[data-state="error"] { color: var(--ctg-danger); }
.card-stats[data-state="loading"],
.card-stats[data-state="empty"],
.card-stats[data-state="none"] { color: var(--ctg-text-subtle); }

.stat-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr));
  gap: 8px;
}
.stat-tiles-sub { margin-top: 8px; }
.stat-tile {
  background: var(--ctg-white);
  border-radius: var(--ctg-radius-inner);
  padding: 12px 14px;
}
.stat-value {
  font-size: 22px;
  line-height: 29px;
  font-weight: 600;
  letter-spacing: var(--ctg-tracking);
  color: var(--ctg-text-heading);
}
.stat-label { color: var(--ctg-text-subtle); font-size: 12px; margin-top: 2px; }
.stat-group { margin-top: 16px; }
.stat-group h3 {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ctg-text-subtle);
}
.stat-list { margin: 4px 0 0; padding-left: 18px; color: var(--ctg-text-subtle); }
.stat-list li { margin-bottom: 3px; }
.stale-note { margin-top: 10px; font-size: 12px; color: var(--ctg-text-subtle); font-style: italic; }

.card-actions { margin-top: auto; display: flex; flex-wrap: wrap; gap: 8px; }

/* ── Login hero / error / empty states ───────────────────────────────── */
.login-card, .error-card, .empty-state {
  max-width: 26.5rem;
  margin: clamp(40px, 12vh, 112px) auto 0;
  background: var(--ctg-white);
  border: 1px solid var(--ctg-border);
  border-radius: var(--ctg-radius-card);
  padding: 48px 40px;
  text-align: center;
}
.login-card h1, .error-card h1, .empty-state h1 {
  margin: 0 0 12px;
  font-size: 34px;
  line-height: 43px;
  font-weight: 800;
}
.login-card .muted, .error-card .muted, .empty-state .muted { margin: 0 0 20px; }
.login-eyebrow {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--ctg-text-body);
  margin: 0 0 12px;
}
.config-hint { font-size: 14px; color: var(--ctg-text-subtle); text-align: left; margin-bottom: 0; }

.muted { color: var(--ctg-text-subtle); }
.small { font-size: 13px; }
code {
  background: var(--ctg-secondary);
  border: 1px solid var(--ctg-border);
  border-radius: 6px;
  padding: 1px 5px;
  font-size: 0.85em;
  letter-spacing: 0;
}

/* ── /admin console ──────────────────────────────────────────────────── */
.admin-head { margin-bottom: 28px; }
.admin-head h1 {
  margin: 0 0 8px;
  font-size: 34px;
  line-height: 43px;
  font-weight: 800;
}
.admin-head p { margin: 0 0 12px; max-width: 46rem; }

/* Dark brand surface for the superadmin CTA on the dashboard */
.admin-cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  background: var(--ctg-foreground);
  border: 0;
  color: var(--ctg-primary-foreground);
}
.admin-cta strong { color: var(--ctg-primary-foreground); font-size: 18px; font-weight: 600; }
.admin-cta p { margin: 4px 0 0; }
.admin-cta .muted { color: #94a3b8; }
.admin-cta .btn-primary { background: var(--ctg-primary-foreground); color: var(--ctg-foreground); }
.admin-cta .btn-primary:hover { background: var(--ctg-white); }

.panel {
  background: var(--ctg-white);
  border: 1px solid var(--ctg-border);
  border-radius: var(--ctg-radius-card);
  padding: 28px;
  margin-bottom: 28px;
  overflow-x: auto;
}
.panel h2 { margin: 0 0 8px; font-size: 22px; line-height: 29px; }
.panel h3 { margin: 0 0 8px; font-size: 18px; line-height: 27px; }
.panel h2 + .muted, .panel h3 + .muted { margin-top: 0; }
.panel .kv { color: var(--ctg-text-body); font-size: 14px; }

/* ── Forms ───────────────────────────────────────────────────────────── */
.field-row { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 16px; }
.field-row label { font-size: 13px; font-weight: 600; color: var(--ctg-text-body); }

input[type="text"], input[type="email"], input[type="search"], input[type="url"],
.panel select {
  font-family: var(--ctg-font);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--ctg-border);
  border-radius: var(--ctg-radius-inner);
  background: var(--ctg-white);
  color: var(--ctg-text-heading);
  transition: border-color .15s ease, box-shadow .15s ease;
}
input[type="text"]:focus, input[type="email"]:focus, input[type="search"]:focus,
input[type="url"]:focus, .panel select:focus {
  outline: none;
  border-color: var(--ctg-foreground);
  box-shadow: 0 0 0 3px rgba(2, 6, 23, 0.08);
}
input::placeholder { color: #a1a1aa; }
input[type="email"], input[type="text"], input[type="url"] { min-width: min(16rem, 100%); }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--ctg-foreground); }

table.grid { width: 100%; border-collapse: collapse; font-size: 14px; }
table.grid th, table.grid td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--ctg-border);
  vertical-align: middle;
}
table.grid th {
  color: var(--ctg-text-subtle);
  font-weight: 600;
  font-size: 13px;
}
table.grid td a { font-weight: 600; text-decoration-color: var(--ctg-border); }
table.grid form { margin: 0; display: inline; }

.search-form { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.search-form input[type="search"] { flex: 1 1 14rem; }
.grant-form { display: flex; flex-wrap: wrap; gap: 16px; align-items: end; }
.grant-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ctg-text-body); }

/* ── Badges ──────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
  padding: 2px 10px;
  border-radius: var(--ctg-radius-pill);
  border: 1px solid var(--ctg-border);
  background: var(--ctg-secondary);
  color: var(--ctg-text-body);
  white-space: nowrap;
}
.badge-active   { background: var(--ctg-ok-bg); border-color: var(--ctg-ok-border); color: var(--ctg-ok-text); }
.badge-disabled, .badge-revoked { background: var(--ctg-secondary); border-color: var(--ctg-border); color: var(--ctg-text-subtle); }
.badge-warn     { background: var(--ctg-warn-bg); border-color: var(--ctg-warn-border); color: var(--ctg-warn-text); }

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 720px) {
  .topbar-wrap { padding-top: 8px; }
  .topbar { padding-left: 16px; }
  .brand { font-size: 18px; }
  .who { display: none; }
  .wrap { padding-top: 24px; padding-bottom: 48px; }
  .card { padding: 20px; }
  .panel { padding: 20px; }
  .login-card, .error-card, .empty-state { padding: 32px 24px; }
  .admin-head h1 { font-size: 27px; line-height: 36px; }
  .footer { margin-top: 40px; }
}
