/* SiteFast management UI — a small, maintainable internal design system.
   Server-rendered Jinja2 + this stylesheet + minimal vanilla JS. Nothing
   here touches generated customer-site themes (themes/*, components/*). */

:root {
  color-scheme: light;

  /* Surfaces */
  --color-canvas: #f6f7f9;
  --color-surface: #ffffff;
  --color-surface-muted: #f2f4f7;
  --color-surface-hover: #f8f9fb;

  /* Borders */
  --color-border: #e4e7ec;
  --color-border-strong: #d0d5dd;

  /* Text */
  --color-text: #101828;
  --color-text-muted: #667085;
  --color-text-subtle: #98a2b3;
  --color-text-on-dark: #f2f4f7;

  /* Accent (restrained — one blue, used for links/primary actions/focus) */
  --color-primary: #155eef;
  --color-primary-hover: #0d4ed8;
  --color-primary-surface: #eef4ff;
  --color-primary-border: #c7ddff;

  /* Status */
  --color-success: #12805c;
  --color-success-surface: #e7f7ef;
  --color-success-border: #b7ebd0;
  --color-danger: #b3261e;
  --color-danger-hover: #93201a;
  --color-danger-surface: #fdf1f0;
  --color-danger-border: #f6cdc9;
  --color-warning: #93610a;
  --color-warning-surface: #fef6e7;
  --color-warning-border: #f7e3ae;
  --color-info-surface: #eef4ff;

  /* Spacing scale */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 999px;

  /* Shadow (minimal) */
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 4px 10px rgba(16, 24, 40, 0.06);

  /* Typography */
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-base: 0.9375rem;
  --text-lg: 1.0625rem;
  --text-xl: 1.375rem;
  --text-2xl: 1.75rem;

  /* Shell */
  --sidebar-width: 248px;
  --topbar-height: 56px;
  --control-height: 2.625rem;
  --control-height-sm: 2rem;

  color: var(--color-text);
  background: var(--color-canvas);
}

*,
*::before,
*::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { height: 100%; }
body { margin: 0; font-size: var(--text-base); line-height: 1.5; }
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: var(--space-4); background: var(--color-canvas); }
.login-card { width: min(24rem, 100%); }
.login-brand { margin-bottom: var(--space-6); text-align: center; font-size: var(--text-xl); font-weight: 700; }

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.87em;
  background: var(--color-surface-muted);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 0.05em 0.4em;
  overflow-wrap: anywhere;
}
hr { border: none; border-top: 1px solid var(--color-border); margin: var(--space-4) 0; }

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.01em; color: var(--color-text); }

/* ---------------------------------------------------------------------- */
/* Application shell                                                       */
/* ---------------------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  height: var(--topbar-height);
  padding: 0 var(--space-5);
  color: var(--color-text-on-dark);
  background: #0b0f19;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar a { color: var(--color-text-on-dark); opacity: 0.82; text-decoration: none; }
.topbar a:hover { opacity: 1; text-decoration: none; }
.topbar__brand { font-weight: 700; font-size: var(--text-lg); margin-right: var(--space-2); opacity: 1 !important; }
/* A long site name must never wrap out of the fixed-height topbar on a
   narrow screen; truncate it instead. */
.topbar__site { opacity: 0.55; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar__spacer { margin-left: auto; }
.topbar__menu-button {
  display: none;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: transparent;
  color: var(--color-text-on-dark);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.55rem;
  cursor: pointer;
  font: inherit;
  line-height: 1;
  min-height: auto;
}

.shell { display: flex; align-items: flex-start; }
.sidebar-backdrop { display: none; }

.sidebar {
  flex: 0 0 var(--sidebar-width);
  position: sticky;
  top: var(--topbar-height);
  height: calc(100vh - var(--topbar-height));
  overflow-y: auto;
  padding: var(--space-5) var(--space-4);
  border-right: 1px solid var(--color-border);
  background: var(--color-surface);
}
.sidebar-section { margin-bottom: var(--space-6); }
.sidebar-section:last-child { margin-bottom: 0; }
.sidebar-label {
  display: block;
  padding: 0 var(--space-2);
  margin-bottom: var(--space-2);
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-subtle);
}
.sidebar-site {
  padding: var(--space-3);
  margin-bottom: var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-muted);
}
.sidebar-site__name { font-weight: 650; font-size: var(--text-sm); color: var(--color-text); overflow-wrap: anywhere; }
.sidebar-site__domain { font-size: var(--text-xs); color: var(--color-text-muted); overflow-wrap: anywhere; }
/* Account menu ---------------------------------------------------------- */
/* A native <details> disclosure, so it opens and closes without JavaScript.
   Deliberately quieter than the page's own actions: no fill, no border
   until it is hovered or open, and one soft shadow on the panel only. */
.user-menu { position: relative; margin-left: var(--space-2); }
.user-menu__trigger {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  max-width: 15rem;
  padding: 0.25rem 0.4rem 0.25rem 0.25rem;
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  color: var(--color-text-on-dark);
  font-size: var(--text-sm);
  line-height: 1;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
/* Suppress the native disclosure triangle; the caret below replaces it. */
.user-menu__trigger::-webkit-details-marker { display: none; }
.user-menu__trigger::marker { content: ""; }
.user-menu__trigger:hover { border-color: rgba(255, 255, 255, 0.22); }
.user-menu[open] .user-menu__trigger { border-color: rgba(255, 255, 255, 0.28); background: rgba(255, 255, 255, 0.06); }
.user-menu__trigger:focus-visible { outline: 2px solid rgba(255, 255, 255, 0.7); outline-offset: 2px; }
.user-menu__avatar {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 1.65rem;
  height: 1.65rem;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.14);
  font-size: var(--text-xs);
  font-weight: 700;
}
.user-menu__email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: 0.85; }
.user-menu__caret { font-size: 0.7em; opacity: 0.7; }

/* Browsers hide a closed <details>'s content with content-visibility, which
   an absolutely positioned child has historically escaped in some engines --
   and which still reports a laid-out box to script. Say it outright so the
   panel cannot render, or be measured, while the menu is shut. */
