/* main.css — Complete dashboard stylesheet */

/* ===== CSS Variables ===== */
:root {
  --gold: #c8a84e;
  --gold-light: #f5edda;
  --gold-dark: #8a6d2b;
  --navy: #1a1f3a;
  --navy-light: #2d3561;
  --cream: #faf8f3;
  --warm-gray: #6b6560;
  --text: #2c2a27;
  --text-light: #7a7672;
  --blue-cta: #2e5d8a;
  --blue-cta-hover: #1e4a73;
  --border: #e8e4de;
  --white: #ffffff;
  --green: #2d7a4f;
  --green-bg: #e8f5ee;
  --yellow: #b8860b;
  --yellow-bg: #fef9e7;
  --red: #c0392b;
  --red-bg: #fdecea;
  --orange: #d35400;
  --orange-bg: #fef0e5;
}

/* ===== Reset ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ===== Body ===== */
body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--cream);
  color: var(--text);
  line-height: 1.5;
  max-width: 2200px;
  margin: 0 auto;
  min-height: 100vh;
}

/* ===== Header ===== */
.header {
  background: var(--navy);
  color: var(--white);
  padding: 16px 24px;
}

.header-top {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.header-top h1 {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
  white-space: nowrap;
}

.header-top p {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.6);
  margin: 0;
}

.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.project-select {
  background: var(--navy-light);
  color: var(--white);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  padding: 6px 12px;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s ease;
}

.project-select:focus {
  border-color: var(--gold);
}

.settings-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--white);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.settings-btn:hover {
  background: var(--navy-light);
  border-color: var(--gold);
}

/* ===== Nav Tabs ===== */
.nav-tabs {
  display: flex;
  gap: 0;
  background: var(--white);
  border-bottom: 2px solid var(--border);
  padding: 0 24px;
  overflow-x: auto;
}

.nav-tab {
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-light);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: color 0.2s ease, border-color 0.2s ease;
  user-select: none;
  text-decoration: none;
}

.nav-tab:hover {
  color: var(--text);
}

.nav-tab.active {
  color: var(--gold-dark);
  border-bottom-color: var(--gold);
  font-weight: 600;
}

/* ===== Tab Content ===== */
.tab-content {
  display: none;
  padding: 24px;
}

.tab-content.active {
  display: block;
}

/* ===== Stats Bar ===== */
.stats-bar {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 20px;
  min-width: 140px;
  flex: 1;
  transition: box-shadow 0.2s ease;
}

.stat-card:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.stat-card .num {
  font-size: 28px;
  font-weight: 700;
  color: var(--navy);
  line-height: 1.2;
}

.stat-card .label {
  font-size: 12px;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

/* ===== Controls Bar ===== */
.controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.search-box {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 14px;
  background: var(--white);
  outline: none;
  min-width: 220px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-box:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(200, 168, 78, 0.15);
}

.controls select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  background: var(--white);
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s ease;
}

.controls select:focus {
  border-color: var(--gold);
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--blue-cta);
  color: var(--white);
  border-color: var(--blue-cta);
}

.btn-primary:hover:not(:disabled) {
  background: var(--blue-cta-hover);
  border-color: var(--blue-cta-hover);
}

.btn-secondary {
  background: var(--cream);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--white);
  border-color: var(--warm-gray);
}

.btn-gold {
  background: var(--gold);
  color: var(--white);
  border-color: var(--gold);
}

.btn-gold:hover:not(:disabled) {
  background: var(--gold-dark);
  border-color: var(--gold-dark);
}

.btn-danger {
  background: var(--red);
  color: var(--white);
  border-color: var(--red);
}

.btn-danger:hover:not(:disabled) {
  background: #a93226;
  border-color: #a93226;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

/* ===== Hub Pills ===== */
.hub-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.hub-pill {
  display: inline-block;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--white);
  color: var(--text-light);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
  white-space: nowrap;
  user-select: none;
}

.hub-pill:hover {
  border-color: var(--gold);
  color: var(--text);
}

.hub-pill.active {
  background: var(--gold);
  color: var(--white);
  border-color: var(--gold);
}

/* ===== Table ===== */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--white);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  font-size: 13px;
}

thead {
  background: var(--cream);
}

