:root {
  --zinc-50: #fafafa;
  --zinc-100: #f4f4f5;
  --zinc-200: #e4e4e7;
  --zinc-300: #d4d4d8;
  --zinc-400: #a1a1aa;
  --zinc-500: #71717a;
  --zinc-600: #52525b;
  --zinc-700: #3f3f46;
  --zinc-800: #27272a;
  --zinc-900: #18181b;
  --zinc-950: #09090b;

  --emerald-500: #10b981;
  --amber-400: #fbbf24;
  --amber-500: #f59e0b;
  --amber-600: #d97706;
  --red-500: #ef4444;

  --score-good: #0cce6b;
  --score-mid: #ffa400;
  --score-bad: #ff4e42;
  --score-track: #52525b;

  --background: #09090b;
  --foreground: #ededed;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--background);
  color: var(--foreground);
}

/* --- Auth pages (kept light-neutral, separate from the dashboard theme) --- */
.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #111827, #1f2937);
}
.auth-card {
  background: #ffffff;
  color: #1a1d23;
  padding: 2.5rem;
  border-radius: 10px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}
.auth-card h1 { margin: 0 0 0.25rem; font-size: 1.4rem; }
.auth-sub { color: #667085; margin: 0 0 1.5rem; font-size: 0.9rem; }
.auth-error { color: var(--red-500); font-size: 0.85rem; margin-bottom: 1rem; }
.auth-success { color: var(--emerald-500); font-size: 0.85rem; margin-bottom: 1rem; }
.auth-card form { display: flex; flex-direction: column; gap: 1rem; }
.auth-card label { display: flex; flex-direction: column; gap: 0.4rem; font-size: 0.85rem; color: #667085; }
.auth-card input {
  padding: 0.6rem 0.75rem;
  border: 1px solid #e4e7ec;
  border-radius: 8px;
  font-size: 0.95rem;
}
.auth-submit { position: relative; margin-top: 0.5rem; }
.auth-submit-btn {
  position: relative;
  display: block;
  width: 100%;
  height: 2.75rem;
  border: none;
  border-radius: 8px;
  background: #1a1d23;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.1s ease;
}
.auth-submit-btn:hover { background: #2b2f38; }
.auth-submit-btn:active { transform: scale(0.98); }
.auth-submit-btn:disabled { cursor: not-allowed; opacity: 0.85; }
.auth-submit-btn.shake { animation: lhw-shake 0.4s ease; }
.auth-submit-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}
.auth-submit-ring-rect {
  fill: none;
  stroke: var(--zinc-400);
  opacity: 0;
  transition: opacity 0.15s ease, stroke 0.2s ease;
}
.auth-submit-ring-rect.is-active { opacity: 1; }
.auth-submit-ring-rect.is-pulsing { animation: lhw-pulse 1s ease-in-out infinite; }
.auth-submit-ring-rect.is-empty { stroke: var(--score-mid); }
.auth-submit-ring-rect.is-success { stroke: var(--score-good); }
.auth-submit-ring-rect.is-error { stroke: var(--score-bad); }
@keyframes lhw-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(3px); }
}