.user-menu:not([open]) .user-menu__panel { display: none; }
.user-menu__panel {
  position: absolute;
  top: calc(100% + var(--space-2));
  right: 0;
  z-index: 30;
  width: max-content;
  min-width: 13rem;
  max-width: min(18rem, calc(100vw - var(--space-4) * 2));
  padding: var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-md);
  color: var(--color-text);
}
.user-menu__identity {
  margin: 0;
  padding: var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  overflow-wrap: anywhere;
}
.user-menu__group { margin-top: var(--space-1); }
.user-menu__label {
  display: block;
  padding: 0 var(--space-2);
  margin-bottom: var(--space-1);
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-subtle);
}
.user-menu__choices { display: flex; flex-direction: column; }
/* Every row -- link or submit button -- reads as one menu entry, so a
   language choice and "Sign out" are visually equal despite one being a
   link and the others POST forms.
   The selector carries two classes deliberately: the panel is a child of
   .topbar, whose `.topbar a` rule paints links for the dark bar and would
   otherwise render "Change password" near-white on this white panel. */
.user-menu__panel .user-menu__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  width: 100%;
  min-height: auto;
  padding: var(--space-2);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text);
  font: inherit;
  font-size: var(--text-sm);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  opacity: 1;
}
.user-menu__panel .user-menu__item:hover { background: var(--color-surface-muted); text-decoration: none; opacity: 1; }
.user-menu__panel .user-menu__item:focus-visible { outline: 2px solid var(--color-primary); outline-offset: -2px; }
.user-menu__panel .user-menu__item--choice.is-current { font-weight: 650; }
.user-menu__check { color: var(--color-primary); }
.user-menu__divider { margin: var(--space-2) 0; }

@media (max-width: 700px) {
  /* The address would crowd out the brand and the site name here, so it
     stops being drawn -- but stays in the accessible name, which is why it
     is hidden rather than removed. */
  .user-menu__email { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .user-menu__trigger { max-width: none; padding: 0.25rem; }
  .user-menu__caret { display: none; }
  /* Anchored to the viewport edge instead of the trigger, so a long email
     inside the panel can never push the page into horizontal scrolling. */
  .user-menu__panel { right: 0; max-width: calc(100vw - var(--space-4)); }
}

.sidebar-nav { display: flex; flex-direction: column; gap: 1px; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0.5rem 0.6rem;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  font-weight: 550;
  text-decoration: none;
}
.sidebar-nav a:hover { background: var(--color-surface-hover); color: var(--color-text); text-decoration: none; }
.sidebar-nav a.is-active { background: var(--color-primary-surface); color: var(--color-primary); }

.content { flex: 1 1 0%; min-width: 0; padding: var(--space-8); max-width: 68rem; margin: 0 auto; }

/* ---------------------------------------------------------------------- */
/* Page header                                                             */
/* ---------------------------------------------------------------------- */

.breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1); margin-bottom: var(--space-3); font-size: var(--text-sm); color: var(--color-text-muted); }
.breadcrumb a { color: var(--color-text-muted); }
.breadcrumb a:hover { color: var(--color-primary); }
.breadcrumb__sep { color: var(--color-text-subtle); }

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
}
.page-head h1 { font-size: var(--text-2xl); margin-bottom: var(--space-1); }
.page-head p { margin: 0; color: var(--color-text-muted); font-size: var(--text-sm); max-width: 46rem; }
.page-head .actions { flex-shrink: 0; }

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-3); }
.section-head--flush { margin-bottom: 0; }
.section-head--tight { margin-bottom: var(--space-1); }
.section-head h2 { font-size: var(--text-lg); }
.section-head h3 { font-size: var(--text-base); }
.section-head p { margin: var(--space-1) 0 0; color: var(--color-text-muted); font-size: var(--text-sm); }

/* ---------------------------------------------------------------------- */
/* Cards / panels                                                          */
/* ---------------------------------------------------------------------- */

.panel {
  margin-bottom: var(--space-5);
  padding: var(--space-6);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}
.panel > h2:first-child, .panel > .section-head:first-child { margin-bottom: var(--space-4); }
.panel + .panel { margin-top: 0; }

a.card {
  display: block;
  padding: var(--space-5);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
  color: inherit;
  text-decoration: none;
  transition: border-color .12s ease, box-shadow .12s ease;
}
a.card:hover { border-color: var(--color-border-strong); box-shadow: var(--shadow-md); text-decoration: none; }
a.card h2, a.card h3 { color: var(--color-text); }
a.card p { margin: var(--space-1) 0 0; color: var(--color-text-muted); font-size: var(--text-sm); }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(15.5rem, 1fr)); gap: var(--space-4); margin-bottom: var(--space-5); }

.subcard {
  padding: var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-muted);
}

.fieldset-title { font-size: var(--text-base); font-weight: 650; margin-bottom: var(--space-1); }
.fieldset-hint { font-size: var(--text-sm); color: var(--color-text-muted); margin: 0 0 var(--space-4); max-width: 42rem; }

/* ---------------------------------------------------------------------- */
/* Grids                                                                   */
/* ---------------------------------------------------------------------- */

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: var(--space-4); align-items: start; }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stack { display: flex; flex-direction: column; gap: var(--space-4); }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  column-gap: var(--space-5);
  row-gap: var(--space-5);
  margin-bottom: var(--space-5);
}
.form-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid:last-child { margin-bottom: 0; }
.form-stack { display: flex; flex-direction: column; gap: var(--space-5); }

/* ---------------------------------------------------------------------- */
/* Forms                                                                   */
/* ---------------------------------------------------------------------- */

fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { padding: 0; }

label {
  display: grid;
  gap: var(--space-1);
  margin-bottom: var(--space-4);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
}
label:last-child { margin-bottom: 0; }

