@import url('block-editor.css');

/* ========== CSS Custom Properties ========== */
:root {
  --primary: #10b981;
  --primary-hover: #059669;
  --primary-light: rgba(16,185,129,0.06);
  --btn-primary-bg: #1e293b;
  --btn-primary-hover: #334155;
  --secondary: #64748b;
  --secondary-hover: #475569;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-hover: #f8fafc;
  --text: #0f172a;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --input-bg: #ffffff;
  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --radius: 6px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.06), 0 2px 4px -2px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08);
  --sidebar-width: 240px;
  --toolbar-height: 56px;
  --transition: 150ms ease;
  --site-fork-bg: #f1f5f9;
  --card-gap: 20px;

  /* Sidebar — solid dark navy */
  --sidebar-bg: #1e293b;
  --sidebar-text: #94a3b8;
  --sidebar-text-hover: #e2e8f0;
  --sidebar-text-active: #ffffff;
  --sidebar-icon: #64748b;
  --sidebar-icon-active: #10b981;
  --sidebar-border: #334155;
  --sidebar-hover-bg: rgba(255,255,255,0.05);
  --sidebar-active-bg: rgba(16,185,129,0.10);
  --sidebar-active-accent: #10b981;
  --sidebar-section-label: #64748b;
}

/* ========== Reset ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ========== App Layout ========== */
#app {
  display: grid;
  grid-template-areas:
    "sidebar toolbar"
    "sidebar main";
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: var(--toolbar-height) 1fr;
  height: 100vh;
}
/* Hide app chrome until JS determines auth state */
#app.app-loading > #toolbar,
#app.app-loading > #sidebar,
#app.app-loading > .main-content { display: none; }

#app.login-active {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
  grid-template-areas: "main";
}
#app.login-active > #toolbar,
#app.login-active > #sidebar { display: none; }

/* ========== Login Screen ========== */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}
.login-card {
  width: 100%;
  max-width: 400px;
  padding: 44px 40px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.08), 0 2px 8px rgba(0,0,0,0.04);
}
.login-logo {
  text-align: center;
  margin-bottom: 28px;
  color: var(--text);
}
.login-logo svg {
  margin-bottom: 12px;
  opacity: 0.7;
}
.login-logo h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.3px;
}

/* ========== Toolbar ========== */
#toolbar {
  grid-area: toolbar;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}
.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: 8px; }
.toolbar-breadcrumbs { display: flex; align-items: center; gap: 6px; font-size: 14px; min-width: 0; }
.breadcrumb-site {
  background: none; border: none; color: var(--text); font-size: 14px; font-weight: 600;
  cursor: pointer; padding: 4px 8px; border-radius: var(--radius);
}
.breadcrumb-site:hover { background: var(--primary-light); color: var(--primary); }
.breadcrumb-sep { color: var(--text-muted); font-size: 13px; user-select: none; }
.breadcrumb-link { color: var(--text-secondary); font-size: 14px; }
.breadcrumb-link:hover { color: var(--primary); text-decoration: none; }
.breadcrumb-current { color: var(--text); font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px; }
.site-switcher-dropdown {
  position: absolute; top: var(--toolbar-height); left: 60px; z-index: 300;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); min-width: 200px; max-height: 320px; overflow-y: auto;
}
.site-switcher-dropdown.hidden { display: none; }
.site-switcher-item {
  display: block; width: 100%; text-align: left; padding: 8px 14px;
  background: none; border: none; color: var(--text); font-size: 13px; cursor: pointer;
}
.site-switcher-item:hover { background: var(--surface-hover); }
.site-switcher-item.active { color: var(--primary); font-weight: 600; }
.user-menu { position: relative; }
.user-menu-trigger { display: flex; align-items: center; gap: 4px; }
.user-menu-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  min-width: 160px;
  z-index: 200;
}
.user-menu.open .user-menu-dropdown { display: block; }
.user-menu-dropdown a {
  display: block;
  padding: 8px 14px;
  color: var(--text);
  font-size: 13px;
}
.user-menu-dropdown a:hover { background: var(--surface-hover); text-decoration: none; }

/* ========== Sidebar ========== */
#sidebar {
  grid-area: sidebar;
  background: var(--sidebar-bg);
  border-right: none;
  overflow-y: auto;
  transition: transform var(--transition);
}
#sidebar.collapsed { transform: translateX(calc(-1 * var(--sidebar-width))); }
#app.sidebar-collapsed { grid-template-columns: 0 1fr; }
#app.sidebar-collapsed #sidebar { overflow: hidden; }
/* Sidebar site switcher */
.sidebar-site-switcher {
  padding: 12px 10px 4px;
  position: relative;
}
.sidebar-site-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px 12px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  gap: 8px;
}
.sidebar-site-btn:hover {
  background: rgba(255,255,255,0.10);
  border-color: rgba(255,255,255,0.15);
}
.sidebar-site-switcher.open .sidebar-site-btn {
  background: rgba(255,255,255,0.10);
  border-color: var(--sidebar-active-accent);
}
.sidebar-site-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  text-align: left;
}
.sidebar-site-chevron {
  flex-shrink: 0;
  color: var(--sidebar-text);
  transition: transform 0.2s ease;
}
.sidebar-site-switcher.open .sidebar-site-chevron {
  transform: rotate(180deg);
}
.sidebar-site-list {
  display: none;
  margin-top: 4px;
  padding: 4px 0;
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  max-height: 240px;
  overflow-y: auto;
}
.sidebar-site-switcher.open .sidebar-site-list { display: block; }
.sidebar-site-list::-webkit-scrollbar { width: 4px; }
.sidebar-site-list::-webkit-scrollbar-track { background: transparent; }
.sidebar-site-list::-webkit-scrollbar-thumb { background: var(--sidebar-border); border-radius: 2px; }
.sidebar-site-option {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  background: none;
  border: none;
  color: var(--sidebar-text);
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  transition: background 0.1s, color 0.1s;
}
.sidebar-site-option:hover {
  background: rgba(255,255,255,0.06);
  color: var(--sidebar-text-hover);
}
.sidebar-site-option.active {
  color: #fff;
  font-weight: 600;
}
.sidebar-site-option.active::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--sidebar-active-accent);
  flex-shrink: 0;
}
.sidebar-site-option:not(.active)::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  flex-shrink: 0;
}

.sidebar-nav { padding: 8px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius);
  color: var(--sidebar-text);
  font-size: 13px;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
}
.nav-item:hover { background: var(--sidebar-hover-bg); color: var(--sidebar-text-hover); text-decoration: none; }
.nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-text-active);
  border-left: 3px solid var(--sidebar-active-accent);
  padding-left: 9px;
}
.nav-item svg { flex-shrink: 0; color: var(--sidebar-icon); }
.nav-item:hover svg { color: var(--sidebar-text-hover); }
.nav-item.active svg { color: var(--sidebar-icon-active); }
.nav-divider { height: 1px; background: var(--sidebar-border); margin: 8px 12px; }
.nav-section-label {
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--sidebar-section-label); padding: 14px 16px 4px; user-select: none;
}

.nav-group .nav-item { position: relative; }
.nav-group-chevron {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  transition: transform 0.2s ease; color: var(--sidebar-text);
}
.nav-group.collapsed .nav-group-chevron { transform: translateY(-50%) rotate(-90deg); }
.nav-group.collapsed .nav-subitems { display: none; }

.nav-subitems {
  display: flex;
  flex-direction: column;
  padding-left: 28px;
}
.nav-subitems:empty { display: none; }

.nav-subitem {
  display: block;
  padding: 5px 12px;
  border-radius: var(--radius);
  color: rgba(255,255,255,0.5);
  font-size: 12px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: background var(--transition), color var(--transition);
}
.nav-subitem:hover {
  background: var(--sidebar-hover-bg);
  color: var(--sidebar-text-hover);
  text-decoration: none;
}
.nav-subitem.active {
  color: var(--sidebar-active-accent);
}

/* ========== Main Content ========== */
#main-content {
  grid-area: main;
  overflow-y: auto;
  padding: 20px 32px;
}
#page-content { max-width: none; }