/* --- App topbar (our own, kept minimal, sits above the extension-style dashboard) --- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.25rem;
  background: var(--zinc-950);
  border-bottom: 1px solid var(--zinc-800);
}
.topbar-left { display: flex; align-items: center; gap: 0.75rem; min-width: 0; }
.app-logo {
  display: flex;
  height: 2.25rem;
  width: 2.25rem;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--zinc-100);
  color: var(--zinc-900);
}
.app-logo .icon { width: 1.125rem; height: 1.125rem; }
.topbar-title { min-width: 0; }
.title-row { display: flex; align-items: center; gap: 0.5rem; }
.topbar h1 { font-size: 1.05rem; margin: 0; font-weight: 700; }
.topbar-sub { margin: 0.125rem 0 0; font-size: 0.6875rem; color: var(--zinc-500); }
.topbar-right { display: flex; align-items: center; gap: 1rem; }
.topbar-account { display: flex; align-items: center; gap: 0.75rem; min-width: 0; }
.logout-form { display: contents; }
.user-pill { font-size: 0.8rem; color: var(--zinc-500); }
.quota-pill {
  font-size: 0.75rem;
  color: var(--zinc-500);
  background: var(--zinc-900);
  border: 1px solid var(--zinc-800);
  border-radius: 999px;
  padding: 0.25rem 0.625rem;
}

.conn-badge {
  display: inline-flex;
  height: 1.5rem;
  width: 1.5rem;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: rgba(16, 185, 129, 0.15);
  color: var(--emerald-500);
  transition: background-color 0.15s;
}
.conn-badge:hover { background: rgba(16, 185, 129, 0.25); }

.panel-collapse {
  margin-left: 0.25rem;
  display: inline-flex;
  height: 1.75rem;
  width: 1.75rem;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--zinc-400);
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}
.panel-collapse:hover { background: var(--zinc-800); color: var(--zinc-300); }

/* --- Dashboard shell --- */
.content {
  max-width: 72rem;
  margin: 0 auto;
  padding: 1.5rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* --- Generic bits shared with the extension's shadcn primitives --- */
.icon { width: 1em; height: 1em; display: inline-block; vertical-align: -0.125em; flex-shrink: 0; }
.icon-sm { width: 0.875rem; height: 0.875rem; }
.icon-xs { width: 0.75rem; height: 0.75rem; }

.spin { animation: lhw-spin 1s linear infinite; }
@keyframes lhw-spin { to { transform: rotate(360deg); } }
.pulse { animation: lhw-pulse 1.5s ease-in-out infinite; }
@keyframes lhw-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  white-space: nowrap;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background-color 0.15s, opacity 0.15s;
  border: none;
  cursor: pointer;
  height: 2.25rem;
  padding: 0.5rem 1rem;
  background: var(--zinc-100);
  color: var(--zinc-900);
}
.btn:hover { background: rgba(244, 244, 245, 0.9); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
.btn-sm { height: 2rem; padding: 0 0.75rem; font-size: 0.75rem; border-radius: 6px; }
.btn-icon { height: 2.25rem; width: 2.25rem; padding: 0; }
.btn-icon-sm { height: 1.75rem; width: 1.75rem; padding: 0; }

.btn-outline { background: var(--zinc-950); color: var(--foreground); border: 1px solid var(--zinc-800); }
.btn-outline:hover { background: var(--zinc-800); }
.btn-ghost { background: transparent; color: var(--foreground); }
.btn-ghost:hover { background: var(--zinc-800); }
.btn-destructive { background: var(--red-500); color: white; }
.btn-destructive:hover { background: rgba(239, 68, 68, 0.9); }

.input {
  height: 2.25rem;
  width: 100%;
  border-radius: 6px;
  border: 1px solid var(--zinc-800);
  background: var(--zinc-950);
  color: var(--foreground);
  padding: 0.25rem 0.75rem;
  font-size: 0.875rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.input::placeholder { color: var(--zinc-400); }
.input:focus-visible { outline: 1px solid var(--zinc-400); outline-offset: 0; }
.input:disabled { opacity: 0.5; cursor: not-allowed; }
.input-mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.75rem; }

/* --- API key panel --- */
.panel {
  border-radius: 8px;
  border: 1px solid var(--zinc-800);
  background: var(--zinc-950);
  padding: 1rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.panel-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  color: var(--zinc-500);
}
.panel-head h2 { flex: 1; font-size: 0.875rem; font-weight: 600; margin: 0; color: var(--foreground); }

.status-dot { width: 0.625rem; height: 0.625rem; border-radius: 50%; flex-shrink: 0; background: var(--zinc-400); }
.status-dot[data-status="valid"] { background: var(--emerald-500); box-shadow: 0 0 6px rgba(16,185,129,0.6); }
.status-dot[data-status="invalid"] { background: var(--red-500); }
.status-dot[data-status="testing"] { background: var(--amber-400); animation: lhw-pulse 1.5s ease-in-out infinite; }

.status-label { font-size: 0.75rem; font-weight: 500; color: var(--zinc-500); }
.status-label[data-status="valid"] { color: var(--emerald-500); }
.status-label[data-status="invalid"] { color: var(--red-500); }
.status-label[data-status="testing"] { color: var(--amber-600); }

.status-icon-valid { color: var(--emerald-500); }
.status-icon-invalid { color: var(--red-500); }

.form-row { display: flex; flex-direction: column; gap: 0.5rem; }
@media (min-width: 640px) { .form-row { flex-direction: row; } }

.field-error { margin-top: 0.5rem; font-size: 0.75rem; color: var(--red-500); }
.field-warning { margin-top: 0.5rem; font-size: 0.75rem; color: var(--amber-600); }

.accordion { margin-top: 0.75rem; }
.accordion-trigger {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 0.5rem;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem 0;
  font-size: 0.75rem;
  color: var(--zinc-400);
  text-align: left;
}
.accordion-trigger .chevron { margin-left: auto; transition: transform 0.15s; }
.accordion-trigger[aria-expanded="true"] .chevron { transform: rotate(180deg); }
.accordion-content {
  display: grid;
  grid-template-rows: minmax(0, 0fr);
  overflow: hidden;
  transition: grid-template-rows 0.2s ease-out;
}
.accordion-content.open { grid-template-rows: minmax(0, 1fr); }
.accordion-content > .accordion-inner { min-height: 0; overflow: hidden; padding-bottom: 0.25rem; }

.gcp-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.75rem; }
.gcp-step { border-radius: 6px; border: 1px solid var(--zinc-800); background: var(--zinc-900); padding: 0.75rem; }
.gcp-step p.gcp-title { margin: 0; font-size: 0.75rem; font-weight: 500; }
.gcp-step p.gcp-desc { margin: 0.25rem 0 0; font-size: 0.6875rem; color: var(--zinc-500); }
.gcp-step .btn { margin-top: 0.5rem; height: 1.75rem; font-size: 0.75rem; }
.gcp-note { margin-top: 0.75rem; font-size: 0.6875rem; color: var(--zinc-500); }

