/*
 * dashboard-style.css
 * -------------------
 * Shared CSS for all survey dashboard pages.
 * Provides a clean, print-friendly light theme.
 */

/* --- Light Theme CSS Variables --- */
:root {
  --bg: #f4f7f6;
  --card: #ffffff;
  --muted: #555555;
  --text: #000000;
  --grid: #e0e0e0;
  --border: #cccccc;
  --accent: #0056b3;
  --shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
  --radius: 14px;
}

/* --- Base Styles --- */
* {
  box-sizing: border-box;
}
body {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  margin: 0;
  padding: clamp(16px, 2.6vw, 32px);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}
h1 {
  font-size: clamp(1.35rem, 2.2vw, 2rem);
  margin: 0 0 16px;
  text-align: center;
  color: var(--text);
}
a {
  color: inherit;
}
.page-shell {
  max-width: 1100px;
  margin: 0 auto;
}
.page-header {
  max-width: 1100px;
  margin: 0 auto 18px;
  padding: clamp(16px, 2.4vw, 24px);
  border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--border));
  border-radius: 18px;
  background:
    radial-gradient(circle at top right, color-mix(in srgb, var(--accent) 9%, white), transparent 34%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(255, 255, 255, 0.92));
  box-shadow: var(--shadow);
}
.page-header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.page-kicker {
  display: inline-block;
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.page-title {
  margin: 0;
  text-align: left;
}
.page-intro {
  margin: 10px 0 0;
  max-width: 760px;
  color: var(--muted);
}
.page-meta {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}
.page-meta strong {
  color: var(--text);
}
.page-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}
.page-actions form {
  display: contents;
}
.page-actions .back-link {
  margin-bottom: 0;
}
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  min-height: 38px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--accent) 26%, var(--border));
  background: color-mix(in srgb, var(--accent) 6%, white);
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}
.back-link:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}
.short-label {
  display: none;
}
.table-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}
.content-panel {
  max-width: 1100px;
  margin: 0 auto;
  padding: clamp(18px, 2.5vw, 28px);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.content-panel.narrow {
  max-width: 920px;
}
.dashboard-grid {
  max-width: 1100px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
  align-items: stretch;
}
.dashboard-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 196px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid color-mix(in srgb, var(--accent) 12%, var(--border));
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.dashboard-card h2 {
  margin: 0;
  font-size: 1.1rem;
  line-height: 1.25;
}
.dashboard-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
  flex: 1;
}
.dashboard-card .action-link,
.dashboard-card .btn,
.dashboard-card .button-style-download {
  align-self: flex-start;
}
.dashboard-meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding: 8px 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 8%, white);
  color: var(--muted);
  font-size: 0.92rem;
  border: 1px solid var(--border);
}
.dashboard-meta-pill strong {
  color: var(--text);
}
.dashboard-copy {
  max-width: 760px;
}
.dashboard-copy p {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.55;
}
.cohort-legend {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 12px;
}
.cohort-legend .key {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.cohort-legend .swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
  border: 1px solid rgba(0, 0, 0, 0.08);
}
.chart-grid {
  max-width: 1100px;
  margin: 12px auto 10px;
  display: none;
  gap: 18px;
  grid-template-columns: minmax(0, 1fr);
}
.chart-grid.visible {
  display: grid;
}
.chart-grid.two-col {
  display: grid;
}
.toggle-control {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}
.toggle-control input {
  display: none;
}
.toggle-control .slider {
  width: 46px;
  height: 24px;
  border-radius: 999px;
  background: #e5e7eb;
  position: relative;
  transition: background 0.2s;
}
.toggle-control .slider::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #ffffff;
  left: 3px;
  top: 3px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  transition: transform 0.2s;
}
.toggle-control input:checked + .slider {
  background: #3b82f6;
}
.toggle-control input:checked + .slider::before {
  transform: translateX(20px);
}
.toggle-control .toggle-labels {
  margin-left: 6px;
  display: flex;
  gap: 4px;
}
.toggle-control .toggle-labels span {
  opacity: 0.5;
}
.toggle-control[data-mode="table"] span[data-mode="table"],
.toggle-control[data-mode="charts"] span[data-mode="charts"] {
  opacity: 1;
  font-weight: 600;
}
.section-intro {
  margin: 0 0 18px;
  color: var(--muted);
}
.form-stack {
  display: grid;
  gap: 16px;
}
.status-note {
  margin-top: 18px;
  color: var(--muted);
  font-style: italic;
}
.output-panel {
  margin-top: 24px;
  padding: 20px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #f8fafc;
  white-space: pre-wrap;
  overflow-x: auto;
  font-family: "SF Mono", Consolas, monospace;
}
button,
.btn,
.action-link,
.action-button,
.button-style-download,
.button-style-ai,
.ai-download-button {
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}
button:hover,
.btn:hover,
.action-link:hover,
.action-button:hover,
.button-style-download:hover,
.button-style-ai:hover,
.ai-download-button:hover {
  transform: translateY(-1px);
}
button:focus-visible,
select:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 70%, white);
  outline-offset: 2px;
}

