/* =========================
   Global theme & baseline
   ========================= */
   :root {
    --bg: #f5f7fb;
    --text: #111827;
    --muted: #6b7280;
    --primary: #0d6efd;
    --primary-600: #0a58ca;
    --accent: #6f42c1;
    --accent-600: #5a36a3;
    --success: #198754;
    --warning: #ffc107;
    --danger: #dc3545;
  
    --card: #ffffff;
    --border: #e6e8ef;
    --shadow: 0 6px 18px rgba(17,24,39,.06);
    --ring: 0 0 0 3px rgba(13,110,253,.2);
  }
  
  html, body {
    height: 100%;
  }
  
  body {
    font-family: "Noto Sans SC", system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
  }
  
  /* =========================
     Header (white bar + logos)
     ========================= */
  .app-header {
    background: #ffffff;
    border-bottom: 1px solid var(--border);
  }
  .app-header .header-title {
    color: var(--text);
    font-weight: 700;
    font-size: 2rem;
    margin: 0;
    line-height: 1.2;
  }
  .app-header .subtitle {
    color: var(--muted);
    margin: 0;
  }
  
  /* =========================
     Cards & containers
     ========================= */
  .card,
  .chart-container {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: .75rem;
    box-shadow: var(--shadow);
  }
  
  .chart-container {
    padding: 1rem;
    height: 100%;
  }
  .chart-title {
    margin-bottom: .6rem;
    font-weight: 600;
    color: #374151;
  }
  
  /* Global charts (dimension/modality/task) spacing for canvas */
  #charts canvas {
    max-height: 280px;
    height: 280px;
  }
  
  /* Phase charts compact height - will fit 4 in a row on xl */
  #phase-charts canvas {
    max-height: 220px;
    height: 220px;
  }
  
  /* Hover pointer for interactive charts */
  canvas:hover {
    cursor: pointer;
  }
  
  /* =========================
     Intro box
     ========================= */
  .intro-box {
    background: #ffffff;
    border: 1px solid var(--border);
    border-left: 6px solid var(--primary);
    border-radius: 1rem;
  }
  .intro-box .lead {
    color: var(--muted);
    font-weight: 400;
  }
  
  /* =========================
     Overview images
     ========================= */
  #visual-summary .img-fluid {
    transition: transform .25s ease, box-shadow .25s ease;
  }
  #visual-summary .img-fluid:hover {
    transform: scale(1.01);
    box-shadow: 0 10px 30px rgba(0,0,0,.08);
  }
  
  /* =========================
     Filter row (Mode 1 + Mode 2)
     ========================= */
  #filters {
    transition: box-shadow .25s ease;
  }
  #filters:hover {
    box-shadow: 0 12px 32px rgba(0,0,0,.08);
  }
  .form-control:focus,
  .form-select:focus,
  textarea:focus {
    border-color: var(--primary);
    box-shadow: var(--ring);
  }
  
  /* Mode 1 JSON textarea styling */
  #filter-json {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono","Courier New", monospace;
    background: #f9fafb;
    border: 1px solid var(--border);
    border-radius: .75rem;
  }
  
  /* Phase running highlight (JS adds these classes and keeps while running) */
  #filter-json.phase12-running {
    border-left: 6px solid var(--primary);
    box-shadow: 0 0 0 3px rgba(13,110,253,.12), 0 12px 28px rgba(13,110,253,.15);
  }
  #filter-json.phase34-running {
    border-left: 6px solid var(--accent);
    box-shadow: 0 0 0 3px rgba(111,66,193,.12), 0 12px 28px rgba(111,66,193,.15);
  }
  
  /* Small helper text under JSON */
  .json-help {
    background: #f9fafb;
    border: 1px dashed var(--border);
    border-radius: .5rem;
    color: #334155;
    font-size: .9rem;
    padding: .75rem .85rem;
  }
  
  /* Error text for invalid JSON */
  #json-error {
    font-size: .9rem;
  }
  
  /* =========================
     Results banner above table
     ========================= */
  #results-count {
    background: #e9f5ff;
    border: 1px solid #bde0ff;
    border-left: 6px solid var(--primary);
    border-radius: .75rem;
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
    font-size: 1.05rem;
    font-weight: 500;
    color: var(--primary-600);
    box-shadow: var(--shadow);
  }
  
  /* =========================
     Table styling
     ========================= */
  .table-responsive {
    background: #ffffff;
    border-radius: .75rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
  }
  
  .table thead {
    position: sticky;
    top: 0;
    z-index: 5;
  }
  
  .table thead.table-dark th {
    background: #111827 !important;
    color: #ffffff !important;
    border-color: #0e1116 !important;
  }
  
  .table th {
    font-weight: 600;
    white-space: nowrap;
  }
  .table td, .table th {
    padding: 1rem .85rem;
    vertical-align: middle;
  }
  
  .table-striped > tbody > tr:nth-of-type(odd) > * {
    --bs-table-accent-bg: #f8fafc;
  }
  
  .table-hover tbody tr {
    transition: transform .15s ease, box-shadow .15s ease, background-color .15s ease;
  }
  .table-hover tbody tr:hover {
    background: #eef2ff;
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(0,0,0,.06);
  }
  
  /* Links inside table */
  .table a {
    text-decoration: none;
    font-weight: 600;
    color: var(--primary-600);
  }
  .table a:hover {
    text-decoration: underline;
  }
  
  /* No results alert */
  #no-results {
    font-size: 1.05rem;
    font-weight: 600;
  }
  
  /* Loading indicator spacing */
  #loading-indicator p {
    color: var(--muted);
  }
  
  /* =========================
     Summary table (Phase 4)
     ========================= */
  .summary-title {
    font-size: .95rem;
    font-weight: 700;
  }
  #selection-summary .summary-card {
    border-left: 6px solid var(--accent);
    background: linear-gradient(180deg, #ffffff 0%, #fbfbff 100%);
  }
  #selection-summary table thead th {
    font-size: .85rem;
  }
  #selection-summary table tbody td {
    font-size: .92rem;
  }
  
  /* =========================
     Buttons tweaks
     ========================= */
  .btn-primary {
    background: var(--primary);
    border-color: var(--primary);
  }
  .btn-primary:hover {
    background: var(--primary-600);
    border-color: var(--primary-600);
  }
  .btn-outline-primary {
    color: var(--primary-600);
    border-color: var(--primary-600);
  }
  .btn-outline-primary:hover {
    color: #fff;
    background: var(--primary-600);
    border-color: var(--primary-600);
  }
  
  /* =========================
     Footer
     ========================= */
  footer {
    padding-top: 1.25rem;
    padding-bottom: 1.25rem;
  }
  
  /* =========================
     Utilities
     ========================= */
  .badge {
    font-weight: 600;
    letter-spacing: .2px;
  }
  .text-muted {
    color: var(--muted) !important;
  }
  
  /* Compact selects in Mode 2 */
  #filters .form-select,
  #filters .form-control {
    border-radius: .6rem;
  }
  
  /* Equal height on large screens */
  @media (min-width: 992px) {
    #filter-row .card,
    #filters { height: 100%; }
  }
  