/* ---- List pagination (all screens) ---- */
.list-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  border-top: 1px solid var(--border);
}

/* ---- Fill-height list layout (desktop only) ---- */
@media (min-width: 768px) {
  #main-content:has(.page-list-layout) {
    display: flex;
    flex-direction: column;
    overflow: hidden;          /* outer area no longer scrolls */
  }
  #main-content:has(.page-list-layout) #page-content {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }
  /* Custom elements default to display:inline — make them flex participants */
  #page-content > :has(.page-list-layout) {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
  }
  .page-list-layout {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }
  .page-list-layout > .page-toolbar,
  .page-list-layout > #contacts-bulk-bar {
    flex-shrink: 0;
  }
  .page-list-layout > .card {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }
  .page-list-layout > .card > .card-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 0;
  }
  .page-list-layout .table-wrapper {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
  }
  .page-list-layout .list-pagination {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    border-top: 1px solid var(--border);
  }
  .page-list-layout .table-wrapper thead th {
    position: sticky;
    top: 0;
    background: var(--surface);
    z-index: 1;
  }
  /* Scrollbar on the inner table area */
  .page-list-layout .table-wrapper::-webkit-scrollbar { width: 8px; }
  .page-list-layout .table-wrapper::-webkit-scrollbar-track { background: transparent; }
  .page-list-layout .table-wrapper::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
  .page-list-layout .table-wrapper::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }
}

/* ========== Page Header (hidden — replaced by toolbar breadcrumbs) ========== */
.page-header { display: none; }

/* ========== Page Toolbar ========== */
.page-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding: 6px 0;
  gap: 12px;
  flex-wrap: wrap;
}
.page-toolbar .search-input-wrapper {
  min-width: 200px;
}
.page-toolbar .toolbar-spacer { flex: 1; }
.back-link {
  display: inline-flex; align-items: center; gap: 4px;
  color: var(--text-secondary); font-size: 14px; font-weight: 500;
  text-decoration: none; white-space: nowrap;
}
.back-link:hover { color: var(--primary); }
.back-link svg { flex-shrink: 0; }

/* ========== Cards ========== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}
.card + .card {
  margin-top: var(--card-gap);
}
.card-header {
  padding: 18px 24px 10px;
  border-bottom: none;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.card-body { padding: 6px 24px 24px; }
.card-header + .card-body { padding-top: 0; }
.card-header:only-child { padding-bottom: 18px; }
.card-actions {
  display: flex;
  gap: 4px;
  padding: 12px 24px;
  border-top: 1px solid var(--border);
}
.card-actions .btn-ghost {
  font-size: 12px;
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: var(--radius);
}
.card-actions .btn-ghost:hover {
  color: var(--text);
  background: var(--surface-hover);
}
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--card-gap);
}
/* List-card: unified card pattern for admin list views */
.list-card { transition: box-shadow var(--transition), border-color var(--transition); }
.list-card:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.list-card .card-body { padding: 20px 24px; }
.list-card .card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.list-card .card-title strong {
  font-size: 14px;
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.list-card .card-title strong a { color: var(--text); }
.list-card .card-title strong a:hover { color: var(--primary); text-decoration: none; }
.list-card .card-meta {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
}
.list-card .card-meta:empty { display: none; }
.list-card .card-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.list-card .card-badges:empty { display: none; }

/* Layout cards — larger with wireframe preview */
.layout-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}
.layout-card { overflow: hidden; }
.layout-card-preview {
  background: var(--bg-secondary);
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.layout-card-title { font-size: 15px; }

/* Wireframe rendering */
.layout-wireframe {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 120px;
}
.layout-wireframe .lw-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  color: var(--text-secondary);
  font-size: 13px;
}
.lw-slot {
  border: 1.5px dashed var(--border);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
}
.lw-slot span {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 500;
}
.lw-full { width: 100%; }
.lw-row {
  display: flex;
  gap: 4px;
  flex: 1;
}
.lw-row .lw-wide { flex: 3; }
.lw-row .lw-narrow { flex: 1; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-lg);
  padding: 24px;
}
.stat-card .stat-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.stat-card .stat-value { font-size: 32px; font-weight: 700; margin-top: 6px; letter-spacing: -0.02em; }

/* ========== Tables ========== */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead { background: transparent; }
th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
}
td {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: middle;
}
tr:hover td { background: var(--surface-hover); }
tr.selected td { background: var(--primary-light); }
tr.row-clickable { cursor: pointer; }
tr.row-disabled td { opacity: 0.5; }

/* Row action icon buttons */
.row-actions {
  display: flex;
  gap: 2px;
}
.row-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.row-actions button:hover {
  background: var(--surface-hover);
  color: var(--text);
}
.row-actions .row-action-danger:hover {
  color: var(--danger);
  background: var(--danger-light);
}
tr.row-disabled td:has(.form-toggle) { opacity: 1; }
.pages-table td:first-child a { font-weight: 500; color: var(--text); }
.pages-table td:first-child a:hover { color: var(--primary); text-decoration: none; }

/* ========== Status Badges ========== */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge-draft { background: var(--border); color: var(--text-secondary); }
.badge-published { background: var(--success-light); color: var(--success); }
.badge-archived { background: var(--warning-light); color: var(--warning); }
.badge-trashed { background: var(--danger-light); color: var(--danger); }
.badge-active { background: var(--success-light); color: var(--success); }
.badge-role { background: var(--primary-light, #e3f2fd); color: var(--primary, #1976d2); }
.badge-paused { background: var(--warning-light); color: var(--warning); }
.badge-completed { background: var(--primary-light); color: var(--primary); }
.badge-under_construction { background: var(--warning-light); color: var(--warning); }
.badge-info { background: var(--primary-light); color: var(--primary); }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-muted { background: var(--border); color: var(--text-muted); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-new { background: var(--primary-light); color: var(--primary); font-weight: 700; }

/* ========== Forms Management ========== */
.forms-row { cursor: pointer; }
.forms-row:hover td { color: var(--primary); }
.forms-name-cell { font-weight: 500; }
.forms-count { font-weight: 600; margin-right: 6px; }

.forms-filters { display: flex; gap: 4px; margin-bottom: 16px; }

.forms-actions { white-space: nowrap; text-align: right; }
.btn-delete-sub { color: var(--text-muted); font-size: 16px; }
.btn-delete-sub:hover { color: var(--danger); }
.btn-resend { color: var(--text-muted); font-size: 15px; }
.btn-resend:hover { color: var(--primary); }

.submission-row { cursor: pointer; }

.forms-pagination { display: flex; align-items: center; gap: 12px; justify-content: center; margin-top: 16px; }

/* Submission detail modal */
.sub-detail-meta { display: flex; gap: 16px; font-size: 13px; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.sub-detail-section { margin-bottom: 16px; }
.sub-detail-section h4 { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin: 0 0 8px; }
.sub-detail-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.sub-detail-table td { padding: 5px 0; vertical-align: top; }
.sub-detail-table tr + tr td { border-top: 1px solid var(--border); }
.sub-detail-label { width: 120px; font-weight: 500; color: var(--text-secondary); padding-right: 12px; }
.sub-detail-code { font-size: 12px; word-break: break-all; }
.sub-detail-section .btn { margin-top: 8px; }

/* Sites - fork rows */
.site-fork-row td { background: var(--site-fork-bg) !important; }

/* ========== Alerts ========== */
.alert {
  padding: 12px 16px;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.5;
}
.alert strong { font-weight: 600; }
.alert-warning {
  background: var(--warning-light);
  color: var(--warning);
  border: 1px solid var(--warning);
}
.alert-info {
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid var(--primary);
}
.alert-danger {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid var(--danger);
}
.alert-success {
  background: var(--success-light);
  color: var(--success);
  border: 1px solid var(--success);
}
.alert-muted {
  background: var(--bg-secondary);
  color: var(--text-muted);
  border: 1px solid var(--border);
  cursor: pointer;
}
.alert-compact {
  padding: 6px 12px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.alert-compact .btn-dismiss-warning {
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
  font-size: 1.2em;
  font-weight: bold;
  line-height: 1;
  opacity: 0.6;
  flex-shrink: 0;
}
.alert-compact .btn-dismiss-warning:hover { opacity: 1; }

/* ========== Tabs ========== */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; scrollbar-width: thin; padding-bottom: 1px; }
.tab {
  padding: 8px 10px;
  font-size: 12px;
  white-space: nowrap;
  font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tabs::-webkit-scrollbar { height: 3px; }
.tabs::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.tabs::-webkit-scrollbar-track { background: transparent; }

/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--btn-primary-bg); color: #fff; }
.btn-primary:hover { background: var(--btn-primary-hover); box-shadow: var(--shadow-sm); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-hover); border-color: var(--text-muted); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid transparent; padding: 6px 10px; }
.btn-ghost:hover { background: var(--surface-hover); color: var(--text); border-color: var(--border); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-icon { padding: 8px; }

/* ========== Forms ========== */
.form-group { margin-bottom: 24px; }
.form-group:last-child { margin-bottom: 0; }

.form-label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.form-hint {
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-muted);
  margin-top: 6px;
}

.form-input,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="number"],
input[type="search"],
input[type="tel"],
input[type="date"],
select,
textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--input-bg);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-input-sm {
  padding: 6px 10px;
  font-size: 13px;
}

input:focus, select:focus, textarea:focus, .form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(16,185,129,0.15);
}

