/* ═══════════════════════════════════════════
   HyperChicken Theme System
   Light / Dark / Auto
   ═══════════════════════════════════════════ */

:root,
[data-theme="light"] {
  --hc-bg-primary: #ffffff;
  --hc-bg-secondary: #f7f5f0;
  --hc-bg-tertiary: #f0ede6;
  --hc-bg-page: #faf8f4;
  --hc-bg-card: #ffffff;
  --hc-bg-input: #ffffff;
  --hc-bg-hover: #f0ede6;
  --hc-bg-sidebar: #faf8f4;
  --hc-bg-modal-overlay: rgba(0, 0, 0, 0.4);

  --hc-text-primary: #1a1a1a;
  --hc-text-secondary: #5a5a5a;
  --hc-text-tertiary: #8a8a8a;
  --hc-text-inverse: #ffffff;

  --hc-accent: #3b5998;
  --hc-accent-hover: #2d4373;
  --hc-accent-light: #e8edf5;
  --hc-accent-text: #3b5998;

  --hc-border: #e0ddd5;
  --hc-border-light: #ebe8e1;
  --hc-border-focus: #3b5998;

  --hc-icon: #3b5998;
  --hc-icon-muted: #8a8a8a;

  --hc-send-bg: #3b5998;
  --hc-send-color: #ffffff;
  --hc-send-hover: #2d4373;

  --hc-success: #2e7d32;
  --hc-warning: #f57c00;
  --hc-danger: #c62828;
  --hc-info: #1565c0;

  --hc-shadow-sm: 0 1px 2px rgba(0,0,0,0.06);
  --hc-shadow-md: 0 2px 8px rgba(0,0,0,0.08);
  --hc-shadow-lg: 0 4px 16px rgba(0,0,0,0.12);

  --hc-scrollbar-thumb: #ccc;
  --hc-scrollbar-track: transparent;

  --hc-code-bg: #f5f3ee;
}

[data-theme="dark"] {
  --hc-bg-primary: #0a1628;
  --hc-bg-secondary: #0f1d33;
  --hc-bg-tertiary: #14253f;
  --hc-bg-page: #070f1e;
  --hc-bg-card: #0f1d33;
  --hc-bg-input: #14253f;
  --hc-bg-hover: #1a2d4a;
  --hc-bg-sidebar: #0a1628;
  --hc-bg-modal-overlay: rgba(0, 0, 0, 0.65);

  --hc-text-primary: #e8eaed;
  --hc-text-secondary: #9aa5b4;
  --hc-text-tertiary: #5e6d82;
  --hc-text-inverse: #1a1a1a;

  --hc-accent: #6b8fd4;
  --hc-accent-hover: #89a8e0;
  --hc-accent-light: #1a2d4a;
  --hc-accent-text: #6b8fd4;

  --hc-border: #1e3050;
  --hc-border-light: #162540;
  --hc-border-focus: #6b8fd4;

  --hc-icon: #e8eaed;
  --hc-icon-muted: #5e6d82;

  --hc-send-bg: transparent;
  --hc-send-color: #e8eaed;
  --hc-send-hover: #1a2d4a;

  --hc-success: #66bb6a;
  --hc-warning: #ffa726;
  --hc-danger: #ef5350;
  --hc-info: #42a5f5;

  --hc-shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --hc-shadow-md: 0 2px 8px rgba(0,0,0,0.4);
  --hc-shadow-lg: 0 4px 16px rgba(0,0,0,0.5);

  --hc-scrollbar-thumb: #1e3050;
  --hc-scrollbar-track: transparent;

  --hc-code-bg: #14253f;
}

/* ── Base resets using theme vars ── */
body {
  background: var(--hc-bg-page) !important;
  color: var(--hc-text-primary) !important;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Sidebar */
.sidebar, .nav-sidebar, nav {
  background: var(--hc-bg-sidebar) !important;
  border-color: var(--hc-border) !important;
}

.sidebar a, .nav-link, .sidebar .nav-item {
  color: var(--hc-text-secondary) !important;
}

.sidebar a:hover, .nav-link:hover {
  background: var(--hc-bg-hover) !important;
  color: var(--hc-text-primary) !important;
}

.sidebar a.active, .nav-link.active {
  background: var(--hc-accent-light) !important;
  color: var(--hc-accent-text) !important;
}

/* Top bar / header */
.top-bar, .header-bar, header {
  background: var(--hc-bg-primary) !important;
  border-color: var(--hc-border) !important;
  color: var(--hc-text-primary) !important;
}

/* Cards & panels */
.card, .panel, .modal-content {
  background: var(--hc-bg-card) !important;
  border-color: var(--hc-border) !important;
  color: var(--hc-text-primary) !important;
}

/* Inputs */
input, textarea, select {
  background: var(--hc-bg-input) !important;
  color: var(--hc-text-primary) !important;
  border-color: var(--hc-border) !important;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--hc-border-focus) !important;
}

input::placeholder, textarea::placeholder {
  color: var(--hc-text-tertiary) !important;
}

/* Buttons - general */
button, .btn {
  color: var(--hc-text-primary);
}

/* Icon buttons */
.chat-icon-btn svg,
.icon-btn svg {
  color: var(--hc-icon) !important;
  stroke: var(--hc-icon);
}

/* Send button */
.draft-send-btn,
.send-btn,
#sendBtn {
  background: var(--hc-send-bg) !important;
  color: var(--hc-send-color) !important;
  border: 1px solid var(--hc-border) !important;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

[data-theme="light"] .draft-send-btn,
[data-theme="light"] .send-btn,
[data-theme="light"] #sendBtn {
  background: var(--hc-accent) !important;
  color: #ffffff !important;
  border: none !important;
}

