/* ===========================
   APP LAYOUT & HEADER
   =========================== */
.app-header {
  position: relative;
  margin: 2.75rem auto 1.75rem;
  width: min(1280px, 100% - 3rem);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1.6rem 2.1rem;
  background: linear-gradient(140deg, rgba(12, 26, 68, 0.94) 0%, rgba(29, 78, 245, 0.9) 65%, rgba(14, 165, 233, 0.88) 100%);
  color: #f5f7ff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-header);
  overflow: hidden;
}

.app-header::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.16) 0%, rgba(255, 255, 255, 0) 70%);
  opacity: 0.6;
  pointer-events: none;
}

.app-header > * {
  position: relative;
  z-index: 1;
}

.app-header .brand {
  display: flex;
  align-items: center;
  gap: 1.35rem;
}

.app-header .logo {
  width: 88px;
  height: 88px;
  border-radius: 14px;
  padding: 0.65rem;
  background: rgba(15, 23, 42, 0.3);
  backdrop-filter: blur(10px);
}

.app-header .titles {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.app-header .eyebrow {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.28em;
  color: rgba(226, 232, 255, 0.72);
  font-weight: 600;
}

.app-header .titles h1 {
  margin: 0;
  font-size: clamp(1.8rem, 2.4vw + 1rem, 2.6rem);
  color: #f8fbff;
  letter-spacing: -0.015em;
}

.app-header .subtitle {
  margin: 0.25rem 0 0;
  font-size: 0.92rem;
  color: rgba(228, 236, 255, 0.78);
  max-width: 38ch;
}

.app-header .actions {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.app-header .header-chip {
  background: rgba(13, 28, 73, 0.54);
  border-color: rgba(226, 232, 255, 0.25);
}

.app-header .header-chip .dot {
  box-shadow: 0 0 0 5px rgba(52, 211, 153, 0.18);
}

.layout {
  width: min(1160px, 100% - 3rem);
  margin: 0 auto 3.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
  position: relative;
}

#loading-panel {
  width: min(560px, 100%);
  align-self: center;
}

/* ===========================
   FORM PANEL
   =========================== */
.form-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: 1.45rem 1.55rem 1.65rem;
  background: var(--gradient-soft);
  border: 1px solid var(--color-border-strong);
  box-shadow: var(--shadow-soft);
}

.form-card form {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.2rem;
}

.header-row .card-title {
  font-size: 1.45rem;
  color: var(--color-heading);
}

.header-row .muted.small {
  flex: 1;
  min-width: 0;
  text-align: right;
  max-width: none;
  white-space: nowrap;
  line-height: 1.3;
  font-size: 0.78rem;
}

.top-form {
  display: grid;
  grid-template-columns: minmax(220px, 290px) minmax(0, 1fr);
  gap: 0.9rem;
  align-items: start;
}

.left-col,
.right-col {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.left-col {
  min-width: 0;
}

.right-stack {
  display: flex;
  flex-direction: column;
  gap: 0.95rem;
  min-width: 0;
}

.right-col {
  min-width: 0;
  border-radius: var(--radius-lg);
  background: var(--color-surface-solid);
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

.section-subtitle {
  font-size: 0.92rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: rgba(17, 28, 58, 0.68);
  margin: 0 0 0.35rem;
}

.inline-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  border-radius: var(--radius-md);
  padding: 0.7rem 0.85rem;
  background: var(--color-input-surface);
  border: 1px solid rgba(15, 23, 42, 0.06);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.85),
    0 10px 22px -18px rgba(15, 23, 42, 0.4);
}

.inline-field label {
  margin: 0;
  color: rgba(17, 28, 58, 0.7);
}

.inline-field input,
.inline-field select {
  width: 100%;
  border-radius: calc(var(--radius-sm) - 2px);
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(255, 255, 255, 0.94);
  padding: 0.55rem 0.7rem;
}

.inline-field input:focus,
.inline-field select:focus {
  border-color: rgba(37, 99, 235, 0.45);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.16);
}

.freq-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.45rem;
}