/* --- Header & Controls --- */
.topbar {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  align-items: center;
  justify-content: center;
  margin: 0 auto 18px;
  max-width: 1100px;
}
.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  align-items: end;
}
.controls > div {
  min-width: 0;
}
label {
  font-size: 0.9rem;
  color: var(--muted);
  display: block;
  margin-bottom: 6px;
}
select,
input[type="number"],
input[type="text"],
input[type="file"],
textarea {
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text);
}
textarea {
  min-height: 96px;
  resize: vertical;
}
button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  text-decoration: none;
}
.btn {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
  background: color-mix(in srgb, var(--accent) 8%, white);
}
.btn:hover {
  color: #ffffff;
  background: var(--accent);
  border-color: var(--accent);
}
.top-actions,
.export-buttons {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.toolbar-block {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.action-link,
.action-button,
.button-style-download,
.ai-download-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  font: inherit;
}
.action-link,
.button-style-download {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
  background: color-mix(in srgb, var(--accent) 7%, white);
}
.action-link:hover,
.button-style-download:hover {
  color: #ffffff;
  background: var(--accent);
  border-color: var(--accent);
}
.action-button,
.button-style-ai {
  color: #ffffff;
  background: #6f42c1;
  border-color: #6f42c1;
}
.action-button:hover,
.button-style-ai:hover {
  background: #5a33a8;
  border-color: #5a33a8;
}
.ai-download-button {
  color: #475569;
  background: #f8fafc;
  border-color: #cbd5e1;
}
.ai-download-button:hover {
  background: #e2e8f0;
  border-color: #94a3b8;
}
.ai-button-icon {
  font-size: 1rem;
  line-height: 1;
}

/* --- Chart Legend --- */
.legend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 18px 0 8px;
  color: var(--muted);
  font-size: 0.9rem;
}
.legend-bar {
  width: 240px;
  height: 10px;
  border-radius: 6px;
  background: linear-gradient(90deg,
      #440154, #472d7b, #3b528b, #2c728e,
      #21918c, #27ad81, #5cc863, #aadc32, #fde725);
  box-shadow: inset 0 0 0 1px var(--border);
}
.legend-note {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  margin: -6px 0 8px;
}

/* --- Layout & Grid --- */
.divider {
  height: 1px;
  width: min(1080px, 92vw);
  margin: 10px auto 22px;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
}
.grid {
  display: grid;
  justify-content: center;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr));
  gap: 28px;
}
.chart-card {
  width: 100%;
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 16px 16px 18px;
  margin: 0 auto;
  overflow: hidden;
}
.chart-card h2 {
  font-size: 1rem;
  margin: 0 0 10px 0;
  text-align: center;
  line-height: 1.35;
  color: var(--accent);
  font-weight: 600;
}
.canvas-wrap {
  width: 100%;
  height: clamp(260px, 42vw, 340px);
  position: relative;
}
canvas {
  width: 100% !important;
  height: 100% !important;
}
.footer-note {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  margin: 22px auto 0;
  line-height: 1.4;
  max-width: 1100px;
}
.table-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.table-container table {
  width: 100%;
  border-collapse: collapse;
}
.table-fit-mobile table {
  min-width: 0;
  table-layout: fixed;
}
.table-fit-mobile th,
.table-fit-mobile td {
  white-space: normal;
  word-break: normal;
  overflow-wrap: anywhere;
}
.ai-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(15, 23, 42, 0.56);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.ai-modal-content {
  background: var(--card);
  color: var(--text);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.22);
  width: min(760px, 100%);
  max-height: min(86vh, 920px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.ai-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.ai-modal-header h2 {
  margin: 0;
  font-size: 1.15rem;
}
.ai-modal-close {
  min-height: auto;
  padding: 0;
  border: none;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--muted);
  box-shadow: none;
}
.ai-modal-close:hover {
  color: var(--text);
  transform: none;
}
.ai-modal-body {
  padding: 22px;
  overflow-y: auto;
  line-height: 1.6;
}
.ai-modal-body .ai-loading {
  text-align: center;
  color: var(--muted);
  font-style: italic;
  padding: 32px 0;
}
.ai-modal-body h3 {
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.ai-modal-body h4 {
  margin: 18px 0 8px;
  color: var(--muted);
}
.ai-modal-body ul,
.ai-modal-body ol {
  padding-left: 20px;
  margin: 0 0 16px;
}
.ai-modal-body p,
.ai-modal-body li {
  margin-bottom: 10px;
}
.ai-error {
  color: #b91c1c;
  background: #fef2f2;
  border: 1px solid #fecaca;
  padding: 16px;
  border-radius: 10px;
}
.empty-state {
  max-width: 900px;
  margin: 40px auto;
  text-align: center;
  color: var(--muted);
}

@media (max-width: 768px) {
  body {
    padding: 14px;
  }
  .topbar {
    margin-bottom: 14px;
  }
  .page-header {
    padding: 16px;
    margin-bottom: 14px;
  }
  .page-actions {
    width: 100%;
    justify-content: flex-start;
  }
  .content-panel {
    padding: 16px;
  }
  .dashboard-card {
    min-height: 0;
  }
  .controls {
    grid-template-columns: 1fr;
  }
  .grid {
    gap: 20px;
  }
  .chart-card {
    padding: 14px;
  }
  .canvas-wrap {
    height: clamp(240px, 58vw, 320px);
  }
  .legend {
    gap: 8px;
    font-size: 0.82rem;
  }
  .table-container table {
    min-width: 0;
  }
  .table-fit-mobile th,
  .table-fit-mobile td {
    padding: 8px 6px;
  }
  .table-fit-mobile th {
    font-size: 0.68rem;
    line-height: 1.35;
  }
  .table-fit-mobile td {
    font-size: 0.8rem;
  }
  .stack-on-mobile thead {
    display: none;
  }
  .stack-on-mobile,
  .stack-on-mobile tbody,
  .stack-on-mobile tr,
  .stack-on-mobile td {
    display: block;
    width: 100%;
  }
  .stack-on-mobile tr {
    margin-bottom: 12px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--card);
    overflow: hidden;
  }
  .stack-on-mobile td {
    display: grid;
    grid-template-columns: minmax(110px, 42%) 1fr;
    gap: 10px;
    align-items: start;
    padding: 10px 12px !important;
    border-bottom: 1px solid var(--border);
    text-align: left !important;
  }
  .stack-on-mobile td:last-child {
    border-bottom: none;
  }
  .stack-on-mobile td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
  }
  .stack-on-mobile td.no-data-msg {
    display: block;
    padding: 18px 14px !important;
    text-align: center !important;
  }
  .stack-on-mobile td.no-data-msg::before {
    display: none;
  }
  .short-label {
    display: inline;
  }
  .long-label {
    display: none;
  }
  .footer-note {
    font-size: 0.82rem;
  }
}

