:root {
  --bg-a: #f7fbff;
  --bg-b: #eef7f2;
  --panel: rgba(255, 255, 255, 0.88);
  --panel-strong: rgba(255, 255, 255, 0.95);
  --line: rgba(22, 42, 67, 0.08);
  --text: #14243c;
  --muted: #60708d;
  --accent: #00a7c4;
  --accent-2: #5ce0ad;
  --danger: #cf4f67;
  --danger-ink: #882638;
  --shadow: 0 22px 60px rgba(28, 56, 102, 0.12);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Aptos", "Segoe UI Variable Display", "Trebuchet MS", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(0, 167, 196, 0.18), transparent 35%),
    radial-gradient(circle at bottom right, rgba(92, 224, 173, 0.2), transparent 30%),
    linear-gradient(135deg, var(--bg-a) 0%, var(--bg-b) 100%);
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

.shell { width: min(1700px, calc(100vw - 20px)); margin: 14px auto 24px; }
.shell-detail { width: min(1720px, calc(100vw - 20px)); }
.topbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 14px;
}
.brand-line { display: flex; gap: 12px; align-items: center; }
.brand-line img {
  width: 58px;
  border-radius: 999px;
  filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.08));
}
.brand-line h1 { margin: 2px 0 0; font-size: clamp(24px, 2.7vw, 40px); line-height: 1.02; letter-spacing: -0.04em; max-width: 980px; }
.eyebrow { color: var(--accent); text-transform: uppercase; letter-spacing: 0.12em; font-size: 12px; font-weight: 700; }
.subtle { margin: 6px 0 0; color: var(--muted); line-height: 1.4; font-size: 14px; }
.ghost-link { padding: 9px 13px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,0.62); font-size: 14px; }

.surface, .auth-card, .stat-card, .directory-row {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}
.surface, .auth-card { border-radius: 22px; }
.surface { padding: 16px; }
.surface-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 12px; }
.surface-head h2 { margin: 2px 0 0; font-size: 20px; line-height: 1.05; letter-spacing: -0.03em; }

.hero-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.stat-card { border-radius: 18px; padding: 12px 14px; }
.stat-card span { display: block; color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; }
.stat-card strong { display: block; margin-top: 4px; font-size: 28px; letter-spacing: -0.04em; }

.create-surface { margin-bottom: 12px; }
.create-grid, .field-grid {
  display: grid;
  grid-template-columns: repeat(14, minmax(0, 1fr));
  gap: 10px;
}
.create-grid > label,
.field-grid > label,
.wide-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.create-grid > label,
.field-grid > label { grid-column: span 2; }
.create-grid label span, .field-grid label span, .wide-field span {
  color: var(--muted);
  font-size: 12px;
}
input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="file"], select, textarea {
  width: 100%;
  border: 1px solid rgba(65, 92, 142, 0.16);
  border-radius: 13px;
  padding: 10px 12px;
  background: var(--panel-strong);
  color: var(--text);
  font: inherit;
  resize: vertical;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: rgba(0, 167, 196, 0.55);
  box-shadow: 0 0 0 4px rgba(0, 167, 196, 0.12);
}
.toggle-block {
  grid-column: span 3;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.62);
}
.service-toggle-row {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.62);
}
.service-toggle-note {
  flex-basis: 100%;
  margin-top: 0;
}
.create-grid > .actions-row { grid-column: 1 / -1; margin-top: 2px; }
.micro-note { margin: 6px 0 0; font-size: 12px; color: var(--muted); line-height: 1.35; }
.actions-row { display: flex; gap: 10px; align-items: center; margin-top: 12px; }
.actions-row.wrap { flex-wrap: wrap; }

.primary-button, .secondary-button, .danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 13px;
  padding: 10px 14px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}
