/* FReD Static Apps - Shared Theme */

:root {
  /* Primary colors - FORRT burgundy */
  --fred-primary: #3F0508;
  --fred-primary-dark: #2A0305;
  --fred-primary-light: #5C1015;

  /* Outcome colors */
  --fred-success: #8FBC8F;
  --fred-failure: #FF7F7F;
  --fred-failure-reversal: darkred;
  --fred-not-significant: #D3D3D3;
  --fred-not-coded: #C8C8C8;
  --fred-mixed: #EAB308;

  /* Accent colors - teal/coral */
  --fred-sig-yes: #4DCCD0;
  --fred-sig-no: #FA948C;
  --fred-accent-teal: #4DCCD0;
  --fred-accent-coral: #FA948C;

  /* UI colors - warm cream light mode */
  --fred-bg: #FEFDF6;
  --fred-bg-alt: #F5F4ED;
  --fred-bg-card: #FFFFFF;
  --fred-border: #E5E3D8;
  --fred-text: #212529;
  --fred-text-muted: #6c757d;

  /* Chart colors */
  --fred-chart-bg: #FFFFFF;
  --fred-chart-grid: #E5E3D8;
  --fred-chart-text: #212529;

  /* Shadows */
  --fred-shadow: 0 2px 8px rgba(63, 5, 8, 0.08);
  --fred-shadow-lg: 0 4px 16px rgba(63, 5, 8, 0.12);

  /* Transitions */
  --fred-transition: 0.2s ease;
}

/* Dark mode */
[data-theme="dark"] {
  /* Backgrounds: Cool Slate Blues */
  --fred-bg: #0F172A;              /* Deep Slate - page background */
  --fred-bg-alt: #1E293B;          /* Lighter Slate - secondary areas */
  --fred-bg-card: #1E293B;         /* Card surface (same as alt for cohesion) */
  --fred-bg-input: #0F172A;        /* Input fields match page bg (not recessed) */

  /* Borders */
  --fred-border: #334155;          /* Slate border */
  --fred-border-focus: #4DCCD0;    /* Teal focus */

  /* Accent - Brighter rose-red for dark mode */
  --fred-primary: #E11D48;
  --fred-primary-dark: #BE123C;
  --fred-primary-light: #FB7185;

  /* Text */
  --fred-text: #F1F5F9;            /* Off-white, crisp */
  --fred-text-secondary: #CBD5E1;  /* Light slate */
  --fred-text-muted: #94A3B8;      /* Blue-grey muted */

  /* Outcome colors adjusted */
  --fred-success: #4ADE80;
  --fred-failure: #F87171;
  --fred-mixed: #FBBF24;
  --fred-not-significant: #9A9A9A;
  --fred-not-coded: #7A7A7A;

  /* Chart colors */
  --fred-chart-bg: #1E293B;
  --fred-chart-grid: #334155;
  --fred-chart-text: #CBD5E1;

  /* Shadows */
  --fred-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  --fred-shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
}

/* Reset and base */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
  color: var(--fred-text);
  background-color: var(--fred-bg);
  margin: 0;
  padding: 0;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  margin-top: 0;
  margin-bottom: 0.5rem;
  font-weight: 500;
  line-height: 1.2;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.125rem; }
h6 { font-size: 1rem; }

a {
  color: var(--fred-primary);
  text-decoration: none;
}

a:hover {
  color: var(--fred-primary-dark);
  text-decoration: underline;
}

/* Dark mode links - use accent teal for visibility */
[data-theme="dark"] a {
  color: var(--fred-accent-teal);
}

[data-theme="dark"] a:hover {
  color: #7FE0E3;
}

/* Layout containers */
.container {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1rem;
}

.page-header {
  background: linear-gradient(135deg, var(--fred-primary), var(--fred-primary-dark));
  color: white;
  padding: 1.5rem 0;
  margin-bottom: 1.5rem;
}

.page-header h1 {
  margin: 0;
}