textarea { resize: vertical; min-height: 80px; }

/* Checkbox styling */
input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--primary);
  flex-shrink: 0;
}

.form-check,
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  cursor: pointer;
  user-select: none;
}

.form-check input[type="checkbox"],
.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
}

.form-check-label {
  font-weight: 500;
  color: var(--text);
}

/* Field with help text pattern */
.form-field {
  margin-bottom: 20px;
}

.form-field:last-child {
  margin-bottom: 0;
}

.form-field-help {
  margin: 6px 0 0 28px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-muted);
}

/* Range input styling */
input[type="range"] {
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: 2px solid var(--surface);
  box-shadow: var(--shadow);
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: 2px solid var(--surface);
  box-shadow: var(--shadow);
}

input[type="range"]:focus {
  outline: none;
  box-shadow: none;
}

.form-row { display: flex; gap: 16px; }
.form-row > * { flex: 1; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.char-count { font-size: 11px; color: var(--text-muted); text-align: right; margin-top: 2px; }
.char-count.over { color: var(--danger); }

/* Toggle switch style (optional, for special cases) */
.form-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.form-toggle input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 36px;
  height: 20px;
  background: var(--border);
  border-radius: 10px;
  position: relative;
  cursor: pointer;
  transition: background var(--transition);
}

.form-toggle input[type="checkbox"]::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.form-toggle input[type="checkbox"]:checked {
  background: var(--primary);
}

.form-toggle input[type="checkbox"]:checked::after {
  transform: translateX(16px);
}

/* ========== Search ========== */
.search-input-wrapper {
  position: relative;
  max-width: 300px;
}
.search-input-wrapper input {
  padding-left: 32px;
}
.search-input-wrapper svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

/* ========== Modals ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3000;
}
.modal-overlay.hidden { display: none; }
.modal-container {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 560px;
  max-height: 80vh;
  overflow-y: auto;
}
.modal-container.modal-sm { max-width: 400px; }
.modal-container.modal-lg { max-width: 780px; }
.modal-container.modal-xl { max-width: 1000px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}
.modal-body { padding: 20px; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}

/* Scrollable modal variant - fixed header/footer, scrollable body */
.modal-container.modal-scrollable {
  overflow-y: hidden;
  display: flex;
  flex-direction: column;
}
.modal-scrollable .modal-header {
  flex-shrink: 0;
}
.modal-scrollable .modal-body {
  flex: 1;
  overflow-y: auto;
}
.modal-scrollable .modal-footer {
  flex-shrink: 0;
}
.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  transition: background var(--transition), color var(--transition);
}
.modal-close:hover {
  background: var(--hover);
  color: var(--text);
}
.modal-confirm-message {
  margin: 0;
  font-size: 1rem;
  line-height: 1.5;
}
.modal-confirm-details {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--text-muted);
  max-height: 200px;
  overflow-y: auto;
  margin-top: 12px;
}
/* ========== Starter Preset Cards ========== */
.starter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}
.starter-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.starter-card:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}
.starter-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn.btn-danger:hover {
  background: #b91c1c;
  border-color: #b91c1c;
}
.btn-warning {
  background: var(--warning);
  color: #fff;
  border-color: var(--warning);
}
.btn-warning:hover {
  background: #b45309;
  border-color: #b45309;
}

