/* ============================================================
   USD21 Church Admin — Main Stylesheet
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
img { max-width: 100%; }

:root {
  --color-primary:      #1a56a4;
  --color-primary-dark: #143f80;
  --color-primary-light:#dbeafe;
  --color-danger:       #dc2626;
  --color-danger-light: #fee2e2;
  --color-success:      #16a34a;
  --color-success-light:#dcfce7;
  --color-warning:      #ca8a04;
  --color-text:         #111827;
  --color-muted:        #6b7280;
  --color-border:       #e5e7eb;
  --color-bg:           #f9fafb;
  --color-surface:      #ffffff;
  --radius:             6px;
  --shadow-sm:          0 1px 2px rgba(0,0,0,.07);
  --shadow:             0 2px 8px rgba(0,0,0,.10);
  --navbar-h:           60px;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.5;
}

/* ---- Navbar ---- */
.navbar {
  display: flex;
  align-items: center;
  gap: 24px;
  height: var(--navbar-h);
  padding: 0 24px;
  background: var(--color-primary);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
}
.navbar-brand a {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 10px;
}
.navbar-logo {
  height: 38px;
  width: auto;
  display: block;
  border-radius: 4px;
  mix-blend-mode: multiply;
  background: transparent;
}
.navbar-menu { display: flex; gap: 4px; flex: 1; }
.nav-link {
  padding: 6px 14px;
  border-radius: var(--radius);
  color: rgba(255,255,255,.85);
  text-decoration: none;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-link:hover, .nav-link.active {
  background: rgba(255,255,255,.18);
  color: #fff;
}
.navbar-user { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.user-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.5);
}
.user-name { font-size: 13px; color: rgba(255,255,255,.9); }

/* ---- Main content ---- */
.main-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 24px 60px;
}

