:root {
  --bg: #eef1f5;
  --card-bg: #ffffff;
  --text: #1c2430;
  --text-muted: #5b6472;
  --border: #d7dce3;
  --accent: #2456c7;
  --accent-hover: #1c449e;
  --error: #b3261e;
  --error-bg: #fdecea;
  --success: #1e4620;
  --success-bg: #eaf6ea;
  --radius: 10px;
  --font: -apple-system, "Segoe UI", system-ui, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  margin: 0;
  padding: 32px 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.demo-banner {
  position: sticky;
  top: 0;
  z-index: 1000;
  margin: -32px -16px 24px;
  padding: 10px 16px;
  background: #fff3cd;
  color: #664d03;
  border-bottom: 2px solid #ffca2c;
  font-weight: 600;
  text-align: center;
  font-size: 0.9rem;
}

.card {
  background: var(--card-bg);
  max-width: 560px;
  margin: 0 auto;
  padding: 36px 40px;
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(20, 26, 36, 0.08), 0 8px 24px rgba(20, 26, 36, 0.06);
}

h1 {
  font-size: 1.5rem;
  margin: 0 0 8px;
}

.lede {
  color: var(--text-muted);
  margin: 0 0 28px;
  font-size: 0.95rem;
}

fieldset {
  border: none;
  padding: 0;
  margin: 28px 0 0;
}

fieldset legend {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  padding: 0;
  margin-bottom: 4px;
}

fieldset .lede {
  margin-top: -4px;
  margin-bottom: 12px;
}

.field {
  margin-top: 16px;
}

.field:first-child {
  margin-top: 0;
}

label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 6px;
}

.hint {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin: 4px 0 0;
}

.hint.available { color: var(--success); font-weight: 600; }
.hint.taken { color: var(--error); font-weight: 600; }

input[type=text],
input[type=email],
input[type=password],
input[type=date],
select {
  width: 100%;
  padding: 10px 12px;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input[type=text]:focus,
input[type=email]:focus,
input[type=password]:focus,
input[type=date]:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(36, 86, 199, 0.18);
}

select.invalid,
input[type=date].invalid {
  border-color: var(--error);
}

input.invalid {
  border-color: var(--error);
}

input.invalid:focus {
  box-shadow: 0 0 0 3px rgba(179, 38, 30, 0.16);
}

.field-error {
  color: var(--error);
  font-size: 0.82rem;
  margin: 6px 0 0;
}

.banner {
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 0.9rem;
  margin-bottom: 20px;
  background: var(--bg);
  color: var(--text);
}

.banner.error { background: var(--error-bg); color: var(--error); }
.banner.success { background: var(--success-bg); color: var(--success); }

button {
  display: inline-block;
  width: 100%;
  margin-top: 28px;
  padding: 12px 18px;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease;
}

button:hover { background: var(--accent-hover); }

button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(36, 86, 199, 0.35);
}

button.secondary {
  width: auto;
  margin-top: 0;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

button.secondary:hover { background: var(--bg); }

nav { margin-bottom: 24px; display: flex; justify-content: flex-end; }

.footer-links {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
  text-align: center;
}

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

.card.wide { max-width: 860px; }

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 32px 0 4px;
}

.section-title:first-of-type,
.section-title.flush { margin-top: 0; }

.section-title h2 { font-size: 1.05rem; margin: 0; }
.section-title p { margin: 2px 0 0; color: var(--text-muted); font-size: .85rem; }

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin-top: 10px;
}

.tile {
  display: block;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
  color: var(--text);
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.tile:hover { border-color: var(--accent); box-shadow: 0 2px 8px rgba(20, 26, 36, 0.08); }

.tile h3 { margin: 0 0 4px; font-size: 0.95rem; }
.tile p { margin: 0; font-size: 0.8rem; color: var(--text-muted); }

.tile.disabled {
  background: var(--bg);
  color: var(--text-muted);
  cursor: default;
}

.tile.disabled:hover { border-color: var(--border); box-shadow: none; }

.badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 2px 8px;
  border-radius: 999px;
  margin-bottom: 6px;
}

.badge.soon { background: #e9edf2; color: var(--text-muted); }
.badge.restricted { background: var(--error-bg); color: var(--error); }
.badge.success { background: var(--success-bg); color: var(--success); }

.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}

.filter-bar label { margin: 0; white-space: nowrap; }
.filter-bar select { width: auto; }
.filter-bar button { width: auto; margin-top: 0; padding: 8px 14px; font-size: 0.85rem; }

table.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  font-size: 0.88rem;
}

table.data-table th,
table.data-table td {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

table.data-table th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.status-pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}

.status-pill.active { background: var(--success-bg); color: var(--success); }
.status-pill.pending_setup { background: #fff4e0; color: #8a5a00; }
.status-pill.disabled { background: #f1f1f1; color: #666; }

details > summary {
  cursor: pointer;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 600;
  width: auto;
  display: inline-block;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

details[open] > summary { margin-bottom: 4px; }

.details-form { margin-top: 10px; min-width: 220px; }

.row-actions { display: flex; gap: 8px; align-items: flex-start; }
.row-actions form { margin: 0; }
.row-actions > a {
  text-decoration: none;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.row-actions > a:hover { background: var(--bg); }
.row-actions button {
  width: auto;
  margin-top: 0;
  padding: 6px 12px;
  font-size: 0.8rem;
}

.row-actions button.danger { background: #fff; color: var(--error); border: 1px solid var(--error); }
.row-actions button.danger:hover { background: var(--error-bg); }

.top-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 860px;
  margin: 0 auto 16px;
  padding: 0 4px;
}

.top-nav a { font-size: 0.9rem; font-weight: 600; text-decoration: none; }
.top-nav form { margin: 0; }
.top-nav button { width: auto; margin: 0; padding: 8px 14px; font-size: 0.85rem; }

.invite-link-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.82rem;
  word-break: break-all;
  margin: 12px 0;
}

.empty-state {
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 20px 0;
  text-align: center;
}

/* Overflow ("3-dot") menu — a <details> element doubling as a dropdown,
   same no-JS-required approach as the inline edit toggles elsewhere. */
.menu { position: relative; display: inline-block; }

.menu > summary {
  /* Overrides the generic details > summary pill styling — this one's a
     compact square icon button, not a text link. */
  width: 32px;
  height: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  line-height: 1;
}

.menu > summary::-webkit-details-marker { display: none; }

.menu[open] > summary { background: var(--bg); }

.menu-items {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 20;
  min-width: 200px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(20, 26, 36, 0.14);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.menu-items form { margin: 0; }

.menu-items a,
.menu-items button,
.menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 400;
  text-decoration: none;
  cursor: pointer;
  margin: 0;
}

.menu-items a:hover,
.menu-items button:hover { background: var(--bg); }

.menu-items button.danger { color: var(--error); }

.menu-item.disabled {
  color: var(--text-muted);
  cursor: default;
}

.menu-item.disabled:hover { background: none; }

@media (max-width: 480px) {
  body { padding: 16px 8px; }
  .demo-banner { margin: -16px -8px 24px; }
  .card { padding: 24px 20px; }
  table.data-table { font-size: 0.82rem; }
  .row-actions { flex-wrap: wrap; }
}