thead th {
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--border);
  user-select: none;
  white-space: nowrap;
}

th[data-sort] {
  cursor: pointer;
  transition: color 0.2s ease;
}

th[data-sort]:hover {
  color: var(--text);
}

th[data-sort]::after {
  content: ' \2195';
  font-size: 10px;
  opacity: 0.4;
}

th[data-sort].sort-asc::after {
  content: ' \2191';
  opacity: 1;
  color: var(--gold-dark);
}

th[data-sort].sort-desc::after {
  content: ' \2193';
  opacity: 1;
  color: var(--gold-dark);
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.15s ease;
}

tbody tr:nth-child(even) {
  background: rgba(250, 248, 243, 0.5);
}

tbody tr:hover {
  background: var(--gold-light);
}

tbody td {
  padding: 10px 12px;
  vertical-align: middle;
}

.cell-title {
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
  color: var(--navy);
  cursor: pointer;
}

.cell-title:hover {
  color: var(--blue-cta);
  text-decoration: underline;
}

.cell-hub {
  font-size: 12px;
  color: var(--warm-gray);
}

.cell-check {
  width: 40px;
  text-align: center;
}

.cell-words {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text-light);
}

.cell-desc {
  max-width: 250px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: var(--text-light);
}

/* ===== Badges ===== */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  line-height: 1.4;
}

.badge-ready {
  background: var(--green-bg);
  color: var(--green);
}

.badge-review {
  background: var(--yellow-bg);
  color: var(--yellow);
}

.badge-missing {
  background: var(--red-bg);
  color: var(--red);
}

/* ===== Score Badges ===== */
.score-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  min-width: 32px;
  text-align: center;
}

.score-good {
  background: var(--green-bg);
  color: var(--green);
}

.score-ok {
  background: var(--yellow-bg);
  color: var(--yellow);
}

.score-bad {
  background: var(--red-bg);
  color: var(--red);
}

.score-none {
  color: var(--text-light);
  background: transparent;
}

/* ===== Hub View ===== */
.hub-group {
  margin-bottom: 24px;
}

.hub-group-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px 8px 0 0;
  font-weight: 600;
  font-size: 15px;
  color: var(--navy);
  cursor: pointer;
  transition: background 0.2s ease;
}

.hub-group-header:hover {
  background: var(--gold-light);
}

.hub-group-header .hub-count {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-light);
  background: var(--cream);
  padding: 2px 8px;
  border-radius: 10px;
}

.hub-articles {
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 8px 8px;
  overflow: hidden;
}

/* Collapsed state */
.hub-group.collapsed .hub-articles {
  display: none;
}

.hub-group.collapsed .hub-group-header {
  border-radius: 8px;
}

/* Toggle icon */
.hub-toggle-icon {
  font-size: 10px;
  color: var(--text-light);
  transition: transform 0.2s ease;
  display: inline-block;
}

.hub-group.collapsed .hub-toggle-icon {
  transform: rotate(-90deg);
}

/* Hub article row */
.hub-article-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  transition: background 0.15s ease;
}

.hub-article-row:last-child {
  border-bottom: none;
}

.hub-article-row:hover {
  background: var(--gold-light);
}

.hub-article-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hub-article-title a:hover {
  color: var(--blue-cta) !important;
  text-decoration: underline !important;
}

.hub-article-words {
  font-size: 12px;
  color: var(--text-light);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  min-width: 80px;
  text-align: right;
}

.hub-article-status {
  white-space: nowrap;
}

.hub-article-scores {
  display: flex;
  gap: 4px;
  white-space: nowrap;
}

/* ===== Issues View ===== */
.issue-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 8px;
  transition: background 0.2s ease;
}

.issue-row:hover {
  background: var(--cream);
}

.issue-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.issue-badge.critical {
  background: var(--red-bg);
  color: var(--red);
}

.issue-badge.warning {
  background: var(--orange-bg);
  color: var(--orange);
}

.issue-badge.info {
  background: var(--gold-light);
  color: var(--gold-dark);
}

/* ===== Editor Overlay ===== */
.editor-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  background: var(--white);
  flex-direction: row;
}

.editor-overlay.open {
  display: flex;
}

