/* ════════════════════════════════════════════════════════════
   Stancia CMS — Brand-compliant admin styles
   ════════════════════════════════════════════════════════════ */

:root {
  --navy: #0F1E33;
  --terracotta: #C27C5A;
  --charcoal: #2B2E34;
  --gold: #B8A36A;
  --sage: #8FAEA3;
  --slate: #6E7681;
  --offwhite: #F2F1ED;
  --white: #FFFFFF;
  --font-heading: 'Cormorant Garamond', Georgia, serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --sidebar-w: 260px;
  --header-h: 56px;
  --radius: 6px;
  --transition: 0.2s ease;
}

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

html, body { height: 100%; }
body {
  font-family: var(--font-body);
  background: var(--offwhite);
  color: var(--charcoal);
  line-height: 1.5;
  font-size: 14px;
  overflow: hidden;
}

/* ── Layout ──────────────────────────────────────────────── */
#cms-app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--header-h) 1fr;
  height: 100vh;
}

.cms-header {
  grid-column: 1 / -1;
  background: var(--navy);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 2px solid var(--terracotta);
  z-index: 100;
}

.cms-logo {
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.38em;
  text-transform: uppercase;
  color: var(--offwhite);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 6px;
  padding: 6px 14px;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 10px;
}
.cms-logo .cms-badge {
  font-family: var(--font-body);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.12em;
  background: var(--terracotta);
  color: var(--white);
  padding: 2px 7px;
  border-radius: 3px;
}
/* Current site name — shown next to the Stancia logo so the admin
   always makes it clear which client site you're editing. */
.cms-logo .cms-site-name {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: rgba(255,255,255,0.72);
  padding-left: 10px;
  margin-left: 2px;
  border-left: 1px solid rgba(255,255,255,0.18);
}

.cms-header-right {
  display: flex;
  align-items: center;
  gap: 16px;
  color: rgba(242,241,237,0.6);
  font-size: 12px;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.cms-sidebar {
  background: var(--navy);
  overflow-y: auto;
  padding: 20px 0;
  border-right: 1px solid rgba(255,255,255,0.04);
}
.cms-sidebar::-webkit-scrollbar { width: 4px; }
.cms-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

.cms-sidebar-group { margin-bottom: 8px; }
.cms-sidebar-group-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(242,241,237,0.35);
  padding: 8px 20px 6px;
}

.cms-sidebar-item {
  display: block;
  padding: 9px 20px;
  color: rgba(242,241,237,0.7);
  text-decoration: none;
  font-size: 13px;
  font-weight: 400;
  cursor: pointer;
  transition: color var(--transition), background var(--transition);
  border-left: 3px solid transparent;
}
.cms-sidebar-item:hover {
  color: var(--offwhite);
  background: rgba(255,255,255,0.04);
}
.cms-sidebar-item.active {
  color: var(--offwhite);
  border-left-color: var(--terracotta);
  background: rgba(194,124,90,0.08);
  font-weight: 500;
}

.cms-sidebar-media {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

/* ── Main content ────────────────────────────────────────── */
.cms-main {
  overflow-y: auto;
  padding: 32px 40px;
  background: var(--offwhite);
}
.cms-main::-webkit-scrollbar { width: 6px; }
.cms-main::-webkit-scrollbar-thumb { background: rgba(15,30,51,0.12); border-radius: 3px; }

/* ── Page header / breadcrumbs ───────────────────────────── */
.cms-page-header {
  margin-bottom: 28px;
}
.cms-page-header h1 {
  font-family: var(--font-heading);
  font-size: 28px;
  font-weight: 500;
  color: var(--navy);
  margin: 0;
}
.cms-page-header .cms-subtitle {
  color: var(--slate);
  font-size: 13px;
  margin-top: 4px;
}

.cms-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--slate);
  margin-bottom: 12px;
}
.cms-breadcrumb a {
  color: var(--terracotta);
  text-decoration: none;
}
.cms-breadcrumb a:hover { text-decoration: underline; }
.cms-breadcrumb .sep { color: rgba(110,118,129,0.4); }