.audit-all-wrap { position: relative; display: inline-flex; }
.audit-all-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}
.audit-all-ring-rect {
  fill: none;
  stroke: var(--amber-400);
  stroke-dasharray: 16 12;
  opacity: 0;
}
.audit-all-ring-rect.is-active {
  opacity: 1;
  animation: lhw-border-march 1.2s linear infinite;
}
@keyframes lhw-border-march {
  to { stroke-dashoffset: -56; }
}

/* --- Controls row --- */
.controls-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem; }
.controls-group { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.sort-count { font-size: 0.875rem; color: var(--zinc-500); }
.sort-notice { color: var(--emerald-500); }

/* --- Site list --- */
.site-list { display: flex; flex-direction: column; gap: 0.5rem; }

.empty-state {
  border-radius: 12px;
  border: 1px dashed var(--zinc-700);
  background: rgba(24, 24, 27, 0.5);
  padding: 4rem 1.5rem;
  text-align: center;
}
.empty-state p.empty-title { margin: 0; font-size: 1.125rem; font-weight: 500; color: var(--zinc-300); }
.empty-state p.empty-sub { margin: 0.5rem 0 0; font-size: 0.875rem; color: var(--zinc-500); }

.site-row {
  border-radius: 8px;
  border: 1px solid var(--zinc-800);
  background: var(--zinc-950);
  padding: 0.5rem 0.625rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.site-row-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 1.75rem;
  align-items: start;
  column-gap: 0.375rem;
}
.site-row-main {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 0.75rem;
  row-gap: 0.375rem;
}
.site-row-checkbox { width: 0.875rem; height: 0.875rem; flex-shrink: 0; accent-color: var(--zinc-100); }

.site-link-group { display: flex; min-width: 120px; flex: 1; align-items: center; gap: 0.375rem; overflow: hidden; }
.site-link {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 0.125rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--foreground);
  text-decoration: none;
}
.site-link:hover { text-decoration: underline; }
.site-link span.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.site-link .icon { opacity: 0.6; }
.site-date { flex-shrink: 0; font-size: 0.625rem; color: var(--zinc-400); }