.editor-main {
  flex: 0 0 65%;
  overflow-y: auto;
  padding: 24px;
  border-right: 1px solid var(--border);
  position: relative;
}

.editor-sidebar {
  flex: 0 0 35%;
  overflow-y: auto;
  padding: 24px;
  background: var(--cream);
}

.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.editor-toolbar .sep {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 4px;
}

/* ===== Editor Mode Toggle ===== */
.editor-mode-toggle {
  display: flex;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  margin-right: auto;
}

.editor-mode-btn {
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 500;
  background: var(--white);
  border: none;
  border-right: 1px solid var(--border);
  color: var(--text-light);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.editor-mode-btn:last-child {
  border-right: none;
}

.editor-mode-btn:hover {
  background: var(--cream);
  color: var(--navy);
}

.editor-mode-btn.active {
  background: var(--navy);
  color: var(--white);
}

/* ===== WYSIWYG Toolbar ===== */
.wysiwyg-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 8px 16px;
  background: var(--cream);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.wysiwyg-toolbar button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.wysiwyg-toolbar button:hover {
  background: var(--white);
  border-color: var(--border);
}

.wysiwyg-toolbar button.active {
  background: var(--gold);
  color: var(--white);
  border-color: var(--gold);
}

.wysiwyg-toolbar .sep {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 6px;
}

/* ===== WYSIWYG Content Area ===== */
.wysiwyg-content {
  width: 100%;
  min-height: 500px;
  max-height: calc(100vh - 350px);
  overflow-y: auto;
  padding: 32px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 0 0 6px 6px;
  font-family: 'Crimson Pro', 'Georgia', serif;
  font-size: 18px;
  line-height: 1.8;
  color: var(--text);
  outline: none;
  cursor: text;
}

.wysiwyg-content:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(200, 168, 78, 0.1);
}

.wysiwyg-content h1 {
  font-family: 'DM Sans', sans-serif;
  font-size: 28px;
  font-weight: 700;
  color: var(--navy);
  margin: 0 0 16px 0;
  line-height: 1.3;
}

.wysiwyg-content h2 {
  font-family: 'DM Sans', sans-serif;
  font-size: 22px;
  font-weight: 600;
  color: var(--navy);
  margin: 28px 0 12px 0;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--gold);
  line-height: 1.3;
}

.wysiwyg-content h3 {
  font-family: 'DM Sans', sans-serif;
  font-size: 18px;
  font-weight: 600;
  color: var(--navy);
  margin: 20px 0 8px 0;
  line-height: 1.4;
}

.wysiwyg-content p {
  margin: 0 0 16px 0;
}

.wysiwyg-content a {
  color: var(--blue-cta);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.wysiwyg-content a:hover {
  color: var(--gold);
}

.wysiwyg-content blockquote {
  margin: 16px 0;
  padding: 12px 20px;
  border-left: 4px solid var(--gold);
  background: var(--cream);
  font-style: italic;
  color: var(--text-light);
}

.wysiwyg-content ul,
.wysiwyg-content ol {
  margin: 0 0 16px 0;
  padding-left: 24px;
}

.wysiwyg-content li {
  margin-bottom: 6px;
}

.wysiwyg-content img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
}

.wysiwyg-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
}

.wysiwyg-content table td,
.wysiwyg-content table th {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}

.wysiwyg-content [dir="rtl"] {
  text-align: right;
  font-family: 'SBL Hebrew', 'Ezra SIL', 'David', serif;
}

/* ===== Edit Fields ===== */
.edit-field {
  margin-bottom: 16px;
}

.edit-field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.edit-field input,
.edit-field textarea,
.edit-field select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 14px;
  background: var(--white);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.edit-field input:focus,
.edit-field textarea:focus,
.edit-field select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(200, 168, 78, 0.15);
}

.edit-field textarea {
  min-height: 80px;
  resize: vertical;
}

/* ===== Detail Section (sidebar) ===== */
.detail-section {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.detail-section:last-child {
  border-bottom: none;
}

.detail-section h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

/* ===== Outline Items ===== */
.outline-item {
  padding: 6px 0;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  transition: color 0.2s ease;
}

.outline-item:hover {
  color: var(--blue-cta);
}

.outline-item::before {
  content: '\2022';
  color: var(--gold);
  margin-right: 8px;
}

/* ===== Modal Overlay ===== */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.5);
  align-items: center;
  justify-content: center;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: var(--white);
  border-radius: 12px;
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  padding: 28px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
}