/* ---- Page header ---- */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.page-header h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--color-text);
}
.page-subtitle { color: var(--color-muted); font-size: 13px; margin-top: 2px; }
.breadcrumb {
  display: inline-block;
  color: var(--color-primary);
  text-decoration: none;
  font-size: 13px;
  margin-bottom: 4px;
}
.breadcrumb:hover { text-decoration: underline; }
.heading-badge {
  font-size: 14px;
  font-weight: 600;
  background: var(--color-primary-light);
  color: var(--color-primary);
  padding: 2px 10px;
  border-radius: 20px;
  vertical-align: middle;
  margin-left: 8px;
}
.header-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ---- Alerts ---- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: 13px;
}
.alert-success { background: var(--color-success-light); color: #14532d; border: 1px solid #bbf7d0; }
.alert-danger   { background: var(--color-danger-light);  color: #7f1d1d; border: 1px solid #fecaca; }
.alert ul { margin: 6px 0 0 16px; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid transparent;
  transition: all .15s;
  white-space: nowrap;
  line-height: 1;
}
.btn-primary  { background: var(--color-primary);  color: #fff; border-color: var(--color-primary); }
.btn-primary:hover { background: var(--color-primary-dark); border-color: var(--color-primary-dark); }
.btn-secondary { background: #fff; color: var(--color-primary); border-color: var(--color-border); }
.btn-secondary:hover { background: var(--color-primary-light); }
.btn-danger   { background: var(--color-danger);   color: #fff; border-color: var(--color-danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-outline  { background: transparent; color: #fff; border-color: rgba(255,255,255,.6); }
.btn-outline:hover { background: rgba(255,255,255,.15); }
.btn-ghost    { background: transparent; color: var(--color-muted); border-color: transparent; }
.btn-ghost:hover { background: var(--color-border); color: var(--color-text); }
.btn-xs   { padding: 2px 8px; font-size: 11px; }
.btn-sm   { padding: 5px 10px; font-size: 12px; }
.btn-omit { background: transparent; color: #6b7280; border-color: #d1d5db; }
.btn-omit:hover { background: #fef2f2; color: #b91c1c; border-color: #fca5a5; }
.btn-lg { padding: 10px 24px; font-size: 15px; }
.btn-google {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: #fff; color: #374151;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 600;
  width: 100%;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, box-shadow .15s;
  margin-bottom: 12px;
}
.btn-google:hover { background: #f9fafb; box-shadow: var(--shadow); }

/* ---- Badges ---- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
}
.badge-active   { background: var(--color-success-light); color: #166534; }
.badge-inactive { background: #f3f4f6; color: var(--color-muted); }
.badge-country  { background: var(--color-primary-light); color: var(--color-primary); }

/* ---- Filter bar ---- */
.filter-bar { margin-bottom: 20px; }
.search-form {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  flex-wrap: wrap;
}
/* filter-controls sits after search-group in DOM, but search-group
   uses order:-1 on desktop so it appears first (left) visually */
.filter-controls {
  display: flex;
  gap: 16px;
  align-items: flex-end;
}
.search-group {
  display: flex;
  gap: 8px;
  align-items: center;
  flex: 1;
  min-width: 260px;
  order: -1;
}
.search-input { flex: 1; }
.search-btn-mobile { display: none; }
.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.filter-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--color-muted);
}
.filter-dropdowns {
  display: flex;
  gap: 6px;
  align-items: center;
}
.filter-select { width: auto; font-size: 12px; padding: 6px 8px; }
.filter-checkbox-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
  color: var(--color-text);
}

/* ---- Country grouping ---- */
.country-section { margin-bottom: 28px; }
.country-heading {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--color-primary);
  padding: 0 2px 8px;
  border-bottom: 2px solid var(--color-primary-light);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.country-count {
  background: var(--color-primary-light);
  color: var(--color-primary);
  border-radius: 20px;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
}

/* ---- Table ---- */
.table-container {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  color: var(--color-muted);
  background: #f9fafb;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}
.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #f9fafb; }
.row-inactive { opacity: .65; }
.row-inactive:hover td { background: #f3f4f6; }
.link-strong { color: var(--color-primary); text-decoration: none; font-weight: 600; }
.link-strong:hover { text-decoration: underline; }
.ext-link { color: var(--color-muted); text-decoration: none; font-size: 12px; margin-left: 4px; }
.ext-link:hover { color: var(--color-primary); }
td.actions { white-space: nowrap; }
.actions-wrap { display: flex; gap: 6px; align-items: center; }
.link { color: var(--color-primary); }

/* ---- Empty state ---- */
.empty-state {
  text-align: center;
  padding: 64px 24px;
  color: var(--color-muted);
}
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state h2 { font-size: 18px; color: var(--color-text); margin-bottom: 8px; }
.empty-text { color: var(--color-muted); font-style: italic; }

/* ---- Detail cards ---- */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 20px;
}
.detail-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
}
.detail-card-full { grid-column: 1 / -1; }
.card-title {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--color-muted);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--color-border);
}
.detail-list { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; font-size: 13px; }
.detail-list dt { color: var(--color-muted); font-weight: 500; padding-top: 2px; }
.detail-list dd { color: var(--color-text); }
.prose { font-size: 13px; line-height: 1.7; white-space: pre-wrap; }

/* ---- Social list ---- */
.social-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.social-list li { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.platform-name { font-weight: 600; min-width: 80px; color: var(--color-muted); }

/* ---- Forms ---- */
.church-form { max-width: 900px; }
.form-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--color-muted);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--color-border);
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group-lg { grid-column: span 2; }
.form-group-full { grid-column: 1 / -1; }
.form-group-sm { max-width: 140px; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--color-muted); }
.required { color: var(--color-danger); }
.form-input, .form-select, .form-textarea {
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--color-text);
  background: #fff;
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(26, 86, 164, .12);
}
.input-error { border-color: var(--color-danger); }
.form-hint { font-size: 11px; color: var(--color-muted); }
.form-textarea { resize: vertical; min-height: 100px; }
.form-actions { display: flex; gap: 12px; align-items: center; margin-top: 8px; }
.input-group { display: flex; gap: 8px; }
.input-group .form-input { flex: 1; }

/* ---- Social rows ---- */
.social-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.social-platform { width: 180px; flex-shrink: 0; }
.social-url { flex: 1; }

/* ---- Platform list ---- */
.platform-list { list-style: none; }
.platform-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--color-border);
  font-size: 13px;
}
.platform-item:last-child { border-bottom: none; }
.inline-form { margin-bottom: 0; }

/* ---- Sector Tree ---- */
.sector-tree { display: flex; flex-direction: column; gap: 16px; }

.tree-ws-node {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
}
.tree-unassigned { opacity: .75; }