/* ========== Toast Notifications ========== */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
}
.toast {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toastIn 200ms ease;
  min-width: 260px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.toast-success { background: var(--success); color: #fff; }
.toast-error { background: var(--danger); color: #fff; }
.toast-warning { background: var(--warning); color: #fff; }
.toast.removing { animation: toastOut 200ms ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateY(10px); } }

/* ========== Media Grid ========== */
.media-layout { display: flex; gap: 16px; min-height: calc(100vh - 200px); }
.media-sidebar { width: 200px; flex-shrink: 0; min-width: 0; overflow: hidden; }
.media-main { flex: 1; position: relative; }
.media-main.drag-over { outline: 2px dashed var(--primary); outline-offset: -4px; border-radius: var(--radius-lg); background: var(--primary-light); }
.media-empty-drop { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; min-height: 300px; color: var(--text-muted); text-align: center; }
.media-empty-drop p { margin-top: 8px; font-size: 13px; }
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.media-item {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition);
  background: var(--surface);
}
.media-item:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.media-item.selected { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary); }
.media-thumb {
  width: 100%;
  aspect-ratio: 1;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.media-thumb img { width: 100%; height: 100%; object-fit: cover; }
.media-thumb .file-icon { font-size: 28px; color: var(--text-muted); }
.media-info { padding: 8px 10px; }
.media-info .media-name { font-size: 12px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-info .media-size { font-size: 11px; color: var(--text-muted); }
.media-list-view .media-grid {
  grid-template-columns: 1fr;
}
.media-list-view .media-item {
  display: flex;
  align-items: center;
}
.media-list-view .media-thumb { width: 48px; height: 48px; aspect-ratio: auto; flex-shrink: 0; }
.media-list-view .media-info { flex: 1; }

/* Drag feedback */
.category-drop-target { background: var(--primary-light) !important; color: var(--primary) !important; }
.media-item.dragging { opacity: 0.4; }

/* Media delete button overlay */
.media-delete-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: var(--danger);
  color: #fff;
  font-size: 14px;
  line-height: 24px;
  text-align: center;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  padding: 0;
}
.media-item:hover .media-delete-btn { opacity: 1; }
.media-delete-btn:hover { filter: brightness(1.1); }
.media-list-view .media-delete-btn {
  position: static;
  opacity: 0;
  flex-shrink: 0;
  margin-right: 8px;
}
.media-list-view .media-item:hover .media-delete-btn { opacity: 1; }

/* Media select checkbox overlay */
.media-select-cb {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  border: 2px solid rgba(255,255,255,0.8);
  background: rgba(0,0,0,0.25);
  cursor: pointer;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: bold;
  color: #fff;
  opacity: 0;
  transition: opacity var(--transition), background var(--transition);
  user-select: none;
}
.media-item:hover .media-select-cb,
.media-item.bulk-selected .media-select-cb { opacity: 1; }
.media-item.bulk-selected .media-select-cb {
  background: var(--primary);
  border-color: var(--primary);
}
.media-list-view .media-select-cb {
  position: static;
  flex-shrink: 0;
  margin-left: 8px;
  margin-right: 8px;
  opacity: 0;
}
.media-list-view .media-item:hover .media-select-cb,
.media-list-view .media-item.bulk-selected .media-select-cb { opacity: 1; }

/* Media bulk action bar */
.media-bulk-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  margin-bottom: 12px;
  background: var(--primary-light);
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  position: sticky;
  top: 0;
  z-index: 5;
}
.media-bulk-bar .bulk-count {
  color: var(--primary);
  white-space: nowrap;
}
.media-bulk-bar select {
  width: auto;
  min-width: 140px;
  padding: 4px 8px;
  font-size: 12px;
}

/* Media usage section in detail panel */
.media-usage-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.media-usage-section h4 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.media-usage-list {
  list-style: none;
  font-size: 13px;
}
.media-usage-list li {
  padding: 4px 0;
}
.media-usage-list .usage-type {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-right: 4px;
}
.media-usage-empty {
  font-size: 12px;
  font-style: italic;
  color: var(--text-muted);
}

/* Media Detail Panel */
.media-detail {
  position: fixed;
  right: 0;
  top: var(--toolbar-height);
  bottom: 0;
  width: 340px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  padding: 20px;
  overflow-y: auto;
  z-index: 50;
  transform: translateX(100%);
  transition: transform 200ms ease;
}
.media-detail.open { transform: none; }

/* ========== Pagination ========== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-top: 20px;
}
.pagination button {
  min-width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}
.pagination button:hover { background: var(--surface-hover); }
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination button:disabled { opacity: 0.4; cursor: default; }

/* ========== Split Test Chart ========== */
.bar-chart { display: flex; align-items: flex-end; gap: 12px; height: 200px; padding: 16px 0; }
.bar-chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.bar-chart-bar { width: 100%; max-width: 60px; background: var(--primary); border-radius: 4px 4px 0 0; transition: height 300ms ease; }
.bar-chart-label { font-size: 11px; color: var(--text-secondary); text-align: center; }
.bar-chart-value { font-size: 12px; font-weight: 600; }

/* ========== Category Tree ========== */
.category-tree { list-style: none; }
.category-tree li {
  padding: 6px 10px;
  font-size: 13px;
  cursor: pointer;
  border-radius: var(--radius);
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 4px;
}
.category-tree .category-name { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.category-tree .category-delete {
  display: none; background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 16px; line-height: 1; padding: 0 2px; flex-shrink: 0;
}
.category-tree .category-delete:hover { color: var(--danger, #e53e3e); }
.category-tree li:hover .category-delete { display: block; }
.category-tree li:hover { background: var(--surface-hover); }
.category-tree li.active { background: var(--primary-light); color: var(--primary); font-weight: 500; }

/* ========== Loading Spinner ========== */
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
.spinner-sm { width: 16px; height: 16px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-center {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
}

/* ========== Empty State ========== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state h3 { font-size: 16px; color: var(--text-secondary); margin-bottom: 8px; }
.empty-state p { font-size: 13px; margin-bottom: 16px; }

/* ========== Responsive ========== */
@media (max-width: 1024px) {
  .editor-layout { grid-template-columns: 1fr; }
  .editor-palette { display: none; }
}
@media (max-width: 768px) {
  #app {
    grid-template-columns: 1fr;
    grid-template-areas:
      "toolbar"
      "main";
  }
  #sidebar {
    position: fixed;
    top: var(--toolbar-height);
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    z-index: 90;
    transform: translateX(-100%);
    transition: transform 200ms ease;
  }
  #sidebar.mobile-open { transform: none; }
  .media-layout { flex-direction: column; }
  .media-sidebar { width: 100%; }
  .form-row { flex-direction: column; }
}

/* ========== Utility ========== */
.hidden { display: none !important; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.gap-2 { gap: 8px; }
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.inline-flex { display: inline-flex; align-items: center; gap: 6px; }

/* ========== Polish ========== */

/* Form row halves (contact editor etc.) */
.form-group-half { flex: 1; min-width: 0; }
.form-row { gap: 20px; }

/* Card without header — body gets full padding */
.card-body:first-child { padding-top: 24px; }

/* Links in table cells */
td a { font-weight: 500; }
td a:hover { text-decoration: none; }

/* Focus-visible for keyboard nav */
.btn:focus-visible, .nav-item:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Scrollbar styling */
#main-content::-webkit-scrollbar { width: 8px; }
#main-content::-webkit-scrollbar-track { background: transparent; }
#main-content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
#main-content::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }
#sidebar::-webkit-scrollbar { width: 6px; }
#sidebar::-webkit-scrollbar-track { background: transparent; }
#sidebar::-webkit-scrollbar-thumb { background: var(--sidebar-border); border-radius: 3px; }

/* ========== Split Test Inline Results ========== */
.split-results-row > td { background: color-mix(in srgb, var(--surface), var(--surface-hover)); }
.split-results-panel {
  padding: 16px 20px;
  border-top: 2px solid var(--color-primary, #3b82f6);
  color: var(--text);
}
.split-results-header {
  margin-bottom: 12px;
  font-size: 0.9rem;
}
.split-results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.split-results-table th,
.split-results-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.split-results-table th {
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
.split-results-table th.num,
.split-results-table td.num { text-align: right; }
.split-bar {
  background: var(--border);
  border-radius: 4px;
  height: 8px;
  overflow: hidden;
}
.split-bar-fill {
  background: var(--color-primary, #3b82f6);
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
}
.split-results-promote {
  display: flex;
  align-items: center;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* ========== Contact Editor Layout ========== */

/* Card header with action button (e.g. Emails + Add) */
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Contact editor rows */
.ce-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 20px;
  margin-bottom: 16px;
}
.ce-row-2:last-child { margin-bottom: 0; }
.ce-row-2 .form-group { margin-bottom: 0; }

.ce-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px 20px;
}
.ce-row-3 .form-group { margin-bottom: 0; }

@media (max-width: 768px) {
  .ce-row-3 { grid-template-columns: 1fr; }
}

/* 2-column detail grid for emails/phones & addresses/tags */
.ce-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--card-gap);
  margin-top: var(--card-gap);
}
@media (max-width: 900px) {
  .ce-detail-grid {
    grid-template-columns: 1fr;
  }
}
.ce-detail-col {
  display: flex;
  flex-direction: column;
  gap: var(--card-gap);
}

/* Sub-entry rows (email, phone) */
.sub-entry {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.sub-entry:first-child { padding-top: 0; }
.sub-entry:last-child { border-bottom: none; padding-bottom: 0; }
.sub-entry-fields {
  display: flex;
  align-items: center;
  gap: 10px;
}
.sub-entry-fields .form-control { flex: 1; min-width: 0; }
.sub-entry-type { flex: 0 0 110px !important; }
.sub-entry-label { flex: 0 0 100px !important; }
.sub-entry-meta {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  padding-left: 2px;
}

/* Block sub-entry for addresses */
.sub-entry-block {
  padding: 12px 0;
}

/* Remove button (X) */
.btn-remove {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  border-radius: 50%;
  transition: background var(--transition), color var(--transition);
  padding: 0;
}
.btn-remove:hover {
  background: var(--danger-light);
  color: var(--danger);
}

/* Address city/state/zip row */
.addr-city-row {
  display: flex;
  gap: 8px;
}
.addr-city-row .form-control { min-width: 0; }
.addr-city-row .form-control:first-child { flex: 1; }

/* Company searchable dropdown */
.company-search-wrap {
  position: relative;
}
.company-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-height: 240px;
  overflow-y: auto;
  z-index: 100;
}
.company-dd-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  transition: background var(--transition);
}
.company-dd-item:hover { background: var(--surface-hover); }
.company-dd-item.selected { background: var(--primary-light); color: var(--primary); }
.company-dd-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.company-dd-count {
  flex-shrink: 0;
  font-size: 11px;
  color: var(--text-muted);
  background: var(--border);
  border-radius: 999px;
  padding: 1px 7px;
  margin-left: 8px;
}
.company-dd-empty {
  padding: 12px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}
.company-selected {
  font-weight: 500;
  color: var(--primary);
}

/* Small empty state (inside card bodies) */
.empty-state-sm {
  padding: 16px 0;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

/* Tag pills */
.tag-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.tag-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  background: transparent;
  transition: all var(--transition);
  line-height: 1.4;
}
.tag-pill:hover { opacity: 0.85; }
.tag-pill.active { box-shadow: var(--shadow-sm); }
.tag-new-input {
  margin-top: 2px;
  font-size: 13px;
}

/* ========== Smart List Filter Builder ========== */
.sl-filter-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-bottom: 10px;
}
.sl-filter-field { width: 160px; flex-shrink: 0; }
.sl-filter-op { width: 130px; flex-shrink: 0; }
.sl-filter-value { flex: 1; min-width: 0; }
.sl-filter-value .form-control,
.sl-filter-value select,
.sl-filter-value input[type="date"],
.sl-filter-value input[type="text"],
.sl-filter-value input[type="number"] {
  width: 100%;
  box-sizing: border-box;
}
.sl-filter-remove {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
  color: var(--text-muted);
  border: none;
  background: none;
  cursor: pointer;
  border-radius: var(--radius);
  padding: 0;
}
.sl-filter-remove:hover { color: var(--danger); background: var(--danger-light); }
.sl-add-filter { margin-top: 4px; }
.sl-count-bar {
  padding: 12px 16px;
  background: var(--bg-secondary, var(--surface-hover));
  border-radius: var(--radius);
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}
.sl-count-bar .count { font-weight: 600; font-size: 1.05em; }
.sl-preview-table { margin-top: 12px; }
.spinner-sm { width: 16px; height: 16px; border-width: 2px; }

/* Tag filter — tokenized combo input */
.sl-tag-wrap { position: relative; }
.sl-tag-combo {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  min-height: 40px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: text;
  transition: border-color var(--transition);
  box-sizing: border-box;
}
.sl-tag-combo:focus-within { border-color: var(--primary); }
.sl-tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 0 6px;
  font-size: 11px;
  font-weight: 500;
  border-radius: 999px;
  border: 1px solid;
  background: transparent;
  cursor: default;
  line-height: 1.8;
  white-space: nowrap;
}
.sl-tag-chip .sl-chip-x {
  cursor: pointer;
  opacity: 0.5;
  font-size: 14px;
  font-weight: 400;
  margin-left: 1px;
  line-height: 1;
}
.sl-tag-chip .sl-chip-x:hover { opacity: 1; }
.sl-tag-combo .sl-tag-input {
  flex: 1;
  min-width: 80px;
  width: auto;
  border: none;
  outline: none;
  background: transparent;
  font-size: 14px;
  padding: 2px 0;
  color: var(--text);
  line-height: 1.2;
  box-shadow: none;
}
.sl-tag-input::placeholder { color: var(--text-muted); }
.sl-tag-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-height: 200px;
  overflow-y: auto;
  z-index: 100;
}
.sl-tag-dropdown.open { display: block; }
.sl-tag-dd-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  cursor: pointer;
  font-size: 13px;
  transition: background var(--transition);
}
.sl-tag-dd-item:hover { background: var(--surface-hover); }
.sl-tag-dd-item.selected { opacity: 0.35; pointer-events: none; }
.sl-tag-dd-swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.sl-tag-dd-empty {
  padding: 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* ---- List member search dropdown ---- */
.le-member-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  width: 360px;
  margin-top: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-height: 280px;
  overflow-y: auto;
  z-index: 100;
}
.le-member-dropdown.open { display: block; }
.le-dd-item {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  transition: background var(--transition);
}
.le-dd-item:hover { background: var(--surface-hover); }
.le-dd-item.disabled { opacity: 0.4; cursor: default; }
.le-dd-item.disabled:hover { background: transparent; }
.le-dd-empty {
  padding: 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}