.page-header a {
  color: white;
}

/* Dark mode header - refined gradient */
[data-theme="dark"] .page-header {
  background: linear-gradient(to bottom, #3E1414, #2D0E0E);
}

/* Cards */
.card {
  background: var(--fred-bg-card);
  border: 1px solid var(--fred-border);
  border-radius: 0.75rem;
  box-shadow: var(--fred-shadow);
  margin-bottom: 1rem;
  transition: box-shadow var(--fred-transition), background var(--fred-transition);
}

.card-header {
  padding: 1rem;
  border-bottom: 1px solid var(--fred-border);
  background: var(--fred-bg-alt);
  border-radius: 0.5rem 0.5rem 0 0;
  font-weight: 500;
  color: var(--fred-text);
}

.card-body {
  padding: 1rem;
}

/* Dark mode cards - enhanced depth and definition */
[data-theme="dark"] .card {
  background: var(--fred-bg-card);
  border: 1px solid var(--fred-border);
  box-shadow: var(--fred-shadow-lg);
}

[data-theme="dark"] .card-header {
  background: var(--fred-bg-alt);
  border-bottom: 1px solid var(--fred-border);
  color: var(--fred-text);
  font-weight: 600;
}

/* Sidebar layout */
.sidebar-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1.5rem;
  min-height: calc(100vh - 200px);
}

.sidebar {
  background: var(--fred-bg-alt);
  border-radius: 0.5rem;
  padding: 1rem;
  height: fit-content;
  position: sticky;
  top: 1rem;
}

.main-content {
  min-width: 0; /* Prevent overflow in grid */
  overflow: visible; /* Prevent unwanted scrollbars */
}

/* Forms */
.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  font-size: 0.875rem;
}

.form-control {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--fred-text);
  background-color: var(--fred-bg);
  border: 1px solid var(--fred-border);
  border-radius: 0.25rem;
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-control:focus {
  border-color: var(--fred-primary);
  outline: 0;
  box-shadow: 0 0 0 0.2rem rgba(166, 40, 40, 0.25);
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 16px 12px;
  padding-right: 2.25rem;
}

/* Range slider */
.form-range {
  width: 100%;
  height: 1.5rem;
  padding: 0;
  background-color: transparent;
  -webkit-appearance: none;
  appearance: none;
}

/* Track styling - WebKit */
.form-range::-webkit-slider-runnable-track {
  width: 100%;
  height: 0.5rem;
  background-color: var(--fred-border);
  border-radius: 0.25rem;
}

/* Track styling - Firefox */
.form-range::-moz-range-track {
  width: 100%;
  height: 0.5rem;
  background-color: var(--fred-border);
  border-radius: 0.25rem;
  border: none;
}

/* Track styling - IE/Edge */
.form-range::-ms-track {
  width: 100%;
  height: 0.5rem;
  background-color: var(--fred-border);
  border-radius: 0.25rem;
  border: none;
  color: transparent;
}

/* Thumb styling - WebKit */
.form-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 1rem;
  height: 1rem;
  margin-top: -0.25rem;
  background-color: var(--fred-primary);
  border-radius: 50%;
  cursor: pointer;
  transition: background-color 0.15s ease-in-out;
  border: none;
}

.form-range::-webkit-slider-thumb:hover {
  background-color: var(--fred-primary-dark);
}

/* Thumb styling - Firefox */
.form-range::-moz-range-thumb {
  width: 1rem;
  height: 1rem;
  background-color: var(--fred-primary);
  border-radius: 50%;
  cursor: pointer;
  transition: background-color 0.15s ease-in-out;
  border: none;
}

.form-range::-moz-range-thumb:hover {
  background-color: var(--fred-primary-dark);
}