/* ── Entry list ──────────────────────────────────────────── */
.cms-entry-list {
  list-style: none;
}
.cms-entry-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--white);
  border-radius: var(--radius);
  margin-bottom: 6px;
  cursor: pointer;
  transition: box-shadow var(--transition), transform var(--transition);
  border: 1px solid rgba(15,30,51,0.06);
}
.cms-entry-row:hover {
  box-shadow: 0 2px 8px rgba(15,30,51,0.06);
  transform: translateY(-1px);
}
.cms-entry-row .entry-label {
  font-weight: 500;
  color: var(--navy);
  font-size: 14px;
}
.cms-entry-row .entry-meta {
  font-size: 12px;
  color: var(--slate);
}
.cms-entry-row .entry-arrow {
  color: var(--slate);
  font-size: 16px;
  opacity: 0.4;
}

/* ── New entry button ────────────────────────────────────── */
.cms-btn-new {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  background: var(--terracotta);
  color: var(--white);
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition);
  margin-bottom: 20px;
}
.cms-btn-new:hover { background: #b06d4c; }

/* ── Form / Editor ───────────────────────────────────────── */
.cms-editor {
  max-width: 760px;
}

.cms-editor-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(15,30,51,0.08);
}

.cms-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 22px;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.cms-btn-primary {
  background: var(--terracotta);
  color: var(--white);
}
.cms-btn-primary:hover { background: #b06d4c; }
.cms-btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.cms-btn-secondary {
  background: transparent;
  color: var(--navy);
  border: 1px solid rgba(15,30,51,0.2);
}
.cms-btn-secondary:hover { border-color: var(--navy); }

.cms-btn-danger {
  background: transparent;
  color: #c0392b;
  border: 1px solid rgba(192,57,43,0.2);
  margin-left: auto;
}
.cms-btn-danger:hover { border-color: #c0392b; background: rgba(192,57,43,0.04); }

.cms-draft-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: var(--gold);
  background: rgba(184,163,106,0.12);
  padding: 3px 10px;
  border-radius: 3px;
  margin-left: 8px;
}

/* Live URL badge at top of the editor - shows where an entry renders,
   copy button + open-in-new-tab link. Sits between page header and
   action buttons so it's the first thing an editor sees. */
.cms-live-url {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: -8px 0 20px;
  padding: 10px 14px;
  background: rgba(60,160,255,0.06);
  border: 1px solid rgba(60,160,255,0.18);
  border-radius: 6px;
  font-size: 13px;
}
.cms-live-url-label {
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--slate);
}
.cms-live-url-link {
  color: var(--blue, #3CA0FF);
  text-decoration: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  word-break: break-all;
  flex: 1;
  min-width: 0;
}
.cms-live-url-link:hover { text-decoration: underline; }
.cms-live-url-copy {
  border: 1px solid rgba(0,0,0,0.12);
  background: #fff;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  color: var(--slate);
}
.cms-live-url-copy:hover { background: rgba(60,160,255,0.08); }

/* ── Field groups ────────────────────────────────────────── */
.cms-field {
  margin-bottom: 20px;
}
.cms-field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--slate);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}
.cms-field-hint {
  font-size: 11px;
  color: rgba(110,118,129,0.7);
  margin-top: 3px;
  font-style: italic;
}

/* Inputs */
.cms-input,
.cms-textarea,
.cms-select {
  width: 100%;
  padding: 10px 12px;
  background: var(--white);
  border: 1px solid rgba(15,30,51,0.15);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--charcoal);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.cms-input:focus,
.cms-textarea:focus,
.cms-select:focus {
  outline: none;
  border-color: var(--terracotta);
  box-shadow: 0 0 0 3px rgba(194,124,90,0.12);
}
.cms-textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.6;
}

