:root {
  --primary: #0090d4;
  --primary-dark: #003058;
  --bg: #f8fafc;
  --bg-top: #ffffff;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --radius: 12px;
  --tp-color: #22c55e;
  --tn-color: #3b82f6;
  --fp-color: #f59e0b;
  --fn-color: #ef4444;
}

:root[data-theme="dark"] {
  --primary: #34c5ff;
  --primary-dark: #e7f4ff;
  --bg: #0f1b27;
  --bg-top: #122233;
  --card: #152637;
  --border: #28435b;
  --text: #e7f4ff;
  --muted: #9db5ca;
  --shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Inter', -apple-system, sans-serif;
  background: linear-gradient(180deg, var(--bg-top), var(--bg));
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

:root[data-theme="dark"] body {
  background: radial-gradient(circle at 14% 8%, rgba(0, 144, 212, 0.12), transparent 34%),
    radial-gradient(circle at 90% 18%, rgba(0, 48, 88, 0.10), transparent 32%),
    linear-gradient(180deg, #0f1b27, #091420);
}

.wrap {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

/* Banner */
.report-banner {
  background: linear-gradient(135deg, #003058 0%, #0090d4 100%);
  border-radius: var(--radius);
  padding: 24px 32px;
  margin-bottom: 24px;
  color: white;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}

.report-banner::before {
  content: '';
  position: absolute;
  top: -50px;
  right: -50px;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
}

.report-banner.compact {
  padding: 16px 24px;
}

.banner-content {
  display: flex;
  align-items: center;
  gap: 20px;
  position: relative;
  z-index: 1;
}

.banner-logo img {
  height: 48px;
  width: auto;
}

.banner-text h1 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
}

.banner-text p {
  margin: 4px 0 0;
  opacity: 0.9;
}

.banner-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.logout-btn,
.back-btn,
.theme-btn {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  padding: 8px 16px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
}

.logout-btn:hover,
.back-btn:hover,
.theme-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* Panels */
.panel {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.panel h2 {
  margin: 0 0 20px;
  font-size: 1.4rem;
  color: var(--primary-dark);
}

.panel h3 {
  margin: 0 0 12px;
  font-size: 1.1rem;
}

.panel-description {
  color: var(--muted);
  margin: -12px 0 20px;
  font-size: 0.9rem;
}

/* Error */
.error-panel {
  display: flex;
  align-items: center;
  gap: 16px;
  background: #fef2f2;
  border-color: #fecaca;
}

:root[data-theme="dark"] .error-panel {
  background: #3b1515;
  border-color: #7f1d1d;
}

.error-icon {
  width: 48px;
  height: 48px;
  background: #ef4444;
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: bold;
  flex-shrink: 0;
}

.error-text h3 {
  color: #dc2626;
  margin: 0;
}

.error-text p {
  margin: 4px 0 0;
}

/* Config */
.config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.config-item {
  background: var(--bg);
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.config-label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.config-value {
  font-size: 1rem;
  font-weight: 600;
}

.sub-detail {
  font-weight: 400;
  font-size: 0.85rem;
  color: var(--muted);
}

.set-link {
  color: #34c5ff;
  text-decoration: none;
  font-weight: 600;
}

.set-link:hover {
  text-decoration: underline;
}

:root[data-theme="light"] .set-link {
  color: #0090d4;
}

.threshold-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.threshold-chips {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.threshold-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: color-mix(in srgb, var(--chip-color) 15%, var(--card));
  border: 2px solid var(--chip-color);
  padding: 8px 16px;
  border-radius: 999px;
}

.threshold-name {
  font-weight: 600;
  color: var(--chip-color);
}

.threshold-value {
  font-weight: 700;
  background: var(--card);
  padding: 2px 8px;
  border-radius: 4px;
}

/* Metrics */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.metric-card {
  background: var(--bg);
  padding: 20px;
  border-radius: 12px;
  text-align: center;
  border: 2px solid transparent;
}

.metric-card.accuracy {
  border-color: #3b82f6;
}

.metric-card.recall {
  border-color: #f59e0b;
}

.metric-card.f1 {
  border-color: #8b5cf6;
}

.metric-card.specificity {
  border-color: #06b6d4;
}

.metric-card .metric-value {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--primary-dark);
}

.metric-card .metric-label {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 4px;
}

/* Confusion */
.confusion-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.confusion-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px;
  border-radius: 8px;
  background: var(--bg);
}

.confusion-item.tp {
  border-left: 4px solid var(--tp-color);
}

.confusion-item.tn {
  border-left: 4px solid var(--tn-color);
}

.confusion-item.fp {
  border-left: 4px solid var(--fp-color);
}

.confusion-item.fn {
  border-left: 4px solid var(--fn-color);
}

.confusion-count {
  font-size: 2rem;
  font-weight: 700;
}

.confusion-label {
  font-size: 0.85rem;
  color: var(--muted);
}

.confusion-desc {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 4px;
  text-align: center;
}

/* Class Cards */
.class-card {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  border-left: 6px solid var(--class-color);
}

.class-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.class-name {
  font-size: 1.3rem;
  margin: 0;
  color: var(--class-color);
}

.class-badge {
  display: flex;
  gap: 12px;
}

.class-badge span {
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
}

.ok-count {
  background: #dcfce7;
  color: #166534;
}

.nok-count {
  background: #fee2e2;
  color: #991b1b;
}

:root[data-theme="dark"] .ok-count {
  background: #14532d;
  color: #86efac;
}

:root[data-theme="dark"] .nok-count {
  background: #450a0a;
  color: #fca5a5;
}

.class-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.class-metric {
  text-align: center;
  padding: 12px;
  background: var(--card);
  border-radius: 8px;
}

.class-metric .metric-value {
  font-size: 1.5rem;
  font-weight: 700;
}

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

/* CM Mini */
.confusion-matrix-mini {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.cm-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: white;
  transition: all 0.2s;
  cursor: pointer;
}

.cm-cell.tp {
  background: var(--tp-color);
}

.cm-cell.tn {
  background: var(--tn-color);
}

.cm-cell.fp {
  background: var(--fp-color);
}

.cm-cell.fn {
  background: var(--fn-color);
}

.cm-cell:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.cm-cell.has-issues {
  animation: pulse 2s infinite;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1
  }

  50% {
    opacity: 0.8
  }
}

.cm-count {
  font-size: 1.75rem;
  font-weight: 700;
}

.cm-label {
  font-size: 0.8rem;
  opacity: 0.9;
}

.cm-warning {
  font-size: 0.7rem;
  background: rgba(255, 255, 255, 0.3);
  padding: 2px 6px;
  border-radius: 4px;
  margin-top: 4px;
}

/* Rate Bars */
.rate-bars {
  display: flex;
  gap: 24px;
}

.rate-bar {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
}

.rate-label {
  font-size: 0.85rem;
  color: var(--muted);
  min-width: 80px;
}

.rate-track {
  flex: 1;
  height: 10px;
  background: var(--border);
  border-radius: 5px;
  overflow: hidden;
}

.rate-fill {
  height: 100%;
  border-radius: 5px;
}

.rate-fill.fp {
  background: var(--fp-color);
}

.rate-fill.fn {
  background: var(--fn-color);
}

.rate-value {
  font-weight: 600;
  min-width: 50px;
  text-align: right;
}

/* Charts */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
  margin-top: 16px;
}

.chart-container {
  background: var(--bg);
  padding: 20px;
  border-radius: 8px;
}

.chart-container h3 {
  margin: 0 0 8px;
  font-size: 1rem;
  text-align: center;
}

.chart-tall {
  min-height: 380px;
}

/* Parts Blocks */
.parts-blocks-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.part-block {
  background: linear-gradient(135deg, color-mix(in srgb, var(--part-color) 18%, var(--card)), var(--card));
  border: 2px solid var(--part-color);
  border-radius: 14px;
  padding: 20px;
  transition: transform 0.2s, box-shadow 0.2s;
}

.part-block:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.part-block-header h3 {
  margin: 0 0 8px;
  color: var(--part-color);
  font-size: 1.1rem;
}

.part-block-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.pb-badge {
  font-size: 0.75rem;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-weight: 500;
}

.pb-badge.nio {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.3);
}

