/*
 * Captain Schedule Predictor — dashboard styles.

 * Dark-themed layout with:
 *   - Header stats bar
 *   - Drag-and-drop XML upload zone
 *   - Tabbed panels for predictions, captains, calendar, history
 *   - Busy-day color intensity on calendar cells
 */
:root {
  --bg: #070b14;
  --bg-elevated: #0c1222;
  --surface: #111827;
  --surface-2: #1a2332;
  --surface-hover: #1f2937;
  --border: rgba(148, 163, 184, 0.14);
  --border-strong: rgba(148, 163, 184, 0.28);
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --accent: #38bdf8;
  --accent-soft: rgba(56, 189, 248, 0.12);
  --accent-hover: #0ea5e9;
  --success: #34d399;
  --success-soft: rgba(52, 211, 153, 0.12);
  --warning: #fbbf24;
  --warning-soft: rgba(251, 191, 36, 0.12);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 4px 16px rgba(0, 0, 0, 0.25);
  --font-sans: "DM Sans", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(56, 189, 248, 0.12), transparent),
    radial-gradient(ellipse 60% 40% at 100% 0%, rgba(99, 102, 241, 0.06), transparent),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.55;
}

code {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.85em;
  background: var(--surface-2);
  padding: 0.15em 0.4em;
  border-radius: 4px;
}

.app {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.5rem 3rem;
}

.header {
  padding: 1.75rem 0 1.25rem;
  margin-bottom: 1rem;
  border-bottom: none;
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  align-items: flex-start;
  justify-content: space-between;
}

.brand {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.brand-icon {
  font-size: 2rem;
  line-height: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 3rem;
  height: 3rem;
  display: grid;
  place-items: center;
}

.brand h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

.stats-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(5.5rem, 1fr));
  gap: 0.65rem;
  min-width: min(100%, 28rem);
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.75rem 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}

.stat-value {
  font-size: 1.15rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--accent);
  line-height: 1.2;
}

.stat-label {
  font-size: 0.68rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.storage-banner {
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  line-height: 1.5;
}

.storage-banner.hidden {
  display: none;
}

.storage-banner.ready {
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.35);
}

.storage-banner.empty {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.upload-divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1.25rem 0 1rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.upload-divider::before,
.upload-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.direct-upload-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
}

.direct-upload-hint {
  color: var(--text-muted);
  font-size: 0.85rem;
}
  flex-wrap: wrap;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 5rem;
}

.stat-value {
  font-size: 1.25rem;
  font-weight: 700;
  font-family: "JetBrains Mono", monospace;
  color: var(--accent);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.main {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.card h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.card-desc {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.06);
}

.upload-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
}

.upload-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  text-decoration: underline;
}

.upload-result {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
}

.upload-result.success {
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.35);
  color: #86efac;
}

.upload-result.error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fca5a5;
}

.hidden {
  display: none !important;
}

.main {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.dashboard-toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1rem;
  background: rgba(7, 11, 20, 0.92);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.toolbar-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: flex-end;
}

.controls {
  display: contents;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.control-group label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  font: inherit;
  min-width: 10rem;
}

.btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 0.55rem 1.1rem;
  border-radius: 8px;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.btn:hover {
  background: var(--accent-hover);
}

.btn.secondary {
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.btn.secondary:hover {
  background: var(--border);
}

.btn.primary-action {
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  font-weight: 600;
}

.btn.primary-action:hover:not(:disabled) {
  background: linear-gradient(135deg, #1d4ed8, #6d28d9);
}

.btn.primary-action:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

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

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
}

.schedule-actions {
  white-space: nowrap;
  display: flex;
  gap: 0.35rem;
}

.schedule-edit-input {
  width: 100%;
  min-width: 4.5rem;
  background: var(--surface-2);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  font: inherit;
  font-size: 0.85rem;
}

.schedule-edit-boats {
  min-width: 8rem;
}

tr.schedule-row-editing td {
  background: rgba(59, 130, 246, 0.08);
}

.schedule-add-form {
  margin-bottom: 1.25rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}

.schedule-add-form h3 {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.schedule-add-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 0.75rem;
}

.schedule-add-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.schedule-add-grid input {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  font: inherit;
  font-size: 0.875rem;
  text-transform: none;
  letter-spacing: normal;
}

.schedule-add-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.85rem;
}

.schedule-add-result {
  font-size: 0.85rem;
}

.schedule-add-result.success {
  color: #34d399;
}

.schedule-add-result.error {
  color: #f87171;
}

.schedule-bulk-form {
  margin-top: 1rem;
}

.schedule-bulk-help {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.schedule-bulk-label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.75rem;
}