.threshold-grid {
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 16px;
  overflow: hidden;
  overflow-x: auto;
  background: linear-gradient(180deg, rgba(241, 245, 255, 0.9), rgba(255, 255, 255, 0.96));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.threshold-grid .row {
  display: grid;
  grid-template-columns: 140px repeat(8, minmax(56px, 1fr));
  min-width: 740px;
  align-items: center;
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
}

.threshold-grid .row:last-child {
  border-bottom: none;
}

.threshold-grid .row.freq-header {
  background: linear-gradient(90deg, rgba(29, 78, 245, 0.12), rgba(14, 165, 233, 0.14));
  color: rgba(15, 23, 42, 0.78);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.threshold-grid .row.freq-header span {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.25rem;
  border-right: 1px solid rgba(15, 23, 42, 0.05);
}

.threshold-grid .row.freq-header span:first-child {
  justify-content: flex-start;
  padding-left: 1rem;
}

.threshold-grid .row label {
  display: flex;
  align-items: center;
  padding: 0.65rem 1rem;
  font-weight: 600;
  color: rgba(15, 23, 42, 0.76);
  border-right: 1px solid rgba(15, 23, 42, 0.05);
  background: rgba(255, 255, 255, 0.68);
}

.threshold-grid .row input.htl {
  width: 100%;
  height: 100%;
  border: none;
  border-left: 1px solid rgba(15, 23, 42, 0.05);
  font-size: 0.88rem;
  text-align: center;
  background: transparent;
  padding: 0.4rem 0.35rem;
  transition: background-color var(--transition-base);
}

.threshold-grid .row input.htl:focus-visible {
  outline: none;
  background: rgba(37, 99, 235, 0.08);
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.2);
}

.right-col.thresholds {
  padding: 1.1rem 1.2rem 1.25rem;
}

.right-col.modules {
  padding: 1.1rem 1.2rem 1.25rem;
  gap: 1rem;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(15, 23, 42, 0.08);
}

.validation {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-height: 1.1rem;
}

.validation .msg {
  padding: 0.55rem 0.75rem;
  font-size: 0.86rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: rgba(15, 23, 42, 0.06);
  color: rgba(15, 23, 42, 0.75);
}

.validation .msg.warn {
  background: rgba(234, 179, 8, 0.12);
  border-color: rgba(202, 138, 4, 0.32);
  color: #854d0e;
}

.validation .msg.error {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.35);
  color: #b91c1c;
}

.modules-section {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1.05rem;
  padding: 1.1rem 1.2rem;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: var(--radius-lg);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

.modules-list {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  color: rgba(15, 23, 42, 0.84);
  font-weight: 600;
  letter-spacing: -0.005em;
}

.toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle .slider {
  position: relative;
  flex: 0 0 46px;
  height: 26px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.18);
  transition: background var(--transition-base);
}

.toggle .slider::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 8px 16px rgba(15, 23, 42, 0.15);
  transition: transform var(--transition-base);
}

.toggle input:checked + .slider {
  background: var(--gradient-main);
}

.toggle input:checked + .slider::before {
  transform: translateX(20px);
}

.toggle input:focus-visible + .slider {
  outline: 2px solid rgba(37, 99, 235, 0.45);
  outline-offset: 2px;
}

.toggle .toggle-label {
  font-size: 0.92rem;
}

.modules-options {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  align-items: flex-end;
}

.modules-option {
  width: 100%;
  max-width: 280px;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.modules-option label {
  color: rgba(15, 23, 42, 0.68);
}

.modules-option select {
  border-radius: var(--radius-sm);
  border: 1px solid rgba(15, 23, 42, 0.1);
  background: rgba(255, 255, 255, 0.95);
  padding: 0.6rem 0.75rem;
}

.modules-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.88rem;
  color: rgba(15, 23, 42, 0.8);
  cursor: pointer;
}

.modules-checkbox input {
  width: 18px;
  height: 18px;
  accent-color: #2563eb;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.85rem;
  margin-top: 0.35rem;
  padding-top: 0.95rem;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
}

/* ===========================
   LOADING PANEL
   =========================== */
.loading-panel {
  display: flex;
  justify-content: center;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.loading-panel.visible {
  opacity: 1;
  transform: translateY(0);
}

.loading-card {
  width: 100%;
  padding: 1.3rem 1.5rem;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(29, 78, 245, 0.12), rgba(14, 165, 233, 0.18));
  border: 1px solid rgba(37, 99, 235, 0.25);
  box-shadow: 0 22px 40px -30px rgba(29, 78, 245, 0.55);
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  align-items: center;
  text-align: center;
  color: rgba(15, 23, 42, 0.72);
}