.tree-node-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
}
.tree-ws-header {
  background: var(--color-primary-light);
  border-bottom: 1px solid #bfdbfe;
}
.tree-gs-header { background: #f8fafc; border-bottom: 1px solid var(--color-border); }

.tree-icon { font-size: 14px; flex-shrink: 0; }
.tree-icon-ws      { color: var(--color-primary); }
.tree-icon-gs      { color: var(--color-warning); }
.tree-icon-church  { color: var(--color-muted); font-size: 12px; }
.tree-icon-unassigned { color: var(--color-muted); }

.tree-node-name {
  font-weight: 600;
  font-size: 14px;
  flex: 1;
}
.tree-node-meta {
  font-size: 12px;
  color: var(--color-muted);
  margin-right: 8px;
}
.tree-node-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-left: auto;
}

.tree-children { padding: 0 0 4px 0; }
.tree-gs-node { border-bottom: 1px solid var(--color-border); }
.tree-gs-node:last-child { border-bottom: none; }

.tree-connector {
  font-family: monospace;
  color: var(--color-border);
  font-size: 13px;
  margin-left: 20px;
  flex-shrink: 0;
}
.tree-connector-deep { margin-left: 56px; }

.tree-church-list { padding: 4px 0; }
.tree-church-node {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  font-size: 13px;
}
.tree-church-node:hover { background: var(--color-bg); }
.tree-church-direct { background: #fefce8; }

.tree-church-link { color: var(--color-primary); text-decoration: none; font-weight: 500; }
.tree-church-link:hover { text-decoration: underline; }
.tree-church-loc { color: var(--color-muted); font-size: 12px; }

/* ---- Dialog / Modal ---- */
.sector-dialog {
  border: none;
  border-radius: 10px;
  box-shadow: 0 8px 40px rgba(0,0,0,.22);
  padding: 28px 28px 20px;
  width: 100%;
  max-width: 440px;
  background: #fff;
}
.sector-dialog::backdrop {
  background: rgba(0,0,0,.4);
}
.dialog-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--color-text);
}
.dialog-subtitle {
  font-size: 13px;
  color: var(--color-muted);
  margin-top: -12px;
  margin-bottom: 14px;
}
.dialog-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
}

/* ---- Select + Add button row ---- */
.select-with-add { display: flex; gap: 8px; align-items: center; }
.select-with-add .form-select { flex: 1; }

/* ---- Misc ---- */
.section-hint { font-size: 12px; color: var(--color-muted); margin: -8px 0 14px; }
.link-muted { color: var(--color-muted); text-decoration: underline; }

/* ---- Login page ---- */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--color-primary) 0%, #1e40af 100%);
}
.login-card {
  background: #fff;
  border-radius: 12px;
  padding: 44px 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  text-align: center;
}
.login-logo { margin-bottom: 16px; }
.login-logo-img { height: 64px; width: auto; display: block; margin: 0 auto; }
.login-title { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.login-subtitle { color: var(--color-muted); font-size: 13px; margin-bottom: 28px; }
.login-note { font-size: 12px; color: var(--color-muted); margin-top: 12px; }

/* ---- Hamburger / Mobile nav ---- */
.nav-hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 8px;
  color: #fff;
  font-size: 22px;
  line-height: 1;
  border-radius: var(--radius);
  margin-left: auto;
  flex-shrink: 0;
}
.nav-hamburger:hover { background: rgba(255,255,255,.15); }

.mobile-nav {
  display: none;
  position: fixed;
  top: var(--navbar-h);
  left: 0; right: 0; bottom: 0;
  background: var(--color-primary-dark);
  z-index: 99;
  padding: 12px 16px 24px;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}