.form-field {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-2);
  min-width: 0;
  margin: 0;
}
.form-field__label {
  display: block;
  min-height: 1.25rem;
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1.25rem;
  color: var(--color-text);
}
.form-grid > .form-field > .form-field__label {
  display: flex;
  align-items: flex-end;
  min-height: 2.5rem;
}
.form-field__help,
.field-hint {
  display: block;
  margin: 0;
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  font-weight: 450;
  line-height: 1.45;
}
.form-field__error,
.field-error {
  margin: 0;
  color: var(--color-danger);
  font-size: var(--text-xs);
  font-weight: 550;
  line-height: 1.45;
}
.form-field--compact { max-width: 30rem; }
.color-field__control { display: flex; align-items: center; gap: var(--space-3); min-height: 2.75rem; }
.color-field__picker { width: 4rem; min-width: 4rem; height: 2.75rem; padding: .2rem; cursor: pointer; }
.color-field__picker:disabled { cursor: not-allowed; opacity: .45; }
.color-field__value { font-family: var(--font-mono); font-size: var(--text-sm); color: var(--color-text-muted); }
.check-row { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); cursor: pointer; }
.check-row input { width: auto; }
.brand-media-grid { align-items: start; }
.media-selection-preview { display: grid; grid-template-columns: 5rem minmax(0, 1fr); align-items: center; gap: var(--space-3); min-height: 5rem; padding: var(--space-2); border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface-muted); overflow: hidden; }
.media-selection-preview img { width: 5rem; height: 4rem; display: block; object-fit: contain; border-radius: var(--radius-sm); background: var(--color-surface); }
.media-selection-preview--favicon img { object-fit: contain; }
.media-selection-preview span { min-width: 0; overflow-wrap: anywhere; font-size: var(--text-sm); }
.media-selection-preview__empty { grid-column: 1 / -1; color: var(--color-text-muted); text-align: center; }
.pagination { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: var(--space-3); margin-top: var(--space-4); }
.pagination__status { font-size: var(--text-sm); color: var(--color-text-muted); text-align: center; }
.button.is-disabled { opacity: .5; pointer-events: none; }
.login-language { display: flex; justify-content: flex-end; gap: var(--space-2); font-size: var(--text-sm); }

input[type="text"],
input[type="email"],
input[type="url"],
input[type="number"],
input[type="password"],
input[type="date"],
input[type="time"],
input[type="datetime-local"],
input[type="tel"],
input[type="search"],
input:not([type]),
select,
textarea {
  width: 100%;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.7rem;
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit;
  font-size: var(--text-base);
  transition: border-color .12s ease, box-shadow .12s ease;
}
input[type="text"],
input[type="email"],
input[type="url"],
input[type="number"],
input[type="password"],
input[type="date"],
input[type="time"],
input[type="datetime-local"],
input[type="tel"],
input[type="search"],
input:not([type]),
select { height: var(--control-height); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--color-text-muted) 50%), linear-gradient(135deg, var(--color-text-muted) 50%, transparent 50%); background-position: calc(100% - 18px) center, calc(100% - 13px) center; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 2rem; }
textarea { min-height: 6.5rem; line-height: 1.5; resize: vertical; }
input[type="file"] {
  width: 100%;
  min-height: var(--control-height);
  padding: 0.3rem;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text-muted);
  font: inherit;
  font-size: var(--text-sm);
}
input[type="file"]::file-selector-button {
  min-height: calc(var(--control-height) - 0.7rem);
  margin-right: var(--space-3);
  padding: 0 var(--space-3);
  border: 0;
  border-radius: calc(var(--radius-sm) - 2px);
  color: var(--color-text);
  background: var(--color-surface-muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
textarea[name$="_json"], textarea[name="settings"], textarea[name="colors"] {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: var(--text-xs);
  min-height: 8rem;
}

input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-surface);
  outline: none;
}

label small.muted, small.muted {
  display: block;
  font-size: var(--text-xs);
  font-weight: 450;
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

/* Checkbox / radio: kept as native controls (accessible by default),
   just sized and aligned to read as a deliberate row rather than a
   bare browser default. */
label:has(> input[type="checkbox"]),
label:has(> input[type="radio"]) {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--space-2);
  font-weight: 550;
}
input[type="checkbox"], input[type="radio"] {
  width: 1.05rem;
  height: 1.05rem;
  flex-shrink: 0;
  accent-color: var(--color-primary);
  cursor: pointer;
}
.form-check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: var(--space-2) var(--space-5);
  margin-bottom: var(--space-5);
}
.form-check-grid:last-child { margin-bottom: 0; }
.form-check {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--control-height);
  margin: 0;
  padding: 0 var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface-muted);
  font-size: var(--text-sm);
  font-weight: 550;
}
.form-check--plain { padding-inline: 0; border-color: transparent; background: transparent; }

/* Translation language panels */
.translation {
  padding: var(--space-4);
  margin-bottom: var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
}
.translation:last-child { margin-bottom: 0; }
.translation.form-field .translation__label { margin-bottom: 0; }
.translation > legend, .translation__label {
  font-size: var(--text-sm);
  font-weight: 700;
  margin-bottom: var(--space-3);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.missing {
  display: inline-flex;
  align-items: center;
  font-weight: 550;
  color: var(--color-warning);
  background: var(--color-warning-surface);
  border: 1px solid var(--color-warning-border);
  border-radius: var(--radius-full);
  padding: 0.05rem 0.55rem;
  font-size: var(--text-xs);
}
.translation-notice { margin-bottom: var(--space-4); }

/* Language tabs (minimal vanilla-JS enhanced; all panels render and
   submit fine with JS disabled — see admin.js) */
.lang-tabs { display: flex; gap: var(--space-1); margin-bottom: var(--space-3); border-bottom: 1px solid var(--color-border); }
.lang-tabs button {
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: var(--color-text-muted);
  font-weight: 600;
  font-size: var(--text-sm);
  padding: var(--space-2) var(--space-1);
  margin-bottom: -1px;
  cursor: pointer;
  min-height: auto;
}
.lang-tabs button.is-active { color: var(--color-primary); border-bottom-color: var(--color-primary); }
.lang-tabs button .missing { margin-left: var(--space-2); }
[data-lang-panel][hidden] { display: none !important; }

details.advanced { margin-top: var(--space-2); }
details.advanced summary {
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-muted);
  padding: var(--space-2) 0;
}
details.advanced summary:hover { color: var(--color-text); }
details.advanced[open] summary { margin-bottom: var(--space-2); }

/* ---------------------------------------------------------------------- */
/* Buttons                                                                 */
/* ---------------------------------------------------------------------- */