/* Toggle switch */
.cms-toggle-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}
.cms-toggle {
  position: relative;
  width: 40px;
  height: 22px;
  appearance: none;
  background: rgba(15,30,51,0.12);
  border-radius: 11px;
  cursor: pointer;
  transition: background var(--transition);
  border: none;
  flex-shrink: 0;
}
.cms-toggle:checked { background: var(--terracotta); }
.cms-toggle::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  background: var(--white);
  border-radius: 50%;
  transition: transform var(--transition);
}
.cms-toggle:checked::after { transform: translateX(18px); }

/* ── Object / collapsible fieldset ───────────────────────── */
.cms-fieldset {
  border: 1px solid rgba(15,30,51,0.08);
  border-radius: var(--radius);
  margin-bottom: 16px;
  background: var(--white);
  overflow: hidden;
}
.cms-fieldset > summary,
.cms-fieldset-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(15,30,51,0.02);
  border-bottom: 1px solid rgba(15,30,51,0.06);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--navy);
  list-style: none;
  user-select: none;
}
.cms-fieldset > summary::-webkit-details-marker { display: none; }
.cms-fieldset > summary .chevron {
  transition: transform var(--transition);
  color: var(--slate);
  font-size: 12px;
}
.cms-fieldset[open] > summary .chevron { transform: rotate(90deg); }
.cms-fieldset-body {
  padding: 16px;
}

/* ── List items ──────────────────────────────────────────── */
.cms-list-container {
  border: 1px solid rgba(15,30,51,0.08);
  border-radius: var(--radius);
  background: rgba(15,30,51,0.015);
  padding: 12px;
}
.cms-list-item {
  background: var(--white);
  border: 1px solid rgba(15,30,51,0.08);
  border-radius: var(--radius);
  margin-bottom: 8px;
  overflow: hidden;
}
.cms-list-item-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: rgba(15,30,51,0.02);
  border-bottom: 1px solid rgba(15,30,51,0.05);
  cursor: pointer;
  font-size: 13px;
  color: var(--navy);
  user-select: none;
}
.cms-list-item-header .drag-handle {
  color: var(--slate);
  opacity: 0.4;
  cursor: grab;
  font-size: 14px;
}
.cms-list-item-header .item-summary {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}
.cms-list-item-header .item-actions {
  display: flex;
  gap: 4px;
}
.cms-list-item-body {
  padding: 12px;
  display: none;
}
.cms-list-item.open .cms-list-item-body { display: block; }

.cms-list-btn {
  background: none;
  border: 1px solid rgba(15,30,51,0.12);
  border-radius: 4px;
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--slate);
  font-size: 14px;
  transition: all var(--transition);
}
.cms-list-btn:hover { border-color: var(--navy); color: var(--navy); }
.cms-list-btn.danger:hover { border-color: #c0392b; color: #c0392b; }

.cms-list-add {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 14px;
  background: transparent;
  color: var(--terracotta);
  border: 1px dashed rgba(194,124,90,0.4);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  margin-top: 8px;
  transition: all var(--transition);
}
.cms-list-add:hover { border-color: var(--terracotta); background: rgba(194,124,90,0.04); }

/* Type picker dropdown for variable-type lists */
.cms-type-picker {
  position: relative;
  display: inline-block;
}
.cms-type-picker-menu {
  position: absolute;
  bottom: 100%;
  left: 0;
  background: var(--white);
  border: 1px solid rgba(15,30,51,0.12);
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(15,30,51,0.1);
  padding: 4px 0;
  min-width: 160px;
  z-index: 50;
  display: none;
}
.cms-type-picker-menu.open { display: block; }
.cms-type-picker-option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 14px;
  background: none;
  border: none;
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--charcoal);
  cursor: pointer;
}
.cms-type-picker-option:hover { background: rgba(194,124,90,0.06); color: var(--navy); }