.le-remove-member {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  color: var(--text-muted);
  padding: 2px 6px;
  border-radius: 4px;
}
.le-remove-member:hover { color: var(--danger); background: var(--danger-light); }

/* ========== Settings Panels ========== */
.settings-panels {
  display: flex;
  flex-direction: column;
  gap: var(--card-gap);
}
.settings-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.settings-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 16px 24px;
  border: none;
  background: none;
  cursor: pointer;
  font: inherit;
  color: var(--text);
  text-align: left;
}
.settings-card-header:hover {
  background: var(--surface-hover);
}
.settings-card-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
}
.settings-card-icon {
  color: var(--text-muted);
  flex-shrink: 0;
}
.settings-card-chevron {
  color: var(--text-muted);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}
.settings-card.is-expanded .settings-card-chevron {
  transform: rotate(180deg);
}
.settings-card-body {
  display: none;
  padding: 0 24px 24px;
}
.settings-card.is-expanded .settings-card-body {
  display: block;
}
.settings-field {
  margin-bottom: 16px;
}
.settings-field:last-child {
  margin-bottom: 0;
}
.settings-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.settings-field-help {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ========== Site Assignment ========== */
.site-assign-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.site-assign-row:last-child { border-bottom: none; }
.site-assign-label {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  cursor: pointer;
}
.site-assign-label input[disabled] + .site-assign-name {
  color: var(--text-muted);
}
.site-assign-name {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.site-assign-date {
  flex-shrink: 0;
  font-size: 11px;
  color: var(--text-muted);
}
.site-assign-noaccess {
  flex-shrink: 0;
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
}

/* ========== Template Editor ========== */
.te-wrap {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--toolbar-height));
  /* Dark chrome frame tokens */
  --te-chrome: #1e293b;
  --te-chrome-light: #263348;
  --te-border: #334155;
  --te-text: #e2e8f0;
  --te-text-muted: #94a3b8;
  --te-input-bg: #334155;
  --te-canvas-bg: #d1d8e0;
}
/* Dark site navbar when template editor is active */
body:has(pelican-template-editor) #toolbar {
  background: var(--sidebar-bg);
  border-bottom-color: #334155;
}
body:has(pelican-template-editor) #toolbar,
body:has(pelican-template-editor) .breadcrumb-site,
body:has(pelican-template-editor) .breadcrumb-current {
  color: #e2e8f0;
}
body:has(pelican-template-editor) .breadcrumb-link { color: #94a3b8; }
body:has(pelican-template-editor) .breadcrumb-link:hover { color: #10b981; }
body:has(pelican-template-editor) .breadcrumb-sep { color: #475569; }
body:has(pelican-template-editor) .breadcrumb-site:hover { background: rgba(255,255,255,0.05); color: #e2e8f0; }
body:has(pelican-template-editor) .toolbar-right .btn { color: #94a3b8; }
body:has(pelican-template-editor) .toolbar-right .btn:hover { color: #e2e8f0; }
/* Remove main-content padding and make bg dark when editor is active */
body:has(pelican-template-editor) #main-content {
  padding: 0;
  overflow: hidden;
  background: var(--sidebar-bg);
}
.te-toolbar {
  position: relative;
  z-index: 21;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: var(--te-chrome);
  border-bottom: 1px solid var(--te-border);
  flex-shrink: 0;
}
.te-back-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  color: var(--te-text-muted) !important;
}
.te-back-btn:hover { color: var(--te-text) !important; background: rgba(255,255,255,0.08); }
.te-name-input {
  flex: 1;
  min-width: 0;
  border: 1px solid transparent;
  background: transparent !important;
  font-size: 15px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: var(--radius);
  color: var(--te-text) !important;
  transition: border-color var(--transition);
}
.te-name-input::placeholder { color: var(--te-text-muted); }
.te-name-input:hover { border-color: var(--te-border); }
.te-name-input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--te-chrome-light) !important;
  box-shadow: none;
}
.te-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.te-toolbar-actions .btn-ghost { color: var(--te-text-muted); }
.te-toolbar-actions .btn-ghost:hover { color: var(--te-text); background: rgba(255,255,255,0.08); }
.te-toolbar-actions .btn-primary { background: var(--primary); color: #fff; }
.te-toolbar-actions .btn-primary:hover { background: var(--primary-hover); }
.te-panel {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 20;
  background: var(--te-chrome-light);
  border-bottom: 1px solid var(--te-border);
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}
.te-panel-inner {
  padding: 16px 20px;
  max-width: 900px;
}
.te-panel-header {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary);
  margin-bottom: 12px;
}
.te-panel .form-row {
  display: flex;
  gap: 12px;
}
.te-panel .form-group {
  margin-bottom: 8px;
}
.te-panel label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--te-text-muted);
  margin-bottom: 4px;
}
.te-panel input[type="text"],
.te-panel select,
.te-panel textarea {
  background: var(--te-input-bg);
  border-color: var(--te-border);
  color: var(--te-text);
}
.te-panel input:focus, .te-panel select:focus, .te-panel textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(16,185,129,0.15);
}
/* Section group within panels */
.te-field-group {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}
.te-field-group .form-group { flex: 1; }
.te-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--te-text-muted);
  margin: 8px 0 8px;
}
/* Color field: swatch + hex input */
.te-color-field {
  display: flex;
  align-items: center;
  gap: 6px;
}
.te-color-swatch {
  width: 28px;
  height: 28px;
  border-radius: var(--radius);
  border: 1px solid var(--te-border);
  cursor: pointer;
  padding: 0;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}