.button, button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.9rem;
  color: #fff;
  background: var(--color-primary);
  cursor: pointer;
  text-decoration: none;
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1.2;
  min-height: var(--control-height);
  transition: background-color .12s ease, border-color .12s ease;
}
.button:hover, button:hover { background: var(--color-primary-hover); text-decoration: none; }
.button--secondary, button.button--secondary {
  color: var(--color-text);
  background: var(--color-surface);
  border-color: var(--color-border-strong);
}
.button--secondary:hover, button.button--secondary:hover { background: var(--color-surface-muted); }
.button--danger, button.button--danger { background: var(--color-danger); }
.button--danger:hover, button.button--danger:hover { background: var(--color-danger-hover); }
.button--warning, button.button--warning { color: var(--color-warning); background: var(--color-warning-surface); border-color: var(--color-warning-border); }
.button--warning:hover, button.button--warning:hover { background: #fbecc9; }
.button--ghost { color: var(--color-text-muted); background: transparent; border-color: transparent; padding: 0.4rem 0.55rem; }
.button--ghost:hover { background: var(--color-surface-hover); color: var(--color-text); }
.button--sm { min-height: var(--control-height-sm); padding: 0.35rem 0.6rem; font-size: var(--text-xs); }
.button--icon { width: var(--control-height-sm); height: var(--control-height-sm); min-height: var(--control-height-sm); padding: 0; line-height: 1; }
.button--full { width: 100%; }
.button[disabled], button[disabled] { opacity: 0.5; cursor: not-allowed; }

.actions { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.row-actions { display: flex; flex-wrap: wrap; gap: var(--space-1); align-items: center; justify-content: flex-end; }
form.inline { display: inline-flex; }

/* ---------------------------------------------------------------------- */
/* Tables                                                                  */
/* ---------------------------------------------------------------------- */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}
table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table--wide { min-width: 64rem; }
th, td { padding: var(--space-3) var(--space-4); text-align: left; vertical-align: middle; }
thead th {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-subtle);
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--color-border); }
tbody tr:last-child { border-bottom: 0; }
tbody tr:hover { background: var(--color-surface-hover); }
td.actions, th.actions, td.numeric, th.numeric { text-align: right; }
td.numeric { font-variant-numeric: tabular-nums; white-space: nowrap; }
td .row-title { font-weight: 600; color: var(--color-text); }
td .row-subtitle { font-size: var(--text-xs); color: var(--color-text-muted); }
.table-nowrap { white-space: nowrap; }
.table-path { min-width: 14rem; }
.table-path code { display: inline-block; max-width: 22rem; }

/* ---------------------------------------------------------------------- */
/* Rows-as-cards list (slides, blocks, menu items)                         */
/* ---------------------------------------------------------------------- */

.item-list { display: flex; flex-direction: column; gap: var(--space-3); }
.item-row {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
}
.item-row[data-disabled="true"] { opacity: 0.6; }
.item-row__order {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: var(--radius-sm);
  background: var(--color-surface-muted);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  font-weight: 700;
}
.item-row__thumb {
  flex-shrink: 0;
  width: 3rem;
  height: 3rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-surface-muted);
  object-fit: cover;
}
.item-row__thumb--placeholder { display: flex; align-items: center; justify-content: center; color: var(--color-text-subtle); font-size: var(--text-xs); }
.item-row__body { flex: 1; min-width: 0; }
.item-row__title { font-weight: 650; color: var(--color-text); overflow-wrap: anywhere; }
.item-row__meta { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-3); margin-top: var(--space-1); font-size: var(--text-xs); color: var(--color-text-muted); }
.item-row__actions { flex-shrink: 0; display: flex; gap: var(--space-1); align-items: center; }

/* ---------------------------------------------------------------------- */
/* Navigation tree                                                        */
/* ---------------------------------------------------------------------- */

.nav-tree { display: flex; flex-direction: column; gap: var(--space-2); }
.nav-tree__row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  margin-inline-start: calc(var(--nav-depth, 0) * 1.75rem);
}
.nav-tree__label { font-weight: 600; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.nav-tree__label small { display: block; font-weight: 450; color: var(--color-text-muted); }

/* ---------------------------------------------------------------------- */
/* Badges / status                                                         */
/* ---------------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  border-radius: var(--radius-full);
  padding: 0.15rem 0.6rem;
  font-size: var(--text-xs);
  font-weight: 650;
  background: var(--color-surface-muted);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  white-space: nowrap;
}
.badge--neutral { background: var(--color-surface-muted); color: var(--color-text-muted); border-color: var(--color-border); }
.badge--success, .status--completed { background: var(--color-success-surface); color: var(--color-success); border-color: var(--color-success-border); }
.badge--danger, .status--failed { background: var(--color-danger-surface); color: var(--color-danger); border-color: var(--color-danger-border); }
.badge--warning, .status--pending, .status--building, .status--running { background: var(--color-warning-surface); color: var(--color-warning); border-color: var(--color-warning-border); }
.badge--info { background: var(--color-primary-surface); color: var(--color-primary); border-color: var(--color-primary-border); }
.status { display: inline-flex; align-items: center; border-radius: var(--radius-full); padding: 0.15rem 0.6rem; font-size: var(--text-xs); font-weight: 650; background: var(--color-surface-muted); color: var(--color-text-muted); border: 1px solid var(--color-border); }
.dot { width: 0.4rem; height: 0.4rem; border-radius: 50%; background: currentColor; }

/* ---------------------------------------------------------------------- */
/* Notices / flash feedback                                                */
/* ---------------------------------------------------------------------- */

.notice {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-success-border);
  background: var(--color-success-surface);
  color: var(--color-success);
  font-size: var(--text-sm);
  font-weight: 550;
}
.notice--error { color: var(--color-danger); background: var(--color-danger-surface); border-color: var(--color-danger-border); }
.notice-inline { border-radius: var(--radius-sm); padding: var(--space-2) var(--space-3); font-size: var(--text-xs); }

/* ---------------------------------------------------------------------- */
/* Empty states                                                            */
/* ---------------------------------------------------------------------- */

.empty-state {
  padding: var(--space-8) var(--space-5);
  text-align: center;
  color: var(--color-text-muted);
}
.empty-state strong { display: block; color: var(--color-text); font-size: var(--text-base); margin-bottom: var(--space-1); }
.empty-state p { margin: 0 auto var(--space-4); max-width: 26rem; font-size: var(--text-sm); }
td .empty-state, td.empty-state { padding: var(--space-6) var(--space-4); }

/* ---------------------------------------------------------------------- */
/* Media grid                                                              */
/* ---------------------------------------------------------------------- */

