/* ── CSS variables ─────────────────────────────────────────────────────────── */
:root {
  --color-bg:           #f5f5f5;
  --color-surface:      #ffffff;
  --color-border:       #e0e0e0;
  --color-border-light: #efefef;
  --color-text:         #111111;
  --color-muted:        #737373;
  --color-primary:      #111111;
  --color-primary-h:    #000000;
  --color-success:      #404040;
  --color-warning:      #525252;
  --color-danger:       #dc2626;
  --color-info:         #525252;
  --radius:             8px;
  --radius-sm:          4px;
  --shadow:             0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md:          0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -2px rgba(0,0,0,.04);
  --topnav-h:           56px;
  --font: 'Comfortaa', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', sans-serif;
}

/* ── Reset ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre { font-family: 'SF Mono', Menlo, Monaco, Consolas, monospace; font-size: .88em; }

/* ── Top nav ────────────────────────────────────────────────────────────────── */
.topnav {
  height: var(--topnav-h);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 32px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}
.topnav__brand {
  display: flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 1.1rem; color: var(--color-text);
  text-decoration: none;
}
.topnav__logo { display: block; flex-shrink: 0; }

/* JobDistributor mark — vector SVG, no raster scaling blur */
.jd-logo {
  display: block;
  flex-shrink: 0;
  width: var(--jd-logo-size, 32px);
  height: var(--jd-logo-size, 32px);
  border-radius: 6px;
}
.topnav__logo.jd-logo { --jd-logo-size: 32px; }
.auth-logo__icon.jd-logo { --jd-logo-size: 40px; }
.nav-drawer__brand .jd-logo { --jd-logo-size: 30px; }
.topnav__links { display: flex; gap: 4px; flex: 1; }
.topnav__link {
  padding: 6px 12px; border-radius: var(--radius-sm);
  color: var(--color-muted); font-size: .9rem; text-decoration: none;
  transition: background .15s, color .15s;
}
.topnav__link:hover, .topnav__link.active {
  background: #f0f0f0; color: var(--color-text);
}
.topnav__admin { color: var(--color-danger) !important; }
.topnav__admin:hover { background: #fef2f2 !important; }
.topnav__user { display: flex; align-items: center; gap: 12px; margin-left: auto; position: relative; }

/* ── Learn dropdown ─────────────────────────────────────────────────────────── */
.topnav__dropdown-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.topnav__dropdown-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  /* inherits .topnav__link sizing from the class applied in HTML */
}
.topnav__dropdown-btn .caret {
  transition: transform .18s;
}
.topnav__dropdown-btn[aria-expanded="true"] .caret {
  transform: rotate(180deg);
}
.topnav__dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 200px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: 0 6px 20px rgba(0,0,0,.1);
  padding: 4px 0;
  z-index: 300;
  display: none;
}
.topnav__dropdown--open { display: block; }
.topnav__dropdown__item {
  display: block;
  padding: 9px 16px;
  font-size: .875rem;
  color: var(--color-text);
  text-decoration: none;
  transition: background .12s;
  white-space: nowrap;
}
.topnav__dropdown__item:hover { background: #f3f4f6; }
.topnav__dropdown__item.active { color: var(--color-primary); font-weight: 600; }
.topnav__dropdown__divider {
  height: 1px;
  background: var(--color-border);
  margin: 4px 0;
}

/* ── Mobile drawer — Learn expandable group ─────────────────────────────────── */
.nav-drawer__group-btn {
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-align: left;
}
.nav-drawer__group-btn .caret { transition: transform .18s; }
.nav-drawer__group-btn[aria-expanded="true"] .caret { transform: rotate(180deg); }
.nav-drawer__group-body { display: none; }
.nav-drawer__group-body--open { display: block; }
.nav-drawer__link--sub {
  padding-left: 40px;
  font-size: .85rem;
  color: var(--color-muted);
}

/* ── Main content ───────────────────────────────────────────────────────────── */
.main-content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px;
  flex: 1;          /* stretches to fill remaining viewport height */
  width: 100%;      /* needed when body is flex column */
}

/* ── Page header ────────────────────────────────────────────────────────────── */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
  flex-wrap: wrap;
}
.page-title { font-size: 1.5rem; font-weight: 700; }
.page-sub   { color: var(--color-muted); font-size: .9rem; margin-top: 2px; }

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  padding: 8px 18px;
  font-size: .9rem; font-weight: 500;
  border: none; border-radius: var(--radius);
  cursor: pointer; text-decoration: none;
  transition: background .15s, color .15s, opacity .15s;
  line-height: 1.4;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; opacity: .88; }