.te-color-swatch input[type="color"] {
  position: absolute;
  inset: -4px;
  width: calc(100% + 8px);
  height: calc(100% + 8px);
  border: none;
  padding: 0;
  cursor: pointer;
  opacity: 0;
}
.te-color-hex {
  width: 76px;
  font-size: 12px;
  font-family: monospace;
  padding: 4px 6px;
  border: 1px solid var(--te-border);
  border-radius: var(--radius);
  background: var(--te-input-bg);
  color: var(--te-text);
}
.te-color-hex:focus {
  outline: none;
  border-color: var(--primary);
}
/* Active state on toolbar toggle buttons */
.te-toolbar-actions .btn.active {
  background: rgba(16,185,129,0.15);
  color: var(--primary);
}
#te-editor-container {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
#te-editor-container cms-block-editor {
  height: 100%;
}
#te-editor-container .be-editor {
  height: 100%;
}

/* ---- Dark chrome: block editor overrides ---- */
#te-editor-container cms-block-editor {
  margin-top: 0;
}
#te-editor-container .be-editor {
  border: none;
  border-radius: 0;
  background: var(--te-chrome-light);
  height: 100%;
}
/* Sidebar — medium slate */
#te-editor-container .be-sidebar {
  background: var(--te-chrome-light);
  border-right-color: var(--te-border);
}
#te-editor-container .be-sidebar-tab {
  color: var(--te-text-muted);
}
#te-editor-container .be-sidebar-tab:hover { color: var(--te-text); }
#te-editor-container .be-sidebar-tab.active { color: var(--primary); }
#te-editor-container .be-sidebar-tabs {
  border-bottom-color: var(--te-border);
}
/* Palette area */
#te-editor-container .be-palette { background: var(--te-chrome-light); }
#te-editor-container .be-palette-search-input {
  background: var(--te-input-bg);
  border-color: var(--te-border);
  color: var(--te-text);
}
#te-editor-container .be-palette-search-input::placeholder { color: var(--te-text-muted); }
#te-editor-container .be-palette-search { border-bottom-color: var(--te-border); }
#te-editor-container .palette-group-header { color: var(--te-text-muted); }
#te-editor-container .palette-group-header:hover { background: rgba(255,255,255,0.04); }
#te-editor-container .palette-group-label { color: var(--te-text-muted); }
#te-editor-container .be-palette-item { color: var(--te-text-muted); }
#te-editor-container .be-palette-item:hover { background: rgba(255,255,255,0.06); color: var(--te-text); }
/* Outline */
#te-editor-container cms-block-outline { background: var(--te-chrome-light); }
#te-editor-container .be-outline-item { color: var(--te-text-muted); }
#te-editor-container .be-outline-item:hover { background: rgba(255,255,255,0.05); }
#te-editor-container .be-outline-item.be-outline-selected { background: rgba(16,185,129,0.12); color: var(--primary); }
/* Block list cards */
#te-editor-container .block-card {
  background: rgba(255,255,255,0.04);
  border-color: var(--te-border);
  color: var(--te-text);
}
#te-editor-container .block-card:hover { border-color: rgba(255,255,255,0.2); }
#te-editor-container .block-summary { color: var(--te-text-muted); }
#te-editor-container .drag-handle { color: var(--te-text-muted); }
#te-editor-container .block-type-icon { background: rgba(16,185,129,0.12); color: var(--primary); }
/* Block toolbar (undo/redo bar) */
#te-editor-container .be-toolbar {
  background: var(--te-chrome);
  border-bottom-color: var(--te-border);
}
#te-editor-container .be-toolbar button { color: var(--te-text-muted); }
#te-editor-container .be-toolbar button:hover { color: var(--te-text); background: rgba(255,255,255,0.08); }
#te-editor-container .be-toolbar-sep { background: var(--te-border); }
/* Canvas area — gray background */
#te-editor-container .be-canvas-area {
  background: var(--te-canvas-bg);
}
/* Resize handle */
#te-editor-container .be-resize-handle:hover,
#te-editor-container .be-resize-handle:active { background: var(--primary); }
/* Responsive toggle */
#te-editor-container .le-sidebar-toggle { border-color: var(--te-border); }
#te-editor-container .le-sidebar-toggle button { color: var(--te-text-muted); }
#te-editor-container .le-sidebar-toggle button:hover:not(.active) { background: rgba(255,255,255,0.06); }
/* Properties panel — medium slate */
#te-editor-container cms-block-properties {
  background: var(--te-chrome-light);
  border-left-color: var(--te-border);
}
#te-editor-container .be-props-header {
  background: var(--te-chrome-light);
  border-bottom-color: var(--te-border);
  color: var(--te-text);
}
#te-editor-container .be-props-header strong { color: var(--te-text); }
#te-editor-container .be-props-header .block-type-icon { color: var(--te-text-muted); }
#te-editor-container .be-props-tabs {
  background: var(--te-chrome);
  border-bottom-color: var(--te-border);
}
#te-editor-container .be-props-tab { color: var(--te-text-muted); }
#te-editor-container .be-props-tab:hover { color: var(--te-text); }
#te-editor-container .be-props-tab.active { color: var(--primary); }
#te-editor-container .be-props-section-title { color: var(--te-text-muted); }
#te-editor-container .be-props-category { border-bottom-color: var(--te-border); }
#te-editor-container .be-props-category-header { color: var(--te-text-muted); }
#te-editor-container .be-props-category-header:hover { background: rgba(255,255,255,0.04); color: var(--te-text-muted); }
#te-editor-container .be-prop-label-row { color: var(--te-text-muted); }
#te-editor-container .be-props-footer { border-top-color: var(--te-border); }
#te-editor-container .be-props-footer .be-toggle-json { color: var(--te-text-muted); }
/* Form controls inside properties */
#te-editor-container cms-block-properties .form-control,
#te-editor-container cms-block-properties select.form-control {
  background: var(--te-input-bg);
  border-color: var(--te-border);
  color: var(--te-text);
}
#te-editor-container cms-block-properties input[type="text"],
#te-editor-container cms-block-properties input[type="number"],
#te-editor-container cms-block-properties input[type="url"],
#te-editor-container cms-block-properties select,
#te-editor-container cms-block-properties textarea {
  background: var(--te-input-bg);
  border-color: var(--te-border);
  color: var(--te-text);
}
#te-editor-container cms-block-properties .be-richtext-editor {
  background: var(--te-input-bg);
  border-color: var(--te-border);
  color: var(--te-text);
}
#te-editor-container cms-block-properties .be-color-row input[type="color"] {
  border-color: var(--te-border);
}
/* Sub-panels */
#te-editor-container .be-props-sub-panel { border-top-color: var(--te-border); }
#te-editor-container .be-props-sub-header { color: var(--te-text-muted); }
#te-editor-container .be-props-sub-header:hover { color: var(--te-text); }
#te-editor-container .be-props-sub-fields { border-left-color: var(--te-border); }
/* Presets dropdown */
#te-editor-container .be-presets-dropdown {
  background: var(--te-chrome);
  border-color: var(--te-border);
}
#te-editor-container .be-presets-dropdown-item:hover { background: rgba(255,255,255,0.06); }
#te-editor-container .be-presets-dropdown-name { color: var(--te-text); }
/* Toggle and slider controls */
#te-editor-container .pc-icon-toggle { border-color: var(--te-border); }
#te-editor-container .pc-icon-toggle-btn { color: var(--te-text-muted); border-right-color: var(--te-border); }
#te-editor-container .pc-icon-toggle-btn:hover { background: rgba(255,255,255,0.06); color: var(--te-text); }
#te-editor-container .pc-four-side-link { border-color: var(--te-border); }
/* Breakpoint dropdown */
#te-editor-container .be-bp-dropdown {
  background: var(--te-chrome);
  border-color: var(--te-border);
}
#te-editor-container .be-bp-option { color: var(--te-text-muted); }
#te-editor-container .be-bp-option:hover { background: rgba(255,255,255,0.06); color: var(--te-text); }
/* Breakpoint bar (device preview toggle) */
#te-editor-container .be-breakpoint-bar {
  background: var(--te-chrome);
  border-color: var(--te-border);
}
#te-editor-container .be-bp-btn { color: var(--te-text-muted); }
#te-editor-container .be-bp-btn:hover { color: var(--te-text); background: rgba(255,255,255,0.06); }
#te-editor-container .be-bp-btn.active { color: var(--primary); background: rgba(16,185,129,0.12); border-color: var(--primary); }
/* Slider controls */
#te-editor-container .pc-slider { background: var(--te-border); }
#te-editor-container .pc-slider-num,
#te-editor-container input.pc-slider-num[type="number"] {
  background: var(--te-input-bg); border-color: var(--te-border); color: var(--te-text);
}
#te-editor-container .pc-unit-suffix { color: var(--te-text-muted); }
/* Checkbox/toggle in dark */
#te-editor-container .le-container-toggle { color: var(--te-text-muted); }
#te-editor-container .le-container-toggle input[type="checkbox"] { background: var(--te-border); }
/* Reset button */
#te-editor-container .be-reset-btn { color: var(--te-text-muted); }
/* Presets toggle */
#te-editor-container .be-presets-toggle { color: var(--te-text-muted); }
#te-editor-container .be-presets-toggle:hover { color: var(--primary); }
/* Close button in props header */
#te-editor-container .be-props-header button { color: var(--te-text-muted); }
#te-editor-container .be-props-header button:hover { color: var(--te-text); }
/* Align / icon-toggle buttons */
#te-editor-container .pc-icon-toggle { border-color: var(--te-border); }
#te-editor-container .pc-icon-toggle-btn { color: var(--te-text-muted); border-right-color: var(--te-border); }
#te-editor-container .pc-icon-toggle-btn:hover { background: rgba(255,255,255,0.06); color: var(--te-text); }
#te-editor-container .pc-icon-toggle-btn.active { background: var(--primary); color: #fff; }
/* Four-side input (margin/padding) */
#te-editor-container .pc-four-side input { background: var(--te-input-bg); border-color: var(--te-border); color: var(--te-text); }
#te-editor-container .pc-four-side-link { border-color: var(--te-border); color: var(--te-text-muted); }
/* Menu items */
#te-editor-container .pc-menu-input { background: var(--te-input-bg); border-color: var(--te-border); color: var(--te-text); }
/* Chevron and muted icons */
#te-editor-container .be-props-chevron { color: var(--te-text-muted); }
#te-editor-container .be-props-category-icon { opacity: 0.5; }
/* Media picker control in dark */
#te-editor-container .mp-control-select-btn {
  background: var(--te-chrome-light); border: 2px dashed var(--te-text-muted); color: var(--te-text);
  padding: 12px; font-size: 13px; border-radius: 6px;
}
#te-editor-container .mp-control-select-btn:hover { border-color: var(--primary); color: var(--primary); background: rgba(16,185,129,0.08); }
#te-editor-container .mp-control-preview { border-color: var(--te-border); background: var(--te-input-bg); }
/* Icon picker in dark */
#te-editor-container .ip-control-select {
  background: transparent; border-color: var(--te-text-muted); color: var(--te-text-muted);
}
#te-editor-container .ip-control-select:hover { border-color: var(--primary); color: var(--primary); }
#te-editor-container .ip-control-preview {
  background: var(--te-input-bg); border-color: var(--te-border); color: var(--te-text-muted);
}
#te-editor-container .ip-control-name { color: var(--te-text-muted); }
#te-editor-container .ip-control-change { color: var(--te-text-muted); }
/* pc-icon-btn in dark (alignment, breakpoint buttons) */
#te-editor-container .pc-icon-btn {
  background: var(--te-input-bg); border-color: var(--te-border); color: var(--te-text-muted);
}
#te-editor-container .pc-icon-btn:hover { border-color: var(--primary); color: var(--te-text); }