.group-picker { position: relative; flex-shrink: 0; }
.group-picker-menu {
  position: absolute;
  top: calc(100% + 0.25rem);
  left: 0;
  z-index: 10;
  min-width: 10rem;
  max-height: 14rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  padding: 0.25rem;
  border-radius: 8px;
  border: 1px solid var(--zinc-700);
  background: var(--zinc-900);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.group-picker-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border: none;
  background: none;
  border-radius: 6px;
  padding: 0.375rem 0.5rem;
  font-size: 0.75rem;
  color: var(--foreground);
  cursor: pointer;
  text-align: left;
}
.group-picker-item:hover { background: var(--zinc-800); }
.group-picker-item.current { color: var(--emerald-500); }
.group-picker-item-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-picker-item .icon { flex-shrink: 0; }
.group-picker-empty { margin: 0; padding: 0.5rem; font-size: 0.6875rem; color: var(--zinc-500); text-align: center; }
.group-dot-none { background: none; border: 1px solid var(--zinc-600); }

.device-toggle {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  gap: 0.3rem;
  border-radius: 6px;
  border: 1px solid var(--zinc-700);
  background: var(--zinc-900);
  cursor: pointer;
  font-weight: 500;
  font-size: 0.625rem;
  padding: 0.25rem 0.5rem;
  color: var(--zinc-300);
  transition: background-color 0.15s, border-color 0.15s;
}
.device-toggle:hover { background: var(--zinc-800); border-color: var(--zinc-600); }
.device-toggle .icon { flex-shrink: 0; }

.site-actions { display: flex; align-items: center; gap: 0.25rem; }
.site-error { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.625rem; color: var(--red-500); }

.avg-badge {
  display: flex;
  height: 2rem;
  width: 2rem;
  flex-shrink: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid;
}
.avg-badge .avg-label { font-size: 0.4375rem; line-height: 1; color: var(--zinc-500); }
.avg-badge .avg-score { font-size: 0.75rem; font-weight: 700; line-height: 1; }
.avg-good { background: rgba(16, 185, 129, 0.1); border-color: rgba(16, 185, 129, 0.3); }
.avg-good .avg-score { color: var(--emerald-500); }
.avg-mid { background: rgba(245, 158, 11, 0.1); border-color: rgba(245, 158, 11, 0.3); }
.avg-mid .avg-score { color: var(--amber-500); }
.avg-bad { background: rgba(239, 68, 68, 0.1); border-color: rgba(239, 68, 68, 0.3); }
.avg-bad .avg-score { color: var(--red-500); }

.category-charts { display: flex; align-items: center; gap: 0.125rem; }
.category-chart { display: flex; width: 2.75rem; flex-shrink: 0; flex-direction: column; align-items: center; gap: 0.125rem; }
.category-ring-wrap { position: relative; display: flex; align-items: center; justify-content: center; }
.score-ring { display: block; }
.score-ring-track { stroke: var(--score-track); }
.score-ring-fill { transition: stroke-dashoffset 0.5s ease, stroke 0.3s ease; }
.category-label { font-size: 0.5rem; font-weight: 500; line-height: 1; color: var(--zinc-500); }
.category-score { position: absolute; font-size: 0.625rem; font-weight: 700; line-height: 1; }

.skeleton-circle { border-radius: 50%; background: var(--zinc-800); }

.row-delete { grid-column: 2; grid-row: 1; justify-self: center; }