.btn--primary        { background: var(--color-text); color: #fff; }
.btn--primary:hover  { background: #000; opacity: 1; }
.btn--outline        { background: transparent; color: var(--color-text); border: 1px solid var(--color-border); }
.btn--outline:hover  { background: #f0f0f0; }
.btn--ghost          { background: transparent; color: var(--color-muted); }
.btn--ghost:hover    { background: #f0f0f0; color: var(--color-text); }
.btn--danger         { background: var(--color-danger); color: #fff; }
.btn--warning        { background: #525252; color: #fff; }
.btn--full           { width: 100%; }
.btn--sm             { padding: 5px 12px; font-size: .82rem; }
.btn--xs             { padding: 3px 8px;  font-size: .78rem; }

/* ── Badges ─────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 2px 8px;
  font-size: .75rem; font-weight: 600; border-radius: 20px;
  text-transform: uppercase; letter-spacing: .04em;
}
.badge--active         { background: #e8e8e8; color: #111111; }
.badge--idle           { background: #f0f0f0; color: #525252; }
.badge--expired        { background: #f0f0f0; color: #737373; }
.badge--deleted        { background: #f0f0f0; color: #737373; }
.badge--quota_exceeded { background: #fee2e2; color: #991b1b; }
.badge--pending        { background: #e8e8e8; color: #404040; }
.badge--approved       { background: #e8e8e8; color: #111111; }
.badge--declined       { background: #fee2e2; color: #991b1b; }
.badge--warning        { background: #f0f0f0; color: #525252; }

/* Server online / offline indicator dot */
.server-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-left: 6px;
  vertical-align: middle;
}
.server-dot--online  { background: #22c55e; box-shadow: 0 0 0 2px rgba(34,197,94,.25); }
.server-dot--offline { background: #d1d5db; }

/* ── Alerts ─────────────────────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px; border-radius: var(--radius);
  margin-bottom: 20px; font-size: .9rem;
}
.alert--success { background: #f5f5f5; color: #111111; border: 1px solid #d4d4d4; }
.alert--error   { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert--warning { background: #f5f5f5; color: #404040; border: 1px solid #d4d4d4; }

/* ── Auth ────────────────────────────────────────────────────────────────────── */
.auth-body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.auth-body__center {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 16px;
}
.auth-card {
  background: var(--color-surface); padding: 40px;
  border-radius: 12px; box-shadow: var(--shadow-md);
  width: 100%; max-width: 420px;
}
.auth-logo {
  display: flex; align-items: center; gap: 10px;
  font-size: 1.05rem; font-weight: 700; color: var(--color-text);
  text-decoration: none; margin-bottom: 24px;
}
.auth-logo:hover { text-decoration: none; color: #000; }
.auth-logo__icon { display: block; }
.auth-resend { margin-top: 12px; }
.field__input--otp {
  font-family: 'SF Mono', Menlo, Monaco, Consolas, monospace;
  font-size: 1.35rem; letter-spacing: 0.35em; text-align: center;
  max-width: 12rem;
}
.auth-title { font-size: 1.4rem; font-weight: 700; margin-bottom: 24px; }
.auth-body-text { color: var(--color-muted); margin-bottom: 16px; }
.auth-links { margin-top: 20px; font-size: .88rem; text-align: center; color: var(--color-muted); }
.auth-links__sep { margin: 0 8px; }

/* ── Form fields ────────────────────────────────────────────────────────────── */
.field { margin-bottom: 16px; }
.field__label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 6px; }
.field__hint  { font-size: .78rem; color: var(--color-muted); font-weight: 400; margin-left: 4px; }
.field__input {
  display: block; width: 100%;
  padding: 9px 12px; font-size: .9rem;
  border: 1px solid var(--color-border); border-radius: var(--radius);
  background: var(--color-surface); color: var(--color-text);
  transition: border-color .15s;
  outline: none;
}
.field__input:focus { border-color: #111111; box-shadow: 0 0 0 3px rgba(0,0,0,.07); }
.field__textarea { resize: vertical; min-height: 80px; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }

.form-actions { display: flex; gap: 12px; align-items: center; margin-top: 8px; }

.form-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}
.form-card__title { font-size: 1rem; font-weight: 600; margin-bottom: 16px; }
.form-card__header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.form-card__header-row .form-card__title { margin-bottom: 0; }
.form-card__hint  { font-size: .85rem; color: var(--color-muted); margin-bottom: 16px; }

/* ── Usage card ─────────────────────────────────────────────────────────────── */
.usage-card {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius); padding: 20px 24px;
  margin-bottom: 28px; box-shadow: var(--shadow);
}
.usage-card__header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.usage-card__title  { font-weight: 600; }
.usage-card__month  { color: var(--color-muted); font-size: .85rem; }
.usage-card__footer { margin-top: 12px; font-size: .82rem; color: var(--color-muted); }
.usage-row    { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.usage-label  { font-size: .82rem; color: var(--color-muted); width: 80px; flex-shrink: 0; }
.usage-bar-wrap { flex: 1; height: 8px; background: var(--color-border); border-radius: 99px; overflow: hidden; }
.usage-bar    { height: 100%; background: #111111; border-radius: 99px; transition: width .3s; }
.usage-bar--out { background: #525252; }
.usage-val    { font-size: .8rem; color: var(--color-muted); width: 160px; text-align: right; flex-shrink: 0; }

.mini-bar-wrap { display: inline-block; width: 60px; height: 6px; background: var(--color-border); border-radius: 99px; overflow: hidden; vertical-align: middle; margin-right: 6px; }
.mini-bar      { height: 100%; background: #111111; border-radius: 99px; }
.mini-bar--out { background: #525252; }

/* ── Experiment grid ────────────────────────────────────────────────────────── */
.exp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}
.exp-card {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow);
  transition: box-shadow .2s;
}
.exp-card:hover { box-shadow: var(--shadow-md); }
.exp-card__header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.exp-card__name   { font-weight: 600; font-size: 1rem; display: flex; align-items: center; gap: 5px; }
.exp-name-copy {
  background: none; border: none; cursor: pointer; padding: 2px;
  color: var(--color-muted); border-radius: 4px; display: inline-flex;
  align-items: center; opacity: 0; transition: opacity 0.15s;
}
.exp-card:hover .exp-name-copy { opacity: 1; }
.exp-name-copy:hover { color: var(--color-text); background: var(--color-border); }
.exp-card__urls   { margin-bottom: 14px; display: flex; flex-direction: column; gap: 6px; }
.exp-card__dash   { margin-bottom: 12px; }

/* Compact offline / expired status (experiment cards) */
.exp-card__status {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  background: var(--color-bg);
}
.exp-card__status--expired {
  border-color: #fecaca;
  background: #fef2f2;
}
.exp-card__status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.exp-card__status-label {
  margin: 0;
  font-size: .8125rem;
  font-weight: 600;
  color: #6b7280;
}
.exp-card__status--expired .exp-card__status-label {
  color: #991b1b;
}
.exp-card__status-hint {
  margin: 6px 0 0;
  font-size: .78rem;
  color: var(--color-muted);
  line-height: 1.4;
}
.exp-card__status-hint a {
  font-weight: 500;
  text-decoration: none;
}
.exp-card__status-hint a:hover {
  text-decoration: underline;
}
.exp-card__status-sep {
  margin: 0 5px;
  color: #d1d5db;
  user-select: none;
}
.exp-card__meta-online {
  color: #16a34a;
  font-weight: 600;
}

.dash-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px 8px 12px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
}
.dash-toolbar--panel { margin-bottom: 12px; }
.dash-toolbar__open {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .875rem;
  font-weight: 500;
  color: var(--color-text);
  text-decoration: none;
  min-width: 0;
}
.dash-toolbar__open:hover {
  color: #000;
  text-decoration: none;
}
.dash-toolbar__open--disabled {
  pointer-events: none;
  opacity: 0.45;
  cursor: not-allowed;
}
.dash-toolbar__offline-note {
  font-size: .8125rem;
  color: var(--color-muted);
  margin: 8px 0 0;
  line-height: 1.45;
}

/* Server start instructions (experiment detail, offline only) */
.server-start-steps {
  margin-top: 16px;
  padding: 16px 18px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-bg);
}
.server-start-steps__lead {
  font-size: .875rem;
  color: var(--color-text);
  margin: 0 0 14px;
  font-weight: 500;
}
.server-start-steps--expired .server-start-steps__lead {
  margin-bottom: 8px;
}
.server-start-steps__text {
  font-size: .875rem;
  color: var(--color-muted);
  margin: 0;
  line-height: 1.5;
}
.server-start-steps__item a {
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.server-start-steps__list {
  margin: 0;
  padding-left: 1.25rem;
  font-size: .875rem;
  color: var(--color-text);
  line-height: 1.5;
}
.server-start-steps__item {
  margin-bottom: 14px;
}
.server-start-steps__item:last-child {
  margin-bottom: 0;
}
.server-start-steps__cmd {
  position: relative;
  margin-top: 8px;
  margin-left: -1.25rem;
}
.server-start-steps__pre {
  margin: 0;
  padding: 10px 40px 10px 12px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  overflow-x: auto;
}
.server-start-steps__pre code {
  font-size: .78rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-all;
}
.server-start-steps__copy {
  position: absolute;
  top: 8px;
  right: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-surface);
  color: var(--color-muted);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.server-start-steps__copy:hover {
  background: #f0f0f0;
  border-color: #a3a3a3;
  color: var(--color-text);
}
.dash-toolbar__copy {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-surface);
  color: var(--color-muted);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.dash-toolbar__copy:hover {
  background: #f0f0f0;
  border-color: #a3a3a3;
  color: var(--color-text);
}
.exp-panel__foot {
  font-size: .82rem;
  color: var(--color-muted);
  margin: 0;
}
.exp-panel__foot code {
  font-size: .8rem;
  background: var(--color-bg);
  padding: 1px 5px;
  border-radius: 4px;
}
.exp-card__meta    {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  font-size: .78rem;
  color: var(--color-muted);
  margin-bottom: 14px;
}
.exp-card__meta > span + span::before {
  content: "·";
  margin-right: 10px;
  color: #d1d5db;
}
.exp-card__actions { display: flex; gap: 8px; }

/* ── Empty state ────────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 64px 24px;
  border: 2px dashed var(--color-border); border-radius: var(--radius);
  margin: 24px 0;
}
.empty-state__icon  { font-size: 3rem; color: var(--color-border); margin-bottom: 16px; }
.empty-state__title { font-size: 1.1rem; font-weight: 600; margin-bottom: 8px; }
.empty-state__text  { color: var(--color-muted); margin-bottom: 20px; }

/* ── Detail view ────────────────────────────────────────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
  align-items: start;
}
.detail-card {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow);
}
.detail-card--wide    { grid-column: 1 / -1; }
.detail-card__title   { font-size: .95rem; font-weight: 600; margin-bottom: 16px; }
.detail-card__header  { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.detail-card__hint    { font-size: .8rem; color: var(--color-muted); margin-top: 12px; }

.url-row        { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.url-row__label { font-size: .78rem; font-weight: 600; color: var(--color-muted); width: 80px; }
.url-row__link  { font-size: .88rem; }

.cred-row             { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.cred-row__label      { font-size: .78rem; font-weight: 600; color: var(--color-muted); }
.cred-row__value-wrap { display: flex; align-items: center; gap: 8px; }
.cred-row__value      { word-break: break-all; font-size: .8rem; }

.code-block {
  background: #1a1a1a; color: #e5e5e5;
  padding: 16px; border-radius: var(--radius);
  font-size: .82rem; overflow-x: auto;
  white-space: pre;
}

.meta-table    { width: 100%; border-collapse: collapse; font-size: .88rem; }
.meta-table th { font-weight: 600; color: var(--color-muted); text-align: left; padding: 6px 0; padding-right: 16px; white-space: nowrap; }
.meta-table td { padding: 6px 0; }

.action-list { display: flex; flex-direction: column; gap: 10px; }

/* ── Data table ─────────────────────────────────────────────────────────────── */
.data-table {
  width: 100%; border-collapse: collapse; font-size: .88rem;
  background: var(--color-surface); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow);
}
.data-table th {
  background: var(--color-bg); font-weight: 600; text-align: left;
  padding: 10px 14px; border-bottom: 1px solid var(--color-border);
  font-size: .82rem; color: var(--color-muted); text-transform: uppercase; letter-spacing: .04em;
}
.data-table td  { padding: 10px 14px; border-bottom: 1px solid var(--color-border-light); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--color-bg); }

/* ── API key — one-time display banner ─────────────────────────────────────── */
.key-created-banner {
  display: flex; gap: 16px; align-items: flex-start;
  margin-bottom: 24px; padding: 20px 22px;
  border-radius: 12px;
  background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 45%, #fed7aa 100%);
  border: 2px solid #fb923c;
  box-shadow: 0 4px 24px rgba(234, 88, 12, .15);
}
.key-created-banner__icon {
  font-size: 1.75rem; line-height: 1; flex-shrink: 0; margin-top: 2px;
}
.key-created-banner__body { flex: 1; min-width: 0; }
.key-created-banner__title {
  margin: 0 0 8px; font-size: 1.15rem; font-weight: 800; color: #9a3412;
}
.key-created-banner__text {
  margin: 0 0 14px; font-size: .92rem; line-height: 1.55; color: #7c2d12;
}
.key-created-banner__key-row {
  display: flex; gap: 10px; align-items: stretch; flex-wrap: wrap;
}
.key-created-banner__input {
  flex: 1; min-width: 200px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: .84rem; padding: 10px 12px;
  border: 2px solid #fdba74; border-radius: 8px;
  background: #fff; color: #111;
}
.key-created-banner__copy { flex-shrink: 0; white-space: nowrap; }
.key-created-banner__hint {
  margin: 12px 0 0; font-size: .82rem; color: #c2410c; font-weight: 500;
}
.key-create-note {
  margin: 14px 0 0; padding: 10px 12px;
  background: #fff7ed; border: 1px solid #fed7aa; border-radius: 8px;
  font-size: .85rem; line-height: 1.5; color: #9a3412;
}

/* ── Utility ────────────────────────────────────────────────────────────────── */
.text--muted   { color: var(--color-muted); }
.text--warning { color: #525252; }
.text--danger  { color: var(--color-danger); }
.text--success { color: #404040; }

/* ── Toast ──────────────────────────────────────────────────────────────────── */
#toast {
  position: fixed; bottom: 24px; right: 24px;
  background: #111111; color: #fff;
  padding: 10px 18px; border-radius: 8px;
  font-size: .88rem; opacity: 0;
  transition: opacity .2s;
  pointer-events: none; z-index: 9999;
}
#toast.show { opacity: 1; }

/* ── Experiment detail page ─────────────────────────────────────────────────── */
.exp-detail { max-width: 880px; margin: 0 auto; }

.exp-detail__hero {
  margin: -8px -8px 28px;
  padding: 28px 28px 24px;
  border-radius: 14px;
  background: #f5f5f5;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-md);
}
.exp-detail__back {
  display: inline-block;
  font-size: .82rem;
  font-weight: 500;
  color: var(--color-muted);
  text-decoration: none;
  margin-bottom: 12px;
}
.exp-detail__back:hover { color: var(--color-text); text-decoration: none; }
.exp-detail__title-row {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 12px; margin-bottom: 10px;
}
.exp-detail__title {
  font-size: 1.75rem; font-weight: 700;
  letter-spacing: -0.02em; line-height: 1.2;
}
.exp-detail__lead {
  color: var(--color-muted); font-size: .95rem;
  max-width: 52ch; line-height: 1.55; margin-bottom: 18px;
}
.exp-detail__meta {
  list-style: none; display: flex; flex-wrap: wrap; gap: 10px;
}
.exp-detail__meta li {
  display: flex; flex-direction: column; gap: 2px;
  padding: 8px 14px;
  background: rgba(255,255,255,.8);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: .85rem; font-weight: 500;
}
.exp-detail__meta-label {
  font-size: .7rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--color-muted);
}

.exp-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 24px 26px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.exp-panel--endpoints {
  border-color: #d4d4d4;
  box-shadow: 0 4px 14px rgba(0,0,0,.05);
}
.exp-panel--danger {
  border-color: #fecaca;
  background: #fffbfb;
}
.exp-panel__head  { margin-bottom: 20px; }
.exp-panel__title {
  font-size: 1.05rem; font-weight: 700;
  margin-bottom: 4px; letter-spacing: -0.01em;
}
.exp-panel__desc  { font-size: .88rem; color: var(--color-muted); margin: 0; }
.exp-panel__form .field { margin-bottom: 18px; }
.field__input--pin {
  font-family: 'SF Mono', Menlo, Monaco, Consolas, monospace;
  font-size: 1.1rem; letter-spacing: 0.25em; max-width: 10rem;
}

.exp-detail__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.exp-detail__grid .exp-panel { margin-bottom: 0; }

.endpoint-list { list-style: none; display: flex; flex-direction: column; gap: 14px; }
.endpoint-item {
  display: flex; gap: 16px; align-items: flex-start;
  padding: 16px 18px;
  background: var(--color-bg);
  border: 1px solid var(--color-border-light);
  border-radius: 10px;
  transition: border-color .15s, box-shadow .15s;
}
.endpoint-item:hover {
  border-color: #a3a3a3;
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.endpoint-item__icon {
  flex-shrink: 0;
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px;
}
.endpoint-item__icon--server    { background: #e8e8e8; color: #111111; }
.endpoint-item__icon--dashboard { background: #e8e8e8; color: #111111; }
.endpoint-item__icon--key       { background: #e8e8e8; color: #404040; }
.endpoint-item--profile         { margin-bottom: 20px; }
.endpoint-item--masked .endpoint-item__input {
  color: var(--color-muted);
  letter-spacing: 0.05em;
}
.form-card--api        { margin-top: 0; }
.profile-api-actions   { margin-top: 4px; }
.endpoint-item__body   { flex: 1; min-width: 0; }
.endpoint-item__label  {
  display: block; font-weight: 600; font-size: .92rem;
  margin-bottom: 2px;
}
.endpoint-item__hint {
  display: block; font-size: .78rem; color: var(--color-muted);
  margin-bottom: 10px;
}
.endpoint-item__url-row {
  display: flex; align-items: stretch; gap: 8px;
}
.endpoint-item__input {
  flex: 1; min-width: 0;
  font-family: 'SF Mono', Menlo, Monaco, Consolas, monospace;
  font-size: .8rem;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: #fff;
  color: var(--color-text);
}
.endpoint-item__input:focus {
  outline: none;
  border-color: #111111;
  box-shadow: 0 0 0 3px rgba(0,0,0,.07);
}
.endpoint-item__actions {
  display: flex; gap: 6px; flex-shrink: 0;
}

.btn--icon {
  padding: 0;
  width: 40px; height: 40px;
  border: 1px solid var(--color-border);
  background: #fff;
  color: var(--color-muted);
  border-radius: 8px;
}
.btn--icon:hover {
  background: #f0f0f0;
  border-color: #a3a3a3;
  color: var(--color-text);
  opacity: 1;
  text-decoration: none;
}
.btn--outline-danger {
  background: transparent;
  color: var(--color-danger);
  border: 1px solid #fca5a5;
}
.btn--outline-danger:hover {
  background: #fef2f2;
  opacity: 1;
}

/* ── Profile page ────────────────────────────────────────────────────────────── */

/* Avatar row — horizontal layout: photo | name, email, buttons */
.avatar-row {
  display: flex;
  align-items: center;
  gap: 20px;
  padding-bottom: 20px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--color-border-light);
}
.avatar-row__frame {
  width: 88px; height: 88px; border-radius: 16px;
  position: relative; flex-shrink: 0;
  background: #d4d4d4;
  border: 3px solid var(--color-border);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.avatar-row__frame img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  border-radius: 0; object-fit: cover;
}
.avatar-row__initial {
  font-size: 1.9rem; font-weight: 700; color: #777;
  user-select: none; pointer-events: none; line-height: 1;
}
.avatar-row__meta { flex: 1; min-width: 0; }
.avatar-row__name {
  font-size: 1rem; font-weight: 600;
  margin-bottom: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.avatar-row__email {
  font-size: .85rem; color: var(--color-muted);
  margin-bottom: 10px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.avatar-row__actions {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  margin-bottom: 6px;
}
.avatar-row__hint {
  font-size: .75rem; color: var(--color-muted);
}

/* ── Default avatar picker ───────────────────────────────────────────────────── */
.avatar-defaults {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border-light);
}
.avatar-defaults__label {
  font-size: .8rem; color: var(--color-muted);
  margin-bottom: 10px; font-weight: 500;
}
.avatar-defaults__grid {
  display: flex; flex-wrap: wrap; gap: 10px;
}
.avatar-defaults__btn {
  width: 52px; height: 52px;
  border-radius: 10px; overflow: hidden;
  border: 2.5px solid transparent;
  cursor: pointer; padding: 0; background: none;
  transition: border-color .15s, transform .1s;
  flex-shrink: 0;
}
.avatar-defaults__btn:hover { transform: scale(1.06); }
.avatar-defaults__btn.active {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary-pale, #dbeafe);
}
.avatar-defaults__btn img {
  width: 100%; height: 100%; display: block; object-fit: cover;
}

/* ── Crop modal ──────────────────────────────────────────────────────────────── */
.crop-modal {
  position: fixed; inset: 0; z-index: 9000;
  display: none; align-items: center; justify-content: center;
}
.crop-modal.open { display: flex; }
.crop-modal__backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.55); backdrop-filter: blur(2px);
}
.crop-modal__box {
  position: relative; z-index: 1;
  background: var(--color-surface);
  border-radius: 14px;
  padding: 24px;
  width: min(520px, 94vw);
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.crop-modal__title {
  font-size: 1rem; font-weight: 700;
  margin-bottom: 16px;
}
.crop-modal__preview {
  width: 100%; max-height: 360px;
  overflow: hidden; border-radius: 8px;
  background: #111;
}
.crop-modal__preview img {
  display: block; max-width: 100%; max-height: 360px;
  margin: 0 auto;
}
.crop-modal__actions {
  display: flex; gap: 10px; justify-content: flex-end;
  margin-top: 16px; flex-wrap: wrap;
}

.profile-fields-form { margin-top: 4px; }
.profile-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
}
.profile-api-actions { margin-top: 16px; }

/* Responsive: stack avatar-row on narrow screens */
@media (max-width: 480px) {
  .avatar-row { flex-direction: column; align-items: flex-start; gap: 14px; }
  .avatar-row__name, .avatar-row__email { white-space: normal; }
}

/* ── API Keys table ────────────────────────────────────────────────────────── */
.keys-table {
  width: 100%; border-collapse: collapse; font-size: .9rem;
}
.keys-table thead th {
  text-align: left; padding: 10px 16px;
  border-bottom: 1px solid var(--color-border);
  font-size: .8rem; font-weight: 600; color: var(--color-muted);
  text-transform: uppercase; letter-spacing: .04em;
}
.keys-table tbody tr { border-bottom: 1px solid var(--color-border-light); }
.keys-table tbody tr:last-child { border-bottom: none; }
.keys-table tbody td { padding: 12px 16px; vertical-align: middle; }
.keys-table__name { font-weight: 600; }
.keys-table__prefix code { font-size: .88em; background: #f5f5f5; padding: 2px 6px; border-radius: 4px; }
.keys-table__date { color: var(--color-muted); font-size: .85rem; white-space: nowrap; }
.keys-table__toolbar {
  display: flex;
  justify-content: flex-end;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border-light);
}
.keys-table__footer {
  padding: 12px 16px;
  border-top: 1px solid var(--color-border-light);
}
.keys-table__footer .events-pagination { margin: 0; }
.keys-table__sort {
  color: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.keys-table__sort:hover { color: var(--color-text); }
.keys-table__sort.is-active { color: var(--color-text); }
.keys-table__sort-icon { font-size: .85em; opacity: .75; }

/* ── Modal ───────────────────────────────────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.45); z-index: 200;
  align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--color-surface); border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,.18);
  width: 100%; max-width: 440px; margin: 16px;
  overflow: hidden;
}
.modal__header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 0;
}
.modal__title { font-size: 1.05rem; font-weight: 700; }
.modal__close {
  background: none; border: none; cursor: pointer;
  font-size: 1rem; color: var(--color-muted); line-height: 1;
  padding: 4px; border-radius: 4px;
}
.modal__close:hover { background: #f0f0f0; color: var(--color-text); }
.modal__body { padding: 16px 20px; }
.modal__footer {
  display: flex; gap: 8px; padding: 12px 20px 18px;
  border-top: 1px solid var(--color-border-light);
}

/* ── Nav avatar + dropdown ───────────────────────────────────────────────────── */
.nav-avatar-wrap {
  position: relative;
  display: flex; align-items: center; gap: 5px;
  cursor: pointer;
  padding: 3px 6px 3px 3px;
  border-radius: 20px;
  border: 1px solid transparent;
  transition: background .15s, border-color .15s;
  user-select: none;
}
.nav-avatar-wrap:hover,
.nav-avatar-wrap.open {
  background: #f0f0f0;
  border-color: var(--color-border);
}
/* ── Avatar frame — image + initial-letter fallback ─────────────────────────── */
.nav-avatar-frame {
  width: 32px; height: 32px; border-radius: 8px;
  position: relative; flex-shrink: 0;
  background: #d4d4d4;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.nav-avatar-frame img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  border-radius: 0; object-fit: cover;
}
.nav-avatar-initial {
  font-size: .75rem; font-weight: 700; color: #555;
  user-select: none; pointer-events: none; line-height: 1;
}
/* Medium variant — used inside desktop dropdown header */
.nav-avatar-frame--md  { width: 38px; height: 38px; }
.nav-avatar-initial--md { font-size: .9rem; }

/* Legacy .nav-avatar kept for any remaining uses */
.nav-avatar {
  width: 32px; height: 32px; border-radius: 8px;
  flex-shrink: 0; display: block;
}
.nav-avatar--photo { object-fit: cover; }
.nav-avatar-caret {
  color: var(--color-muted);
  transition: transform .15s;
}
.nav-avatar-wrap.open .nav-avatar-caret { transform: rotate(180deg); }

/* ── Dropdown panel ─────────────────────────────────────────────────────────── */
.nav-avatar-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 240px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  z-index: 200;
  overflow: hidden;
}
.nav-avatar-dropdown.open { display: block; }

.nav-avatar-dropdown__header {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--color-border-light);
  background: #fafafa;
}
.nav-avatar-dropdown__img {
  width: 38px; height: 38px; border-radius: 50%; object-fit: cover; flex-shrink: 0;
}
.nav-avatar-dropdown__info {
  display: flex; flex-direction: column; min-width: 0;
}
.nav-avatar-dropdown__name {
  font-size: .88rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nav-avatar-dropdown__email {
  font-size: .78rem; color: var(--color-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.nav-avatar-dropdown__body {
  padding: 6px 0;
}
.nav-avatar-dropdown__link {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 14px; color: var(--color-text);
  font-size: .88rem; text-decoration: none;
  transition: background .12s;
}
.nav-avatar-dropdown__link:hover {
  background: #f5f5f5; text-decoration: none;
}

.nav-avatar-dropdown__footer {
  border-top: 1px solid var(--color-border-light);
  padding: 6px 0;
}
.nav-avatar-dropdown__signout {
  display: flex; align-items: center; gap: 9px;
  width: 100%; padding: 8px 14px;
  background: none; border: none; cursor: pointer;
  font-size: .88rem; color: var(--color-danger);
  font-family: var(--font);
  transition: background .12s;
  text-align: left;
}
.nav-avatar-dropdown__signout:hover { background: #fef2f2; }

/* ── Site footer (logged-in pages) ──────────────────────────────────────────── */
.site-footer {
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  margin-top: auto;   /* pushes footer to bottom when content is short */
  padding: 20px 24px;
  font-size: .82rem;
  color: var(--color-muted);
}
.site-footer__inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.site-footer__brand {
  display: flex; align-items: center; gap: 10px;
}
.site-footer__logo {
  border-radius: 50%; flex-shrink: 0; opacity: .85;
}
.site-footer__lab  { display: block; font-weight: 600; color: var(--color-text); }
.site-footer__copy { display: block; font-size: .78rem; margin-top: 1px; }
.site-footer__links { display: flex; gap: 16px; }
.site-footer__links a { color: var(--color-muted); text-decoration: none; }
.site-footer__links a:hover { color: var(--color-text); text-decoration: underline; }

/* ── Auth page — site blurb ─────────────────────────────────────────────────── */
.auth-site-blurb {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--color-border-light);
  font-size: .85rem;
  color: var(--color-muted);
  line-height: 1.6;
}
.auth-site-blurb p { margin: 0 0 10px; }
.auth-site-blurb strong { color: var(--color-text); }
.auth-tutorial-link {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .84rem; font-weight: 600;
  color: var(--color-text); text-decoration: none;
  border: 1px solid var(--color-border);
  padding: 5px 12px; border-radius: var(--radius);
  transition: background .14s;
}
.auth-tutorial-link:hover { background: #f0f0f0; text-decoration: none; }

/* ── Auth page — footer ─────────────────────────────────────────────────────── */
.auth-footer {
  margin-top: 20px;
  padding: 14px 0 28px;
  font-size: .78rem;
  color: var(--color-muted);
  text-align: center;
}
.auth-footer__inner {
  display: flex; align-items: center; justify-content: center;
  gap: 8px; flex-wrap: wrap;
}
.auth-footer__logo { border-radius: 50%; opacity: .75; flex-shrink: 0; }

/* ── Hamburger button ────────────────────────────────────────────────────────── */
.nav-hamburger {
  display: none;
  flex-direction: column; justify-content: center; align-items: center;
  gap: 5px;
  width: 36px; height: 36px;
  padding: 0;
  background: none; border: none; cursor: pointer;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  transition: background .15s;
}
.nav-hamburger:hover { background: #f0f0f0; }
.nav-hamburger span {
  display: block;
  width: 20px; height: 2px;
  background: var(--color-text);
  border-radius: 2px;
  transition: transform .2s, opacity .2s;
}
/* Animate to X when open */
.nav-hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-hamburger.open span:nth-child(2) { opacity: 0; }
.nav-hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── Mobile navigation drawer ────────────────────────────────────────────────── */
/* Overlay (darkens the page behind the drawer) */
.nav-drawer-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.48);
  z-index: 298;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
}
.nav-drawer-overlay.open { opacity: 1; pointer-events: auto; }

/* Drawer panel */
.nav-drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 300px; max-width: 85vw;
  background: var(--color-surface);
  z-index: 299;
  transform: translateX(100%);
  transition: transform .28s cubic-bezier(.4,0,.2,1);
  display: flex; flex-direction: column;
  overflow: hidden;
  box-shadow: -6px 0 28px rgba(0,0,0,.13);
}
.nav-drawer.open { transform: translateX(0); }

/* Drawer — header (identity or brand) */
.nav-drawer__header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0; gap: 10px; min-height: 68px;
}
.nav-drawer__identity {
  display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1;
}
.nav-drawer__avatar-frame {
  width: 44px; height: 44px; border-radius: 10px;
  position: relative; flex-shrink: 0;
  background: #d4d4d4;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.nav-drawer__avatar-frame img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  border-radius: 0; object-fit: cover;
}
.nav-drawer__avatar-initial {
  font-size: 1rem; font-weight: 700; color: #555;
  user-select: none; pointer-events: none;
}
.nav-drawer__identity-text { min-width: 0; flex: 1; }
.nav-drawer__identity-name {
  display: block; font-size: .9rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nav-drawer__identity-email {
  display: block; font-size: .78rem; color: var(--color-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nav-drawer__brand {
  display: flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: .95rem;
  color: var(--color-text); text-decoration: none; flex: 1;
}
.nav-drawer__close {
  background: none; border: none; cursor: pointer;
  color: var(--color-muted); padding: 6px; border-radius: 4px;
  flex-shrink: 0; transition: background .13s;
}
.nav-drawer__close:hover { background: #f0f0f0; color: var(--color-text); }
.nav-drawer__close svg { display: block; }

/* Drawer — scrollable nav list */
.nav-drawer__body { flex: 1; overflow-y: auto; padding: 8px 0 16px; }
.nav-drawer__link {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 20px;
  color: var(--color-text); font-size: .92rem;
  text-decoration: none; transition: background .12s;
  background: none; border: none; width: 100%;
  text-align: left; font-family: var(--font); cursor: pointer;
}
.nav-drawer__link:hover  { background: #f5f5f5; text-decoration: none; }
.nav-drawer__link.active { background: #efefef; font-weight: 600; }
.nav-drawer__link--danger { color: var(--color-danger); }
.nav-drawer__link--danger:hover { background: #fef2f2; }
.nav-drawer__link--admin  { color: var(--color-danger); }
.nav-drawer__link--cta    { font-weight: 600; }
.nav-drawer__icon { color: var(--color-muted); flex-shrink: 0; }
.nav-drawer__link.active .nav-drawer__icon,
.nav-drawer__link:hover  .nav-drawer__icon { color: var(--color-text); }
.nav-drawer__divider { height: 1px; background: var(--color-border-light); margin: 8px 0; }

/* ── form-actions: always wrap on small screens ──────────────────────────────── */
.form-actions { flex-wrap: wrap; }

/* ── Responsive — tablet (≤ 860px) ──────────────────────────────────────────── */
@media (max-width: 860px) {
  .detail-grid { grid-template-columns: 1fr; }
  .detail-card--wide { grid-column: 1; }
}

/* ── Responsive — mobile (≤ 640px) ──────────────────────────────────────────── */
@media (max-width: 640px) {
  /* Nav: hide desktop links, show hamburger */
  .topnav { padding: 0 14px; gap: 8px; }
  .topnav__links { display: none; }
  .topnav__brand-text { font-size: .95rem; }
  .nav-hamburger { display: flex; }
  .nav-avatar-caret { display: none; }
  /* Avatar non-interactive on mobile (hamburger/drawer handles nav) */
  .nav-avatar-wrap { pointer-events: none; cursor: default; }
  .nav-avatar-dropdown { display: none !important; }
  /* Hide "Create account" CTA — it's in the drawer */
  .topnav__cta-full { display: none; }

  /* Main layout */
  .main-content { padding: 16px 14px; }

  /* Page header — stack if needed */
  .page-header { flex-wrap: wrap; gap: 10px; }
  .page-header .btn { align-self: flex-start; }

  /* Usage card value: remove fixed width so it wraps gracefully */
  .usage-val { width: auto; min-width: 80px; text-align: right; }

  /* Experiment grid: single column on phones */
  .exp-grid { grid-template-columns: 1fr; }

  /* Experiment detail */
  .exp-detail__hero { margin: 0 0 16px; padding: 16px 14px; }
  .exp-detail__title { font-size: 1.25rem; }
  .exp-detail__grid { grid-template-columns: 1fr; }

  /* Endpoint items */
  .endpoint-item { flex-direction: column; }
  .endpoint-item__url-row { flex-direction: column; }
  .endpoint-item__actions { justify-content: flex-end; }

  /* Profile */
  .profile-row { grid-template-columns: 1fr; }

  /* API Keys table: wrap key cell, hide date column */
  .keys-table__date { display: none; }
  .keys-table__prefix { display: none; }
  .key-created-banner { flex-direction: column; gap: 10px; padding: 16px; }
  .key-created-banner__key-row { flex-direction: column; }
  .key-created-banner__copy { width: 100%; }

  /* Modal: full-width at bottom / centred */
  .modal { max-width: calc(100vw - 24px); margin: 12px; }
  .modal__footer { flex-wrap: wrap; }

  /* Auth card */
  .auth-card { padding: 28px 20px; }
  .auth-body__center { padding: 24px 12px; }

  /* Footer */
  .site-footer { padding: 16px 14px; }
  .site-footer__inner { flex-direction: column; align-items: flex-start; gap: 12px; }
  .site-footer__links { gap: 12px; }
  .site-footer__brand { gap: 8px; }
  .site-footer__lab { font-size: .8rem; }
}

/* ── Data Transfer Heatmap ───────────────────────────────────────────────────── */
.heatmap-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px 24px 16px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.heatmap-card__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}
.heatmap-card__meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.heatmap-card__title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--color-text);
}
.heatmap-card__stat {
  font-size: 0.78rem;
  color: var(--color-muted);
}
.heatmap-year-select {
  font-size: 0.8rem;
  padding: 4px 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
}

/* Full-width, no scroll needed */
.heatmap-wrap {
  overflow: hidden;
}
.heatmap-loading {
  font-size: 0.8rem;
  color: var(--color-muted);
  padding: 20px 0;
  text-align: center;
}

/* Month chunks sit side by side; justify-content is set by JS to space-between
   so the 12 chunks fill the full container width end-to-end with equal gaps. */
.heatmap-months {
  display: flex;
  flex-wrap: nowrap;
  align-items: flex-start;
  width: 100%;
}
.heatmap-month {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex-shrink: 0;
}
.heatmap-month__name {
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--color-muted);
  text-align: center;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

/* JS sets grid-template-rows, grid-auto-columns, and gap inline */
.heatmap-month__grid {
  display: grid;
  grid-auto-flow: column;
}
.heatmap-cell {
  display: block;
  border-radius: 2px;
  cursor: default;
  flex-shrink: 0;
}
.heatmap-cell--empty  { background: transparent; }
.heatmap-cell--0      { background: #ebedf0; }
.heatmap-cell--1      { background: #9be9a8; }
.heatmap-cell--2      { background: #40c463; }
.heatmap-cell--3      { background: #30a14e; }
.heatmap-cell--4      { background: #216e39; }
.heatmap-cell[data-date]:hover { outline: 1px solid #555; outline-offset: 1px; }

/* Footer row: note on the left, legend on the right */
.heatmap-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.heatmap-note {
  font-size: 0.72rem;
  color: var(--color-muted);
  font-style: italic;
}

/* Legend */
.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 3px;
}
.heatmap-legend__label {
  font-size: 0.68rem;
  color: var(--color-muted);
  margin: 0 3px;
}
/* Legend cells need explicit size (no grid parent to drive aspect-ratio) */
.heatmap-legend .heatmap-cell {
  width: 11px;
  height: 11px;
  flex-shrink: 0;
}

/* Tooltip */
.heatmap-tooltip {
  position: fixed;
  z-index: 9999;
  background: #1a1f2e;
  color: #fff;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 0.76rem;
  line-height: 1.6;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}
.heatmap-tooltip__date {
  font-weight: 700;
  margin-bottom: 4px;
  color: #e2e8f0;
}
.heatmap-tooltip__row { display: flex; gap: 8px; justify-content: space-between; }
.heatmap-tooltip__key { color: #94a3b8; }
.heatmap-tooltip__val { font-weight: 600; }

/* ── Dashboard tabs ─────────────────────────────────────────────────────────── */
.dash-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 0;
}
.dash-tabs__btn {
  appearance: none;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: 10px 16px;
  font-size: .875rem;
  font-weight: 500;
  color: var(--color-muted);
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.dash-tabs__btn:hover { color: var(--color-text); }
.dash-tabs__btn.active {
  color: var(--color-text);
  border-bottom-color: #000;
  font-weight: 600;
}
.dash-tab-panel.hidden { display: none; }

/* ── Recent events timeline ─────────────────────────────────────────────────── */
.events-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 20px 22px;
}
.events-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.events-card__title {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0 0 4px;
}
.events-card__desc {
  margin: 0;
  font-size: .8125rem;
  color: var(--color-muted);
}
.events-page-size {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .8125rem;
  color: var(--color-muted);
}
.events-card__controls--right {
  margin-left: auto;
}
.events-page-size select {
  padding: 4px 8px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-bg);
  font-size: .8125rem;
}
.events-timeline { display: flex; flex-direction: column; gap: 8px; }
.timeline-empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--color-muted);
  font-size: .875rem;
}
.timeline-item {
  border-left: 3px solid #cbd5e1;
  background: var(--color-bg);
  border-radius: 0 8px 8px 0;
  padding: 10px 14px;
}
.timeline-item.tl-done     { border-left-color: #16a34a; background: #f0fdf4; }
.timeline-item.tl-aborted  { border-left-color: #dc2626; background: #fef2f2; }
.timeline-item.tl-deleted  { border-left-color: #64748b; background: #f8fafc; }
.timeline-item.tl-restored { border-left-color: #16a34a; background: #f0fdf4; }
.timeline-item.tl-params   { border-left-color: #ca8a04; background: #fefce8; }
.timeline-item.tl-status   { border-left-color: #ea580c; background: #fff7ed; }
.timeline-item__msg {
  font-size: .875rem;
  font-weight: 500;
  color: var(--color-text);
  line-height: 1.45;
}
.timeline-item__exp {
  font-size: .75rem;
  color: var(--color-muted);
  margin-top: 2px;
  font-family: ui-monospace, monospace;
}
.timeline-item__time {
  font-size: .75rem;
  color: var(--color-muted);
  margin-top: 6px;
}
.events-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
  flex-wrap: wrap;
}
.events-pagination__info {
  font-size: .8125rem;
  color: var(--color-muted);
  flex: 1;
  text-align: center;
}

/* ── Notification toggles ───────────────────────────────────────────────────── */
.notif-form { margin-top: 8px; }
.notif-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--color-border);
}
.notif-row:last-of-type { border-bottom: none; }
.notif-row__text { min-width: 0; flex: 1; }
.notif-row__label {
  display: block;
  font-size: .9375rem;
  font-weight: 600;
  margin-bottom: 2px;
}
.notif-row__desc {
  display: block;
  font-size: .8125rem;
  color: var(--color-muted);
  line-height: 1.4;
}
.toggle-switch {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
  cursor: pointer;
}
.toggle-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-switch__track {
  display: block;
  width: 44px;
  height: 24px;
  background: #cbd5e1;
  border-radius: 12px;
  transition: background .2s;
  position: relative;
}
.toggle-switch__track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.15);
}
.toggle-switch input:checked + .toggle-switch__track {
  background: #16a34a;
}
.toggle-switch input:checked + .toggle-switch__track::after {
  transform: translateX(20px);
}
.toggle-switch input:focus-visible + .toggle-switch__track {
  outline: 2px solid #000;
  outline-offset: 2px;
}

/* ── Responsive — small phones (≤ 400px) ────────────────────────────────────── */
@media (max-width: 400px) {
  .topnav__brand-text { display: none; }  /* icon alone at very tiny sizes */
  .auth-card { padding: 22px 16px; }
  .form-card { padding: 16px; }
  /* Keep "Sign in" button, hide it from topnav (it's in hamburger) */
  .topnav__user .btn--outline { display: none; }
}