.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); grid-auto-rows: 1fr; gap: var(--space-4); }
.media-card { display: flex; flex-direction: column; min-width: 0; border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface); overflow: hidden; }
.media-card__preview { aspect-ratio: 4 / 3; background: var(--color-surface-muted); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.media-card__preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-card__preview .placeholder-icon { font-size: 1.6rem; color: var(--color-text-subtle); }
.media-card__body { display: flex; flex: 1; flex-direction: column; padding: var(--space-3); }
.media-card__name { font-size: var(--text-sm); font-weight: 600; overflow-wrap: anywhere; }
.media-card__meta { font-size: var(--text-xs); color: var(--color-text-muted); margin-top: var(--space-1); }
.media-card__body > form { margin-top: auto; padding-top: var(--space-3); }

.storage-card__summary { margin: 0 0 var(--space-2); }
.storage-meter { width: 100%; height: 0.75rem; overflow: hidden; border-radius: var(--radius-full); background: var(--color-surface-muted); border: 1px solid var(--color-border); }
.storage-meter__fill { display: block; width: var(--storage-percent); max-width: 100%; height: 100%; background: var(--color-primary); }
.storage-capacity-form { display: flex; flex-wrap: wrap; align-items: end; gap: var(--space-3); margin-top: var(--space-4); padding-top: var(--space-4); border-top: 1px solid var(--color-border); }
.storage-capacity-form .form-field { flex: 0 1 15rem; }

/* ---------------------------------------------------------------------- */
/* Theme cards                                                             */
/* ---------------------------------------------------------------------- */

.theme-card { display: flex; flex-direction: column; gap: var(--space-3); }
.theme-card > form { margin-top: auto; }
.theme-card > form .button, .theme-card > form button { width: 100%; }
.theme-card__preview { aspect-ratio: 16 / 10; border-radius: var(--radius-sm); background: var(--color-surface-muted); display: flex; align-items: center; justify-content: center; color: var(--color-text-subtle); font-size: var(--text-xs); overflow: hidden; }
.theme-card__preview img { width: 100%; height: 100%; object-fit: cover; }
.theme-card--selected { border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-primary-surface); }

/* ---------------------------------------------------------------------- */
/* Utility                                                                 */
/* ---------------------------------------------------------------------- */

.muted { color: var(--color-text-muted); }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.top-gap { margin-top: var(--space-4); }
.stack-sm { display: flex; flex-direction: column; gap: var(--space-2); }
.clickable-summary { cursor: pointer; }
dl.definition { display: grid; grid-template-columns: auto 1fr; gap: var(--space-2) var(--space-4); margin: 0; }
dl.definition dt { color: var(--color-text-muted); font-size: var(--text-sm); }
dl.definition dd { margin: 0; font-weight: 600; font-size: var(--text-sm); }

/* ---------------------------------------------------------------------- */
/* Responsive                                                              */
/* ---------------------------------------------------------------------- */

@media (max-width: 900px) {
  .content { padding: var(--space-5); }
}

@media (max-width: 780px) {
  .topbar__menu-button { display: inline-flex; }
  .sidebar {
    position: fixed;
    inset: var(--topbar-height) auto 0 0;
    width: min(80vw, 300px);
    z-index: 30;
    transform: translateX(-100%);
    transition: transform .18s ease;
    box-shadow: var(--shadow-md);
  }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar-backdrop { display: none; position: fixed; inset: var(--topbar-height) 0 0 0; background: rgba(16, 24, 40, 0.4); z-index: 25; }
  .sidebar-backdrop.is-open { display: block; }
  .content { padding: var(--space-4); }
  .page-head { flex-direction: column; align-items: stretch; }
  .form-grid, .form-grid--3, .grid--2 { grid-template-columns: minmax(0, 1fr); }
  .form-grid > .form-field > .form-field__label { min-height: 1.25rem; }
  table { display: block; overflow-x: auto; }
  .item-row { flex-wrap: wrap; }
  .item-row__actions { width: 100%; justify-content: flex-end; }
  .nav-tree__row { flex-wrap: wrap; }
  .nav-tree__row { margin-inline-start: calc(var(--nav-depth, 0) * 0.75rem); }
  .nav-tree__row .row-actions { width: 100%; }
}

@media (max-width: 520px) {
  .panel { padding: var(--space-4); }
  .content { padding: var(--space-3); }
  .actions > .button, .actions > button, .actions > form:not(.inline), .actions > form.inline > button { flex: 1 1 auto; }
  .form-check-grid { grid-template-columns: minmax(0, 1fr); }
  dl.definition { grid-template-columns: minmax(7rem, auto) minmax(0, 1fr); }
}

/* ---------------------------------------------------------------------- */
/* Activity (audit history)                                                */
/* ---------------------------------------------------------------------- */

.activity-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}
.activity-filters .form-field { flex: 1 1 9rem; min-width: 0; margin: 0; }
.activity-filters__actions { display: flex; gap: var(--space-2); margin-left: auto; }

.activity-day { margin-bottom: var(--space-5); }
.activity-day > .sidebar-label { display: block; margin-bottom: var(--space-2); }
.activity-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  overflow: hidden;
}
.activity-row {
  display: grid;
  grid-template-columns: 4rem minmax(0, 1fr) auto;
  gap: var(--space-3);
  align-items: start;
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--color-border);
  color: inherit;
  text-decoration: none;
}
.activity-row:first-child { border-top: 0; }
.activity-row:hover { background: var(--color-surface-hover); }
.activity-row__time { padding-top: 0.1rem; font-variant-numeric: tabular-nums; }
.activity-row__body { min-width: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.activity-row__head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }
.activity-row__summary { color: var(--color-text-muted); }
.activity-row__tags { display: flex; flex-wrap: wrap; gap: 0.35rem; justify-content: flex-end; }

.activity-diff { display: flex; flex-direction: column; gap: 0.25rem; }
.activity-diff__row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.45rem;
  font-size: var(--text-xs);
  min-width: 0;
}
.activity-diff__label { color: var(--color-text-subtle); font-weight: 650; }
.activity-diff__before { color: var(--color-text-muted); text-decoration: line-through; overflow-wrap: anywhere; }
.activity-diff__arrow { color: var(--color-text-subtle); }
.activity-diff__after { color: var(--color-text); font-weight: 600; overflow-wrap: anywhere; }

.activity-pagination { display: flex; align-items: center; gap: var(--space-3); margin-top: var(--space-4); }

.activity-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: var(--space-3); margin: 0; }
.activity-meta > div { display: flex; flex-direction: column; gap: 0.2rem; min-width: 0; }
.activity-meta dt { font-size: var(--text-xs); font-weight: 650; color: var(--color-text-subtle); text-transform: uppercase; letter-spacing: 0.04em; }
.activity-meta dd { margin: 0; overflow-wrap: anywhere; }

.activity-changes { display: flex; flex-direction: column; gap: var(--space-3); }
.activity-change { border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: var(--space-3); }
.activity-change__label { font-weight: 650; margin-bottom: var(--space-2); }
.activity-change__values { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: var(--space-3); align-items: center; }
.activity-change__values p { margin: 0.2rem 0 0; overflow-wrap: anywhere; }
.activity-change__before p { color: var(--color-text-muted); }
.activity-change__after p { font-weight: 600; }
.activity-change__arrow { color: var(--color-text-subtle); }