.mobile-nav.open { display: flex; }
.mobile-nav .nav-link {
  color: rgba(255,255,255,.9);
  padding: 13px 16px;
  border-radius: var(--radius);
  font-size: 16px;
  text-decoration: none;
  font-weight: 500;
}
.mobile-nav .nav-link:hover,
.mobile-nav .nav-link.active { background: rgba(255,255,255,.15); color: #fff; }
.mobile-nav-divider {
  border: none;
  border-top: 1px solid rgba(255,255,255,.18);
  margin: 10px 0;
}
.mobile-nav-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: rgba(255,255,255,.7);
  font-size: 14px;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  /* Navbar */
  .navbar { padding: 0 16px; gap: 10px; }
  .navbar-menu { display: none; }
  .navbar-user { display: none; }
  .nav-hamburger { display: flex; }

  /* Layout */
  .main-content { padding: 16px 14px 48px; }

  /* Page header */
  .page-header { flex-direction: column; gap: 10px; }
  .page-header h1 { font-size: 20px; }
  .header-actions { flex-wrap: wrap; }

  /* Tables: keep Name(1), Status(6), Actions(7) — hide 2-5 */
  .data-table th:nth-child(2), .data-table td:nth-child(2),
  .data-table th:nth-child(3), .data-table td:nth-child(3),
  .data-table th:nth-child(4), .data-table td:nth-child(4),
  .data-table th:nth-child(5), .data-table td:nth-child(5) { display: none; }
  .data-table th:nth-child(6), .data-table td:nth-child(6),
  .data-table th:nth-child(7), .data-table td:nth-child(7) { display: table-cell; }
  .data-table td { padding: 10px 10px; }
  /* Compact action buttons in table */
  .actions-wrap { gap: 4px; }
  .actions-wrap .btn-ghost { display: none; }

  /* Search / filter bar — mobile layout:
     Row 1: SEARCH BY | FILTERS | SORT BY (dropdowns with labels above)
     Row 2: [search input ............] [Search]
     Row 3: US Only  Clear               */
  .search-form { flex-direction: column; gap: 10px; }
  .filter-controls {
    order: -1;
    width: 100%;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
  }
  .filter-controls .filter-group { flex: 1; min-width: 80px; }
  .search-group { order: 0; min-width: unset; width: 100%; }
  .filter-group--us { order: 1; }
  .filter-label--us-spacer { display: none; }
  .search-btn-mobile { display: inline-flex; flex-shrink: 0; }
  .filter-dropdowns { flex-wrap: wrap; gap: 6px; }
  .filter-select { font-size: 13px; width: 100%; }

  /* Detail cards */
  .detail-grid { grid-template-columns: 1fr; }
  .detail-card-full { grid-column: 1; }
  .detail-list { grid-template-columns: 1fr; gap: 4px 0; }
  .detail-list dt { color: var(--color-text); font-weight: 600; padding-top: 10px; }
  .detail-list dd { padding-bottom: 4px; border-bottom: 1px solid var(--color-border); }
  .detail-list dd:last-child { border-bottom: none; }

  /* Forms */
  .form-group-lg { grid-column: 1; }
  .form-group-full { grid-column: 1; }
  .church-form { max-width: 100%; }
  .form-actions { flex-wrap: wrap; }
  .input-group { flex-direction: column; }

  /* Social rows */
  .social-row { flex-wrap: wrap; gap: 6px; }
  .social-platform { width: 100%; }
  .social-url { width: 100%; }

  /* Tree: hide edit/delete actions on mobile — read-only view */
  .tree-node-actions { display: none; }
  .tree-node-header { flex-wrap: wrap; row-gap: 4px; padding: 10px 12px; }
  .tree-node-meta { order: 3; flex: 1 0 100%; margin: 0; padding-left: 24px; }
  .tree-church-row { flex-wrap: wrap; padding: 6px 12px; }
  .tree-church-loc { flex: 1 0 100%; padding-left: 4px; font-size: 11px; }

  /* Login */
  .login-card { padding: 32px 20px; margin: 16px; max-width: 100%; }

  /* Dialog */
  .sector-dialog { padding: 20px 16px 16px; max-width: calc(100vw - 32px); }
  .dialog-actions { flex-direction: column-reverse; }
  .dialog-actions .btn { width: 100%; justify-content: center; }
}

/* ============================================================
   Workspace Sync page
   ============================================================ */

/* ── Topbar (title row + menu bar) ─────────────────────────── */
.ws-topbar {
  margin-bottom: 20px;
}
.ws-topbar-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}
.ws-topbar-heading {
  display: flex;
  align-items: baseline;
  gap: 12px;
}
.ws-topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ── Menu bar (tab buttons + checkboxes) ────────────────────── */
.ws-menu-bar, .ws-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
  padding-bottom: 4px;
  border-top: 1px solid var(--color-border);
  padding-top: 12px;
}

/* Checkbox labels in menu bar */
.ws-check-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: .84rem;
  color: var(--color-muted);
  cursor: pointer;
  padding: 6px 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  white-space: nowrap;
  transition: background .12s, color .12s;
}
.ws-check-label:hover {
  background: #f1f5f9;
  color: var(--color-text);
  border-color: var(--color-border);
}
.ws-check-label input[type="checkbox"] {
  accent-color: var(--color-primary);
  cursor: pointer;
}