.loading-track {
  width: 100%;
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.65);
  overflow: hidden;
  border: 1px solid rgba(37, 99, 235, 0.18);
}

.loading-fill {
  display: block;
  width: 140%;
  height: 100%;
  background: linear-gradient(120deg, rgba(29, 78, 245, 0.85), rgba(236, 72, 153, 0.82), rgba(59, 130, 246, 0.9));
  background-size: 200% 100%;
  animation: loading-gradient 1.8s ease-in-out infinite;
}

.loading-copy {
  margin: 0;
  color: rgba(15, 23, 42, 0.6);
  letter-spacing: 0.02em;
}

@keyframes loading-gradient {
  0% {
    transform: translateX(-45%);
  }
  50% {
    transform: translateX(0%);
  }
  100% {
    transform: translateX(45%);
  }
}

/* ===========================
   PREVIEW PANEL
   =========================== */
.preview-card {
  padding: 1.65rem 1.8rem 1.95rem;
  background: var(--color-surface);
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(18px);
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.preview-card.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.summary-card {
  border-radius: var(--radius-lg);
  padding: 1.4rem 1.5rem;
  background: linear-gradient(145deg, rgba(241, 245, 255, 0.9), rgba(246, 250, 255, 0.95));
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.summary-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.summary-kv {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  border-radius: var(--radius-md);
  padding: 0.9rem 1rem;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.summary-kv .k {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: rgba(17, 28, 58, 0.6);
}

.summary-kv .v {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--color-heading);
}

.summary-row.verdicts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.summary-row.meta-notes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.65rem;
}

.summary-row.meta-notes .meta-note {
  display: inline-flex;
  align-items: center;
}

.verdict-chip {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.7rem 1rem;
  border-radius: var(--radius-md);
  background: rgba(248, 250, 255, 0.85);
  border: 1px solid rgba(15, 23, 42, 0.1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
  transition: background 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.verdict-chip .chip-label {
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(15, 23, 42, 0.58);
}

.verdict-chip .chip-value {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--color-heading);
}

.verdict-chip[data-status="pass"] {
  background: rgba(29, 78, 245, 0.14);
  border-color: rgba(29, 78, 245, 0.26);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75), 0 10px 24px -18px rgba(37, 99, 235, 0.45);
}

.verdict-chip[data-status="pass"] .chip-value {
  color: #1d4ef5;
}

.verdict-chip[data-status="warn"] {
  background: rgba(245, 158, 11, 0.18);
  border-color: rgba(245, 158, 11, 0.32);
}

.verdict-chip[data-status="warn"] .chip-value {
  color: #b45309;
}

.verdict-chip[data-status="fail"] {
  background: rgba(239, 68, 68, 0.16);
  border-color: rgba(239, 68, 68, 0.28);
}

.verdict-chip[data-status="fail"] .chip-value {
  color: #c02628;
}

.summary-row.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.65rem;
}

.ear-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  background: rgba(15, 23, 42, 0.08);
  border: 1px solid rgba(15, 23, 42, 0.1);
  color: rgba(15, 23, 42, 0.8);
  font-size: 0.78rem;
  font-weight: 600;
}

.module-overview {
  margin-top: 1.8rem;
}

.module-overview-title {
  font-size: 1.25rem;
  margin: 0 0 0.35rem;
  color: rgba(15, 23, 42, 0.85);
  letter-spacing: -0.01em;
}

.module-overview-subtitle {
  margin: 0;
  font-size: 0.82rem;
  color: rgba(15, 23, 42, 0.62);
}

.chart-card {
  position: relative;
  margin-top: 1.6rem;
  margin-bottom: 1.2rem;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
  min-height: 0;
}

.audiogram-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.2rem;
  align-items: stretch;
}

.audiogram-panel {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 0.6rem;
  padding: 0.65rem 0.8rem 0.8rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(15, 23, 42, 0.04);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
  position: relative;
  min-height: 0;
}

.audiogram-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: rgba(15, 23, 42, 0.82);
}

.audiogram-panel canvas {
  display: block;
  width: 100% !important;
  height: clamp(260px, 30vw, 360px) !important;
  max-height: 380px !important;
  min-height: 220px;
}

.chart-legend-hint {
  font-size: 0.78rem;
  color: rgba(15, 23, 42, 0.6);
  position: relative;
  z-index: 2;
}