.modal h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 16px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* ===== Toast Notifications ===== */
#toastContainer {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 300;
  pointer-events: none;
}

.toast {
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--white);
  background: var(--navy);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  pointer-events: auto;
  transform: translateX(120%);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  max-width: 380px;
}

.toast.show {
  transform: translateX(0);
  opacity: 1;
}

.toast-success {
  background: var(--green);
}

.toast-error {
  background: var(--red);
}

.toast-info {
  background: var(--navy);
}

.toast-saving {
  background: var(--gold-dark);
}

/* ===== Upload Zone ===== */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 40px 24px;
  text-align: center;
  color: var(--text-light);
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--gold);
  background: var(--gold-light);
}

/* ===== Progress Bar ===== */
.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--gold);
  border-radius: 4px;
  transition: width 0.4s ease;
}

/* ===== Upload File Preview ===== */
.upload-zone.has-files {
  padding: 16px 24px;
  text-align: left;
}

/* ===== Plan Tab ===== */
.plan-filter-btn {
  border-color: var(--border);
  background: var(--white);
  color: var(--text-light);
}

.plan-filter-btn:hover:not(.btn-primary) {
  background: var(--white);
  border-color: var(--warm-gray);
}

.plan-filter-btn.btn-primary {
  background: var(--blue-cta);
  color: var(--white);
  border-color: var(--blue-cta);
}

.plan-row td {
  transition: background 0.15s ease;
}

#planTable {
  margin-top: 0;
}

#planTable tbody tr:hover td {
  filter: brightness(0.97);
}

/* ===== Audit Result Formatting ===== */
.audit-result-formatted h3,
.audit-result-formatted h4 {
  font-family: 'Crimson Pro', serif;
}
.audit-result-formatted ul {
  list-style: disc;
  padding-left: 20px;
}
.audit-result-formatted li {
  margin: 3px 0;
  line-height: 1.5;
}
.audit-result-formatted strong {
  color: var(--navy);
}

/* ===== RTL Support ===== */
[dir="rtl"] {
  direction: rtl;
  text-align: right;
  font-family: 'Crimson Pro', 'David Libre', serif;
}

[dir="rtl"] .cell-title {
  text-align: right;
}

/* ===== Responsive: 1400px ===== */
@media (max-width: 1400px) {
  .stats-bar {
    gap: 12px;
  }

  .stat-card {
    min-width: 120px;
    padding: 12px 16px;
  }

  .stat-card .num {
    font-size: 24px;
  }

  .editor-main {
    flex: 0 0 60%;
  }

  .editor-sidebar {
    flex: 0 0 40%;
  }
}

/* ===== Responsive: 1024px ===== */
@media (max-width: 1024px) {
  .header-top {
    flex-wrap: wrap;
  }

  .controls {
    flex-wrap: wrap;
  }

  .search-box {
    min-width: 180px;
    flex: 1;
  }

  .editor-overlay.open {
    flex-direction: column;
  }

  .editor-main {
    flex: 1;
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 60vh;
    overflow-y: auto;
  }

  .editor-sidebar {
    flex: 0 0 auto;
    max-height: 40vh;
  }

  .cell-title {
    max-width: 200px;
  }
}

/* ===== Responsive: 768px ===== */
@media (max-width: 768px) {
  .tab-content {
    padding: 16px;
  }

  .header {
    padding: 12px 16px;
  }

  .nav-tabs {
    padding: 0 16px;
  }

  .nav-tab {
    padding: 10px 14px;
    font-size: 13px;
  }

  .stats-bar {
    flex-direction: column;
  }

  .stat-card {
    min-width: unset;
  }

  .controls {
    flex-direction: column;
    align-items: stretch;
  }

  .search-box {
    min-width: unset;
    width: 100%;
  }

  table {
    font-size: 12px;
  }

  thead th,
  tbody td {
    padding: 8px 8px;
  }

  .cell-title {
    max-width: 150px;
  }

  .cell-desc {
    display: none;
  }

  .editor-main,
  .editor-sidebar {
    padding: 16px;
  }

  .wysiwyg-content {
    min-height: 300px;
    max-height: calc(100vh - 280px);
  }

  .modal {
    width: 95%;
    padding: 20px;
  }

  .hub-pills {
    overflow-x: auto;
    flex-wrap: nowrap;
  }
}