.pb-badge.io {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
  border-color: rgba(34, 197, 94, 0.3);
}

.part-block-big-metric {
  text-align: center;
  margin-bottom: 12px;
}

.pbm-value {
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--part-color);
  display: block;
}

.pbm-label {
  font-size: 0.8rem;
  color: var(--muted);
}

.part-block-confusion {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin-bottom: 12px;
}

.pbc {
  text-align: center;
  padding: 6px 4px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.8rem;
}

.pbc.tp {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
}

.pbc.tn {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
}

.pbc.fp {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
}

.pbc.fn {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

.pbc-num {
  display: block;
  font-size: 1.1rem;
}

.pbc-lbl {
  font-size: 0.65rem;
  opacity: 0.8;
}

.part-block-classes {
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.pbc-class-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  font-size: 0.82rem;
}

.pbc-class-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.pbc-class-name {
  flex: 1;
  font-weight: 500;
}

.pbc-class-val {
  font-weight: 600;
  font-size: 0.78rem;
  color: var(--muted);
}

/* Interactive Table */
.parts-table-wrap {
  margin-top: 24px;
}

.table-scroll {
  overflow-x: auto;
}

.parts-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.parts-table th,
.parts-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.parts-table th {
  background: var(--bg);
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  position: sticky;
  top: 0;
}

.parts-table th[data-sort]::after {
  content: ' \2195';
  opacity: 0.4;
}

.parts-table th[data-dir="asc"]::after {
  content: ' \2191';
  opacity: 1;
}

.parts-table th[data-dir="desc"]::after {
  content: ' \2193';
  opacity: 1;
}

.table-row-hover:hover {
  background: color-mix(in srgb, var(--primary) 8%, var(--card));
}

.class-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

.cell-tp {
  color: var(--tp-color);
  font-weight: 600;
}

.cell-fp {
  color: var(--fp-color);
  font-weight: 600;
}

.cell-fn {
  color: var(--fn-color);
  font-weight: 600;
}

/* Guide */
.guide-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.guide-card {
  padding: 16px;
  border-radius: 8px;
  background: var(--bg);
}

.guide-card h4 {
  margin: 0 0 8px;
  font-size: 0.95rem;
}

.guide-card p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.guide-card.warning {
  background: #fffbeb;
  border: 1px solid #fcd34d;
}

.guide-card.warning h4 {
  color: #b45309;
}

.guide-card.danger {
  background: #fef2f2;
  border: 1px solid #fca5a5;
}

.guide-card.danger h4 {
  color: #dc2626;
}

:root[data-theme="dark"] .guide-card.warning {
  background: #422006;
  border-color: #92400e;
}

:root[data-theme="dark"] .guide-card.warning h4 {
  color: #fbbf24;
}

:root[data-theme="dark"] .guide-card.danger {
  background: #450a0a;
  border-color: #991b1b;
}

:root[data-theme="dark"] .guide-card.danger h4 {
  color: #f87171;
}

.metric-explanations {
  border-top: 1px solid var(--border);
  padding-top: 20px;
}

.metric-explanations h3 {
  margin-bottom: 16px;
}

.metric-explanations dl {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 8px 16px;
  margin: 0;
}

.metric-explanations dt {
  font-weight: 600;
  color: var(--primary-dark);
}

.metric-explanations dd {
  margin: 0;
  color: var(--muted);
}

/* Gallery */
.explanation-panel {
  padding: 20px 24px;
}

.explanation {
  padding: 16px 20px;
  border-radius: 8px;
}

.explanation.success {
  background: #f0fdf4;
  border: 1px solid #86efac;
}

.explanation.warning {
  background: #fffbeb;
  border: 1px solid #fcd34d;
}

.explanation.danger {
  background: #fef2f2;
  border: 1px solid #fca5a5;
}

:root[data-theme="dark"] .explanation.success {
  background: #14532d;
  border-color: #166534;
}

:root[data-theme="dark"] .explanation.warning {
  background: #422006;
  border-color: #92400e;
}

:root[data-theme="dark"] .explanation.danger {
  background: #450a0a;
  border-color: #991b1b;
}

.explanation h3 {
  margin: 0 0 8px;
}

.explanation p {
  margin: 0 0 12px;
}

.explanation ul {
  margin: 0;
  padding-left: 20px;
}

.analysis-hint {
  font-style: italic;
  color: var(--muted);
  margin-top: 12px !important;
}

.threshold-info {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.threshold-badge {
  background: var(--primary);
  color: white;
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 500;
}

:root[data-theme="dark"] .threshold-badge {
  background: #0c4a6e;
}

.threshold-hint {
  flex: 1;
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
  gap: 20px;
}

.gallery-card {
  background: var(--bg);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.image-container {
  position: relative;
  background: #1e293b;
}

.image-container img {
  width: 100%;
  height: auto;
  display: block;
}

.polygon-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.card-info {
  padding: 12px 16px;
}

.filename {
  display: block;
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-meta {
  display: flex;
  gap: 12px;
  margin-top: 8px;
  font-size: 0.8rem;
  color: var(--muted);
}

.empty-gallery {
  grid-column: 1/-1;
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}

.legend-items {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.legend-color {
  width: 24px;
  height: 24px;
  border-radius: 4px;
}

/* Login */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #003058, #0090d4);
}

.login-container {
  width: 100%;
  max-width: 400px;
  padding: 20px;
}

.login-card {
  background: white;
  border-radius: var(--radius);
  padding: 40px 32px;
  box-shadow: var(--shadow-lg);
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-header h1 {
  margin: 0;
  color: #003058;
  font-size: 1.75rem;
}

.login-header p {
  margin: 8px 0 0;
  color: #64748b;
}

.login-error {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  color: #dc2626;
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 20px;
  text-align: center;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label span {
  font-size: 0.9rem;
  font-weight: 500;
  color: #1e293b;
}

.form-label input {
  padding: 12px 16px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 1rem;
}

.form-label input:focus {
  outline: none;
  border-color: #0090d4;
  box-shadow: 0 0 0 3px rgba(0, 144, 212, 0.15);
}

.login-btn {
  background: #0090d4;
  color: white;
  border: none;
  padding: 14px 24px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.login-btn:hover {
  background: #003058;
}

.login-footer {
  text-align: center;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid #e2e8f0;
}

.login-footer p {
  margin: 0;
  font-size: 0.85rem;
  color: #64748b;
}

/* Responsive */
@media(max-width:1024px) {
  .metrics-grid {
    grid-template-columns: repeat(2, 1fr)
  }

  .class-metrics {
    grid-template-columns: repeat(2, 1fr)
  }

  .charts-grid {
    grid-template-columns: 1fr
  }

  .guide-grid {
    grid-template-columns: repeat(2, 1fr)
  }

  .parts-blocks-row {
    grid-template-columns: repeat(2, 1fr)
  }
}

/* Image lightbox modal */
.img-modal { position:fixed; inset:0; z-index:9500; background:rgba(0,0,0,0.82); display:none; align-items:center; justify-content:center; backdrop-filter:blur(6px); }
.img-modal.open { display:flex; }
.img-modal-inner { background:var(--card); border-radius:16px; max-width:90vw; max-height:92vh; overflow:auto; position:relative; box-shadow:0 20px 60px rgba(0,0,0,0.5); }
.img-modal-inner.img-modal-fit { width:auto; }
.img-modal-close { position:absolute; top:10px; right:14px; background:rgba(0,0,0,0.6); border:none; color:white; font-size:2rem; cursor:pointer; z-index:2; line-height:1; width:40px; height:40px; border-radius:50%; display:flex; align-items:center; justify-content:center; }
.img-modal-close:hover { background:rgba(0,0,0,0.8); }
.img-modal-filename { padding:10px 20px; font-size:0.85rem; font-weight:600; color:var(--muted); border-bottom:1px solid var(--border); }
.img-modal-body { padding:0; }
.img-modal-wrap { position:relative; display:inline-block; }
.img-modal-wrap img { max-width:88vw; max-height:80vh; width:auto; height:auto; display:block; }
.img-modal-wrap .polygon-overlay { position:absolute; top:0; left:0; width:100%; height:100%; pointer-events:none; }

/* Gallery card clickable */
.gallery-card { cursor:pointer; transition:transform 0.15s,box-shadow 0.15s; }
.gallery-card:hover { transform:translateY(-3px); box-shadow:0 8px 24px rgba(0,0,0,0.18); }

/* Compact class cards */
.class-card.compact {
  padding: 16px;
  margin-bottom: 14px;
}

.compact-metrics {
  gap: 8px;
}

.compact-metrics .class-metric {
  padding: 8px;
}

.compact-metrics .metric-value {
  font-size: 1.2rem;
}

.compact-cm {
  gap: 6px;
  margin-bottom: 12px;
}

.compact-cm .cm-cell {
  padding: 10px 8px;
}

.compact-cm .cm-count {
  font-size: 1.3rem;
}

/* Chart fullscreen modal */
.chart-modal {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(0, 0, 0, 0.75);
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.chart-modal.open {
  display: flex;
}

.chart-modal-inner {
  background: var(--card);
  border-radius: 16px;
  padding: 32px;
  width: 90vw;
  max-width: 1200px;
  max-height: 90vh;
  position: relative;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.chart-modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text);
  font-size: 2rem;
  cursor: pointer;
  z-index: 2;
  line-height: 1;
}

.chart-clickable {
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.chart-clickable:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

/* FP modal */
.fp-modal-inner {
  background: var(--card);
  border-radius: 16px;
  padding: 32px;
  width: 92vw;
  max-width: 1400px;
  max-height: 90vh;
  overflow: auto;
  position: relative;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.fp-modal-inner h3 {
  margin: 0 0 20px;
  color: var(--primary-dark);
}

.fp-side-by-side {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.fp-img-box h4 {
  text-align: center;
  margin: 0 0 8px;
}

.fp-img-box .image-container {
  border-radius: 8px;
  overflow: hidden;
}

/* FP note */
.fp-note {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.08), rgba(245, 158, 11, 0.03));
  border: 2px solid rgba(245, 158, 11, 0.35);
  border-radius: 12px;
  padding: 20px 24px;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 8px;
}

.fp-note:hover {
  border-color: rgba(245, 158, 11, 0.6);
  box-shadow: 0 4px 16px rgba(245, 158, 11, 0.12);
  transform: translateY(-1px);
}

.fp-note-header {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text);
}

.fp-note-hint {
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--fp-color);
}

.fp-note p {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text);
}

.fp-note-card {
  border-radius: 10px;
  padding: 12px 14px;
  border-left: 4px solid;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}

.fp-note-card+.fp-note-card {
  margin-top: 10px;
}

.fp-note-question {
  background: rgba(59, 130, 246, 0.08);
  border-color: rgba(59, 130, 246, 0.65);
}

.fp-note-explanation {
  background: rgba(245, 158, 11, 0.11);
  border-color: rgba(245, 158, 11, 0.72);
}

.fp-note-result {
  background: rgba(34, 197, 94, 0.09);
  border-color: rgba(34, 197, 94, 0.68);
}

/* Strategy cards */
.strategy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px;
}

.strategy-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: all 0.2s;
}

.strategy-title {
  padding: 16px 20px;
  font-weight: 700;
  font-size: 1rem;
  color: var(--primary-dark);
  cursor: pointer;
  position: relative;
}

.strategy-title::after {
  content: '+';
  position: absolute;
  right: 16px;
  font-size: 1.3rem;
  font-weight: 300;
  opacity: 0.5;
  transition: all 0.25s;
}

.strategy-card:hover .strategy-title::after,
.strategy-card:focus-within .strategy-title::after {
  content: '\2013';
  opacity: 0.8;
}

.strategy-desc {
  max-height: 0;
  overflow: hidden;
  padding: 0 20px;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.6;
  transition: max-height 0.35s ease, padding 0.35s ease;
}

.strategy-card:hover .strategy-desc,
.strategy-card:focus-within .strategy-desc {
  max-height: 200px;
  padding: 0 20px 16px;
}

/* Performance levels explanation */
.perf-levels { margin-bottom:24px; }
.perf-levels h3 { margin:0 0 12px; }
.perf-levels-grid { display:grid; grid-template-columns:1fr 1fr; gap:16px; }
.perf-level-card { background:var(--bg); border:1px solid var(--border); border-radius:10px; padding:16px 20px; border-left:4px solid var(--primary); }
.perf-level-card h4 { margin:0 0 6px; font-size:0.95rem; color:var(--primary-dark); }
.perf-level-card p { margin:0; font-size:0.88rem; color:var(--muted); line-height:1.5; }

/* Imbalance panel */
.imbalance-panel h2 {
  color: var(--fp-color);
}

@media(max-width:768px) {
  .wrap {
    padding: 12px
  }

  .banner-content {
    flex-direction: column;
    text-align: center
  }

  .banner-actions {
    margin-left: 0
  }

  .metrics-grid,
  .confusion-summary {
    grid-template-columns: repeat(2, 1fr)
  }

  .confusion-matrix-mini {
    grid-template-columns: repeat(2, 1fr)
  }

  .rate-bars {
    flex-direction: column
  }

  .guide-grid {
    grid-template-columns: 1fr
  }

  .metric-explanations dl {
    grid-template-columns: 1fr
  }

  .gallery-grid {
    grid-template-columns: 1fr
  }

  .parts-blocks-row {
    grid-template-columns: 1fr
  }

  .fp-side-by-side {
    grid-template-columns: 1fr
  }

  .strategy-grid {
    grid-template-columns: 1fr
  }
}