.tables {
  margin-top: 2.1rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.4rem;
  position: relative;
  z-index: 1;
}

.ear-table {
  padding: 1rem;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.lcb-disability-block {
  margin-top: 1.4rem;
}

.table-title {
  margin-bottom: 0.65rem;
  font-size: 1rem;
  color: rgba(15, 23, 42, 0.82);
  letter-spacing: -0.01em;
}

.ear-table .table th:first-child,
.ear-table .table td:first-child {
  text-align: left;
  font-weight: 600;
}

.cell-flag {
  background: rgba(239, 68, 68, 0.18) !important;
  color: #991b1b !important;
  font-weight: 700 !important;
}

.module-card {
  margin-top: 1.8rem;
  padding: 1.2rem 1.35rem 1.45rem;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8), var(--shadow-soft);
}

.label-with-info {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.modules-list .label-with-info,
.modules-options .label-with-info {
  width: 100%;
}

.label-with-info .toggle,
.label-with-info .modules-checkbox,
.label-with-info label {
  flex: 1;
}

.badge .info-icon {
  width: 1.2rem;
  height: 1.2rem;
  font-size: 0.65rem;
}

.info-icon {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 999px;
  border: 1px solid rgba(59, 130, 246, 0.35);
  background: rgba(59, 130, 246, 0.12);
  color: rgba(30, 64, 175, 0.95);
  font-size: 0.75rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: help;
  position: relative;
  padding: 0;
  line-height: 1;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.info-icon:hover,
.info-icon:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.12);
}

.info-icon:focus-visible {
  outline: 2px solid rgba(59, 130, 246, 0.55);
  outline-offset: 2px;
}

.info-icon::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translate(-50%, 6px);
  width: max-content;
  min-width: 18ch;
  max-width: 260px;
  padding: 0.45rem 0.6rem;
  border-radius: 0.45rem;
  background: rgba(15, 23, 42, 0.92);
  color: #f8fafc;
  font-size: 0.75rem;
  line-height: 1.3;
  text-align: left;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
  z-index: 8;
}

.info-icon:focus-visible::after,
.info-icon:hover::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

.info-icon::before {
  content: '';
  position: absolute;
  left: 50%;
  bottom: calc(100% + 4px);
  transform: translateX(-50%);
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: rgba(15, 23, 42, 0.92);
  opacity: 0;
  transition: opacity 160ms ease, transform 160ms ease;
  z-index: 7;
}

.info-icon:focus-visible::before,
.info-icon:hover::before {
  opacity: 1;
  transform: translateX(-50%) rotate(45deg);
}

.export-actions {
  display: flex;
  justify-content: flex-end;
  padding: 1rem 0 0.4rem;
  margin-top: 1rem;
}

.module-title {
  font-size: 1.1rem;
  color: rgba(15, 23, 42, 0.85);
  margin-bottom: 0.35rem;
}

.module-summary {
  font-size: 0.9rem;
  color: rgba(15, 23, 42, 0.6);
}

.module-card .tables {
  margin-top: 1rem;
  gap: 1.1rem;
}

.mini-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  border: 1px solid rgba(15, 23, 42, 0.08);
}

.mini-table th,
.mini-table td {
  border: 1px solid rgba(15, 23, 42, 0.08);
  padding: 0.5rem 0.65rem;
}

.mini-table th {
  background: rgba(29, 78, 245, 0.1);
  text-align: left;
}

.mini-table td.flag {
  background: rgba(239, 68, 68, 0.18);
  color: #991b1b;
  font-weight: 600;
}

.footnote {
  margin-top: 1.9rem;
  padding-top: 1.1rem;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
  font-size: 0.85rem;
  color: rgba(15, 23, 42, 0.65);
}

.footnote p + p {
  margin-top: 0.5rem;
}

/* ===========================
   TOAST & MISC
   =========================== */
.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  padding: 0.7rem 1.1rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.9);
  color: #f9fbff;
  font-size: 0.9rem;
  box-shadow: 0 20px 45px -30px rgba(15, 23, 42, 0.6);
  z-index: 9999;
}

.noscript {
  margin: 0;
  padding: 0.9rem 1.1rem;
  background: rgba(239, 68, 68, 0.16);
  border-bottom: 1px solid rgba(239, 68, 68, 0.28);
  text-align: center;
  color: #7f1d1d;
}