.details-accordion { grid-column: 1 / span 2; margin-top: -0.25rem; }
.details-trigger {
  display: grid;
  width: 100%;
  grid-template-columns: minmax(0, 1fr) 1.75rem;
  column-gap: 0.375rem;
  align-items: center;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  font-size: 0.6875rem;
  font-weight: 400;
  color: var(--zinc-500);
  text-align: left;
}
.details-trigger .chevron { grid-column: 2; justify-self: center; width: 0.875rem; height: 0.875rem; transition: transform 0.15s; }
.details-trigger[aria-expanded="true"] .chevron { transform: rotate(180deg); }
.details-content {
  display: grid;
  grid-template-rows: minmax(0, 0fr);
  grid-column: 1 / span 2;
  overflow: hidden;
  transition: grid-template-rows 0.2s ease-out;
}
.details-content.open { grid-template-rows: minmax(0, 1fr); }
.details-content > .details-inner { min-height: 0; overflow: hidden; padding: 0.25rem 0 0.5rem; }
.details-updated { margin: 0 0 0.5rem; font-size: 0.75rem; color: var(--zinc-500); }
.details-section { margin-top: 1rem; }
.details-section:first-child { margin-top: 0; }
.details-section h4 { margin: 0 0 0.5rem; font-size: 0.875rem; font-weight: 500; }
.details-section h4.failed { color: var(--red-500); }
.details-section h4.opportunity { color: var(--amber-500); }

.cwv-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
@media (min-width: 640px) { .cwv-grid { grid-template-columns: repeat(5, 1fr); } }
.cwv-cell { border-radius: 8px; background: var(--zinc-900); padding: 0.375rem 0.5rem; }
.cwv-cell .cwv-label { margin: 0; font-size: 0.625rem; color: var(--zinc-500); }
.cwv-cell .cwv-value { margin: 0; font-size: 0.875rem; font-weight: 500; }

.audit-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.audit-item { border-radius: 8px; border: 1px solid; padding: 0.5rem; }
.audit-item.failed { border-color: rgba(239, 68, 68, 0.3); background: rgba(239, 68, 68, 0.05); }
.audit-item.opportunity { border-color: rgba(245, 158, 11, 0.3); background: rgba(245, 158, 11, 0.05); }
.audit-item p.audit-title { margin: 0; font-size: 0.875rem; font-weight: 500; }
.audit-item p.audit-value { margin: 0; font-size: 0.75rem; color: var(--zinc-400); }

/* --- Filtre / création de groupe --- */
.group-filter-select { height: 2rem; width: auto; max-width: 11rem; font-size: 0.75rem; }
.new-group-form { display: flex; align-items: center; gap: 0.375rem; flex-wrap: wrap; }
.new-group-form .input { width: 10rem; height: 2rem; font-size: 0.75rem; }