[data-theme="dark"] .draft-send-btn,
[data-theme="dark"] .send-btn,
[data-theme="dark"] #sendBtn {
  background: transparent !important;
  color: var(--hc-text-primary) !important;
  border: 1px solid var(--hc-border) !important;
}

.send-btn:hover, .draft-send-btn:hover, #sendBtn:hover {
  background: var(--hc-send-hover) !important;
}

.send-btn:active, .draft-send-btn:active, #sendBtn:active {
  transform: scale(0.95);
}

/* Doc editor / Draft page */
.doc-editor-page, .doc-editor-content {
  background: var(--hc-bg-primary) !important;
  color: var(--hc-text-primary) !important;
}

/* Draft right pane */
.draft-chat-panel, .chat-panel {
  background: var(--hc-bg-primary) !important;
  border-color: var(--hc-border) !important;
}

/* Workflow agents panel */
.workflow-agents-panel {
  background: var(--hc-bg-secondary) !important;
  border-color: var(--hc-border) !important;
}

.workflow-agent-card {
  background: var(--hc-bg-card) !important;
  border-color: var(--hc-border) !important;
}

.workflow-agent-card:hover {
  border-color: var(--hc-accent) !important;
}

.workflow-agent-card-title span {
  color: var(--hc-text-primary) !important;
}

.workflow-agent-card-desc {
  color: var(--hc-text-secondary) !important;
}

/* Tables */
table, th, td {
  border-color: var(--hc-border) !important;
}

th {
  background: var(--hc-bg-secondary) !important;
  color: var(--hc-text-primary) !important;
}

td {
  color: var(--hc-text-primary) !important;
}

/* Scrollbars */
::-webkit-scrollbar-thumb {
  background: var(--hc-scrollbar-thumb);
}

::-webkit-scrollbar-track {
  background: var(--hc-scrollbar-track);
}

/* Code blocks */
pre, code {
  background: var(--hc-code-bg) !important;
  color: var(--hc-text-primary) !important;
}

/* Dropdown / context menus */
.dropdown-menu, .context-menu {
  background: var(--hc-bg-card) !important;
  border-color: var(--hc-border) !important;
  box-shadow: var(--hc-shadow-lg);
}

.dropdown-item:hover, .context-menu-item:hover {
  background: var(--hc-bg-hover) !important;
}

/* Modals */
.modal-overlay {
  background: var(--hc-bg-modal-overlay) !important;
}

/* Badges / pills */
.badge {
  color: var(--hc-accent-text);
  background: var(--hc-accent-light);
}

/* Notifications */
.notification {
  background: var(--hc-bg-card) !important;
  border-color: var(--hc-border) !important;
  color: var(--hc-text-primary) !important;
  box-shadow: var(--hc-shadow-md);
}

/* Smooth transition on theme change */
*, *::before, *::after {
  transition: background-color 0.3s ease, color 0.2s ease, border-color 0.3s ease;
}

/* ═══════════════════════════════════════════
   Theme selector (Settings › Appearance)
   ═══════════════════════════════════════════ */
.theme-selector {
  display: flex;
  gap: 16px;
  margin-top: 12px;
}

.theme-option {
  cursor: pointer;
  text-align: center;
  flex: 1;
  max-width: 140px;
}

.theme-option span {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--hc-text-secondary);
  margin-top: 8px;
}

.theme-option.active span {
  color: var(--hc-accent-text);
}

.theme-auto-hint {
  font-size: 11px !important;
  font-weight: 400 !important;
  color: var(--hc-text-tertiary) !important;
  margin-top: 2px !important;
}

.theme-preview {
  width: 100%;
  height: 72px;
  border-radius: 8px;
  border: 2px solid var(--hc-border);
  overflow: hidden;
  display: flex;
  transition: border-color 0.15s;
}

.theme-option.active .theme-preview,
.theme-option:hover .theme-preview {
  border-color: var(--hc-accent);
}