.schedule-bulk-label input[type="number"] {
  width: 6rem;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  font: inherit;
  font-size: 0.875rem;
  text-transform: none;
  letter-spacing: normal;
}

.schedule-bulk-date input[type="date"] {
  width: 11rem;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  font: inherit;
  font-size: 0.875rem;
  text-transform: none;
  letter-spacing: normal;
}

.schedule-bulk-ai {
  margin-bottom: 0.5rem;
}

.schedule-bulk-text {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  font: inherit;
  font-size: 0.875rem;
  line-height: 1.45;
  resize: vertical;
  text-transform: none;
  letter-spacing: normal;
}

.tour-management-section {
  border: 1px solid rgba(59, 130, 246, 0.35);
  background: linear-gradient(180deg, rgba(59, 130, 246, 0.08), transparent);
}

.schedule-table-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
  margin-bottom: 0.75rem;
}

.schedule-table-controls label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.schedule-table-controls input[type="text"],
.schedule-table-controls input[type="date"] {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  font: inherit;
  font-size: 0.875rem;
  text-transform: none;
  letter-spacing: normal;
  min-width: 9rem;
}

.schedule-filter-check {
  flex-direction: row !important;
  align-items: center;
  text-transform: none !important;
  letter-spacing: normal !important;
  font-size: 0.85rem !important;
  color: var(--text) !important;
  gap: 0.45rem !important;
}

.schedule-table-meta {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

tr.schedule-row-highlight td {
  background: rgba(52, 211, 153, 0.12);
}

.source-badge.manual {
  background: rgba(52, 211, 153, 0.15);
  color: #34d399;
}

.source-badge.upload {
  background: rgba(148, 163, 184, 0.15);
  color: var(--text-muted);
}

.tabs {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  border-bottom: none;
  padding-bottom: 0;
}

.tab {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  padding: 0.5rem 0.9rem;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: 999px;
  margin-bottom: 0;
  border-bottom: none;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.tab:hover {
  color: var(--text);
  background: var(--surface-2);
}

.tab.active {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: rgba(56, 189, 248, 0.35);
  border-bottom-color: rgba(56, 189, 248, 0.35);
}

.tab-panel {
  display: none;
  animation: fadeIn 0.2s ease;
}

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

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-height: min(70vh, 720px);
}

thead {
  position: sticky;
  top: 0;
  z-index: 2;
}

th {
  background: var(--surface-2);
  white-space: nowrap;
}

.boat-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 500;
  padding: 0.2em 0.55em;
  border-radius: 6px;
  background: var(--accent-soft);
  border: 1px solid rgba(56, 189, 248, 0.25);
  color: #bae6fd;
}

