:root {
  --ink: #172033;
  --muted: #607087;
  --line: #d8e0e9;
  --surface: #ffffff;
  --soft: #f5f7fa;
  --blue: #0b63b6;
  --green: #137a54;
  --amber: #9a6200;
  --red: #b4232f;
  font-family: "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: #eef2f6;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: #eef2f6; color: var(--ink); }
button, input { font: inherit; }
button { letter-spacing: 0; }
.app-header { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 12px 22px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
.brand-block, .header-actions, .panel-heading, .section-title, .session-actions, .range-controls { display: flex; align-items: center; }
.brand-block { gap: 12px; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; background: #0a4d88; color: #fff; font-weight: 800; border-radius: 6px; }
h1, h2, h3, p { margin-top: 0; }
.brand-block h1 { margin: 0; font-size: 20px; }
.brand-block p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.header-actions { gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.button, .icon-button, .text-button, .tabs button, .range-controls button, .segmented button, .export-select { border: 1px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; }
.button { min-height: 38px; padding: 8px 14px; border-radius: 5px; font-weight: 700; }
.button.primary { background: var(--blue); color: white; border-color: var(--blue); }
.icon-button { width: 38px; height: 38px; border-radius: 5px; font-size: 18px; }
.export-select { height: 38px; max-width: 105px; border-radius: 5px; padding: 0 7px; }
.segmented { display: inline-flex; }
.segmented button { min-width: 38px; height: 36px; padding: 0 8px; }
.segmented button:first-child { border-radius: 5px 0 0 5px; }
.segmented button:last-child { border-radius: 0 5px 5px 0; border-inline-start: 0; }
.segmented button.active { background: #163a5f; color: #fff; }
.status-bar { min-height: 36px; display: flex; gap: 9px; align-items: center; padding: 7px 22px; background: #e8eef5; border-bottom: 1px solid #ccd7e4; font-size: 13px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #8795a8; }
.status-dot.busy { background: var(--amber); animation: pulse 1s infinite; }
.status-dot.ok { background: var(--green); }
.status-dot.error { background: var(--red); }
#progressText { margin-inline-start: auto; color: var(--muted); }
@keyframes pulse { 50% { opacity: .35; } }
.workspace { display: grid; grid-template-columns: 300px minmax(0, 1fr); min-height: calc(100vh - 108px); }
.session-panel { background: var(--surface); border-inline-end: 1px solid var(--line); padding: 16px 12px; overflow: auto; max-height: calc(100vh - 108px); position: sticky; top: 108px; }
.panel-heading { justify-content: space-between; gap: 8px; }
.panel-heading h2 { margin-bottom: 4px; font-size: 17px; }
.panel-heading p { margin: 0; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.count-badge { min-width: 28px; height: 24px; display: grid; place-items: center; background: #e6f0fa; color: #084f90; border-radius: 4px; font-weight: 800; }
.session-actions { gap: 4px; margin: 14px 0 9px; }
.text-button { padding: 5px 7px; border-radius: 4px; font-size: 12px; }
.file-list { display: grid; gap: 5px; }
.recording-filters { display: grid; gap: 9px; margin: 12px 0; font-size: 12px; }
.recording-filters label { display: grid; gap: 4px; min-width: 0; }
.recording-filters input, .recording-filters select { width: 100%; min-width: 0; min-height: 38px; padding: 6px; border: 1px solid var(--line); border-radius: 5px; background: white; color: var(--ink); font: inherit; }
.recording-date-range { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.recording-filters p { margin: 0; color: var(--muted); }
.file-date { display: block; font-weight: 700; margin-bottom: 5px; unicode-bidi: isolate; }
.file-row { display: grid; grid-template-columns: 22px minmax(0,1fr); gap: 7px; padding: 9px 8px; border: 1px solid var(--line); border-radius: 5px; background: #fff; cursor: pointer; }
.file-row:hover { border-color: #8eb4d7; }
.file-row.selected { background: #eaf4ff; border-color: #5d9ed5; }
.file-row input { width: 16px; height: 16px; margin-top: 2px; }
.file-name { display: block; direction: ltr; unicode-bidi: isolate; text-align: left; font-size: 12px; font-weight: 700; overflow-wrap: anywhere; }
.file-meta { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.file-state { display: inline-block; margin-top: 4px; font-size: 11px; color: var(--blue); }
.empty-state, .welcome-band, .notice { padding: 18px; border: 1px dashed #b8c5d4; background: #f9fbfd; color: var(--muted); border-radius: 5px; }
.report-shell { min-width: 0; padding: 16px 18px 40px; }
.report-shell:not(.has-report) .tabs,
.report-shell:not(.has-report) .tab-view { display: none; }
.tabs { display: flex; overflow-x: auto; border-bottom: 1px solid var(--line); background: #fff; }
.tabs button { flex: 0 0 auto; padding: 11px 15px; border: 0; border-bottom: 3px solid transparent; font-weight: 700; color: #45566d; }
.tabs button.active { color: var(--blue); border-bottom-color: var(--blue); }
.welcome-band { margin-top: 14px; }
.welcome-band h2 { margin-bottom: 5px; font-size: 18px; }
.welcome-band p { margin: 0; }
.tab-view { display: none; margin-top: 14px; }
.tab-view.active { display: block; }
.executive-summary { padding: 15px 18px; background: #173a5e; color: #fff; border-radius: 5px; margin-bottom: 12px; }
.executive-summary h2 { font-size: 18px; margin-bottom: 6px; }
.executive-summary p { margin: 0; line-height: 1.55; }
.metric-grid { display: grid; grid-template-columns: repeat(6, minmax(125px,1fr)); gap: 8px; margin-bottom: 12px; }
.metric { min-height: 90px; padding: 11px; background: #fff; border: 1px solid var(--line); border-radius: 5px; }
.metric-label { color: var(--muted); font-size: 12px; font-weight: 700; }
.metric-value { margin-top: 9px; font-size: 21px; font-weight: 800; overflow-wrap: anywhere; }
.metric-note { margin-top: 4px; color: var(--muted); font-size: 11px; }
.overview-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.report-section { background: #fff; border: 1px solid var(--line); border-radius: 5px; margin-bottom: 12px; padding: 14px; min-width: 0; }
.section-title { justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.section-title h2 { margin: 0; font-size: 16px; }
.section-title p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.chart { width: 100%; }
.chart.medium { height: 320px; }
.chart.large { height: 520px; }
.chart-controls { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 16px; padding: 12px 14px; background: #fff; border: 1px solid var(--line); border-radius: 5px; margin-bottom: 12px; }
.chart-controls h2 { margin-bottom: 8px; font-size: 15px; }
.signal-picker { display: flex; flex-wrap: wrap; gap: 6px 12px; }
.signal-option { display: inline-flex; gap: 5px; align-items: center; font-size: 12px; }
.signal-swatch { width: 11px; height: 4px; }
.range-controls { align-self: start; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.range-controls span { font-size: 12px; color: var(--muted); margin-inline-end: 4px; }
.range-controls button { padding: 6px 8px; border-radius: 4px; font-size: 12px; }
.range-controls button.active { background: #173a5e; color: #fff; }
.spinner { width: 22px; height: 22px; border: 3px solid #f2b8bd; border-top-color: var(--red); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.data-table-wrap { max-width: 100%; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
#comparisonTable td:first-child { direction: ltr; unicode-bidi: isolate; text-align: left; }
th, td { padding: 8px; border-bottom: 1px solid #e2e7ee; text-align: start; vertical-align: top; white-space: nowrap; }
th { position: sticky; top: 0; background: #edf2f7; color: #304056; z-index: 1; }
tr:hover td { background: #f7faff; }
.quality-pill { display: inline-block; min-width: 74px; padding: 3px 7px; text-align: center; border-radius: 3px; font-weight: 700; }
.quality-high { background: #d9f3e8; color: #0c6846; }
.quality-moderate { background: #fff0c9; color: #7a4a00; }
.quality-limited { background: #ffe1c7; color: #87410b; }
.quality-insufficient { background: #f7d9dc; color: #8c1f29; }
.findings { display: grid; gap: 8px; }
.finding { border-inline-start: 4px solid #7e94aa; padding: 8px 10px; background: #f7f9fb; }
.finding strong { display: block; margin-bottom: 3px; }
.methods-content { background: #fff; border: 1px solid var(--line); border-radius: 5px; padding: 20px; line-height: 1.6; }
.methods-content h2 { margin-top: 22px; font-size: 17px; }
.methods-content h2:first-child { margin-top: 0; }
.scientific-report-page { background: #fff; border: 1px solid #cfd6df; padding: 26px 30px 20px; color: #17202b; }
.scientific-report-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding-bottom: 12px; border-bottom: 2px solid #263746; }
.scientific-report-header h2 { margin: 0 0 4px; font-size: 28px; }
.scientific-report-header p { margin: 0; color: #647282; font-size: 13px; }
.report-version { color: #6d7782; font-size: 11px; font-weight: 800; white-space: nowrap; }
.report-identity-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); border: 1px solid #aeb8c3; margin: 12px 0 14px; }
.identity-cell { min-height: 66px; padding: 8px 10px; border-inline-end: 1px solid #cbd2d9; }
.identity-cell:last-child { border-inline-end: 0; }
.identity-label { display: block; color: #647282; font-size: 10px; text-transform: uppercase; font-weight: 800; }
.identity-value { display: block; margin-top: 7px; font-size: 16px; font-weight: 800; overflow-wrap: anywhere; }
.identity-note { display: block; margin-top: 2px; color: #647282; font-size: 10px; }
.scientific-block { min-width: 0; padding: 10px 12px; border-top: 1px solid #9da8b4; }
.wide-block { margin-top: 8px; }
.scientific-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 5px; }
.scientific-heading h3 { margin: 0; font-size: 14px; }
.scientific-heading span { color: #708090; font-size: 10px; text-align: end; }
.scientific-three-column { display: grid; grid-template-columns: .95fr 1.05fr 1.25fr; gap: 12px; margin-top: 10px; }
.scientific-two-column { display: grid; grid-template-columns: 1.15fr .85fr; gap: 12px; margin-top: 10px; }
.report-wide-chart { height: 285px; }
.report-small-chart { height: 260px; }
.report-medium-chart { height: 350px; }
.compact-results table { font-size: 11px; }
.compact-results th, .compact-results td { padding: 5px 6px; }
.frequency-summary { margin-top: 4px; font-size: 10px; color: #536171; }
.frequency-summary-grid { display: grid; grid-template-columns: repeat(4,1fr); border-top: 1px solid #d2d8df; }
.frequency-summary-grid div { padding: 5px; border-inline-end: 1px solid #e1e5ea; text-align: center; }
.frequency-summary-grid div:last-child { border-inline-end: 0; }
.frequency-summary-grid strong { display: block; font-size: 12px; color: #17202b; }
.evidence-panel { display: grid; gap: 8px; }
.evidence-row { display: grid; grid-template-columns: 120px minmax(0,1fr) 70px; align-items: center; gap: 8px; font-size: 11px; }
.evidence-track { height: 16px; position: relative; background: linear-gradient(90deg,#d8edf7 0 33%,#e9eef3 33% 66%,#fde5c8 66%); border: 1px solid #c4ccd5; }
.evidence-marker { position: absolute; top: -3px; width: 3px; height: 20px; background: #162b3d; }
.evidence-value { font-weight: 800; text-align: end; }
.scientific-report-footer { margin-top: 14px; padding-top: 10px; border-top: 1px solid #788592; color: #596777; font-size: 10px; text-align: center; }
.help-dialog { width: min(850px, calc(100vw - 30px)); max-height: 84vh; border: 1px solid var(--line); border-radius: 6px; padding: 0; color: var(--ink); }
.help-dialog::backdrop { background: rgba(17, 28, 42, .55); }
.dialog-heading { position: sticky; top: 0; display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; background: #fff; border-bottom: 1px solid var(--line); }
.dialog-heading h2 { margin: 0; font-size: 18px; }
#helpContent { padding: 18px; line-height: 1.6; }
[hidden] { display: none !important; }
html[dir="rtl"] body { direction: rtl; }
html[dir="rtl"] .segmented button:first-child { border-radius: 0 5px 5px 0; }
html[dir="rtl"] .segmented button:last-child { border-radius: 5px 0 0 5px; }
@media (max-width: 1100px) {
  .metric-grid { grid-template-columns: repeat(3, 1fr); }
  .workspace { grid-template-columns: 250px minmax(0,1fr); }
}
@media (max-width: 760px) {
  .app-header { position: static; align-items: flex-start; padding: 10px 12px; flex-direction: column; }
  .header-actions { width: 100%; justify-content: flex-start; }
  .status-bar { padding-inline: 12px; }
  .workspace { display: block; }
  .session-panel { position: static; max-height: none; border-inline-end: 0; border-bottom: 1px solid var(--line); }
  .file-list { max-height: 270px; overflow: auto; }
  .report-shell { padding: 12px 8px 30px; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .overview-grid { grid-template-columns: 1fr; }
  .chart-controls { grid-template-columns: 1fr; }
  .range-controls { justify-content: flex-start; }
  .chart.large { height: 430px; }
  .scientific-report-page { padding: 16px 10px; }
  .scientific-report-header { display: block; }
  .report-version { margin-top: 8px; }
  .report-identity-grid { grid-template-columns: 1fr 1fr; }
  .scientific-three-column, .scientific-two-column { grid-template-columns: 1fr; }
  .report-wide-chart, .report-small-chart, .report-medium-chart { height: 300px; }
}
@media print {
  @page { size: A4 portrait; margin: 10mm; }
  .app-header, .status-bar, .session-panel, .tabs, .chart-controls, .help-dialog { display: none !important; }
  .workspace { display: block; }
  .report-shell { padding: 0; }
  .welcome-band, .tab-view { display: none !important; }
  .has-report #professional { display: block !important; margin: 0; }
  .report-section, .metric { break-inside: avoid; }
  body, :root { background: #fff; }
  .scientific-report-page { border: 0; padding: 0; font-size: 9px; }
  .scientific-report-header h2 { font-size: 23px; }
  .report-identity-grid { margin: 8px 0; }
  .identity-cell { min-height: 48px; padding: 6px 8px; }
  .identity-value { margin-top: 4px; font-size: 13px; }
  .scientific-block { padding: 6px 8px; }
  .scientific-three-column { grid-template-columns: .95fr 1.05fr 1.25fr; gap: 6px; margin-top: 4px; break-inside: avoid; }
  .scientific-two-column { grid-template-columns: 1.15fr .85fr; gap: 6px; break-before: page; break-inside: avoid; }
  .report-wide-chart { height: 170px !important; }
  .report-small-chart { height: 175px !important; }
  .report-medium-chart { height: 225px !important; }
  .compact-results table { font-size: 8px; }
  .compact-results th, .compact-results td { padding: 3px 4px; }
  .evidence-row { grid-template-columns: 88px minmax(0,1fr) 54px; gap: 4px; font-size: 8px; }
  .frequency-summary-grid { font-size: 7px; }
  .frequency-summary-grid strong { font-size: 9px; }
  #timeVaryingChart { height: 180px !important; }
  #professionalSignalsChart { height: 230px !important; }
  .scientific-report-footer { font-size: 7px; }
}
/* Six-language report controls */
.language-control {
  display: inline-flex;
  align-items: center;
}

.language-control #training-language-select {
  min-width: 132px;
  height: 40px;
  border: 1px solid #c9d4df;
  border-radius: 6px;
  background: #fff;
  color: #172133;
  padding: 0 34px 0 12px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

[dir="rtl"] .language-control #training-language-select {
  padding: 0 12px 0 34px;
}

.language-control #training-language-select:focus-visible {
  outline: 3px solid rgba(0, 128, 145, 0.24);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 760px) {
  .language-control #training-language-select {
    min-width: 116px;
    max-width: 140px;
  }
}