.theme-preview-light { background: #ffffff; }
.theme-preview-light .theme-preview-sidebar {
  width: 24px;
  background: #f7f5f0;
  border-right: 1px solid #e0ddd5;
}
.theme-preview-light .theme-preview-content { flex: 1; padding: 12px 10px; }
.theme-preview-light .theme-preview-line {
  height: 4px;
  background: #d0cdc5;
  border-radius: 2px;
  margin-bottom: 6px;
}
.theme-preview-light .theme-preview-line.short { width: 60%; }

.theme-preview-dark { background: #0a1628; }
.theme-preview-dark .theme-preview-sidebar {
  width: 24px;
  background: #0f1d33;
  border-right: 1px solid #1e3050;
}
.theme-preview-dark .theme-preview-content { flex: 1; padding: 12px 10px; }
.theme-preview-dark .theme-preview-line {
  height: 4px;
  background: #1e3050;
  border-radius: 2px;
  margin-bottom: 6px;
}
.theme-preview-dark .theme-preview-line.short { width: 60%; }

.theme-preview-auto {
  background: linear-gradient(135deg, #ffffff 50%, #0a1628 50%);
}
.theme-preview-auto .theme-preview-sidebar { display: none; }
.theme-preview-auto .theme-preview-content { flex: 1; padding: 12px 10px; }
.theme-preview-auto .theme-preview-line {
  height: 4px;
  background: rgba(128, 128, 128, 0.4);
  border-radius: 2px;
  margin-bottom: 6px;
}
.theme-preview-auto .theme-preview-line.short { width: 60%; }

.settings-section-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--hc-text-primary);
  margin-bottom: 4px;
}

.settings-section-desc {
  font-size: 13px;
  color: var(--hc-text-secondary);
  margin-bottom: 0;
}

/* ═══════════════════════════════════════════
   GLOBAL DARK MODE OVERRIDES
   These catch ALL pages regardless of class names.
   Applied last so they win specificity battles.
   ═══════════════════════════════════════════ */

[data-theme="dark"] {
  background: #070f1e !important;
  color: #e8eaed !important;
}

[data-theme="dark"] div,
[data-theme="dark"] section,
[data-theme="dark"] main,
[data-theme="dark"] article,
[data-theme="dark"] aside,
[data-theme="dark"] header,
[data-theme="dark"] footer,
[data-theme="dark"] nav,
[data-theme="dark"] form {
  color: #e8eaed;
}

/* Catch inline style="background: ..." on any element. */
[data-theme="dark"] [style*="background"],
[data-theme="dark"] [style*="Background"] {
  background: var(--hc-bg-page) !important;
}

/* But preserve intentional colored backgrounds (buttons, badges, etc.) */
[data-theme="dark"] button[style*="background"],
[data-theme="dark"] .badge[style*="background"],
[data-theme="dark"] .btn[style*="background"],
[data-theme="dark"] .notification[style*="background"],
[data-theme="dark"] .tag[style*="background"],
[data-theme="dark"] .pill[style*="background"],
[data-theme="dark"] [class*="send"][style*="background"],
[data-theme="dark"] [class*="export"][style*="background"] {
  background: revert !important;
}

[data-theme="dark"] body,
[data-theme="dark"] html {
  background: #070f1e !important;
}

[data-theme="dark"] .main-content,
[data-theme="dark"] .content-area,
[data-theme="dark"] .page-content,
[data-theme="dark"] .content,
[data-theme="dark"] .container,
[data-theme="dark"] .wrapper,
[data-theme="dark"] .app-content,
[data-theme="dark"] .view-container {
  background: #070f1e !important;
  color: #e8eaed !important;
}

/* ── Draft page ── */
[data-theme="dark"] .doc-editor-page,
[data-theme="dark"] .doc-editor-content,
[data-theme="dark"] .doc-editor-wrapper,
[data-theme="dark"] .draft-container,
[data-theme="dark"] .draft-editor,
[data-theme="dark"] .editor-wrapper {
  background: #0f1d33 !important;
  color: #e8eaed !important;
}

[data-theme="dark"] .draft-chat-panel,
[data-theme="dark"] .chat-panel,
[data-theme="dark"] .draft-sidebar,
[data-theme="dark"] .right-panel {
  background: #0a1628 !important;
  border-color: #1e3050 !important;
}

/* ── History page ── */
[data-theme="dark"] .history-container,
[data-theme="dark"] .history-list,
[data-theme="dark"] .history-detail,
[data-theme="dark"] .session-list,
[data-theme="dark"] .chat-history {
  background: #070f1e !important;
  color: #e8eaed !important;
}

[data-theme="dark"] .history-item,
[data-theme="dark"] .session-item {
  border-color: #1e3050 !important;
  color: #e8eaed !important;
}

[data-theme="dark"] .history-item:hover,
[data-theme="dark"] .session-item:hover {
  background: #14253f !important;
}

/* ── Review Tables page ── */
[data-theme="dark"] .review-container,
[data-theme="dark"] .review-tables-container,
[data-theme="dark"] .extraction-container {
  background: #070f1e !important;
  color: #e8eaed !important;
}

[data-theme="dark"] .extraction-results,
[data-theme="dark"] .results-panel {
  background: #0a1628 !important;
  border-color: #1e3050 !important;
}

/* ── Library page ── */
[data-theme="dark"] .library-container,
[data-theme="dark"] .library-content,
[data-theme="dark"] .file-list,
[data-theme="dark"] .folder-list {
  background: #070f1e !important;
  color: #e8eaed !important;
}

/* ── Workflows page ── */
[data-theme="dark"] .workflows-container,
[data-theme="dark"] .workflow-list,
[data-theme="dark"] .workflow-builder,
[data-theme="dark"] .workflow-runner {
  background: #070f1e !important;
  color: #e8eaed !important;
}

/* ── Prompts page ── */
[data-theme="dark"] .prompts-container,
[data-theme="dark"] .prompts-list {
  background: #070f1e !important;
  color: #e8eaed !important;
}

/* ── Playbooks page ── */
[data-theme="dark"] .playbook-container,
[data-theme="dark"] .playbooks-container {
  background: #070f1e !important;
  color: #e8eaed !important;
}

/* ── Clause Bank page ── */
[data-theme="dark"] .clause-bank-container,
[data-theme="dark"] .clauses-container {
  background: #070f1e !important;
  color: #e8eaed !important;
}

/* ── Scheduled Agents page ── */
[data-theme="dark"] .agents-container,
[data-theme="dark"] .scheduled-agents-container {
  background: #070f1e !important;
  color: #e8eaed !important;
}

/* ── Client Spaces page ── */
[data-theme="dark"] .client-spaces-container,
[data-theme="dark"] .spaces-container {
  background: #070f1e !important;
  color: #e8eaed !important;
}

/* ── Admin page ── */
[data-theme="dark"] .admin-container,
[data-theme="dark"] .admin-content {
  background: #070f1e !important;
  color: #e8eaed !important;
}

/* ── Settings page ── */
[data-theme="dark"] .settings-container,
[data-theme="dark"] .settings-content {
  background: #070f1e !important;
  color: #e8eaed !important;
}

/* ═══════════════════════════════════════════
   UNIVERSAL ELEMENT OVERRIDES
   ═══════════════════════════════════════════ */

[data-theme="dark"] h1,
[data-theme="dark"] h2,
[data-theme="dark"] h3,
[data-theme="dark"] h4,
[data-theme="dark"] h5,
[data-theme="dark"] h6 {
  color: #e8eaed !important;
}

[data-theme="dark"] p,
[data-theme="dark"] span,
[data-theme="dark"] label,
[data-theme="dark"] li,
[data-theme="dark"] a {
  color: #e8eaed;
}

[data-theme="dark"] .text-muted,
[data-theme="dark"] .text-secondary,
[data-theme="dark"] small,
[data-theme="dark"] .hint,
[data-theme="dark"] .subtitle,
[data-theme="dark"] .description {
  color: #9aa5b4 !important;
}

[data-theme="dark"] .card,
[data-theme="dark"] .panel,
[data-theme="dark"] [class*="card"],
[data-theme="dark"] [class*="panel"] {
  background: #0f1d33 !important;
  border-color: #1e3050 !important;
  color: #e8eaed !important;
}

[data-theme="dark"] input,
[data-theme="dark"] textarea,
[data-theme="dark"] select {
  background: #14253f !important;
  color: #e8eaed !important;
  border-color: #1e3050 !important;
}

[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder {
  color: #5e6d82 !important;
}

[data-theme="dark"] table { color: #e8eaed !important; }

[data-theme="dark"] th {
  background: #14253f !important;
  color: #e8eaed !important;
  border-color: #1e3050 !important;
}

[data-theme="dark"] td {
  border-color: #1e3050 !important;
  color: #e8eaed !important;
}

[data-theme="dark"] tr:hover td {
  background: #14253f !important;
}

[data-theme="dark"] [class*="border"],
[data-theme="dark"] hr {
  border-color: #1e3050 !important;
}

[data-theme="dark"] [class*="drop"],
[data-theme="dark"] [class*="upload"],
[data-theme="dark"] [style*="dashed"] {
  border-color: #1e3050 !important;
  background: #0f1d33 !important;
  color: #9aa5b4 !important;
}

[data-theme="dark"] .modal,
[data-theme="dark"] .modal-content,
[data-theme="dark"] [class*="modal"] {
  background: #0f1d33 !important;
  color: #e8eaed !important;
  border-color: #1e3050 !important;
}

[data-theme="dark"] .dropdown-menu,
[data-theme="dark"] .context-menu,
[data-theme="dark"] [class*="dropdown"],
[data-theme="dark"] [class*="menu"]:not(nav):not(.sidebar) {
  background: #0f1d33 !important;
  border-color: #1e3050 !important;
}

[data-theme="dark"] .toolbar,
[data-theme="dark"] [class*="toolbar"] {
  background: #0a1628 !important;
  border-color: #1e3050 !important;
}

[data-theme="dark"] svg:not([class*="logo"]) {
  color: #e8eaed;
}

[data-theme="dark"] .emoji-icon,
[data-theme="dark"] [class*="emoji"] {
  color: unset;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #1e3050; }
[data-theme="dark"] ::-webkit-scrollbar-track { background: #0a1628; }

[data-theme="dark"] .extract-btn,
[data-theme="dark"] [class*="extract"] button {
  background: #14253f !important;
  color: #9aa5b4 !important;
  border-color: #1e3050 !important;
}

/* ═══════════════════════════════════════════
   GLOBAL BUTTON RESET — WIREFRAME STYLE
   All buttons become outline/wireframe.
   ═══════════════════════════════════════════ */

.btn-primary,
.btn-action,
.primary-btn,
.action-btn,
.create-btn,
.add-btn,
.new-btn,
.run-btn,
.use-btn,
.download-btn,
.export-btn,
.save-btn,
.submit-btn,
.send-message-btn,
[class*="btn-primary"],
[class*="btn-action"],
button[class*="create"],
button[class*="add"],
button[class*="new"],
button[class*="run"],
button[class*="export"],
button[class*="save"],
button[class*="download"] {
  background: transparent !important;
  color: var(--hc-accent-text) !important;
  border: 1.5px solid var(--hc-accent-text) !important;
  border-radius: 6px !important;
  padding: 6px 16px !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  cursor: pointer !important;
  transition: background 0.15s, color 0.15s !important;
}

.btn-primary:hover,
.btn-action:hover,
.primary-btn:hover,
.action-btn:hover,
.create-btn:hover,
.add-btn:hover,
.new-btn:hover,
.run-btn:hover,
.use-btn:hover,
.download-btn:hover,
.export-btn:hover,
.save-btn:hover,
.submit-btn:hover,
.send-message-btn:hover,
[class*="btn-primary"]:hover,
[class*="btn-action"]:hover,
button[class*="create"]:hover,
button[class*="add"]:hover,
button[class*="new"]:hover,
button[class*="run"]:hover,
button[class*="export"]:hover,
button[class*="save"]:hover,
button[class*="download"]:hover {
  background: var(--hc-accent-light) !important;
  color: var(--hc-accent-text) !important;
}

[data-theme="dark"] .btn-primary,
[data-theme="dark"] .btn-action,
[data-theme="dark"] .primary-btn,
[data-theme="dark"] .action-btn,
[data-theme="dark"] .create-btn,
[data-theme="dark"] .add-btn,
[data-theme="dark"] .new-btn,
[data-theme="dark"] .run-btn,
[data-theme="dark"] .use-btn,
[data-theme="dark"] .download-btn,
[data-theme="dark"] .export-btn,
[data-theme="dark"] .save-btn,
[data-theme="dark"] .submit-btn,
[data-theme="dark"] .send-message-btn,
[data-theme="dark"] [class*="btn-primary"],
[data-theme="dark"] [class*="btn-action"],
[data-theme="dark"] button[class*="create"],
[data-theme="dark"] button[class*="add"],
[data-theme="dark"] button[class*="new"],
[data-theme="dark"] button[class*="run"],
[data-theme="dark"] button[class*="export"],
[data-theme="dark"] button[class*="save"],
[data-theme="dark"] button[class*="download"] {
  color: #e8eaed !important;
  border-color: #e8eaed !important;
  background: transparent !important;
}

[data-theme="dark"] .btn-primary:hover,
[data-theme="dark"] .btn-action:hover,
[data-theme="dark"] .primary-btn:hover,
[data-theme="dark"] .action-btn:hover,
[data-theme="dark"] .create-btn:hover,
[data-theme="dark"] .add-btn:hover,
[data-theme="dark"] .new-btn:hover,
[data-theme="dark"] .run-btn:hover,
[data-theme="dark"] .use-btn:hover,
[data-theme="dark"] .download-btn:hover,
[data-theme="dark"] .export-btn:hover,
[data-theme="dark"] .save-btn:hover,
[data-theme="dark"] .submit-btn:hover,
[data-theme="dark"] .send-message-btn:hover,
[data-theme="dark"] [class*="btn-primary"]:hover,
[data-theme="dark"] [class*="btn-action"]:hover,
[data-theme="dark"] button[class*="create"]:hover,
[data-theme="dark"] button[class*="add"]:hover,
[data-theme="dark"] button[class*="new"]:hover,
[data-theme="dark"] button[class*="run"]:hover,
[data-theme="dark"] button[class*="export"]:hover,
[data-theme="dark"] button[class*="save"]:hover,
[data-theme="dark"] button[class*="download"]:hover {
  background: #14253f !important;
  color: #e8eaed !important;
}

/* Secondary / outline buttons */
.btn-secondary,
.btn-outline,
.secondary-btn,
.outline-btn,
.edit-btn,
.reset-btn,
.view-btn,
.clone-btn,
.cancel-btn,
button[class*="edit"],
button[class*="reset"],
button[class*="view"],
button[class*="clone"],
button[class*="cancel"] {
  background: transparent !important;
  color: var(--hc-text-secondary) !important;
  border: 1px solid var(--hc-border) !important;
  border-radius: 6px !important;
  padding: 5px 14px !important;
  font-size: 13px !important;
  cursor: pointer !important;
  transition: background 0.15s, border-color 0.15s !important;
}

.btn-secondary:hover,
.btn-outline:hover,
.secondary-btn:hover,
.outline-btn:hover,
.edit-btn:hover,
.reset-btn:hover,
.view-btn:hover,
.clone-btn:hover,
.cancel-btn:hover,
button[class*="edit"]:hover,
button[class*="reset"]:hover,
button[class*="view"]:hover,
button[class*="clone"]:hover,
button[class*="cancel"]:hover {
  background: var(--hc-bg-hover) !important;
  border-color: var(--hc-accent-text) !important;
}

[data-theme="dark"] .btn-secondary,
[data-theme="dark"] .btn-outline,
[data-theme="dark"] .secondary-btn,
[data-theme="dark"] .outline-btn,
[data-theme="dark"] .edit-btn,
[data-theme="dark"] .reset-btn,
[data-theme="dark"] .view-btn,
[data-theme="dark"] .clone-btn,
[data-theme="dark"] .cancel-btn,
[data-theme="dark"] button[class*="edit"],
[data-theme="dark"] button[class*="reset"],
[data-theme="dark"] button[class*="view"],
[data-theme="dark"] button[class*="clone"],
[data-theme="dark"] button[class*="cancel"] {
  color: #9aa5b4 !important;
  border-color: #1e3050 !important;
  background: transparent !important;
}

[data-theme="dark"] .btn-secondary:hover,
[data-theme="dark"] .btn-outline:hover,
[data-theme="dark"] .secondary-btn:hover,
[data-theme="dark"] .edit-btn:hover,
[data-theme="dark"] .reset-btn:hover,
[data-theme="dark"] .view-btn:hover,
[data-theme="dark"] .clone-btn:hover,
[data-theme="dark"] .cancel-btn:hover,
[data-theme="dark"] button[class*="edit"]:hover,
[data-theme="dark"] button[class*="reset"]:hover,
[data-theme="dark"] button[class*="view"]:hover,
[data-theme="dark"] button[class*="clone"]:hover,
[data-theme="dark"] button[class*="cancel"]:hover {
  background: #14253f !important;
  border-color: #9aa5b4 !important;
}

/* Danger buttons */
.btn-danger,
.danger-btn,
.delete-btn,
button[class*="delete"],
button[class*="remove"] {
  background: transparent !important;
  color: var(--hc-danger) !important;
  border: 1px solid var(--hc-danger) !important;
  border-radius: 6px !important;
  padding: 5px 14px !important;
  font-size: 13px !important;
  cursor: pointer !important;
}

.btn-danger:hover,
.danger-btn:hover,
.delete-btn:hover,
button[class*="delete"]:hover,
button[class*="remove"]:hover {
  background: rgba(198, 40, 40, 0.1) !important;
}

[data-theme="dark"] .btn-danger,
[data-theme="dark"] .danger-btn,
[data-theme="dark"] .delete-btn,
[data-theme="dark"] button[class*="delete"],
[data-theme="dark"] button[class*="remove"] {
  color: #ef5350 !important;
  border-color: #ef5350 !important;
  background: transparent !important;
}

[data-theme="dark"] .btn-danger:hover,
[data-theme="dark"] .danger-btn:hover,
[data-theme="dark"] .delete-btn:hover,
[data-theme="dark"] button[class*="delete"]:hover,
[data-theme="dark"] button[class*="remove"]:hover {
  background: rgba(239, 83, 80, 0.15) !important;
}

/* Filter pills / tags */
.filter-pill,
.filter-tag,
.tag-btn,
.category-btn,
[class*="filter-btn"],
[class*="category-pill"] {
  background: transparent !important;
  color: var(--hc-text-secondary) !important;
  border: 1px solid var(--hc-border) !important;
  border-radius: 20px !important;
  padding: 4px 14px !important;
  font-size: 12px !important;
  cursor: pointer !important;
}

.filter-pill.active,
.filter-tag.active,
.tag-btn.active,
.category-btn.active,
[class*="filter-btn"].active,
[class*="category-pill"].active {
  background: var(--hc-accent-light) !important;
  color: var(--hc-accent-text) !important;
  border-color: var(--hc-accent-text) !important;
}

[data-theme="dark"] .filter-pill.active,
[data-theme="dark"] .filter-tag.active,
[data-theme="dark"] .tag-btn.active,
[data-theme="dark"] .category-btn.active,
[data-theme="dark"] [class*="filter-btn"].active,
[data-theme="dark"] [class*="category-pill"].active {
  background: #14253f !important;
  color: #6b8fd4 !important;
  border-color: #6b8fd4 !important;
}

/* Badge pills on cards */
.badge,
.pill,
.tag,
[class*="badge"],
[class*="pill"]:not([class*="filter"]):not([class*="category"]) {
  background: transparent !important;
  border: 1px solid var(--hc-border) !important;
  color: var(--hc-text-secondary) !important;
  border-radius: 4px !important;
  padding: 2px 8px !important;
  font-size: 11px !important;
}

[data-theme="dark"] .badge,
[data-theme="dark"] .pill,
[data-theme="dark"] .tag,
[data-theme="dark"] [class*="badge"],
[data-theme="dark"] [class*="pill"]:not([class*="filter"]):not([class*="category"]) {
  border-color: #1e3050 !important;
  color: #9aa5b4 !important;
  background: transparent !important;
}

/* Status badges */
.status-badge,
[class*="status"],
[class*="role-badge"] {
  border-radius: 4px !important;
  padding: 2px 10px !important;
  font-size: 11px !important;
  font-weight: 500 !important;
}

/* Export DOCX button on Draft */
.export-docx-btn,
[class*="export-docx"] {
  background: transparent !important;
  color: var(--hc-accent-text) !important;
  border: 1.5px solid var(--hc-accent-text) !important;
}

[data-theme="dark"] .export-docx-btn,
[data-theme="dark"] [class*="export-docx"] {
  color: #e8eaed !important;
  border-color: #e8eaed !important;
}

/* Catch-all for inline gold backgrounds (pre-stripping fallback) */
[data-theme="dark"] button[style*="background: var(--gold)"],
[data-theme="dark"] button[style*="background: #c9a227"],
[data-theme="dark"] button[style*="background-color: var(--gold)"],
[data-theme="dark"] button[style*="background-color: #c9a227"],
[data-theme="dark"] a[style*="background: var(--gold)"],
[data-theme="dark"] a[style*="background: #c9a227"] {
  background: transparent !important;
  color: #e8eaed !important;
  border: 1.5px solid #e8eaed !important;
}

[data-theme="light"] button[style*="background: var(--gold)"],
[data-theme="light"] button[style*="background: #c9a227"],
[data-theme="light"] button[style*="background-color: var(--gold)"],
[data-theme="light"] button[style*="background-color: #c9a227"],
[data-theme="light"] a[style*="background: var(--gold)"],
[data-theme="light"] a[style*="background: #c9a227"] {
  background: transparent !important;
  color: var(--hc-accent-text) !important;
  border: 1.5px solid var(--hc-accent-text) !important;
}

/* ═══════════════════════════════════════════
   REMAINING BACKGROUND FIXES (Part 4)
   ═══════════════════════════════════════════ */

/* Admin page table rows */
[data-theme="dark"] tr:nth-child(even) { background: #0f1d33 !important; }
[data-theme="dark"] tr:nth-child(odd)  { background: #0a1628 !important; }

/* Playbooks card grid */
[data-theme="dark"] .playbook-card,
[data-theme="dark"] [class*="playbook-card"] {
  background: #0f1d33 !important;
  border-color: #1e3050 !important;
}

/* Word Add-in installer cards */
[data-theme="dark"] .installer-card,
[data-theme="dark"] [class*="installer"],
[data-theme="dark"] [class*="download-card"] {
  background: #0f1d33 !important;
  border-color: #1e3050 !important;
}

/* Clause Bank filter area */
[data-theme="dark"] .filter-bar,
[data-theme="dark"] [class*="filter-bar"],
[data-theme="dark"] [class*="search-bar"] {
  background: #0a1628 !important;
  border-color: #1e3050 !important;
}

/* Tab navigation */
[data-theme="dark"] .tab,
[data-theme="dark"] .tab-btn,
[data-theme="dark"] [class*="tab-btn"],
[data-theme="dark"] [class*="tab-item"] {
  color: #9aa5b4 !important;
  border-color: transparent !important;
}

[data-theme="dark"] .tab.active,
[data-theme="dark"] .tab-btn.active,
[data-theme="dark"] [class*="tab-btn"].active,
[data-theme="dark"] [class*="tab-item"].active {
  color: #6b8fd4 !important;
  border-bottom-color: #6b8fd4 !important;
}

/* Empty state text */
[data-theme="dark"] .empty-state,
[data-theme="dark"] [class*="empty"],
[data-theme="dark"] [class*="no-results"],
[data-theme="dark"] [class*="placeholder"] {
  color: #5e6d82 !important;
}

/* Light mode button colors */
[data-theme="light"] .btn-primary,
[data-theme="light"] .primary-btn,
[data-theme="light"] .action-btn,
[data-theme="light"] .create-btn {
  color: #3b5998 !important;
  border-color: #3b5998 !important;
}

[data-theme="light"] .btn-primary:hover,
[data-theme="light"] .primary-btn:hover,
[data-theme="light"] .action-btn:hover,
[data-theme="light"] .create-btn:hover {
  background: #e8edf5 !important;
}

/* ═══════════════════════════════════════════
   LARGE ICON SIZING
   SVGs in upload-zone / empty-state / folder-card
   were originally emoji rendered at font-size:2-3rem.
   Bump replaced SVGs to 32px so they read as intended.
   ═══════════════════════════════════════════ */
.upload-zone .icon svg,
.empty-state .icon svg,
.folder-card .icon svg,
.folder-card .folder-icon svg,
.upload-zone-icon svg {
  width: 32px !important;
  height: 32px !important;
}

/* ═══════════════════════════════════════════
   KILL ALL GOLD/ORANGE TEXT & ICON COLORS
   ═══════════════════════════════════════════ */

[data-theme="dark"] [style*="color: var(--gold)"],
[data-theme="dark"] [style*="color: #c9a227"],
[data-theme="dark"] [style*="color: #c9a84c"],
[data-theme="dark"] [style*="color: #b8941f"],
[data-theme="dark"] [style*="color:var(--gold)"],
[data-theme="dark"] [style*="color:#c9a227"],
[data-theme="dark"] [style*="color: var(--gold-dark)"] {
  color: #e8eaed !important;
}

[data-theme="light"] [style*="color: var(--gold)"],
[data-theme="light"] [style*="color: #c9a227"],
[data-theme="light"] [style*="color: #c9a84c"],
[data-theme="light"] [style*="color: #b8941f"],
[data-theme="light"] [style*="color:var(--gold)"],
[data-theme="light"] [style*="color:#c9a227"],
[data-theme="light"] [style*="color: var(--gold-dark)"] {
  color: #3b5998 !important;
}

[data-theme="dark"] .gold-text,
[data-theme="dark"] .accent-text,
[data-theme="dark"] [class*="gold"],
[data-theme="dark"] .section-header,
[data-theme="dark"] .category-header {
  color: #e8eaed !important;
}

[data-theme="light"] .gold-text,
[data-theme="light"] .accent-text,
[data-theme="light"] [class*="gold"] {
  color: #3b5998 !important;
}

[data-theme="dark"] svg [stroke="var(--gold)"],
[data-theme="dark"] svg [stroke="#c9a227"],
[data-theme="dark"] svg [stroke="#c9a84c"] {
  stroke: #e8eaed !important;
}

[data-theme="light"] svg [stroke="var(--gold)"],
[data-theme="light"] svg [stroke="#c9a227"],
[data-theme="light"] svg [stroke="#c9a84c"] {
  stroke: #3b5998 !important;
}

[data-theme="dark"] svg [fill="var(--gold)"],
[data-theme="dark"] svg [fill="#c9a227"],
[data-theme="dark"] svg [fill="#c9a84c"] {
  fill: #e8eaed !important;
}

[data-theme="light"] svg [fill="var(--gold)"],
[data-theme="light"] svg [fill="#c9a227"],
[data-theme="light"] svg [fill="#c9a84c"] {
  fill: #3b5998 !important;
}

[data-theme="dark"] [style*="border-color: var(--gold)"],
[data-theme="dark"] [style*="border-color: #c9a227"],
[data-theme="dark"] [style*="border: 1px solid var(--gold)"],
[data-theme="dark"] [style*="border: 2px solid var(--gold)"] {
  border-color: #e8eaed !important;
}

[data-theme="light"] [style*="border-color: var(--gold)"],
[data-theme="light"] [style*="border-color: #c9a227"],
[data-theme="light"] [style*="border: 1px solid var(--gold)"],
[data-theme="light"] [style*="border: 2px solid var(--gold)"] {
  border-color: #3b5998 !important;
}

[data-theme="dark"] .workflow-agents-header span {
  color: #e8eaed !important;
}
[data-theme="light"] .workflow-agents-header span {
  color: #3b5998 !important;
}

[data-theme="dark"] .workflow-agent-card svg [stroke="var(--gold, #c9a227)"] {
  stroke: #e8eaed !important;
}
[data-theme="light"] .workflow-agent-card svg [stroke="var(--gold, #c9a227)"] {
  stroke: #3b5998 !important;
}

/* ═══════════════════════════════════════════
   HELP CENTER DARK MODE
   ═══════════════════════════════════════════ */

[data-theme="dark"] .help-container,
[data-theme="dark"] .help-content,
[data-theme="dark"] .help-center {
  background: #070f1e !important;
  color: #e8eaed !important;
}

[data-theme="dark"] .help-sidebar,
[data-theme="dark"] .help-nav {
  background: #0a1628 !important;
  border-color: #1e3050 !important;
}

[data-theme="dark"] .help-sidebar a,
[data-theme="dark"] .help-nav a {
  color: #9aa5b4 !important;
}

[data-theme="dark"] .help-sidebar a:hover,
[data-theme="dark"] .help-nav a:hover {
  color: #e8eaed !important;
}

[data-theme="dark"] .help-section-title,
[data-theme="dark"] .help-category {
  color: #5e6d82 !important;
}

[data-theme="dark"] .help-card,
[data-theme="dark"] .help-topic-card,
[data-theme="dark"] [class*="help-card"] {
  background: #0f1d33 !important;
  border-color: #1e3050 !important;
  color: #e8eaed !important;
}

[data-theme="dark"] .help-card:hover,
[data-theme="dark"] .help-topic-card:hover {
  border-color: #6b8fd4 !important;
}

[data-theme="dark"] .version-badge,
[data-theme="dark"] [class*="version"] {
  background: #14253f !important;
  color: #9aa5b4 !important;
  border-color: #1e3050 !important;
}

[data-theme="dark"] .help-sidebar input,
[data-theme="dark"] .help-nav input {
  background: #14253f !important;
  color: #e8eaed !important;
  border-color: #1e3050 !important;
}

[data-theme="dark"] .section-number,
[data-theme="dark"] [class*="section-num"] {
  background: #14253f !important;
  color: #6b8fd4 !important;
  border: 1px solid #1e3050 !important;
}

[data-theme="light"] .section-number,
[data-theme="light"] [class*="section-num"] {
  background: #e8edf5 !important;
  color: #3b5998 !important;
  border: 1px solid #3b5998 !important;
}

[data-theme="dark"] .help-content h2,
[data-theme="dark"] .help-content h3 {
  color: #e8eaed !important;
  border-color: #1e3050 !important;
}

[data-theme="dark"] .back-btn,
[data-theme="dark"] [class*="back-to-app"] {
  color: #e8eaed !important;
  border-color: #e8eaed !important;
  background: transparent !important;
}

/* ═══════════════════════════════════════════
   NUCLEAR DARK MODE — FINAL OVERRIDE
   Targets every possible container element.
   This block must be LAST in the file.
   ═══════════════════════════════════════════ */

[data-theme="dark"],
[data-theme="dark"] body {
  background: #070f1e !important;
  color: #e8eaed !important;
}

[data-theme="dark"] div:not([class*="send"]):not([class*="export"]):not(.badge):not(.pill):not(.tag):not(.status) {
  background-color: transparent;
  color: inherit;
}

[data-theme="dark"] div[style*="padding"][style*="margin"],
[data-theme="dark"] div[style*="max-width"],
[data-theme="dark"] div[style*="min-height"] {
  background: transparent !important;
}

[data-theme="dark"] .history-list-container,
[data-theme="dark"] .history-items,
[data-theme="dark"] .session-list-container,
[data-theme="dark"] .history-detail-panel,
[data-theme="dark"] .detail-panel {
  background: #070f1e !important;
}

[data-theme="dark"] .history-item,
[data-theme="dark"] .session-item,
[data-theme="dark"] .history-entry {
  background: transparent !important;
  border-bottom: 1px solid #1e3050 !important;
}

[data-theme="dark"] .history-item:hover,
[data-theme="dark"] .session-item:hover,
[data-theme="dark"] .history-entry:hover {
  background: #0f1d33 !important;
}

[data-theme="dark"] select,
[data-theme="dark"] select option {
  background: #14253f !important;
  color: #e8eaed !important;
}

/* ═══════════════════════════════════════════
   WIREFRAME BOX STYLE — ALL BORDERED ELEMENTS
   ═══════════════════════════════════════════ */

[data-theme="dark"] .card,
[data-theme="dark"] .panel,
[data-theme="dark"] .box,
[data-theme="dark"] [class*="card"]:not([class*="send"]),
[data-theme="dark"] [class*="panel"],
[data-theme="dark"] [class*="box"]:not(select):not(input):not(textarea) {
  background: transparent !important;
  border: 1px solid #1e3050 !important;
  color: #e8eaed !important;
}

[data-theme="dark"] .card:hover,
[data-theme="dark"] .panel:hover,
[data-theme="dark"] [class*="card"]:not([class*="send"]):hover {
  border-color: #6b8fd4 !important;
}

[data-theme="light"] .card,
[data-theme="light"] .panel,
[data-theme="light"] .box,
[data-theme="light"] [class*="card"]:not([class*="send"]),
[data-theme="light"] [class*="panel"],
[data-theme="light"] [class*="box"]:not(select):not(input):not(textarea) {
  background: transparent !important;
  border: 1px solid #e0ddd5 !important;
  color: #1a1a1a !important;
}

[data-theme="light"] .card:hover,
[data-theme="light"] .panel:hover,
[data-theme="light"] [class*="card"]:not([class*="send"]):hover {
  border-color: #3b5998 !important;
}

[data-theme="dark"] .installer-card,
[data-theme="dark"] [class*="install"],
[data-theme="dark"] [class*="download-card"],
[data-theme="dark"] [class*="platform-card"] {
  background: transparent !important;
  border: 1px solid #1e3050 !important;
}

[data-theme="dark"] .playbook-card,
[data-theme="dark"] [class*="playbook"][class*="card"] {
  background: transparent !important;
  border: 1px solid #1e3050 !important;
}

[data-theme="dark"] .prompt-card,
[data-theme="dark"] [class*="prompt"][class*="card"] {
  background: transparent !important;
  border: 1px solid #1e3050 !important;
}

[data-theme="dark"] .workflow-card,
[data-theme="dark"] [class*="workflow"][class*="card"] {
  background: transparent !important;
  border: 1px solid #1e3050 !important;
}

[data-theme="dark"] .help-card,
[data-theme="dark"] [class*="help"][class*="card"],
[data-theme="dark"] [class*="topic-card"] {
  background: transparent !important;
  border: 1px solid #1e3050 !important;
}

[data-theme="dark"] .drop-zone,
[data-theme="dark"] .upload-zone,
[data-theme="dark"] [class*="drop-zone"],
[data-theme="dark"] [class*="upload-area"],
[data-theme="dark"] [class*="dropzone"] {
  background: transparent !important;
  border: 2px dashed #1e3050 !important;
  color: #5e6d82 !important;
}

/* Draft editor keeps a subtle bg for readability */
[data-theme="dark"] .doc-editor-page,
[data-theme="dark"] .doc-editor-content {
  background: #0f1d33 !important;
}

/* ═══════════════════════════════════════════
   SEARCH INPUTS — consistent dark styling
   ═══════════════════════════════════════════ */

[data-theme="dark"] input[type="search"],
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[placeholder*="search" i],
[data-theme="dark"] input[placeholder*="Search" i] {
  background: #14253f !important;
  color: #e8eaed !important;
  border: 1px solid #1e3050 !important;
  border-radius: 6px !important;
}

[data-theme="dark"] input[type="search"]:focus,
[data-theme="dark"] input[type="text"]:focus {
  border-color: #6b8fd4 !important;
  outline: none !important;
}

[data-theme="dark"] input[type="checkbox"] {
  accent-color: #6b8fd4;
}