.badge.small.hidden {
  display: none;
}

/* ===========================
   RESPONSIVE BEHAVIOUR
   =========================== */
@media (max-width: 960px) {
  .app-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1.25rem;
    padding: 1.5rem 1.65rem;
  }
  .app-header .actions {
    width: 100%;
    justify-content: space-between;
  }
  .top-form {
    grid-template-columns: 1fr;
  }
  .modules-section {
    grid-template-columns: 1fr;
  }
  .modules-options {
    align-items: flex-start;
  }
  .tables {
    grid-template-columns: 1fr;
  }
  .audiogram-grid {
    grid-template-columns: 1fr;
  }
  .export-actions {
    justify-content: center;
  }
}

@media (max-width: 720px) {
  .app-header,
  .layout {
    width: min(100% - 2rem, 100%);
  }
  .app-header {
    margin: 2rem auto 1.25rem;
  }
  .layout {
    gap: 1.5rem;
  }
  .form-card {
    padding: 1.4rem 1.35rem 1.6rem;
  }
  .right-col {
    padding: 1.15rem 1.2rem;
  }
  .audiogram-panel canvas {
    height: 220px !important;
    max-height: 240px !important;
  }
  .audiogram-panel canvas {
    min-height: 220px;
  }
  .summary-card {
    padding: 1.2rem 1.25rem;
  }
  .preview-card {
    padding: 1.5rem 1.4rem 1.8rem;
  }
  #loading-panel {
    width: 100%;
  }
  .header-row .muted.small {
    white-space: normal;
    text-align: left;
  }
}

@media (max-width: 520px) {
  .app-header .titles h1 {
    font-size: clamp(1.6rem, 6vw, 2rem);
  }
  .app-header .actions {
    flex-direction: column;
    align-items: stretch;
  }
  .app-header .header-chip {
    justify-content: center;
  }
  .form-actions {
    flex-direction: column-reverse;
    align-items: stretch;
  }
}

/* ===========================
   REDUCED MOTION
   =========================== */
@media (prefers-reduced-motion: reduce) {
  .preview-card,
  .loading-panel,
  .loading-fill {
    transition: none;
    animation: none;
  }
}

/* ===========================
   PDF EXPORT MODES
   =========================== */
body.pdf-mode #preview-panel {
  width: 190mm;
  margin: 0 auto;
}

body.pdf-mode .chart-card {
  position: relative;
  margin-bottom: 12px;
}

body.pdf-mode .audiogram-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8mm;
}

body.pdf-mode .audiogram-panel {
  min-height: 0;
}

body.pdf-mode .chart-card canvas,
body.pdf-mode .audiogram-panel canvas {
  height: 220px !important;
  max-height: 240px !important;
}

body.pdf-mode .chart-legend-hint {
  display: block;
  margin-top: 6px;
  margin-bottom: 18px;
  font-size: 10.5px;
}

body.pdf-mode .tables {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10mm;
  margin-top: 6px;
}

body.pdf-mode .ear-table table,
body.pdf-mode .report-table {
  width: 100% !important;
  table-layout: fixed !important;
  border-collapse: collapse !important;
  font-size: 10.2px !important;
  line-height: 1.2 !important;
}

body.pdf-mode .ear-table table th,
body.pdf-mode .ear-table table td,
body.pdf-mode .report-table th,
body.pdf-mode .report-table td {
  padding: 2px 3px !important;
  vertical-align: middle !important;
  white-space: normal !important;
  word-break: break-word !important;
}

body.pdf-mode .ear-table table th:nth-child(1),
body.pdf-mode .ear-table table td:nth-child(1),
body.pdf-mode .report-table th:nth-child(1),
body.pdf-mode .report-table td:nth-child(1) {
  width: 22% !important;
}

body.pdf-mode .ear-table table th:nth-child(n + 2):nth-child(-n + 9),
body.pdf-mode .ear-table table td:nth-child(n + 2):nth-child(-n + 9),
body.pdf-mode .report-table th:nth-child(n + 2):nth-child(-n + 9),
body.pdf-mode .report-table td:nth-child(n + 2):nth-child(-n + 9) {
  width: 9.75% !important;
}

body.pdf-mode .ear-table {
  page-break-inside: avoid;
}

body.pdf-mode * {
  page-break-inside: avoid;
}