.build-changes { margin-top: var(--space-2); }
.build-changes summary { cursor: pointer; }

@media (max-width: 900px) {
  .activity-row { grid-template-columns: minmax(0, 1fr); }
  .activity-row__tags { justify-content: flex-start; }
  .activity-change__values { grid-template-columns: minmax(0, 1fr); }
  .activity-change__arrow { display: none; }
  .activity-filters__actions { margin-left: 0; width: 100%; }
}

/* ── Analytics ─────────────────────────────────────────────────────────
   Four headline numbers, one bar chart and three short lists. Everything
   is built from the same tokens as the rest of the management UI, with no
   charting library: the server hands each bar a percentage height. */

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}
.metric {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-5);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.metric__value { font-size: var(--text-2xl); font-weight: 680; line-height: 1.1; font-variant-numeric: tabular-nums; }
.metric__label { font-size: var(--text-sm); color: var(--color-text-muted); }
.metric__note { font-size: var(--text-xs); color: var(--color-text-subtle); }

/* The dashboard summary reuses the same cards at a calmer weight. */
.metric-grid--compact { gap: var(--space-3); margin-bottom: 0; }
.metric-grid--compact .metric { padding: var(--space-3) var(--space-4); box-shadow: none; background: var(--color-surface-muted); }
.metric-grid--compact .metric__value { font-size: var(--text-xl); }

.period-switch { display: inline-flex; border: 1px solid var(--color-border); border-radius: var(--radius-full); background: var(--color-surface); overflow: hidden; }
.period-switch__option {
  padding: 0.35rem var(--space-4);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-muted);
  text-decoration: none;
  white-space: nowrap;
}
.period-switch__option + .period-switch__option { border-left: 1px solid var(--color-border); }
.period-switch__option:hover { background: var(--color-surface-hover); color: var(--color-text); }
.period-switch__option.is-active { background: var(--color-primary-surface); color: var(--color-primary); }

.chart {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 9rem;
  padding-top: var(--space-2);
}
.chart__column { position: relative; flex: 1 1 0; display: flex; align-items: flex-end; height: 100%; min-width: 2px; }
.chart__bar { width: 100%; min-height: 2px; border-radius: 2px 2px 0 0; background: var(--color-primary); }
/* A day with no traffic still gets a visible stub, so a quiet period reads
   as quiet rather than as a chart that failed to draw. */
.chart__bar--empty { min-height: 3px; background: var(--color-border-strong); }
.chart__column:hover .chart__bar { background: var(--color-primary-hover); }
/* A CSS-only tooltip: no script, and it stays readable on touch because the
   same text is available to assistive technology through the chart label. */
.chart__tooltip {
  position: absolute;
  bottom: calc(100% + var(--space-2));
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  display: none;
  padding: 0.3rem var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--color-text);
  color: var(--color-text-on-dark);
  font-size: var(--text-xs);
  white-space: nowrap;
  pointer-events: none;
}
.chart__column:hover .chart__tooltip, .chart__column:focus-within .chart__tooltip { display: block; }
.chart__axis { display: flex; justify-content: space-between; margin-top: var(--space-2); }

.rank-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.rank-list__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--color-border);
}
.rank-list__row:last-child { border-bottom: 0; padding-bottom: 0; }
.rank-list__row:first-child { padding-top: 0; }
.rank-list__label { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.rank-list__label strong { font-weight: 600; overflow-wrap: anywhere; }
.rank-list__label small { font-size: var(--text-xs); overflow-wrap: anywhere; }
.rank-list__value { font-variant-numeric: tabular-nums; font-weight: 650; white-space: nowrap; }
.rank-list__bar { display: block; width: 6rem; height: 6px; border-radius: var(--radius-full); background: var(--color-surface-muted); overflow: hidden; }
.rank-list__bar > span { display: block; height: 100%; border-radius: var(--radius-full); background: var(--color-primary); }
/* Rows that carry a share bar need a third column for it. */
.rank-list__row:has(.rank-list__bar) { grid-template-columns: minmax(0, 1fr) auto auto; }
/* A secondary figure under the headline one, used where a row reports two
   numbers -- a city's visitors above its page views. */
.rank-list__value small { display: block; font-weight: 500; font-size: var(--text-xs); color: var(--color-text-muted); }
/* The "unknown location" row is real data but not a place, so it reads as
   a footnote to the list rather than as another city. */
.rank-list__row--muted .rank-list__label strong { color: var(--color-text-muted); font-weight: 600; }

.switch-field { display: flex; align-items: flex-start; gap: var(--space-3); cursor: pointer; }
.switch-field input { margin-top: 0.2rem; width: 1rem; height: 1rem; flex-shrink: 0; }
.switch-field span { display: flex; flex-direction: column; gap: var(--space-1); }
.switch-field small { color: var(--color-text-muted); font-size: var(--text-sm); max-width: 46rem; }

.analytics-footnote { margin-top: var(--space-5); max-width: 52rem; }
/* DB-IP requires a visible credit wherever its data is displayed. Small and
   out of the way, but a real link and never hidden. */
.attribution { margin-top: var(--space-3); font-size: var(--text-xs); }

@media (max-width: 900px) {
  .metric-grid { grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr)); gap: var(--space-3); }
  .metric { padding: var(--space-4); }
  .chart { height: 7rem; }
  .rank-list__bar { width: 3.5rem; }
  .period-switch__option { padding: 0.35rem var(--space-3); }
}

/* ── Site health ───────────────────────────────────────────────────────
   A status mark, a label and a sentence per row. No charts, no new
   palette: the four states reuse the existing status colours. */

.health-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: 700;
  line-height: 1;
}
.health-mark--healthy { background: var(--color-success-surface); color: var(--color-success); }
.health-mark--warning { background: var(--color-warning-surface); color: var(--color-warning); }
.health-mark--error { background: var(--color-danger-surface); color: var(--color-danger); }
.health-mark--unknown,
.health-mark--not_applicable { background: var(--color-surface-muted); color: var(--color-text-subtle); }

.health-overall {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}
.health-overall__status { display: flex; align-items: center; gap: var(--space-3); }
.health-overall__status .health-mark { width: 2rem; height: 2rem; font-size: var(--text-lg); }
.health-overall__status strong { font-size: var(--text-lg); }
.health-overall__status p { margin: 0.1rem 0 0; }
.health-overall__meta { text-align: right; display: flex; flex-direction: column; gap: 0.15rem; }
/* A left edge in the status colour, so the verdict reads at a glance. */
.health-overall--healthy { border-left: 3px solid var(--color-success); }
.health-overall--warning { border-left: 3px solid var(--color-warning); }
.health-overall--error { border-left: 3px solid var(--color-danger); }