/* Thumb styling - IE/Edge */
.form-range::-ms-thumb {
  width: 1rem;
  height: 1rem;
  background-color: var(--fred-primary);
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

.range-value {
  text-align: center;
  font-size: 0.875rem;
  color: var(--fred-text-muted);
  margin-top: 0.25rem;
}

/* Radio buttons */
.radio-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.radio-option {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  cursor: pointer;
}

.radio-option input[type="radio"] {
  margin-top: 0.25rem;
  accent-color: var(--fred-primary);
}

.radio-option label {
  cursor: pointer;
  font-size: 0.875rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.5;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  vertical-align: middle;
  cursor: pointer;
  user-select: none;
  border: 1px solid transparent;
  border-radius: 0.25rem;
  transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out;
}

.btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.btn-primary {
  color: white;
  background-color: var(--fred-primary);
  border-color: var(--fred-primary);
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--fred-primary-dark);
  border-color: var(--fred-primary-dark);
}

.btn-secondary {
  color: var(--fred-text);
  background-color: var(--fred-bg);
  border-color: var(--fred-border);
}

.btn-secondary:hover:not(:disabled) {
  background-color: var(--fred-bg-alt);
}

/* Dark mode buttons - more vibrant and tactile */
[data-theme="dark"] .btn-primary {
  background: var(--fred-primary);
  border-color: var(--fred-primary);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .btn-primary:hover:not(:disabled) {
  background: var(--fred-primary-light);
  border-color: var(--fred-primary-light);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .btn-secondary {
  background-color: transparent;
  border: 1px solid var(--fred-border);
  color: var(--fred-text-secondary);
}

[data-theme="dark"] .btn-secondary:hover:not(:disabled) {
  background-color: rgba(255, 255, 255, 0.1);
  border-color: #475569;
  color: var(--fred-text);
}

.btn-sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.875rem;
}

.btn-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Form Select - Custom styled dropdowns */
.form-select {
  display: inline-block;
  width: auto;
  padding: 0.5rem 2.25rem 0.5rem 0.75rem;
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.5;
  color: var(--fred-text);
  background-color: var(--fred-bg);
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 16px 12px;
  border: 1px solid var(--fred-border);
  border-radius: 0.375rem;
  appearance: none;
  cursor: pointer;
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-select:focus {
  border-color: var(--fred-primary);
  outline: 0;
  box-shadow: 0 0 0 0.2rem rgba(166, 40, 40, 0.25);
}

.form-select-sm {
  padding: 0.25rem 2rem 0.25rem 0.5rem;
  font-size: 0.875rem;
  border-radius: 0.25rem;
}

[data-theme="dark"] .form-select {
  background-color: var(--fred-bg);
  border-color: var(--fred-border);
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23CBD5E1' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
}

[data-theme="dark"] .form-select:focus {
  border-color: var(--fred-border-focus);
  box-shadow: 0 0 0 3px rgba(77, 204, 208, 0.2);
}

[data-theme="dark"] .form-select:hover:not(:focus):not(:disabled) {
  border-color: #475569;
}

/* Outline Button Styles */
.btn-outline-secondary {
  color: var(--fred-text-muted);
  background-color: transparent;
  border: 1px solid var(--fred-border);
}

.btn-outline-secondary:hover:not(:disabled) {
  color: var(--fred-text);
  background-color: var(--fred-bg-alt);
}

[data-theme="dark"] .btn-outline-secondary {
  color: var(--fred-text-secondary);
  border-color: var(--fred-border);
}

[data-theme="dark"] .btn-outline-secondary:hover:not(:disabled) {
  color: var(--fred-text);
  background-color: rgba(255, 255, 255, 0.08);
  border-color: #475569;
}

/* Forest Plot Controls */
.forest-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  background: var(--fred-bg-alt);
  border: 1px solid var(--fred-border);
  border-radius: 0.5rem;
}

.forest-controls-left,
.forest-controls-right {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.forest-control-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.forest-control-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--fred-text-muted);
  margin: 0;
  white-space: nowrap;
}