/* ── Markdown-lite toolbar ───────────────────────────────── */
.cms-md-toolbar {
  display: flex;
  gap: 4px;
  padding: 6px 8px;
  background: rgba(15,30,51,0.03);
  border: 1px solid rgba(15,30,51,0.12);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
}
.cms-md-btn {
  width: 30px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--white);
  border: 1px solid rgba(15,30,51,0.12);
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  color: var(--charcoal);
  transition: all var(--transition);
}
.cms-md-btn:hover { border-color: var(--terracotta); color: var(--terracotta); }
.cms-md-editor {
  border-radius: 0 0 var(--radius) var(--radius) !important;
  border-top: 1px solid rgba(15,30,51,0.12) !important;
}

/* ── Image field ─────────────────────────────────────────── */
.cms-image-field {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}
.cms-image-thumb {
  width: 100px;
  height: 72px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid rgba(15,30,51,0.1);
  background: rgba(15,30,51,0.03);
  flex-shrink: 0;
}
.cms-image-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cms-image-path {
  font-size: 12px;
  color: var(--slate);
  word-break: break-all;
}

/* ── Media library modal ─────────────────────────────────── */
.cms-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,30,51,0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cms-modal {
  background: var(--white);
  border-radius: 10px;
  width: 90vw;
  max-width: 860px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(15,30,51,0.2);
}
.cms-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid rgba(15,30,51,0.08);
}
.cms-modal-header h2 {
  font-family: var(--font-heading);
  font-size: 22px;
  font-weight: 500;
  color: var(--navy);
}
.cms-modal-subtitle,
.cms-page-subtitle {
  font-size: 12px;
  color: var(--slate);
  margin-top: 4px;
  letter-spacing: 0.02em;
}
.cms-modal-close {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--slate);
  cursor: pointer;
  padding: 4px;
}
.cms-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}
.cms-media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
}
.cms-media-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius);
  overflow: hidden;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color var(--transition);
}
.cms-media-item:hover { border-color: var(--terracotta); }
.cms-media-item.selected { border-color: var(--terracotta); }
.cms-media-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.cms-media-item .media-name {
  position: absolute;
  bottom: 24px;
  left: 0;
  right: 0;
  padding: 4px 6px;
  background: rgba(15,30,51,0.75);
  color: var(--offwhite);
  font-size: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cms-media-item .media-path-copy {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 4px 6px;
  background: rgba(15,30,51,0.9);
  color: rgba(242,241,237,0.7);
  font-family: 'SF Mono', 'Menlo', monospace;
  font-size: 10px;
  border: 0;
  border-top: 1px solid rgba(255,255,255,0.08);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
  transition: background 0.12s;
}
.cms-media-item .media-path-copy:hover { background: var(--terracotta); color: var(--white); }

/* Hover actions (Replace / Delete) on media grid tiles */
.cms-media-item .media-actions {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}
.cms-media-item:hover .media-actions,
.cms-media-item:focus-within .media-actions { opacity: 1; pointer-events: auto; }
.media-action-btn {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.06em;
  padding: 4px 8px;
  border: 0;
  border-radius: 3px;
  background: rgba(15,30,51,0.9);
  color: var(--offwhite);
  cursor: pointer;
  transition: background 0.12s;
}
.media-action-btn:hover { background: var(--terracotta); color: var(--white); }
.media-action-danger:hover { background: #c25a5a; color: var(--white); }

/* Usage chip — sits in the filename footer, not overlaying the image.
   Shows how many content files reference this image; click for list. */
.cms-media-item .media-name {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.cms-media-item .media-name .media-name-text {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.media-usage-chip {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.06em;
  padding: 2px 7px;
  border: 0;
  border-radius: 100px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: filter 0.15s;
  text-transform: uppercase;
}
.media-usage-chip.used    { background: rgba(74,124,89,0.95);  color: var(--white); }
.media-usage-chip.unused  { background: rgba(110,118,129,0.85); color: var(--white); }
.media-usage-chip.unknown { background: rgba(184,163,106,0.9);  color: var(--navy); }
.media-usage-chip:hover   { filter: brightness(1.08); }
.cms-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-top: 1px solid rgba(15,30,51,0.08);
}

/* ── Toast notifications ─────────────────────────────────── */
.cms-toast-container {
  position: fixed;
  top: 68px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cms-toast {
  background: var(--navy);
  color: var(--offwhite);
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  box-shadow: 0 4px 12px rgba(15,30,51,0.2);
  animation: toast-in 0.3s ease;
  max-width: 360px;
}
.cms-toast.success { border-left: 3px solid var(--sage); }
.cms-toast.error { border-left: 3px solid #c0392b; }
.cms-toast.info { border-left: 3px solid var(--gold); }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ── Loading spinner ─────────────────────────────────────── */
.cms-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(15,30,51,0.1);
  border-top-color: var(--terracotta);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.cms-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 48px;
  color: var(--slate);
  font-size: 13px;
}

/* ── Empty state ─────────────────────────────────────────── */
.cms-empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--slate);
}
.cms-empty h3 {
  font-family: var(--font-heading);
  font-size: 22px;
  color: var(--navy);
  margin-bottom: 8px;
}

/* ── Confirm dialog ──────────────────────────────────────── */
.cms-confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,30,51,0.5);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cms-confirm {
  background: var(--white);
  border-radius: 10px;
  padding: 28px;
  max-width: 560px;
  width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 12px 40px rgba(15,30,51,0.15);
}
.cms-confirm h3 {
  font-family: var(--font-heading);
  font-size: 20px;
  color: var(--navy);
  margin-bottom: 12px;
}
.cms-confirm p {
  color: var(--slate);
  font-size: 13px;
  line-height: 1.55;
  margin-bottom: 20px;
}
.cms-confirm p code {
  background: rgba(15,30,51,0.06);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: 'SF Mono', 'Menlo', monospace;
  font-size: 12px;
  color: var(--navy);
}
.cms-confirm-btns {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  #cms-app {
    grid-template-columns: 1fr;
  }
  .cms-sidebar {
    display: none;
  }
  .cms-sidebar.open {
    display: block;
    position: fixed;
    top: var(--header-h);
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    z-index: 99;
  }
  .cms-main {
    padding: 20px 16px;
  }
  .cms-menu-toggle {
    display: flex !important;
  }
}
.cms-menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--offwhite);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
}