/* ========== Palette Picker ========== */
.pp-modal {
  max-width: 620px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
}
.pp-modal .modal-body { flex: 1; overflow-y: auto; }
.pp-section {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.pp-section-last { border-bottom: none; }

/* Seed color inputs */
.pp-seed-row {
  display: flex;
  gap: 20px;
}
.pp-seed-input { flex: 1; }
.pp-color-input {
  display: flex;
  align-items: center;
  gap: 8px;
  transition: opacity var(--transition);
}
.pp-color-input.pp-disabled { opacity: 0.4; pointer-events: none; }
.pp-color-well {
  width: 40px;
  height: 36px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  background: none;
  flex-shrink: 0;
  -webkit-appearance: none;
  appearance: none;
}
.pp-color-well::-webkit-color-swatch-wrapper { padding: 0; }
.pp-color-well::-webkit-color-swatch { border: none; border-radius: 3px; }
.pp-color-input .form-control { flex: 1; font-family: monospace; font-size: 13px; }

/* Options bar */
.pp-options-bar {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  background: var(--bg);
}
.pp-option { flex: 1; }
.pp-option .form-label { margin-bottom: 4px; }
.pp-option-sm { flex: 0 0 72px; }
.pp-option-action {
  flex: 0 0 auto;
  padding-bottom: 1px;
}

/* Palette strip */
.pp-palette-strip {
  display: flex;
  height: 64px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
}
.pp-palette-color { flex: 1; transition: flex 200ms ease; }
.pp-palette-color:hover { flex: 1.4; }

/* Assignment rows */
.pp-section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}
.pp-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.pp-assignments { display: flex; flex-direction: column; gap: 6px; }
.pp-assign-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: var(--radius);
  background: var(--bg);
}
.pp-assign-swatch {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.pp-assign-info {
  display: flex;
  flex-direction: column;
  min-width: 100px;
}
.pp-assign-hex {
  font-size: 12px;
  font-weight: 600;
  font-family: monospace;
  color: var(--text);
}
.pp-assign-name {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.2;
}
.pp-assign-arrow { color: var(--text-muted); flex-shrink: 0; }
.pp-assign-select { flex: 1; }

/* Tab bar */
.pp-tab-bar {
  display: flex;
  border-bottom: 1px solid var(--border);
}
.pp-tab {
  flex: 1;
  padding: 10px 16px;
  border: none;
  background: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}
.pp-tab:hover { color: var(--text); }
.pp-tab-active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* Explore grid */
.pp-explore-section { padding-top: 12px !important; padding-bottom: 12px !important; }
.pp-explore-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pp-explore-item {
  cursor: pointer;
  border-radius: var(--radius-lg);
  border: 2px solid transparent;
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.pp-explore-item:hover { border-color: var(--border); }
.pp-explore-selected {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.18);
}
.pp-explore-strip {
  height: 44px !important;
  border-radius: 0 !important;
  border: none !important;
}

/* Search result meta */
.pp-search-result-inner {
  display: flex;
  flex-direction: column;
}
.pp-search-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 5px 10px 6px;
  background: var(--bg);
}
.pp-search-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pp-search-tags {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ========== Email Settings ========== */
.es-palette-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.es-palette-slot {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.es-palette-slot label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}
.es-palette-input {
  display: flex;
  align-items: center;
  gap: 6px;
}
.es-palette-swatch {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  cursor: pointer;
}
.es-palette-swatch input[type="color"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}
.es-palette-input .form-control {
  flex: 1;
  font-family: monospace;
  font-size: 13px;
}

/* Template defaults color fields */
.es-defaults-colors {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.es-color-field {
  flex: 1;
  min-width: 120px;
}
.es-color-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.es-color-swatch {
  width: 28px;
  height: 28px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  cursor: pointer;
  padding: 0;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}
.es-color-swatch input[type="color"] {
  position: absolute;
  inset: -4px;
  width: calc(100% + 8px);
  height: calc(100% + 8px);
  border: none;
  padding: 0;
  cursor: pointer;
  opacity: 0;
}
.es-color-hex {
  flex: 1;
  font-size: 12px;
  font-family: monospace;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--text);
  min-width: 0;
}
.es-color-hex:focus {
  outline: none;
  border-color: var(--primary);
}
.es-color-chips {
  display: flex;
  gap: 3px;
  margin-top: 6px;
}
.es-color-chip {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
  flex-shrink: 0;
}
.es-color-chip:hover {
  transform: scale(1.2);
  border-color: var(--border-dark);
}
.es-chip-active {
  border-color: var(--text) !important;
  transform: scale(1.15);
}

/* Webhook URL display */
.es-webhook-url {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 13px;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  user-select: all;
  word-break: break-all;
}
.es-webhook-url:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

/* Settings toggle switch */
.settings-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
}
.settings-toggle input { display: none; }
.settings-toggle-slider {
  position: relative;
  width: 36px;
  height: 20px;
  background: var(--border-strong);
  border-radius: 10px;
  transition: background 0.2s;
  flex-shrink: 0;
}
.settings-toggle-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
.settings-toggle input:checked + .settings-toggle-slider {
  background: var(--primary);
}
.settings-toggle input:checked + .settings-toggle-slider::after {
  transform: translateX(16px);
}
.settings-toggle-label {
  color: var(--text-secondary);
  font-size: 12px;
}