.health-list { list-style: none; margin: 0; padding: 0; }
.health-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--color-border);
}
.health-row:last-child { border-bottom: 0; padding-bottom: 0; }
.health-row:first-child { padding-top: 0; }
.health-row__body { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.health-row__label { font-weight: 650; }
.health-row__summary { color: var(--color-text); }
.health-row__detail { overflow-wrap: anywhere; }
.health-row__status { white-space: nowrap; padding-top: 0.15rem; }

.health-summary { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-2); }
.health-summary strong { font-size: var(--text-lg); }
.health-summary__problems { margin: 0; padding-left: var(--space-5); color: var(--color-text-muted); }
.health-summary__problems li { margin-bottom: 0.15rem; }

.health-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-3); }
.health-filters__search { flex: 1 1 16rem; max-width: 24rem; }

.health-table th, .health-table td { vertical-align: top; }
.health-table__site { display: flex; flex-direction: column; gap: 0.1rem; text-decoration: none; }
.health-table__site small { font-size: var(--text-xs); }

.health-footnote { margin-top: var(--space-5); max-width: 52rem; }

@media (max-width: 900px) {
  .health-overall { flex-direction: column; align-items: flex-start; }
  .health-overall__meta { text-align: left; }
  .health-row { grid-template-columns: auto minmax(0, 1fr); }
  .health-row__status { grid-column: 2; padding-top: 0; }
  .health-filters__search { max-width: none; }
}

/* ── Undo (Activity) ───────────────────────────────────────────────────
   The history row is itself a link, so the Undo action sits beside it
   rather than inside it -- a nested anchor would not be valid markup. */

.activity-entry { display: flex; align-items: stretch; gap: var(--space-3); }
.activity-entry > .activity-row { flex: 1 1 auto; min-width: 0; }
.activity-entry__actions {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  padding-right: var(--space-3);
}

.undo-list { list-style: none; margin: 0; padding: 0; }
.undo-change {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: baseline;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--color-border);
}
.undo-change:last-child { border-bottom: 0; padding-bottom: 0; }
.undo-change:first-child { padding-top: 0; }
.undo-change__label { font-weight: 650; overflow-wrap: anywhere; }
.undo-change__from { color: var(--color-text-muted); text-decoration: line-through; overflow-wrap: anywhere; }
.undo-change__arrow { color: var(--color-text-subtle); }
.undo-change__to { font-weight: 600; overflow-wrap: anywhere; }

@media (max-width: 900px) {
  .activity-entry { flex-direction: column; gap: 0; }
  .activity-entry__actions { padding: 0 var(--space-4) var(--space-3); }
  .undo-change { grid-template-columns: minmax(0, 1fr); gap: var(--space-1); }
  .undo-change__arrow { display: none; }
}

/* ── Business Content Manager ──────────────────────────────────────────
   The same design system as the advanced admin; only the vocabulary and
   the density change. Nothing here is a second visual language. */

.sidebar-count {
  margin-left: auto;
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
  color: var(--color-text-subtle);
}
.sidebar-nav a.is-active .sidebar-count { color: var(--color-primary); }

.quick-actions { display: flex; flex-wrap: wrap; gap: var(--space-3); }

.content-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-3); }
.content-filters__search,
.content-filters__export { display: flex; align-items: flex-end; gap: var(--space-3); }
.content-filters__export { margin-left: auto; }

.content-list { list-style: none; margin: 0; padding: 0; }
.content-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--color-border);
}
.content-row:last-child { border-bottom: 0; padding-bottom: 0; }
.content-row:first-child { padding-top: 0; }
/* A picture is how a shop owner recognises their own product, so the list
   leads with one rather than with a filename. */
.content-row__thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3.5rem;
  height: 3.5rem;
  flex-shrink: 0;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-muted);
}
.content-row__thumb img { width: 100%; height: 100%; object-fit: cover; }
.content-row__thumb--empty { color: var(--color-text-subtle); }
.content-row__body { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.content-row__body small { overflow-wrap: anywhere; }
.content-row__actions { display: flex; align-items: center; gap: var(--space-2); flex-shrink: 0; }

.media-picker { display: flex; flex-direction: column; gap: var(--space-4); }
.media-choices {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  border: 0;
}
.media-choices legend { margin-bottom: var(--space-2); }
.media-choice { cursor: pointer; }
.media-choice input { position: absolute; opacity: 0; width: 0; height: 0; }
.media-choice img,
.media-choice__none {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 4.5rem;
  height: 4.5rem;
  object-fit: cover;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-muted);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
.media-choice input:checked + img,
.media-choice input:checked + .media-choice__none { border-color: var(--color-primary); }
.media-choice input:focus-visible + img,
.media-choice input:focus-visible + .media-choice__none { outline: 2px solid var(--color-primary); outline-offset: 2px; }

.brand-preview {
  max-width: 14rem;
  max-height: 5rem;
  margin-bottom: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-muted);
  padding: var(--space-2);
}
.brand-preview--small { max-width: 4rem; max-height: 4rem; }

/* Visitor-written text: preserve their line breaks, wrap anything long,
   and never let it escape its container. */