/* ── User identity & logout ──────────────────────────────── */
.cms-user-email {
  font-size: 12px;
  color: rgba(242,241,237,0.6);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
}
.cms-btn-logout, .cms-btn-view-site {
  background: transparent;
  color: rgba(242,241,237,0.5);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 4px;
  font-family: var(--font-body);
  font-size: 11px;
  padding: 5px 12px;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  display: inline-block;
}
.cms-btn-view-site:hover {
  color: var(--offwhite);
  border-color: rgba(255,255,255,0.35);
}
.cms-btn-logout:hover {
  color: var(--offwhite);
  border-color: rgba(255,255,255,0.3);
}

/* ── Version history ─────────────────────────────────────── */
.cms-history-timeline {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.cms-history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(15,30,51,0.06);
}
.cms-history-item:last-child { border-bottom: none; }
.cms-history-meta {
  font-size: 13px;
  color: var(--charcoal);
  flex: 1;
  min-width: 0;
}
.cms-history-meta strong { color: var(--navy); font-weight: 600; }
.cms-history-meta span { color: var(--slate); font-size: 12px; }
.cms-history-message {
  font-size: 12px;
  color: var(--slate);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cms-history-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* ── Diff view ───────────────────────────────────────────── */
.cms-diff-view {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  line-height: 1.5;
  overflow-x: auto;
}
.cms-diff-line { display: flex; flex-direction: column; }
.cms-diff-removed {
  background: rgba(192,57,43,0.08);
  color: #c0392b;
  padding: 1px 8px;
}
.cms-diff-added {
  background: rgba(143,174,163,0.15);
  color: #1a6b4e;
  padding: 1px 8px;
}
.cms-diff-same {
  color: var(--slate);
  padding: 1px 8px;
}

/* ── Role badges ─────────────────────────────────────────── */
.cms-role-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 3px;
}
.cms-role-admin { background: rgba(194,124,90,0.15); color: var(--terracotta); }
.cms-role-editor { background: rgba(143,174,163,0.2); color: #3d7a62; }
.cms-role-contributor { background: rgba(184,163,106,0.15); color: var(--gold); }

/* ── Analytics Dashboard ────────────────────────────────── */
.analytics-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
}
.analytics-range-btn {
  padding: 6px 16px;
  border: 1px solid var(--slate);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--charcoal);
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
}
.analytics-range-btn:hover { border-color: var(--terracotta); color: var(--terracotta); }
.analytics-range-btn.active {
  background: var(--terracotta);
  border-color: var(--terracotta);
  color: var(--white);
}