.table-meta {
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.card-header h2 {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.empty-state {
  text-align: center;
  padding: 2.5rem 1.5rem;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  opacity: 0.7;
}

.loading-row td {
  text-align: center;
  padding: 2rem !important;
  color: var(--text-muted);
}

.spinner {
  display: inline-block;
  width: 1.1rem;
  height: 1.1rem;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 0.5rem;
}

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

details.collapsible-section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

details.collapsible-section summary {
  cursor: pointer;
  padding: 1rem 1.25rem;
  font-weight: 600;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  user-select: none;
}

details.collapsible-section summary::-webkit-details-marker {
  display: none;
}

details.collapsible-section summary::after {
  content: "▾";
  color: var(--text-muted);
  transition: transform 0.2s;
}

details.collapsible-section[open] summary::after {
  transform: rotate(180deg);
}

details.collapsible-section .details-body {
  padding: 0 1.25rem 1.25rem;
  border-top: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

th, td {
  text-align: left;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

th {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.empty {
  color: var(--text-muted);
  text-align: center;
  padding: 2rem !important;
}

.confidence-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.confidence-track {
  flex: 1;
  height: 6px;
  background: var(--surface-2);
  border-radius: 3px;
  overflow: hidden;
  min-width: 4rem;
}

.confidence-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
}

.busy-badge {
  display: inline-block;
  padding: 0.2em 0.55em;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.busy-low { background: rgba(34, 197, 94, 0.2); color: #86efac; }
.busy-med { background: rgba(245, 158, 11, 0.2); color: #fcd34d; }
.busy-high { background: rgba(239, 68, 68, 0.2); color: #fca5a5; }

.source-badge {
  display: inline-block;
  padding: 0.15em 0.5em;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.source-badge.pattern {
  background: rgba(148, 163, 184, 0.2);
  color: #cbd5e1;
}

.source-badge.ai {
  background: rgba(139, 92, 246, 0.25);
  color: #c4b5fd;
}

.cal-day.ai-forecast {
  outline: 1px dashed rgba(139, 92, 246, 0.45);
}

.captain-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}

.captain-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.captain-card h3 {
  font-family: "JetBrains Mono", monospace;
  font-size: 1rem;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.captain-card .meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.captain-card .next {
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 0.5rem;
}

.cal-day {
  border-radius: 8px;
  padding: 0.6rem;
  text-align: center;
  border: 1px solid var(--border);
  font-size: 0.75rem;
}

.cal-day .date-num {
  font-weight: 700;
  font-size: 1rem;
  font-family: "JetBrains Mono", monospace;
}

.cal-day .dow {
  color: var(--text-muted);
  font-size: 0.65rem;
  text-transform: uppercase;
}

.cal-day .ships {
  margin-top: 0.25rem;
  font-size: 0.65rem;
  opacity: 0.85;
}

.cal-day.actual {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.xml-input {
  width: 100%;
  min-height: 160px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: "JetBrains Mono", monospace;
  font-size: 0.85rem;
  padding: 1rem;
  resize: vertical;
  margin-bottom: 1rem;
}

.xml-output {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  overflow-x: auto;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.8rem;
  line-height: 1.5;
  max-height: 420px;
  white-space: pre-wrap;
  word-break: break-word;
}

.repair-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.repair-summary {
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.35);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.repair-summary.hidden {
  display: none;
}

.hero-section {
  border-color: rgba(59, 130, 246, 0.35);
}

.csv-section {
  border-color: rgba(34, 197, 94, 0.45);
  background: linear-gradient(180deg, rgba(34, 197, 94, 0.06) 0%, var(--surface) 100%);
}

.csv-format-hint {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  line-height: 1.6;
}

.replace-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  cursor: pointer;
}

.replace-checkbox input {
  accent-color: var(--accent);
}

.hero-header {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.5rem;
}

.field-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0.75rem 0 0.35rem;
}

.xml-output-editable {
  min-height: 200px;
  background: rgba(34, 197, 94, 0.05);
  border-color: rgba(34, 197, 94, 0.25);
}

.xml-output-editable:not([readonly]) {
  background: var(--surface-2);
  border-color: var(--border);
}

.output-actions {
  margin-top: 0.75rem;
}

.repair-table-wrap {
  margin: 1rem 0;
  max-height: 240px;
  overflow-y: auto;
}

.ai-badge {
  display: inline-block;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 500;
  margin-bottom: 1rem;
}

.ai-badge.connected {
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.4);
  color: #86efac;
}

.ai-badge.disabled {
  background: rgba(148, 163, 184, 0.12);
  border: 1px solid rgba(148, 163, 184, 0.35);
  color: var(--text-muted);
}

.ai-badge.error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fca5a5;
}

.nested-card {
  margin-bottom: 1rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
}

.prediction-chat-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.prediction-chat-header h3 {
  margin: 0 0 0.25rem;
  font-size: 1rem;
}

.prediction-chat-log {
  max-height: 260px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  padding: 0.75rem;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.35);
  border: 1px solid var(--border);
}

.prediction-chat-message {
  padding: 0.65rem 0.8rem;
  border-radius: 10px;
  font-size: 0.92rem;
}

.prediction-chat-message strong {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.prediction-chat-message.user {
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.25);
}

.prediction-chat-message.assistant {
  background: rgba(148, 163, 184, 0.08);
  border: 1px solid rgba(148, 163, 184, 0.18);
}

.prediction-chat-message p {
  margin: 0;
}

.prediction-chat-actions {
  margin: 0.5rem 0 0;
  padding-left: 1rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.prediction-chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  align-items: end;
}

.prediction-chat-form textarea {
  width: 100%;
  min-height: 72px;
  resize: vertical;
}

.prediction-chat-status {
  margin-top: 0.75rem;
  font-size: 0.9rem;
}

.prediction-chat-status.success {
  color: #86efac;
}

.prediction-chat-status.error {
  color: #fca5a5;
}

.subheading {
  font-size: 0.95rem;
  margin: 1.25rem 0 0.75rem;
}

.footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
}

@media (max-width: 768px) {
  .app {
    padding: 0 1rem 2rem;
  }

  .header-inner {
    flex-direction: column;
  }

  .stats-bar {
    width: 100%;
    grid-template-columns: repeat(2, 1fr);
  }

  .dashboard-toolbar {
    position: static;
  }

  .toolbar-controls {
    width: 100%;
  }

  .control-group,
  select,
  input[type="search"] {
    width: 100%;
    min-width: 0;
  }

  .tabs {
    width: 100%;
  }

  .table-wrap {
    max-height: none;
  }
}