.forest-page-indicator {
  padding: 0.25rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--fred-text-muted);
  background: var(--fred-bg);
  border-radius: 0.25rem;
  border: 1px solid var(--fred-border);
}

[data-theme="dark"] .forest-controls {
  background: var(--fred-bg-card);
}

[data-theme="dark"] .forest-page-indicator {
  background: var(--fred-bg);
  color: var(--fred-text-secondary);
}

/* Tabs */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--fred-border);
  margin-bottom: 1rem;
  overflow-x: auto;
}

.tab {
  padding: 0.75rem 1.25rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  font-size: 1rem;
  color: var(--fred-text-muted);
  white-space: nowrap;
  transition: color 0.15s ease-in-out, border-color 0.15s ease-in-out, background 0.15s ease-in-out;
}

.tab:hover {
  color: var(--fred-primary);
}

.tab.active {
  color: var(--fred-primary);
  border-bottom-color: var(--fred-primary);
}

/* Dark mode tabs - fused with card */
[data-theme="dark"] .tabs {
  border-bottom: 1px solid var(--fred-border);
  background: transparent;
  margin-bottom: 0;  /* Remove gap between tabs and content */
}

[data-theme="dark"] .tab {
  color: var(--fred-text-muted);
  border: 1px solid transparent;
  border-bottom: none;
  margin-bottom: -1px;  /* Overlap the border */
}

[data-theme="dark"] .tab:hover {
  color: var(--fred-text);
  background: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .tab.active {
  color: var(--fred-primary);
  font-weight: 600;
  background: var(--fred-bg-card);
  border: 1px solid var(--fred-border);
  border-bottom: 1px solid var(--fred-bg-card);  /* Hide bottom to fuse with card */
  border-top-left-radius: 6px;
  border-top-right-radius: 6px;
}

/* Remove top border-radius from cards following tabs in dark mode */
[data-theme="dark"] .tab-content .card:first-child {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  margin-top: 0;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Tables - DataTables styling */
.dataTables_wrapper {
  font-size: 0.875rem;
}

table.dataTable {
  width: 100% !important;
  border-collapse: collapse;
}

table.dataTable thead th {
  background: var(--fred-bg-alt);
  border-bottom: 2px solid var(--fred-border);
  padding: 0.75rem;
  text-align: left;
  font-weight: 600;
}

table.dataTable tbody td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--fred-border);
  vertical-align: top;
}

table.dataTable tbody tr:hover {
  background-color: var(--fred-bg-alt);
}

.dataTables_filter input {
  margin-left: 0.5rem;
  padding: 0.375rem 0.75rem;
  border: 1px solid var(--fred-border);
  border-radius: 0.25rem;
}

.dataTables_length select {
  padding: 0.375rem 2rem 0.375rem 0.75rem;
  border: 1px solid var(--fred-border);
  border-radius: 0.25rem;
}

.dataTables_paginate .paginate_button {
  padding: 0.375rem 0.75rem;
  margin: 0 0.125rem;
  border: 1px solid var(--fred-border);
  border-radius: 0.25rem;
  cursor: pointer;
}

.dataTables_paginate .paginate_button.current {
  background: var(--fred-primary);
  color: white !important;
  border-color: var(--fred-primary);
}

.dataTables_paginate .paginate_button:hover:not(.current):not(.disabled) {
  background: var(--fred-bg-alt);
}

/* Plot containers */
.plot-container {
  min-height: 400px;
  position: relative;
}

.plot-container.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  border: 4px solid var(--fred-border);
  border-top-color: var(--fred-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Success note */
.success-note {
  background: var(--fred-bg-alt);
  border-left: 4px solid var(--fred-primary);
  padding: 1rem;
  margin: 1rem 0;
  font-size: 0.875rem;
  font-style: italic;
}

/* Legend */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin: 1rem 0;
  font-size: 0.875rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.legend-color {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.2);
}

/* Badge */
.badge {
  display: inline-block;
  padding: 0.25em 0.5em;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  vertical-align: baseline;
  border-radius: 0.25rem;
}