@media (min-width: 980px) {
  .chart-grid.two-col {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* --- SIMPLE PRINT STYLES --- */
@media print {
  body {
    margin: 20px !important;
    padding: 0 !important;
  }

  /* Hide non-print elements */
  .no-print,
  .controls,
  .divider,
  .legend,
  .legend-note {
    display: none !important;
  }

  /* Force 1-column layout */
  .grid {
    grid-template-columns: 1fr !important;
    gap: 20px;
    width: 100%;
    margin: 0;
  }
  .chart-card {
    box-shadow: none !important;
    border: 1px solid #bbbbbb !important;
    /* THIS PREVENTS CHARTS SPLITTING ACROSS PAGES */
    page-break-inside: avoid;
  }
  .canvas-wrap {
    height: 300px !important; /* Fixed height for print */
  }
  .footer-note {
    display: block !important; /* Show the footer note */
  }
}

/* ==================================================================== */
/* Subject Overview page (report_subject_overview.php)                  */
/* ==================================================================== */

/* Page-specific colour tokens */
body.subject-overview {
  --seriesA: #0056b3;
  --seriesD: #6f42c1;
  --muted: #6b7280;
  --border: #e5e7eb;
  --bg: #ffffff;
  --text: #1f2937;
  --accent: #0ea5e9;
}

/* Controls layout for this page: 3 columns on desktop */
body.subject-overview .controls {
  max-width: 1100px;
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr 1fr 1fr;
}
@media (max-width: 900px) {
  body.subject-overview .controls {
    grid-template-columns: 1fr;
  }
}

/* Table layout */
body.subject-overview .table-container {
  max-width: 1100px;
  margin: 20px auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  overflow: hidden;
}
body.subject-overview .table-container table {
  width: 100%;
  min-width: 0;
  border-collapse: collapse;
  table-layout: fixed;
}
body.subject-overview .table-container th,
body.subject-overview .table-container td {
  padding: 12px 15px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
body.subject-overview .table-container th {
  background-color: #f9fafb;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
}
body.subject-overview .table-container td {
  color: var(--text);
}
body.subject-overview .table-container tbody tr:nth-child(even) {
  background-color: #fcfcfd;
}
body.subject-overview .table-container tbody tr:hover {
  background-color: #f5f5f5;
}
body.subject-overview .table-container th:nth-child(1) {
  width: 5%;
  text-align: center;
}
body.subject-overview .table-container td:nth-child(1) {
  text-align: center;
  color: var(--muted);
  font-weight: 500;
}
body.subject-overview .table-container th:nth-child(2) {
  width: 55%;
}
body.subject-overview .table-container th:nth-child(3),
body.subject-overview .table-container th:nth-child(5) {
  width: 12%;
  text-align: center;
}
body.subject-overview .table-container td:nth-child(3),
body.subject-overview .table-container td:nth-child(5) {
  font-weight: 500;
  font-size: 1.1rem;
  text-align: center;
}
body.subject-overview .table-container td:nth-child(3) {
  color: var(--seriesA);
}
body.subject-overview .table-container td:nth-child(5) {
  color: var(--seriesD);
}
body.subject-overview .table-container th:nth-child(4),
body.subject-overview .table-container th:nth-child(6) {
  width: 8%;
  text-align: center;
}
body.subject-overview .table-container td:nth-child(4),
body.subject-overview .table-container td:nth-child(6) {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  padding-top: 16px;
}
body.subject-overview .no-data-msg {
  text-align: center;
  padding: 40px;
  font-style: italic;
  color: var(--muted);
}

/* Overall dept block */
body.subject-overview .dept-overall {
  max-width: 1100px;
  margin: 14px auto 8px;
  padding: 14px 16px;
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: 8px;
  text-align: center;
}
body.subject-overview .dept-overall-score {
  font-size: 1.8rem;
  line-height: 1;
  font-weight: 800;
  color: var(--seriesA);
}
body.subject-overview .dept-overall-label {
  color: var(--muted);
  font-size: 0.95rem;
  margin-top: 6px;
}

/* Subject list at footer */
body.subject-overview .subject-list {
  max-width: 1100px;
  margin: 18px auto 28px;
}
body.subject-overview .subject-list h2 {
  margin: 0 0 8px;
  font-size: 1rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .02em;
}
body.subject-overview .subject-columns {
  columns: 3 280px;
  column-gap: 24px;
  font-size: 0.95rem;
  line-height: 1.6;
}
body.subject-overview .subject-list ul {
  margin: 0;
  padding-left: 18px;
}

body.subject-overview .button-style-ai:disabled,
body.subject-overview .action-button:disabled {
  background-color: var(--muted);
  border-color: var(--muted);
  cursor: not-allowed;
}

/* AI Modal Styles */
body.subject-overview .ai-modal-backdrop {
  position: fixed;
  z-index: 1000;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
}
body.subject-overview .ai-modal-content {
  background: var(--bg);
  color: var(--text);
  border-radius: 8px;
  box-shadow: 0 5px 20px rgba(0,0,0,0.25);
  max-width: 700px;
  width: 90%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}
body.subject-overview .ai-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}
body.subject-overview .ai-modal-header h2 {
  margin: 0;
  font-size: 1.2rem;
}
body.subject-overview .ai-modal-close {
  font-size: 1.5rem;
  font-weight: bold;
  line-height: 1;
  color: var(--muted);
  border: none;
  background: none;
  cursor: pointer;
  padding: 4px;
}
body.subject-overview .ai-modal-close:hover {
  color: var(--text);
}
body.subject-overview .ai-modal-body {
  padding: 24px;
  overflow-y: auto;
  line-height: 1.6;
}
body.subject-overview .ai-modal-body .ai-loading {
  text-align: center;
  font-style: italic;
  color: var(--muted);
  padding: 40px 0;
}
body.subject-overview .ai-modal-body h3 {
  font-size: 1.1rem;
  margin-top: 24px;
  margin-bottom: 10px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--border);
}
body.subject-overview .ai-modal-body ul,
body.subject-overview .ai-modal-body ol {
  padding-left: 20px;
  margin-bottom: 16px;
}
body.subject-overview .ai-modal-body li {
  margin-bottom: 8px;
}
body.subject-overview .ai-modal-body p {
  margin-bottom: 16px;
}
body.subject-overview .ai-modal-body strong {
  font-weight: 600;
  color: var(--text);
}
body.subject-overview .ai-modal-body .ai-error {
  color: #d9534f;
  background: rgba(217, 83, 79, 0.1);
  border: 1px solid rgba(217, 83, 79, 0.3);
  padding: 16px;
  border-radius: 6px;
  font-weight: bold;
}

/* Print: also hide modal on this page */
@media print {
  body.subject-overview .ai-modal-backdrop {
    display: none !important;
  }
}

@media (max-width: 768px) {
  body.subject-overview .table-container {
    border-radius: 12px;
  }
  body.subject-overview .stack-on-mobile tr {
    background: #ffffff;
  }
  body.subject-overview .table-container th,
  body.subject-overview .table-container td {
    padding: 8px 6px;
    font-size: 0.78rem;
    line-height: 1.35;
  }
  body.subject-overview .table-container th {
    font-size: 0.66rem;
  }
  body.subject-overview .table-container th:nth-child(1),
  body.subject-overview .table-container td:nth-child(1) {
    width: 10%;
  }
  body.subject-overview .table-container th:nth-child(2) {
    width: 34%;
  }
  body.subject-overview .table-container th:nth-child(3),
  body.subject-overview .table-container th:nth-child(5),
  body.subject-overview .table-container td:nth-child(3),
  body.subject-overview .table-container td:nth-child(5) {
    width: 16%;
    font-size: 0.9rem;
  }
  body.subject-overview .table-container th:nth-child(4),
  body.subject-overview .table-container th:nth-child(6),
  body.subject-overview .table-container td:nth-child(4),
  body.subject-overview .table-container td:nth-child(6) {
    width: 12%;
    font-size: 0.72rem;
    padding-top: 8px;
  }
  body.subject-overview .stack-on-mobile td,
  body.subject-overview .stack-on-mobile td:nth-child(3),
  body.subject-overview .stack-on-mobile td:nth-child(4),
  body.subject-overview .stack-on-mobile td:nth-child(5),
  body.subject-overview .stack-on-mobile td:nth-child(6) {
    width: 100%;
    font-size: 0.82rem;
    color: var(--text);
  }
  body.subject-overview .stack-on-mobile td:nth-child(3) {
    color: var(--seriesA);
  }
  body.subject-overview .stack-on-mobile td:nth-child(5) {
    color: var(--seriesD);
  }
}