/* ── Collapsible sections ──────────────────────────────────── */
.ws-section {
  margin-bottom: 16px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  overflow: hidden;
}
.ws-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  cursor: pointer;
  background: #f8fafc;
  border-bottom: 1px solid var(--color-border);
  user-select: none;
  transition: background .12s;
}
.ws-section-header:hover {
  background: #f1f5f9;
}
.ws-section-arrow {
  font-size: .78rem;
  width: 1em;
  display: inline-block;
  color: var(--color-muted);
  flex-shrink: 0;
  transition: transform .12s;
}
.ws-section-title {
  font-weight: 600;
  font-size: .95rem;
  color: var(--color-text);
}
.ws-section-body {
  padding: 16px;
}
.ws-section-body.ws-collapsed {
  display: none;
}

/* Tab bar (old name kept for compatibility) */
.ws-tab-btn {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 8px 16px;
  font-size: .875rem;
  font-weight: 500;
  color: var(--color-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: background .12s, color .12s, border-color .12s, box-shadow .12s;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
  white-space: nowrap;
}
.ws-tab-btn:hover {
  background: #f1f5f9;
  color: var(--color-text);
  border-color: #94a3b8;
}
.ws-tab-btn.active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
  box-shadow: 0 2px 6px rgba(37,99,235,.25);
}
.ws-tab-btn.active .ws-badge {
  background: rgba(255,255,255,.25);
  color: #fff;
}
/* "Show all" button variant */
.ws-tab-btn-all {
  background: #fff;
  border: 1px dashed var(--color-border);
}
.ws-tab-btn-all:hover {
  background: #f8fafc;
  border-color: #94a3b8;
}
.ws-tab-btn-all.active {
  background: #334155;
  color: #fff;
  border-color: #334155;
  border-style: solid;
}
/* Separator between tab group and utility buttons */
.ws-tab-sep {
  display: inline-block;
  width: 1px;
  height: 28px;
  background: var(--color-border);
  margin: 0 4px;
  align-self: center;
}
/* Utility toggle buttons (Show Omitted / Show Ignored) */
.ws-tab-util {
  font-size: .78rem;
  color: var(--color-muted);
  border-style: dashed;
}
.ws-tab-util:hover {
  color: var(--color-text);
  border-color: #94a3b8;
  border-style: solid;
}
.ws-tab-util.active {
  background: #1e3a5f;
  color: #fff;
  border-color: #1e3a5f;
  border-style: solid;
  box-shadow: 0 2px 6px rgba(30,58,95,.3);
}

.ws-tab-panel          { display: none; }
.ws-tab-panel.active   { display: block; }