.badge-success { background: var(--fred-success); color: #155724; }
.badge-failure { background: var(--fred-failure); color: #721c24; }
.badge-neutral { background: var(--fred-not-significant); color: #383d41; }

/* Alerts */
.alert {
  padding: 1rem;
  margin-bottom: 1rem;
  border-radius: 0.25rem;
  border: 1px solid transparent;
}

.alert-info {
  background-color: #d1ecf1;
  border-color: #bee5eb;
  color: #0c5460;
}

.alert-warning {
  background-color: #fff3cd;
  border-color: #ffeeba;
  color: #856404;
}

.alert-error {
  background-color: #f8d7da;
  border-color: #f5c6cb;
  color: #721c24;
}

.alert-success {
  background-color: #d4edda;
  border-color: #c3e6cb;
  color: #155724;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--fred-bg);
  border-radius: 0.5rem;
  max-width: 600px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--fred-shadow-lg);
}

.modal-header {
  padding: 1rem;
  border-bottom: 1px solid var(--fred-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  color: var(--fred-text-muted);
}

.modal-body {
  padding: 1rem;
}

.modal-footer {
  padding: 1rem;
  border-top: 1px solid var(--fred-border);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* Dark mode modal overlay */
[data-theme="dark"] .modal-overlay {
  background: rgba(0, 0, 0, 0.7);
}

/* Form controls dark mode */
[data-theme="dark"] .form-control {
  background-color: var(--fred-bg);  /* Same as page, not darker */
  color: var(--fred-text);
  border: 1px solid var(--fred-border);
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

[data-theme="dark"] .form-control:focus {
  border-color: var(--fred-primary);
  box-shadow: 0 0 0 3px rgba(225, 29, 72, 0.15);
  outline: none;
}

[data-theme="dark"] .form-control::placeholder {
  color: var(--fred-text-muted);
}

[data-theme="dark"] select.form-control {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23CBD5E1' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
}

[data-theme="dark"] textarea.form-control {
  background-color: var(--fred-bg);
}

/* Range slider dark mode */
[data-theme="dark"] .form-range::-webkit-slider-runnable-track {
  background-color: var(--fred-border);
}

[data-theme="dark"] .form-range::-moz-range-track {
  background-color: var(--fred-border);
}

/* Alerts dark mode */
[data-theme="dark"] .alert-info {
  background-color: rgba(77, 204, 208, 0.15);
  border-color: rgba(77, 204, 208, 0.3);
  color: #7FE0E3;
}

[data-theme="dark"] .alert-warning {
  background-color: rgba(250, 148, 140, 0.15);
  border-color: rgba(250, 148, 140, 0.3);
  color: #FAB0AA;
}

[data-theme="dark"] .alert-error {
  background-color: rgba(220, 53, 69, 0.15);
  border-color: rgba(220, 53, 69, 0.3);
  color: #F1A0A8;
}

[data-theme="dark"] .alert-success {
  background-color: rgba(40, 167, 69, 0.15);
  border-color: rgba(40, 167, 69, 0.3);
  color: #7FD995;
}

/* Responsive */
@media (max-width: 992px) {
  .sidebar-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }
}

@media (max-width: 576px) {
  html {
    font-size: 14px;
  }

  .container {
    padding: 0 0.5rem;
  }

  .tabs {
    flex-wrap: nowrap;
  }

  .tab {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
  }
}

/* Utility classes */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--fred-text-muted); }
.text-success { color: #155724; }
.text-danger { color: #721c24; }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

.d-none { display: none; }
.d-flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

/* Theme Toggle Button */
.theme-toggle {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 0.5rem;
  color: white;
  padding: 0.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  transition: background var(--fred-transition), border-color var(--fred-transition);
}

.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.5);
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
  display: none;
}

/* Show sun in dark mode (click to go light) */
[data-theme="dark"] .theme-toggle .icon-sun {
  display: block;
}

/* Show moon in light mode (click to go dark) */
:root:not([data-theme="dark"]) .theme-toggle .icon-moon,
[data-theme="light"] .theme-toggle .icon-moon {
  display: block;
}

/* Sidebar Navigation */
.sidebar-nav {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--fred-border);
}

.sidebar-nav-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--fred-text-muted);
  margin-bottom: 0.75rem;
}