.primary-button { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #05202a; }
.secondary-button { background: rgba(255,255,255,0.92); border: 1px solid var(--line); color: var(--text); }
.danger-button { background: rgba(207,79,103,0.14); color: var(--danger-ink); border: 1px solid rgba(207,79,103,0.24); }

.search-form { width: min(340px, 100%); }
.directory-list { display: grid; gap: 10px; }
.directory-row {
  border-radius: 18px;
  padding: 12px 14px;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(300px, 0.8fr) minmax(520px, auto);
  gap: 12px;
  align-items: center;
}
.row-main h3 { margin: 0 0 4px; font-size: 18px; letter-spacing: -0.03em; }
.meta-line { color: var(--muted); font-size: 13px; display: flex; flex-wrap: wrap; gap: 8px; }
.service-pill-row { display: flex; flex-wrap: wrap; gap: 8px; }
.service-pill {
  border-radius: 999px;
  padding: 7px 11px;
  background: rgba(255,255,255,0.7);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.service-pill.active { color: var(--text); background: rgba(92, 224, 173, 0.15); border-color: rgba(92, 224, 173, 0.35); }
.service-pill.locked { color: var(--danger-ink); background: rgba(207,79,103,0.12); border-color: rgba(207,79,103,0.26); }
.service-pill.missing { color: var(--muted); background: rgba(255,255,255,0.68); border-color: var(--line); }
.pill-form { margin: 0; }
.service-pill-button {
  cursor: pointer;
  font: inherit;
  font-weight: 800;
}
.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  align-items: center;
}
.inline-form { margin: 0; }
.reset-password-dialog {
  width: min(460px, calc(100vw - 28px));
  border: 1px solid rgba(65, 92, 142, 0.16);
  border-radius: 22px;
  padding: 0;
  background: var(--panel-strong);
  color: var(--text);
  box-shadow: 0 28px 80px rgba(28, 56, 102, 0.22);
}
.reset-password-dialog::backdrop {
  background: rgba(20, 36, 60, 0.3);
  backdrop-filter: blur(6px);
}
.reset-password-form {
  display: grid;
  gap: 12px;
  padding: 18px;
}
.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.dialog-head h3 {
  margin: 2px 0 0;
  font-size: 22px;
  letter-spacing: -0.03em;
}
.dialog-close {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,0.9);
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-weight: 900;
}
.reset-dialog-actions {
  flex-wrap: wrap;
  margin-top: 0;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.detail-card-wide { grid-column: 1 / -1; }
.detail-card h3 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.detail-card h4 { margin: 0 0 8px; font-size: 14px; }
.shared-pill-row { margin-top: 10px; }
.check-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 8px;
}
.check-grid.dense { gap: 10px 12px; }
.check-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 14px;
}
.check-row input { width: 18px; height: 18px; accent-color: var(--accent); }
.assignments { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.channel-block { margin-top: 12px; }
.wide-field { margin-top: 10px; }
.wide-field textarea { min-height: 130px; }
.membership-matrix {
  display: grid;
  gap: 8px;
  margin-top: 8px;
  max-height: 240px;
  overflow: auto;
  padding-right: 4px;
}
.membership-matrix-tall { max-height: 320px; }
.membership-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,0.62);
}
.membership-row span {
  min-width: 0;
  color: var(--text);
  font-size: 13px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.membership-row select {
  padding-top: 8px;
  padding-bottom: 8px;
}

.flash-stack { display: grid; gap: 8px; margin-bottom: 10px; }
.flash-stack-wide { margin-bottom: 12px; }
.flash {
  border-radius: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.86);
  font-size: 14px;
}
.flash-success { border-color: rgba(92, 224, 173, 0.3); background: rgba(92, 224, 173, 0.12); }
.flash-error { border-color: rgba(207, 79, 103, 0.3); background: rgba(207, 79, 103, 0.12); }

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
}
.auth-card {
  width: min(560px, 100%);
  padding: 22px;
}
.brand-mark { width: 68px; margin-bottom: 12px; }
.brand-mark img {
  width: 100%;
  border-radius: 999px;
  filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.08));
}
.auth-card h1 { margin: 4px 0 8px; font-size: clamp(28px, 4vw, 44px); line-height: 0.98; letter-spacing: -0.05em; }
.auth-form { display: grid; gap: 12px; margin-top: 14px; }

@media (max-width: 1180px) {
  .detail-grid { grid-template-columns: 1fr; }
  .directory-row { grid-template-columns: 1fr; }
  .row-actions { justify-content: flex-start; }
  .create-grid, .field-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .create-grid > label, .field-grid > label { grid-column: span 2; }
  .toggle-block { grid-column: span 3; }
}

@media (max-width: 760px) {
  .shell { width: min(100vw - 20px, 100%); margin-top: 12px; }
  .topbar, .surface-head, .directory-row { grid-template-columns: 1fr; display: grid; }
  .brand-line { align-items: flex-start; }
  .brand-line img { width: 64px; }
  .create-grid, .field-grid { grid-template-columns: 1fr; }
  .create-grid > label, .field-grid > label { grid-column: span 1; }
  .toggle-block { grid-column: span 1; }
  .row-actions { justify-content: flex-start; }
}