.analytics-loading {
  text-align: center;
  padding: 80px 20px;
  color: var(--slate);
  font-size: 14px;
}

.analytics-error {
  text-align: center;
  padding: 60px 20px;
  color: #b91c1c;
}
.analytics-error h3 { margin-bottom: 8px; }

.analytics-empty {
  color: var(--slate);
  font-size: 13px;
  padding: 24px 0;
  text-align: center;
}

/* Section titles */
.analytics-section-title {
  font-family: var(--font-heading);
  font-size: 20px;
  color: var(--navy);
  margin-top: 40px;
  margin-bottom: 4px;
  padding-top: 24px;
  border-top: 1px solid #e5e5e5;
}
.analytics-section-desc {
  color: var(--slate);
  font-size: 13px;
  margin-bottom: 20px;
  line-height: 1.5;
}

/* Stat cards */
.analytics-stat-desc {
  font-size: 11px;
  color: var(--slate);
  margin-top: 6px;
  line-height: 1.4;
}
.analytics-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.analytics-stat-card {
  background: var(--white);
  border: 1px solid #e5e5e5;
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}
.analytics-stat-icon {
  color: var(--terracotta);
  margin-bottom: 8px;
}
.analytics-stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--navy);
  line-height: 1.2;
}
.analytics-stat-label {
  font-size: 12px;
  color: var(--slate);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 4px;
}

/* Chart cards */
.analytics-card {
  background: var(--white);
  border: 1px solid #e5e5e5;
  border-radius: var(--radius);
  padding: 20px;
}
.analytics-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--charcoal);
}
.analytics-card-desc {
  font-size: 12px;
  color: var(--slate);
  margin-top: -8px;
  margin-bottom: 16px;
}
.analytics-card-wide { width: 100%; }

.analytics-charts-row {
  margin-bottom: 24px;
}

.analytics-bottom-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* Line chart */
.analytics-line-chart {
  width: 100%;
  height: auto;
  max-height: 240px;
}

/* Top pages table */
.analytics-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: fixed;
}
.analytics-table th {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 2px solid #e5e5e5;
  color: var(--slate);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}
.analytics-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #f0f0f0;
  font-size: 13px;
}
/* Column widths for top pages (3 cols) */
.analytics-table th:first-child,
.analytics-table td:first-child { width: 55%; }
/* Column widths for keywords (5 cols) */
.analytics-keywords-table th:first-child,
.analytics-keywords-table td:first-child { width: 36%; }
.analytics-keywords-table th:nth-child(2),
.analytics-keywords-table td:nth-child(2) { width: 14%; }
.analytics-keywords-table th:nth-child(3),
.analytics-keywords-table td:nth-child(3) { width: 18%; }
.analytics-keywords-table th:nth-child(4),
.analytics-keywords-table td:nth-child(4) { width: 14%; }
.analytics-keywords-table th:nth-child(5),
.analytics-keywords-table td:nth-child(5) { width: 18%; }
.analytics-page-cell {
  position: relative;
  overflow: hidden;
  text-overflow: ellipsis;
}
.analytics-bar {
  position: absolute;
  left: 0;
  top: 2px;
  bottom: 2px;
  background: rgba(194,124,90,0.08);
  border-radius: 3px;
  z-index: 0;
}
.analytics-page-path {
  position: relative;
  z-index: 1;
  word-break: break-all;
}