.submission-message {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

@media (max-width: 900px) {
  .content-row { grid-template-columns: auto minmax(0, 1fr); }
  .content-row__actions { grid-column: 2; }
  .content-filters__export { margin-left: 0; }
}

/* ── SEO Health ────────────────────────────────────────────────────────
   The same finding row on the technical and the business screens; only
   the surrounding page differs. */

.seo-list { list-style: none; margin: 0; padding: 0; }
.seo-finding {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--color-border);
}
.seo-finding:last-child { border-bottom: 0; padding-bottom: 0; }
.seo-finding:first-child { padding-top: 0; }
.seo-finding__body { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.seo-finding__label { font-weight: 650; }
.seo-finding__page code,
.seo-finding__related code { font-size: var(--text-xs); }
/* Customer content: may be long, must never widen the page. */
.seo-finding__detail { overflow-wrap: anywhere; color: var(--color-text-muted); font-size: var(--text-sm); }
.seo-finding__hint { overflow-wrap: anywhere; }
.seo-finding__severity { white-space: nowrap; padding-top: 0.1rem; }

.seo-footnote { margin-top: var(--space-5); max-width: 52rem; }

/* ── SEO reports and Google integrations ─────────────────────────────── */
.seo-freshness { margin: 0 0 var(--space-4); max-width: 52rem; }
.seo-search { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; max-width: 36rem; }
.seo-search input[type="search"] { flex: 1 1 14rem; }
/* Search Console URLs are long and unbroken; let them wrap anywhere. */
.seo-url { max-width: 28rem; overflow-wrap: anywhere; font-size: var(--text-sm); }
.seo-query-title { overflow-wrap: anywhere; }
.sort-link { color: inherit; text-decoration: none; white-space: nowrap; }
.sort-link:hover { color: var(--color-primary); text-decoration: none; }
.sort-link.is-active { color: var(--color-text); }

/* A change against the previous period. Colour carries direction; the sign
   and number carry it too, so nothing depends on colour alone. */
.delta { font-variant-numeric: tabular-nums; font-weight: 600; font-size: var(--text-xs); }
.delta--good { color: var(--color-success); }
.delta--bad { color: var(--color-danger); }
.delta--flat, .delta--none { color: var(--color-text-subtle); font-weight: 500; }

.integration-card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-4); }
.integration-card__head h2 { font-size: var(--text-lg); }
.integration-card__head p { margin: var(--space-1) 0 0; max-width: 46rem; }
.integration-card__parts { align-items: stretch; }
.integration-code { margin: 0 0 var(--space-3); padding: var(--space-2) var(--space-3); border: 1px solid var(--color-border); border-radius: var(--radius-sm); background: var(--color-surface); font-size: var(--text-xs); white-space: pre-wrap; overflow-wrap: anywhere; }
.integration-code code { border: 0; padding: 0; background: none; }
.switch-field.is-disabled { opacity: 0.6; cursor: not-allowed; }

.fact-list { display: grid; gap: var(--space-2); margin: 0 0 var(--space-3); }
.fact-list > div { display: grid; grid-template-columns: minmax(8rem, 12rem) minmax(0, 1fr); gap: var(--space-3); }
.fact-list dt { font-size: var(--text-sm); color: var(--color-text-muted); }
.fact-list dd { margin: 0; font-size: var(--text-sm); overflow-wrap: anywhere; }

/* Filters with too many or too long options for the one-row pill switch:
   they wrap onto as many rows as the screen needs. */
.filter-chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.filter-chip { display: inline-flex; align-items: center; gap: var(--space-1); padding: 0.3rem var(--space-3); border: 1px solid var(--color-border); border-radius: var(--radius-full); background: var(--color-surface); color: var(--color-text-muted); font-size: var(--text-sm); font-weight: 600; text-decoration: none; }
.filter-chip:hover { background: var(--color-surface-hover); color: var(--color-text); text-decoration: none; }
.filter-chip.is-active { border-color: var(--color-primary-border); background: var(--color-primary-surface); color: var(--color-primary); }
.filter-chip__count { font-variant-numeric: tabular-nums; color: var(--color-text-subtle); }
.filter-chip.is-active .filter-chip__count { color: inherit; }

.opportunity__head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); }
.opportunity__title { font-size: var(--text-lg); margin-top: var(--space-2); overflow-wrap: anywhere; }

@media (max-width: 700px) {
  .fact-list > div { grid-template-columns: 1fr; gap: 0; }
  .opportunity__head, .integration-card__head { flex-direction: column; }
}

@media (max-width: 900px) {
  .seo-finding { grid-template-columns: auto minmax(0, 1fr); }
  .seo-finding__severity { grid-column: 2; padding-top: 0; }
}
.import-progress-state {
  align-items: center;
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.import-progress-spinner {
  animation: import-progress-spin 0.8s linear infinite;
  border: 3px solid var(--color-border);
  border-radius: 50%;
  border-top-color: var(--color-primary);
  height: 1.25rem;
  width: 1.25rem;
}

@keyframes import-progress-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .import-progress-spinner { animation-duration: 1.8s; }
}

/* ------------------------------------------------------- publication flow */
.publication-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}

.publication-bar__actions { flex-shrink: 0; }
.publication-status { font-size: var(--text-sm); font-weight: 650; }
.publication-status::before { margin-right: var(--space-2); }
.publication-status--dirty { color: var(--color-warning); }
.publication-status--dirty::before { content: "●"; }
.publication-status--clean { color: var(--color-success); }
.publication-status--clean::before { content: "✓"; }

@media (max-width: 700px) {
  .publication-bar { align-items: stretch; flex-direction: column; }
  .publication-bar__actions,
  .publication-bar__actions form,
  .publication-bar__actions button { width: 100%; }
}

/* ---------------------------------------------------------------- SiteFast AI
   The conversational management screen. Plain flow layout: the whole chat
   is server-rendered, so nothing here depends on JavaScript running. */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.chat__log {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin: 0 0 var(--space-4);
  padding: 0;
  list-style: none;
}

.chat__turn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-1);
  max-width: 46rem;
}

.chat__turn--user { align-self: flex-end; align-items: flex-end; }

.chat__who {
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  font-weight: 600;
}

.chat__text {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  background: var(--color-surface);
  font-size: var(--text-sm);
  line-height: 1.55;
  white-space: pre-wrap;
}

.chat__turn--user .chat__text {
  background: var(--color-surface-muted);
}

.proposal {
  border: 1px solid var(--color-warning-border);
  border-radius: var(--radius-md);
  background: var(--color-warning-surface);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
}

.proposal__summary { font-size: var(--text-sm); font-weight: 600; }

.proposal__diff {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-1) var(--space-3);
  margin: var(--space-3) 0;
  font-size: var(--text-sm);
}

.proposal__diff dt { color: var(--color-text-muted); font-weight: 600; }
.proposal__diff dd { margin: 0; overflow-wrap: anywhere; }

.proposal__actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }

.chat__undo {
  border-top: 1px solid var(--color-border);
  padding-top: var(--space-3);
  margin-bottom: var(--space-4);
}

.chat__undo form {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) 0;
}

.chat__undo-summary {
  flex: 1;
  color: var(--color-text-muted);
  font-size: var(--text-xs);
}

.chat__compose {
  display: flex;
  align-items: flex-end;
  gap: var(--space-2);
}

.chat__compose textarea { flex: 1; resize: vertical; }

@media (max-width: 640px) {
  .chat__compose { flex-direction: column; align-items: stretch; }
  .chat__turn { max-width: 100%; }
}