/* ========== Blueprint Gallery ========== */
.tpl-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.tpl-gallery-card {
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  overflow: hidden;
}
.tpl-gallery-card:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.tpl-gallery-blank {
  border-style: dashed;
}
.tpl-gallery-preview {
  height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--text-muted);
  overflow: hidden;
  position: relative;
}
.tpl-gallery-card:hover .tpl-gallery-preview {
  color: var(--primary);
}
.tpl-gallery-iframe {
  width: 600px;
  height: 1200px;
  border: none;
  transform: scale(0.35);
  transform-origin: top center;
  pointer-events: none;
  position: absolute;
  top: 6px;
  left: 50%;
  margin-left: -300px;
  box-shadow: 0 0 0 1px var(--border);
}
.tpl-gallery-info {
  padding: 12px;
}
.tpl-gallery-name {
  font-weight: 600;
  font-size: 0.9em;
  margin-bottom: 4px;
}
.tpl-gallery-desc {
  font-size: 0.8em;
  color: var(--text-muted);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ========== Template Picker Panel (slide-in from right) ========== */
.ce-picker-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.15);
  z-index: 2499;
}
.ce-picker-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 400px;
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 2500;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 250ms ease;
}
.ce-picker-panel.open {
  transform: translateX(0);
}
.ce-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.ce-picker-header span {
  font-weight: 600;
  font-size: 0.95em;
}
.ce-picker-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 4px;
  border-radius: var(--radius);
  transition: color var(--transition);
}
.ce-picker-close:hover {
  color: var(--text);
}
.ce-picker-search {
  padding: 8px 16px 12px;
}
.ce-picker-search input {
  width: 100%;
}
.ce-picker-list {
  flex: 1;
  overflow-y: auto;
}
.ce-picker-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}
.ce-picker-row:hover {
  background: var(--surface-hover);
}
.ce-picker-row-info {
  min-width: 0;
  flex: 1;
}
.ce-picker-row-name {
  font-weight: 500;
  font-size: 0.9em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ce-picker-row-cat {
  font-size: 0.75em;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Clickable variant template name */
.ce-variant-tpl-link {
  color: var(--primary);
  cursor: pointer;
  font-weight: 500;
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
}
.ce-variant-tpl-link:hover {
  text-decoration: underline;
}

/* Variant rows */
.cc-variant-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-hover);
}
.cc-variant-row + .cc-variant-row { margin-top: 8px; }
.cc-variant-badge {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}
.cc-variant-fields {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  min-width: 0;
}
.cc-variant-fields input {
  flex: 1;
  min-width: 140px;
}
.cc-variant-tpl {
  font-size: 0.85em;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}
.cc-variant-actions {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-shrink: 0;
}
.cc-variant-weight {
  width: 60px;
  text-align: center;
}
.cc-weight-warn {
  color: var(--warning);
  font-size: 0.85em;
  margin-top: 8px;
}

/* Audience chips */
.cc-list-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.cc-list-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px 4px 10px;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.85em;
  line-height: 1.3;
}
.cc-list-chip-x {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1.1em;
  line-height: 1;
  padding: 0 2px;
  border-radius: 50%;
}
.cc-list-chip-x:hover {
  color: var(--danger);
}

/* Add-list modal rows */
.cc-list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  font-size: 0.9em;
}
.cc-list-row:last-child { border-bottom: none; }
.cc-list-row:hover { background: var(--surface-hover); }
.cc-list-row-name {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ========== Datetime-local styling ========== */
input[type="datetime-local"].form-control {
  appearance: none;
  background: var(--card-bg, var(--surface));
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 14px;
  color: var(--text);
  font-family: inherit;
}
input[type="datetime-local"].form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(16,185,129,0.15);
}

/* ========== Campaign Editor — embedded block editor mode ========== */
#ce-editor-wrap {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 10;
}
#ce-editor-wrap.active {
  display: flex;
  flex-direction: column;
}

/* Dark toolbar/chrome when campaign editor is in editor mode */
body:has(#ce-editor-wrap.active) #toolbar {
  background: var(--sidebar-bg);
  border-bottom-color: #334155;
}
body:has(#ce-editor-wrap.active) #toolbar,
body:has(#ce-editor-wrap.active) .breadcrumb-site,
body:has(#ce-editor-wrap.active) .breadcrumb-current {
  color: #e2e8f0;
}
body:has(#ce-editor-wrap.active) .breadcrumb-link { color: #94a3b8; }
body:has(#ce-editor-wrap.active) .breadcrumb-link:hover { color: #10b981; }
body:has(#ce-editor-wrap.active) .breadcrumb-sep { color: #475569; }
body:has(#ce-editor-wrap.active) .breadcrumb-site:hover { background: rgba(255,255,255,0.05); color: #e2e8f0; }
body:has(#ce-editor-wrap.active) .toolbar-right .btn { color: #94a3b8; }
body:has(#ce-editor-wrap.active) .toolbar-right .btn:hover { color: #e2e8f0; }
body:has(#ce-editor-wrap.active) #main-content {
  padding: 0;
  overflow: hidden;
  background: var(--sidebar-bg);
}

/* ========== Dashboard ========== */
.dash-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.dash-metric-card {
  display: block;
  padding: 20px 24px;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: box-shadow var(--transition), border-color var(--transition);
}
.dash-metric-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
  text-decoration: none;
}
.dash-metric-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-weight: 500;
}
.dash-metric-value {
  font-size: 28px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}
.dash-metric-card .spinner-sm {
  display: inline-block;
  vertical-align: middle;
}
.dash-metrics .card + .card {
  margin-top: 0;
}

.dash-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
@media (max-width: 900px) {
  .dash-body { grid-template-columns: 1fr; }
}

.dash-campaign-summary { padding: 4px 0; }
.dash-campaign-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.dash-campaign-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}
.dash-campaign-name:hover { color: var(--primary); text-decoration: none; }
.dash-campaign-meta {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.dash-stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
@media (max-width: 600px) {
  .dash-stat-row { grid-template-columns: repeat(2, 1fr); }
}
.dash-stat { text-align: center; }
.dash-stat-value {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
}
.dash-stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