/* Recommendations */
.analytics-recs {
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid #e5e5e5;
}
.analytics-rec-item {
  display: flex;
  gap: 14px;
  padding: 16px 20px;
  background: var(--white);
  border: 1px solid #e5e5e5;
  border-radius: var(--radius);
  margin-bottom: 12px;
}
.analytics-rec-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}
.analytics-rec-icon.green { background: rgba(143,174,163,0.2); }
.analytics-rec-icon.amber { background: rgba(184,163,106,0.2); }
.analytics-rec-icon.red { background: rgba(194,124,90,0.15); }
.analytics-rec-body { flex: 1; }
.analytics-rec-title {
  font-weight: 600;
  font-size: 13px;
  color: var(--charcoal);
  margin-bottom: 4px;
}
.analytics-rec-text {
  font-size: 12px;
  color: var(--slate);
  line-height: 1.6;
}

/* Traffic sources */
.analytics-source-item {
  margin-bottom: 12px;
}
.analytics-source-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 13px;
}
.analytics-source-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.analytics-source-name {
  flex: 1;
  color: var(--charcoal);
}
.analytics-source-value {
  color: var(--slate);
  font-size: 12px;
}
.analytics-source-bar-bg {
  height: 6px;
  background: #f0f0f0;
  border-radius: 3px;
  overflow: hidden;
}
.analytics-source-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* Setup guide */
.analytics-setup {
  max-width: 560px;
  margin: 40px auto;
  text-align: center;
}
.analytics-setup-icon {
  color: var(--terracotta);
  margin-bottom: 16px;
}
.analytics-setup h2 {
  font-family: var(--font-heading);
  color: var(--navy);
  margin-bottom: 12px;
}
.analytics-setup > p {
  color: var(--slate);
  margin-bottom: 24px;
}
.analytics-setup-steps {
  text-align: left;
  padding-left: 20px;
}
.analytics-setup-steps li {
  margin-bottom: 12px;
  color: var(--charcoal);
  font-size: 13px;
  line-height: 1.6;
}

.analytics-stats-grid-4 { grid-template-columns: repeat(4, 1fr); }
.analytics-stats-grid-3 { grid-template-columns: repeat(3, 1fr); }

/* Responsive */
@media (max-width: 768px) {
  .analytics-stats-grid { grid-template-columns: repeat(2, 1fr); }
  .analytics-stats-grid-4 { grid-template-columns: repeat(2, 1fr); }
  .analytics-stats-grid-3 { grid-template-columns: repeat(2, 1fr); }
  .analytics-bottom-row { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .analytics-stats-grid,
  .analytics-stats-grid-4,
  .analytics-stats-grid-3 { grid-template-columns: 1fr; }
}

/* ── Preview Panel ──────────────────────────────────────── */
.cms-preview-panel {
  position: fixed;
  right: 0;
  top: 0;
  height: 100vh;
  width: 460px;
  background: var(--white);
  box-shadow: -4px 0 20px rgba(0,0,0,0.15);
  z-index: 1000;
  display: flex;
  flex-direction: column;
}
.cms-preview-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  border-bottom: 1px solid #e5e5e5;
  background: var(--offwhite);
}
.cms-preview-size-btn {
  padding: 4px 12px;
  border: 1px solid #ccc;
  border-radius: var(--radius);
  background: var(--white);
  font-size: 12px;
  cursor: pointer;
}
.cms-preview-size-btn.active {
  background: var(--navy);
  color: var(--white);
  border-color: var(--navy);
}
.cms-preview-close {
  margin-left: auto;
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--slate);
  padding: 4px 8px;
}
.cms-preview-iframe-wrap {
  flex: 1;
  overflow: auto;
  display: flex;
  justify-content: center;
  background: #f0f0f0;
  padding: 16px;
}
.cms-preview-iframe {
  border: 1px solid #ccc;
  border-radius: 8px;
  height: 100%;
  background: var(--white);
  box-shadow: 0 2px 12px rgba(0,0,0,0.1);
}