/* ── Summary pills ─────────────────────────────────────────── */
.ws-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
}
.ws-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .78rem;
  font-weight: 600;
}
.ws-pill-green  { background: var(--color-success-light); color: var(--color-success); }
.ws-pill-yellow { background: #fef9c3; color: #854d0e; }
.ws-pill-gray   { background: #f3f4f6; color: var(--color-muted); }
.ws-pill-muted  { background: #f3f4f6; color: #9ca3af; }
.ws-pill-mapped { background: #ede9fe; color: #5b21b6; }
.ws-total       { font-size: .82rem; color: var(--color-muted); margin-left: 4px; }

/* ── Badges on tab buttons ─────────────────────────────────── */
.ws-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: .72rem;
  font-weight: 600;
  line-height: 1.4;
}
.ws-badge-warn   { background: #fef3c7; color: #92400e; }
.ws-badge-info   { background: #dbeafe; color: #1e40af; }
.ws-badge-mapped { background: #ede9fe; color: #5b21b6; }

/* ── Comparison table ──────────────────────────────────────── */
.ws-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
.ws-table th {
  text-align: left;
  padding: 8px 12px;
  background: #f8fafc;
  border-bottom: 2px solid var(--color-border);
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--color-muted);
  font-weight: 600;
}
.ws-table td {
  padding: 10px 12px;
  vertical-align: top;
  border-bottom: 1px solid var(--color-border);
}
/* Zebra striping — !important on TD forces the color regardless of any
   other rule or browser default that might paint cells a solid background */
.ws-table tbody tr:nth-child(odd)  td { background: #ffffff !important; }
.ws-table tbody tr:nth-child(even) td { background: #eeeeee !important; }

/* Row colour accents */
.ws-row-matched  td:first-child { border-left: 3px solid var(--color-success); }
.ws-row-manual   td:first-child { border-left: 3px solid #7c3aed; }
.ws-row-gw-only  td:first-child { border-left: 3px solid #f59e0b; }
.ws-row-db-only  td:first-child { border-left: 3px solid #93c5fd; }
.ws-row-ignored  td:first-child { border-left: 3px solid #d1d5db; }
.ws-row-ignored  { opacity: .65; }

/* Status badges */
.ws-status {
  display: inline-block;
  white-space: nowrap;
  font-size: .8rem;
  font-weight: 600;
}
.ws-status-match   { color: var(--color-success); }
.ws-status-manual  { color: #5b21b6; }
.ws-status-gw      { color: #b45309; }
.ws-status-db      { color: #1d4ed8; }
.ws-status-ignored { color: var(--color-muted); }

/* Cell content */
.ws-name          { font-weight: 500; display: block; }
.ws-leaders       { font-size: .8rem; color: var(--color-muted); margin-top: 2px; }
.ws-leaders-diff  { color: #b45309; font-style: italic; }
.ws-leaders-empty { color: #d1d5db; font-style: italic; }
.ws-leaders-flag         { font-size: .72rem; color: #b45309; margin-top: 3px; font-weight: 500; }
.ws-leaders-flag-info    { color: #6b7280; }
.ws-leaders-flag-ignored { color: #9ca3af; font-style: italic; font-weight: 400; }
.ws-row-needs-action td:first-child { border-left-color: #f59e0b !important; }

/* Omitted tbody: hidden by default, shown via body.ws-show-omitted */
.ws-omitted-tbody                          { display: none; }
body.ws-show-omitted .ws-omitted-tbody     { display: table-row-group; }

/* Diff-ignored rows: hidden by default, shown via body.ws-show-ignored */
.ws-row-diff-ignored                       { display: none; }
body.ws-show-ignored .ws-row-diff-ignored  { display: table-row; }
.ws-path          { font-size: .72rem; color: #9ca3af; margin-top: 2px; font-family: monospace; }
.ws-ignored-name  { text-decoration: line-through; }

/* Action cells */
.ws-actions     { display: flex; flex-wrap: wrap; gap: 6px; align-items: flex-start; }

/* ── Regions collapsible ───────────────────────────────────── */
.ws-regions-panel  { margin-top: 24px; border: 1px solid var(--color-border); border-radius: var(--radius); padding: 12px 16px; }
.ws-regions-summary { cursor: pointer; font-weight: 500; font-size: .9rem; color: var(--color-muted); user-select: none; }
.ws-regions-summary:hover { color: var(--color-text); }

/* ── Manual mapping form ───────────────────────────────────── */
.ws-map-details summary.ws-map-summary {
  cursor: pointer;
  font-size: .78rem;
  color: #5b21b6;
  font-weight: 500;
  user-select: none;
  display: inline-block;
  margin-top: 2px;
}
.ws-map-details summary.ws-map-summary:hover { text-decoration: underline; }
.ws-map-form {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}
.ws-map-select {
  font-size: .8rem;
  padding: 3px 6px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  max-width: 220px;
  background: #fff;
}
option.ws-opt-matched { color: var(--color-muted); }
.ws-db-only-hint { color: #9ca3af; font-style: italic; }

/* Mobile */
@media (max-width: 640px) {
  .ws-table th:nth-child(3),
  .ws-table td:nth-child(3) { display: none; }
  .ws-tab-btn { padding: 8px 12px; font-size: .82rem; }
  .ws-actions { flex-direction: column; }
}

/* ── Contact lookup button ────────────────────────────────────────────── */
.btn-lookup { background: transparent; color: #0369a1; border-color: #bae6fd; font-size:.72rem; }
.btn-lookup:hover { background: #f0f9ff; border-color: #7dd3fc; }

/* ── Contact lookup / Help — native <dialog> ──────────────────────────── */
/* inset:0 + margin:auto is the bullet-proof centering technique for
   position:fixed elements. The browser's UA stylesheet uses the same trick
   for <dialog> but CSS resets (especially * { margin:0 }) can undo it.
   Declaring both here overrides any reset while keeping native dialog z-index. */
#ws-contact-modal {
    position: fixed;
    inset: 0;
    margin: auto;
    padding: 0;
    border: none;
    border-radius: 10px;
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
    width: min(520px, calc(100vw - 32px));
    max-height: min(88vh, 700px);
    overflow: hidden;
}
#ws-help-dialog {
    position: fixed;
    inset: 0;
    margin: auto;
    padding: 0;
    border: none;
    border-radius: 10px;
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
    width: min(560px, calc(100vw - 32px));
    max-height: min(80vh, 600px);
    overflow: hidden;
}
#ws-contact-modal[open] {
    display: flex;
    flex-direction: column;
    animation: ws-dialog-in .18s cubic-bezier(.4,0,.2,1) both;
}
#ws-help-dialog[open] {
    display: flex;
    flex-direction: column;
    animation: ws-dialog-in .18s cubic-bezier(.4,0,.2,1) both;
}
/* ::backdrop cannot be grouped in a comma selector in some browsers — list separately */
#ws-contact-modal::backdrop {
    background: rgba(15,23,42,.5);
}
#ws-help-dialog::backdrop {
    background: rgba(15,23,42,.5);
}
@keyframes ws-dialog-in {
    from { opacity: 0; transform: scale(.96) translateY(-6px); }
    to   { opacity: 1; transform: scale(1)  translateY(0); }
}
.ws-modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px 14px;
    border-bottom: 1px solid var(--color-border);
}
.ws-modal-title { margin: 0; font-size: 1rem; font-weight: 600; color: var(--color-text); }
.ws-modal-close {
    background: none; border: none; cursor: pointer; padding: 4px 8px;
    font-size: 1rem; color: var(--color-muted); border-radius: 4px; line-height:1;
}
.ws-modal-close:hover { background: #f3f4f6; color: var(--color-text); }
.ws-modal-body {
    padding: 16px 20px; overflow-y: auto; flex: 1;
}
.ws-modal-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--color-border);
    display: flex; justify-content: flex-end; gap: 8px;
    background: #fafafa;
}
.ws-modal-section-header {
    font-size: .72rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: .06em; color: var(--color-muted);
    margin-bottom: 8px;
}
.ws-modal-hint { font-size: .8rem; color: #9ca3af; margin: 0 0 10px; }
.ws-modal-loading { font-size: .85rem; color: var(--color-muted); font-style: italic; margin: 0; }
.ws-modal-notice {
    font-size: .82rem; padding: 8px 12px; border-radius: 6px;
    background: #f3f4f6; color: var(--color-muted);
}
.ws-modal-notice-warn { background: #fef9c3; color: #854d0e; }
.ws-modal-field { margin-bottom: 12px; }
.ws-modal-field label { display: block; font-size: .82rem; font-weight: 500; margin-bottom: 4px; color: var(--color-text); }
.ws-modal-form-flash { animation: ws-flash .5s ease; }
@keyframes ws-flash { 0%,100%{background:transparent} 30%{background:#dcfce7} }

/* Suggestion cards */
.ws-suggestion-card {
    border: 1px solid var(--color-border);
    border-radius: 6px; padding: 10px 12px; margin-bottom: 8px;
    cursor: pointer; transition: background .15s, border-color .15s;
}
.ws-suggestion-card:hover { background: #f0f9ff; border-color: #7dd3fc; }
.ws-suggestion-name { font-weight: 600; font-size: .9rem; color: var(--color-text); }
.ws-suggestion-meta { font-size: .78rem; color: var(--color-muted); margin-top: 3px; }
.ws-suggestion-hint { font-size: .72rem; color: #93c5fd; margin-top: 4px; }

/* Leaders GW copy box (in contact dialog) */
.ws-modal-leaders-gw {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 6px;
    padding: 8px 10px;
    font-size: .82rem;
    color: #0369a1;
    margin-bottom: 6px;
}
.ws-modal-leaders-gw span { flex: 1; }
.ws-modal-leaders-gw button {
    flex-shrink: 0;
    background: #0369a1;
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 3px 9px;
    font-size: .75rem;
    cursor: pointer;
    white-space: nowrap;
}
.ws-modal-leaders-gw button:hover { background: #0284c7; }

/* Each suggestion card phone/email row */
.ws-suggestion-contacts {
    margin-top: 6px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.ws-suggestion-use-btn {
    font-size: .72rem;
    padding: 3px 8px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 4px;
    cursor: pointer;
    color: #1d4ed8;
    transition: background .12s;
}
.ws-suggestion-use-btn:hover { background: #dbeafe; }