.sidebar-nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sidebar-nav-item {
  margin-bottom: 0.25rem;
}

.sidebar-nav-link {
  display: flex;
  align-items: center;
  padding: 0.625rem 0.875rem;
  border-radius: 0.5rem;
  color: var(--fred-text);
  text-decoration: none;
  font-size: 0.9375rem;
  font-weight: 500;
  transition: background var(--fred-transition), color var(--fred-transition);
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}

.sidebar-nav-link:hover {
  background: var(--fred-bg-card);
  color: var(--fred-primary);
  text-decoration: none;
}

.sidebar-nav-link.active {
  background: var(--fred-primary);
  color: white;
}

.sidebar-nav-link.active:hover {
  background: var(--fred-primary-dark);
  color: white;
}

/* Sidebar section divider */
.sidebar-section {
  margin-bottom: 1.5rem;
}

.sidebar-section-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--fred-text-muted);
  margin-bottom: 0.75rem;
  padding-top: 0.5rem;
}

/* Effect count badge */
.effect-count {
  font-size: 0.875rem;
  color: var(--fred-text-muted);
  padding: 0.75rem;
  background: var(--fred-bg-card);
  border-radius: 0.5rem;
  margin-top: 1rem;
}

.effect-count-number {
  font-weight: 700;
  color: var(--fred-accent-teal);
  font-size: 1.25rem;
}

/* Info icon link */
.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--fred-border);
  color: var(--fred-text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  text-decoration: none;
  margin-left: 0.5rem;
  transition: background var(--fred-transition), color var(--fred-transition);
}

.info-icon:hover {
  background: var(--fred-primary);
  color: white;
  text-decoration: none;
}

/* Header navigation links */
.header-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-nav-link {
  color: rgba(255, 255, 255, 0.9);
  text-decoration: none;
  font-size: 0.9375rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.375rem;
  transition: background var(--fred-transition), color var(--fred-transition);
}

.header-nav-link:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
  text-decoration: none;
}

/* Print styles */
@media print {
  .sidebar,
  .tabs,
  .btn,
  .dataTables_filter,
  .dataTables_length,
  .dataTables_paginate {
    display: none !important;
  }

  .sidebar-layout {
    grid-template-columns: 1fr;
  }

  .card {
    box-shadow: none;
    border: 1px solid #000;
  }
}

/* ============================================
   DARK MODE - COMPREHENSIVE ENHANCEMENTS
   ============================================ */

/* Tables - Improved readability */
[data-theme="dark"] table.dataTable {
  color: var(--fred-text-secondary);
  background: var(--fred-bg-card);
}

[data-theme="dark"] table.dataTable thead th {
  background: #1E293B;
  color: #F1F5F9;
  border-bottom: 2px solid #475569;
}

[data-theme="dark"] table.dataTable tbody td {
  color: #CBD5E1;
  border-bottom: 1px solid #334155;
}

[data-theme="dark"] table.dataTable tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] table.dataTable tbody tr:nth-child(even) {
  background-color: rgba(255, 255, 255, 0.02);
}

/* DataTables controls */
[data-theme="dark"] .dataTables_wrapper .dataTables_filter input,
[data-theme="dark"] .dataTables_wrapper .dataTables_length select {
  background: var(--fred-bg);
  color: var(--fred-text);
  border: 1px solid var(--fred-border);
}