/* ===== Focus Visible ===== */
:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

button:focus-visible,
.btn:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(200, 168, 78, 0.2);
}

/* ===== Loading Spinner ===== */
.loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-light);
  font-size: 14px;
  gap: 12px;
}

.loading-spinner::before {
  content: '';
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
  font-size: 14px;
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.3;
}

/* ===== Editor HTML Textarea ===== */
.html-editor-area {
  width: 100%;
  min-height: 500px;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.6;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--white);
  color: var(--text);
  resize: vertical;
  tab-size: 2;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.html-editor-area:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(200, 168, 78, 0.15);
  outline: none;
}

/* ===== Editor Close Button ===== */
.editor-close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-light);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  z-index: 10;
}

.editor-close-btn:hover {
  background: var(--red-bg);
  color: var(--red);
  border-color: var(--red);
}

/* ===== Editor Header ===== */
.editor-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.editor-header h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--navy);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== Dirty Indicator ===== */
.dirty-indicator {
  display: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
  flex-shrink: 0;
}

.editor-overlay.dirty .dirty-indicator {
  display: block;
}

/* ===== Confirm Dialog ===== */
.confirm-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 500;
  background: rgba(0, 0, 0, 0.5);
  align-items: center;
  justify-content: center;
}

.confirm-overlay.open {
  display: flex;
}

.confirm-dialog {
  background: var(--white);
  border-radius: 12px;
  max-width: 420px;
  width: 90%;
  padding: 28px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.25);
}

.confirm-dialog p {
  font-size: 14px;
  color: var(--text);
  margin-bottom: 20px;
  line-height: 1.6;
}

.confirm-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--warm-gray);
}

/* ===== Audit Progress ===== */
.audit-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
}

.audit-progress .progress-bar {
  flex: 1;
}

.audit-progress .progress-text {
  font-size: 12px;
  color: var(--text-light);
  white-space: nowrap;
  min-width: 80px;
}

/* ===== View Toggle ===== */
.view-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.view-toggle-btn {
  padding: 6px 14px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  background: var(--white);
  border: none;
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.2s ease;
}

.view-toggle-btn + .view-toggle-btn {
  border-left: 1px solid var(--border);
}

.view-toggle-btn.active {
  background: var(--navy);
  color: var(--white);
}

.view-toggle-btn:hover:not(.active) {
  background: var(--cream);
  color: var(--text);
}

/* ===== Sidebar Scores Grid ===== */
.scores-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.score-card {
  text-align: center;
  padding: 10px 8px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.score-card .score-value {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
}

.score-card .score-label {
  font-size: 10px;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

/* ===== Sidebar Info Grid ===== */
.info-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 12px;
  font-size: 13px;
}

.info-grid dt {
  color: var(--text-light);
  font-weight: 500;
}

.info-grid dd {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== Link List ===== */
.link-list {
  list-style: none;
  padding: 0;
}

.link-list li {
  padding: 4px 0;
  font-size: 12px;
}

.link-list li a {
  color: var(--blue-cta);
  text-decoration: none;
}

.link-list li a:hover {
  text-decoration: underline;
}

/* ===== Bulk Select ===== */
.bulk-bar {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--gold-light);
  border: 1px solid var(--gold);
  border-radius: 6px;
  margin-bottom: 12px;
  font-size: 13px;
  font-weight: 500;
}

.bulk-bar.visible {
  display: flex;
}

.bulk-bar .bulk-count {
  font-weight: 700;
  color: var(--gold-dark);
}

/* ===== Print ===== */
@media print {
  .header, .nav-tabs, .controls, .stats-bar,
  .editor-toolbar, .editor-sidebar, .btn,
  #toastContainer { display: none !important; }

  .tab-content { display: block !important; padding: 0; }
  .editor-overlay.open { position: static; }
  .editor-main { flex: 1; border: none; padding: 0; }

  table { font-size: 11px; }
  .modal-overlay { display: none !important; }
}