.color-swatches { display: flex; align-items: center; gap: 0.25rem; padding: 0.125rem 0; }
.color-swatch {
  width: 1.125rem;
  height: 1.125rem;
  flex-shrink: 0;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.color-swatch:hover { transform: scale(1.1); }
.color-swatch.selected { border-color: var(--foreground); box-shadow: 0 0 0 1px var(--zinc-950); }
.site-group > .color-swatches { padding: 0 0.625rem 0.5rem; }

/* --- Groupes de sites --- */
.site-group {
  position: relative;
  border-radius: 8px;
  border: 1px solid var(--zinc-800);
  background: rgba(24, 24, 27, 0.4);
  transition: border-color 0.15s, background-color 0.15s;
}
.site-group.drag-over { border-color: var(--emerald-500); background: rgba(16, 185, 129, 0.06); }
.site-group.dragging-group { opacity: 0.4; }
.site-group.drop-before { box-shadow: inset 0 2px 0 0 var(--emerald-500); }
.site-group.drop-after { box-shadow: inset 0 -2px 0 0 var(--emerald-500); }
.site-group.group-busy { pointer-events: none; }
.site-group.group-busy::after {
  content: "";
  position: absolute;
  top: 0.625rem;
  right: 0.625rem;
  width: 0.9rem;
  height: 0.9rem;
  border: 2px solid var(--zinc-700);
  border-top-color: var(--emerald-500);
  border-radius: 50%;
  animation: lhw-spin 0.6s linear infinite;
}
.group-header { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0.625rem; }
.group-header[draggable="true"] { cursor: grab; }
.group-select-checkbox { width: 0.875rem; height: 0.875rem; flex-shrink: 0; accent-color: var(--zinc-100); }
.group-toggle {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  text-align: left;
  color: var(--foreground);
}
.group-toggle .chevron { flex-shrink: 0; width: 0.875rem; height: 0.875rem; color: var(--zinc-400); transition: transform 0.15s; }
.group-toggle[aria-expanded="true"] .chevron { transform: rotate(180deg); }
.group-dot { flex-shrink: 0; width: 0.5625rem; height: 0.5625rem; border-radius: 50%; }
.group-name { font-size: 0.875rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-count { flex-shrink: 0; font-size: 0.6875rem; color: var(--zinc-500); background: var(--zinc-900); border-radius: 999px; padding: 0.0625rem 0.4375rem; }
.group-avg-badge { flex-shrink: 0; font-size: 0.75rem; font-weight: 700; background: none; border: none; }
.group-avg-badge.avg-good { color: var(--emerald-500); background: none; border-color: transparent; }
.group-avg-badge.avg-mid { color: var(--amber-500); background: none; border-color: transparent; }
.group-avg-badge.avg-bad { color: var(--red-500); background: none; border-color: transparent; }
.group-body { display: grid; grid-template-rows: minmax(0, 0fr); overflow: hidden; transition: grid-template-rows 0.2s ease-out; }
.group-body.open { grid-template-rows: minmax(0, 1fr); }
.group-body-inner { min-height: 0; overflow: hidden; display: flex; flex-direction: column; gap: 0.5rem; padding: 0 0.625rem 0.625rem; }
.group-empty { margin: 0; padding: 0.75rem; border-radius: 6px; border: 1px dashed var(--zinc-700); text-align: center; font-size: 0.75rem; color: var(--zinc-500); }

.group-delete-confirm {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.625rem;
  margin: 0 0.625rem 0.5rem;
  border-radius: 6px;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.3);
  font-size: 0.75rem;
  color: var(--zinc-300);
}
.group-delete-confirm select { height: 1.75rem; font-size: 0.6875rem; width: auto; }

.site-row { cursor: grab; }
.site-row.dragging { opacity: 0.4; }

/* --- Mobile (<=640px) --- */
@media (max-width: 640px) {
  .topbar {
    flex-wrap: wrap;
    row-gap: 0.65rem;
    padding: 0.75rem 1rem;
  }
  .topbar-left { flex: 1 1 100%; }
  .topbar-right {
    flex: 1 1 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 0.5rem;
  }
  .topbar h1 { font-size: 1rem; }
  .topbar-sub { font-size: 0.625rem; }
  .user-pill { font-size: 0.75rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 55vw; }
  .quota-pill { font-size: 0.6875rem; }

  .content { padding: 1rem 0.75rem; gap: 1.25rem; }

  .controls-group {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 0.625rem;
    flex: 1 1 100%;
  }
  .controls-group > .sort-count,
  .controls-group > #new-group-form { grid-column: 1 / -1; }

  .site-row { padding: 0.625rem 0.75rem; }
  .site-row-main { row-gap: 0.625rem; column-gap: 0.625rem; }
  .site-actions { gap: 0.5rem; }
  .category-charts { gap: 0.375rem; }

  .group-header { flex-wrap: wrap; row-gap: 0.5rem; gap: 0.625rem; }

  .details-accordion { margin-top: 0.375rem; }

  .auth-body { align-items: stretch; padding: 1rem; }
  .auth-card { display: flex; flex-direction: column; justify-content: center; }
}