[data-theme="dark"] .dataTables_wrapper .dataTables_filter input:focus,
[data-theme="dark"] .dataTables_wrapper .dataTables_length select:focus {
  border-color: var(--fred-primary);
  box-shadow: 0 0 0 3px rgba(225, 29, 72, 0.15);
  outline: none;
}

[data-theme="dark"] .dataTables_wrapper .dataTables_info {
  color: var(--fred-text-muted);
}

[data-theme="dark"] .dataTables_paginate .paginate_button {
  color: var(--fred-text-secondary) !important;
  border: 1px solid var(--fred-border);
  background: transparent;
}

[data-theme="dark"] .dataTables_paginate .paginate_button:hover:not(.current):not(.disabled) {
  background: rgba(255, 255, 255, 0.08);
  color: var(--fred-text) !important;
  border-color: #475569;
}

[data-theme="dark"] .dataTables_paginate .paginate_button.current {
  background: var(--fred-primary) !important;
  color: white !important;
  border-color: var(--fred-primary);
}

[data-theme="dark"] .dataTables_paginate .paginate_button.disabled {
  color: #475569 !important;
}

/* Sidebar dark mode */
[data-theme="dark"] .sidebar {
  background: var(--fred-bg-card);
  border: 1px solid var(--fred-border);
}

[data-theme="dark"] .sidebar-nav-link {
  color: var(--fred-text-secondary);
}

[data-theme="dark"] .sidebar-nav-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--fred-text);
}

/* Modal dark mode improvements */
[data-theme="dark"] .modal {
  background: var(--fred-bg-card);
  border: 1px solid var(--fred-border);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.7);
}

[data-theme="dark"] .modal-header {
  border-bottom-color: var(--fred-border);
}

[data-theme="dark"] .modal-header h3 {
  color: var(--fred-text);
}

[data-theme="dark"] .modal-body {
  color: var(--fred-text-secondary);
}

[data-theme="dark"] .modal-body h4 {
  color: var(--fred-text);
}

[data-theme="dark"] .modal-footer {
  border-top-color: var(--fred-border);
}

/* Badge dark mode - ensure text readability */
[data-theme="dark"] .badge-success {
  background: #166534;
  color: #BBF7D0;
}

[data-theme="dark"] .badge-failure {
  background: #991B1B;
  color: #FECACA;
}

[data-theme="dark"] .badge-neutral {
  background: #334155;
  color: #94A3B8;
}

/* Footer dark mode */
[data-theme="dark"] footer {
  background: var(--fred-bg-alt);
  color: var(--fred-text-muted);
}

/* Scrollbar styling for dark mode */
[data-theme="dark"] ::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

[data-theme="dark"] ::-webkit-scrollbar-track {
  background: var(--fred-bg);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: 5px;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
  background: #475569;
}

/* ============================================
   REFERENCE TOOLTIP STYLING
   ============================================ */

/* Reference tooltip styling */
.ref-tooltip {
  cursor: help;
  border-bottom: 1px dotted var(--fred-text-muted);
}

.ref-tooltip:hover {
  color: var(--fred-primary);
  border-bottom-color: var(--fred-primary);
}

/* JS-powered tooltip (appended to body) */
.tooltip-popup {
  position: fixed;
  background: var(--fred-primary);
  color: white;
  padding: 0.75rem;
  border-radius: 8px;
  max-width: 400px;
  font-size: 0.875rem;
  line-height: 1.4;
  z-index: 9999;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

[data-theme="dark"] .tooltip-popup {
  background: #3A3E40;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}

.tooltip-text {
  margin-bottom: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.2);
}

.tooltip-actions {
  display: flex;
  gap: 0.5rem;
}

.tooltip-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  padding: 0.25rem 0.5rem;
  border-radius: 3px;
  font-size: 0.75rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.tooltip-btn:hover {
  background: rgba(255,255,255,0.25);
  color: white;
}

.tooltip-copy {
  min-width: 70px;
}

.tooltip-link {
  color: #8FD8FF;
}

.tooltip-link:hover {
  color: white;
}