/* ── Help Panel ─────────────────────────────────────────── */
.cms-help-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.4);
  background: transparent;
  color: var(--white);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  margin-right: 8px;
  transition: var(--transition);
}
.cms-help-btn:hover { background: rgba(255,255,255,0.15); border-color: var(--white); }
.cms-help-panel {
  position: fixed;
  right: 0;
  top: 0;
  height: 100vh;
  width: 400px;
  background: var(--white);
  box-shadow: -4px 0 20px rgba(0,0,0,0.15);
  z-index: 1001;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.cms-help-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 2px solid var(--terracotta);
  background: var(--navy);
  color: var(--white);
}
.cms-help-header h2 {
  font-family: var(--font-heading);
  font-size: 18px;
  margin: 0;
}
.cms-help-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}
.cms-help-section {
  border-bottom: 1px solid #e5e5e5;
  padding: 0;
}
.cms-help-section summary {
  padding: 14px 0;
  font-weight: 600;
  font-size: 14px;
  color: var(--charcoal);
  cursor: pointer;
  list-style: none;
}
.cms-help-section summary::before {
  content: '▸ ';
  color: var(--terracotta);
}
.cms-help-section[open] summary::before { content: '▾ '; }
.cms-help-content {
  padding: 0 0 16px;
  font-size: 13px;
  color: var(--slate);
  line-height: 1.7;
}
.cms-help-content p { margin-bottom: 10px; }
.cms-help-content strong { color: var(--charcoal); }

/* ── Locked Fields ──────────────────────────────────────── */
.cms-field-locked .cms-input,
.cms-field-locked .cms-textarea,
.cms-field-locked .cms-select,
.cms-field-locked .cms-checkbox-wrap {
  opacity: 0.6;
  pointer-events: none;
  background: #f5f5f5;
}
.cms-lock-icon {
  font-size: 12px;
  margin-left: 4px;
  opacity: 0.7;
}
.cms-readonly .cms-input,
.cms-readonly .cms-textarea,
.cms-readonly .cms-select {
  opacity: 0.7;
  pointer-events: none;
  background: #f5f5f5;
}

/* ── Drag-and-Drop Lists ────────────────────────────────── */
.cms-list-item.dragging { opacity: 0.4; }
.cms-list-item.drag-over { border-top: 3px solid var(--terracotta); }
.drag-handle { cursor: grab; user-select: none; }
.drag-handle:active { cursor: grabbing; }

/* ── Page Layout Wireframe Map ───────────────────────────── */
.cms-pagemap {
  margin-bottom: 24px;
}
.cms-pagemap-details {
  border: 1px solid #e5e5e5;
  border-radius: var(--radius);
  overflow: hidden;
}
.cms-pagemap-summary {
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--charcoal);
  cursor: pointer;
  background: var(--white);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.cms-pagemap-summary::before {
  content: '▸';
  color: var(--terracotta);
  font-size: 11px;
  transition: transform 0.15s;
}
.cms-pagemap-details[open] .cms-pagemap-summary::before {
  transform: rotate(90deg);
}
.cms-pagemap-diagram {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px;
  background: #f8f8f6;
  border-top: 1px solid #e5e5e5;
}
.cms-pagemap-block {
  padding: 10px 14px;
  border-radius: 4px;
  transition: transform 0.1s;
}
.cms-pagemap-block:hover {
  transform: scale(1.01);
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
}
.cms-pagemap-block-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.9;
}
.cms-pagemap-block-desc {
  font-size: 11px;
  opacity: 0.7;
  margin-top: 2px;
}

/* ── Scheduled Badge ────────────────────────────────────── */
.cms-scheduled-badge {
  display: inline-block;
  background: rgba(184,163,106,0.2);
  color: var(--gold);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 3px;
  margin-left: 8px;
}
