:root {
  --primary: #0d9488;
  --primary-hover: #0f766e;
  --primary-light: #ccfbf1;
  --secondary: #4338ca;
  --secondary-hover: #3730a3;
  --secondary-light: #e0e7ff;
  --accent: #0284c7;
  --vintage-bg: #09121d;
  --vintage-card: #0f1e31;
  --vintage-border: #1e3a5f;
  --vintage-gold: #d97706;
  --vintage-gold-light: #fef3c7;
  --vintage-cyan: #38bdf8;
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-surface: #f1f5f9;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --border-focus: #14b8a6;
  --success: #10b981;
  --success-bg: #ecfdf5;
  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --neutral-gray: #94a3b8;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.06);
  --shadow-md: 0 4px 10px -2px rgb(0 0 0 / 0.08), 0 2px 6px -2px rgb(0 0 0 / 0.05);
  --shadow-lg: 0 12px 24px -4px rgb(0 0 0 / 0.12);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* =========================================================
   VINTAGE TECHNICAL BLUEPRINT AUTHENTICATION GATE
   ========================================================= */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at center, #10233a 0%, #060d16 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 20px;
  overflow-y: auto;
}

.auth-overlay::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: 
    linear-gradient(rgba(56, 189, 248, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(56, 189, 248, 0.07) 1px, transparent 1px),
    linear-gradient(rgba(217, 119, 6, 0.04) 5px, transparent 5px),
    linear-gradient(90deg, rgba(217, 119, 6, 0.04) 5px, transparent 5px);
  background-size: 20px 20px, 20px 20px, 100px 100px, 100px 100px;
  pointer-events: none;
}

.auth-card {
  position: relative;
  background: rgba(15, 30, 49, 0.95);
  border: 1px solid var(--vintage-border);
  border-radius: var(--radius-lg);
  max-width: 460px;
  width: 100%;
  padding: 36px 32px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(56, 189, 248, 0.2);
  color: #e2e8f0;
  text-align: center;
  backdrop-filter: blur(12px);
  animation: modalFadeIn 0.35s ease-out;
}

.auth-card::after {
  content: "TERMINAL CLÍNICO · REF. FONO-SAAS";
  position: absolute;
  top: 10px;
  right: 16px;
  font-size: 9px;
  font-family: 'Courier New', Courier, monospace;
  color: var(--vintage-cyan);
  letter-spacing: 1.5px;
  opacity: 0.7;
}

.auth-seal {
  width: 68px;
  height: 68px;
  margin: 0 auto 14px;
  background: linear-gradient(135deg, #0d9488, #1e3a5f);
  border: 2px solid var(--vintage-cyan);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.3);
}

.auth-seal svg {
  width: 34px;
  height: 34px;
  fill: none;
  stroke: #ffffff;
  stroke-width: 2;
}

.auth-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.3px;
  color: #ffffff;
  margin-bottom: 4px;
}

.auth-tagline {
  font-size: 11px;
  font-family: 'Courier New', Courier, monospace;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--vintage-cyan);
  margin-bottom: 18px;
}

.acoustic-wave {
  width: 100%;
  height: 28px;
  margin-bottom: 20px;
  opacity: 0.85;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: left;
}

.vintage-label {
  font-size: 11px;
  font-family: 'Courier New', Courier, monospace;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #94a3b8;
}

.vintage-input {
  background: rgba(8, 18, 30, 0.85) !important;
  border: 1px solid #1e3a5f !important;
  color: #f8fafc !important;
  font-size: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  outline: none;
  transition: all 0.2s;
  width: 100%;
}

.vintage-input:focus {
  border-color: var(--vintage-cyan) !important;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.3) !important;
}

.btn-vintage-login {
  background: linear-gradient(135deg, var(--primary), #0284c7);
  color: white;
  padding: 13px;
  font-size: 14px;
  font-weight: 700;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.2);
  cursor: pointer;
  margin-top: 6px;
  transition: all 0.2s;
  letter-spacing: 0.5px;
  width: 100%;
}

.btn-vintage-login:hover {
  filter: brightness(1.15);
  box-shadow: 0 0 15px rgba(13, 148, 136, 0.5);
}

/* =========================================================
   APP HEADER & NAVIGATION
   ========================================================= */
header.app-header {
  background: white;
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.brand-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: bold;
}

.brand-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.3px;
}

.brand-badge {
  font-size: 11px;
  background: var(--primary-light);
  color: var(--primary-hover);
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 600;
  margin-left: 6px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--bg-surface);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--secondary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  flex-shrink: 0;
}

/* NAVIGATION BAR */
.main-nav {
  background: white;
  border-bottom: 1px solid var(--border);
  display: flex;
  padding: 0 16px;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.main-nav::-webkit-scrollbar {
  display: none;
}

.nav-tab {
  padding: 13px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: all 0.2s;
  background: transparent;
  border-top: none;
  border-left: none;
  border-right: none;
  flex-shrink: 0;
}

.nav-tab:hover {
  color: var(--primary);
  background: var(--bg-surface);
}

.nav-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: #f0fdfa;
}

/* MAIN CONTAINER */
main.app-main {
  flex: 1;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 20px 16px 80px;
}

/* =========================================================
   SAAS HUB & DASHBOARD
   ========================================================= */
.hub-hero {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  color: white;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.hub-hero::before {
  content: '';
  position: absolute;
  top: -50px;
  right: -50px;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(13, 148, 136, 0.3) 0%, transparent 70%);
  border-radius: 50%;
}

.hub-hero-title {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 6px;
}

.hub-hero-subtitle {
  font-size: 14px;
  color: #94a3b8;
  max-width: 700px;
  line-height: 1.5;
}

.hub-tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
  margin-bottom: 28px;
}

.tool-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 22px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all 0.25s ease;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.tool-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
}

.tool-icon-wrapper {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  margin-bottom: 14px;
}

.tool-icon-adl {
  background: #ccfbf1;
  color: #0d9488;
}

.tool-icon-hmf {
  background: #e0e7ff;
  color: #4338ca;
}

.tool-icon-port {
  background: #fef3c7;
  color: #d97706;
}

.tool-icon-speech {
  background: #fce7f3;
  color: #db2777;
}

.tool-icon-history {
  background: #e2e8f0;
  color: #334155;
}

.tool-icon-settings {
  background: #e0f2fe;
  color: #0284c7;
}

.tool-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 6px;
}

.tool-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.45;
  margin-bottom: 16px;
}

.tool-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  border-top: 1px solid #f1f5f9;
}

.tool-status-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
}

/* CARDS & CONTAINERS */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 22px;
  margin-bottom: 22px;
  transition: box-shadow 0.2s;
}

.card-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

/* FORM CONTROLS */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
}

.form-input, .form-select, .form-textarea {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-main);
  background: white;
  outline: none;
  transition: all 0.2s;
  width: 100%;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.15);
}

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  outline: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(13, 148, 136, 0.25);
}

.btn-secondary {
  background: var(--secondary);
  color: white;
}
.btn-secondary:hover {
  background: var(--secondary-hover);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}

.btn-outline {
  background: white;
  border: 1px solid var(--border);
  color: var(--text-main);
}
.btn-outline:hover {
  background: var(--bg-surface);
  border-color: var(--text-muted);
}

.btn-sm {
  padding: 6px 11px;
  font-size: 12px;
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-success {
  background: var(--success);
  color: white;
}

/* EXPORT ACTION TOOLBAR */
.export-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  padding: 12px 16px;
  background: white;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

/* SUMMARY METRIC CARDS */
.metrics-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.metric-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  overflow: hidden;
}

.metric-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--primary);
}

.metric-card.accent-le::before {
  background: var(--secondary);
}

.metric-card.accent-global::before {
  background: var(--accent);
}

.metric-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.metric-val {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-main);
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.metric-sub {
  font-size: 12px;
  color: var(--text-muted);
}

/* SEVERITY BADGES */
.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
}

.status-normal {
  background: var(--success-bg);
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.status-leve {
  background: var(--warning-bg);
  color: #92400e;
  border: 1px solid #fde68a;
}

.status-moderado {
  background: #fff7ed;
  color: #c2410c;
  border: 1px solid #ffedd5;
}

.status-severo {
  background: var(--danger-bg);
  color: #991b1b;
  border: 1px solid #fecaca;
}

/* =========================================================
   CHARTS (SVG RESPONSIVE RENDERING)
   ========================================================= */
.chart-container {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin: 16px 0;
}

.chart-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.svg-chart {
  width: 100%;
  height: auto;
  max-height: 220px;
}

/* AGE BAND ACCORDION & TESTING PROTOCOL */
.band-section {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
  background: white;
  overflow: hidden;
}

.band-section.highlight-band {
  border: 2px solid var(--primary);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.12);
}

.band-header {
  padding: 12px 16px;
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}

.band-header:hover {
  background: #e2e8f0;
}

.band-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.band-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
}

.band-tag {
  font-size: 11px;
  background: white;
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 10px;
  color: var(--text-muted);
}

.band-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.band-content {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ITEM ROW */
.test-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-main);
  border: 1px solid var(--border);
  gap: 12px;
  transition: all 0.15s;
}

.test-item-row:hover {
  border-color: #cbd5e1;
  background: #f8fafc;
}

.item-left {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex: 1;
}

.item-number {
  font-weight: 800;
  color: var(--primary);
  font-size: 13px;
  min-width: 22px;
}

.item-text {
  font-size: 13px;
  line-height: 1.4;
  color: var(--text-main);
}

/* TACTILE SCORE SELECTOR BUTTONS */
.score-selector {
  display: flex;
  gap: 5px;
}

.score-btn {
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--border);
  background: white;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.score-btn:hover {
  border-color: var(--text-main);
  color: var(--text-main);
}

.score-btn.active-1 {
  background: var(--success);
  color: white;
  border-color: var(--success);
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.score-btn.active-0 {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.score-btn.active-nr {
  background: var(--neutral-gray);
  color: white;
  border-color: var(--neutral-gray);
}

/* PHONOLOGY GRID & BUTTONS */
.phonology-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
}

.phon-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  background: white;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.phon-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.phon-word {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
}

.phon-target {
  font-size: 11px;
  color: var(--secondary);
  font-weight: 600;
  background: var(--secondary-light);
  padding: 2px 6px;
  border-radius: 4px;
}

.phon-btn-group {
  display: flex;
  gap: 4px;
}

.phon-btn {
  flex: 1;
  padding: 6px 0;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-muted);
  cursor: pointer;
  text-align: center;
}

.phon-btn.active-plus {
  background: var(--success);
  color: white;
  border-color: var(--success);
}
.phon-btn.active-minus {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}
.phon-btn.active-n {
  background: #3b82f6;
  color: white;
  border-color: #3b82f6;
}
.phon-btn.active-r {
  background: #8b5cf6;
  color: white;
  border-color: #8b5cf6;
}
.phon-btn.active-nr {
  background: var(--neutral-gray);
  color: white;
  border-color: var(--neutral-gray);
}

/* PEI GOALS SECTION */
.pei-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pei-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: white;
  border: 1px solid var(--border);
}

.pei-item.lc {
  border-left: 4px solid var(--primary);
}

.pei-item.le {
  border-left: 4px solid var(--secondary);
}

.pei-content {
  flex: 1;
}

.pei-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 3px;
}

.pei-origin {
  font-size: 11px;
  color: var(--text-muted);
}

/* =========================================================
   PHONOLOGY GRID & CARDS
   ========================================================= */
.phonology-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.phon-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all 0.2s;
}

.phon-card:hover {
  border-color: var(--primary);
  background: white;
}

.phon-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}

.phon-word {
  font-weight: 700;
  color: var(--text-main);
}

.phon-target {
  font-family: monospace;
  font-weight: 700;
  color: var(--primary-hover);
  background: var(--primary-light);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
}

.phon-btn-group {
  display: flex;
  gap: 4px;
}

.phon-btn {
  flex: 1;
  padding: 5px 0;
  border: 1px solid var(--border);
  background: white;
  color: var(--text-muted);
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}

.phon-btn:hover {
  border-color: var(--primary);
  color: var(--text-main);
}

.phon-btn.active-plus {
  background: var(--success);
  color: white;
  border-color: var(--success);
}

.phon-btn.active-minus {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}

.phon-btn.active-n {
  background: #3b82f6;
  color: white;
  border-color: #3b82f6;
}

.phon-btn.active-r {
  background: #8b5cf6;
  color: white;
  border-color: #8b5cf6;
}

.phon-btn.active-nr {
  background: #64748b;
  color: white;
  border-color: #64748b;
}

/* =========================================================
   CLINICAL REPORT & LETTERHEAD
   ========================================================= */
.report-paper {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 36px 32px;
  max-width: 900px;
  margin: 0 auto;
  box-shadow: var(--shadow-md);
  overflow: visible;
}

.report-header {
  border-bottom: 2px solid var(--primary);
  padding-bottom: 14px;
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 14px;
}

.report-clinic-brand {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-main);
}

.report-title-main {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary-hover);
  margin-top: 2px;
}

.report-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

.report-table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 10px 0;
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0;
  font-size: 12.5px;
  word-break: normal;
  overflow-wrap: break-word;
}

.report-table th, .report-table td {
  border: 1px solid #cbd5e1;
  padding: 8px 10px;
  text-align: left;
  vertical-align: middle;
  word-break: break-word;
}

.report-table th {
  background: var(--bg-surface);
  font-weight: 700;
  color: var(--text-main);
}

.report-section {
  margin-bottom: 22px;
}

.report-section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary-hover);
  border-bottom: 1px solid var(--border);
  padding-bottom: 5px;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.report-clinical-textarea {
  width: 100%;
  font-size: 13.5px;
  line-height: 1.65;
  color: #1e293b;
  min-height: 180px;
  resize: vertical;
  overflow-y: hidden;
  box-sizing: border-box;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: #ffffff;
}

.report-text {
  font-size: 13.5px;
  line-height: 1.65;
  color: #1e293b;
  white-space: pre-wrap;
  word-break: break-word;
}

.signature-box {
  margin-top: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.signature-line {
  width: 280px;
  border-top: 1px solid var(--text-main);
  margin-bottom: 6px;
}

.report-footer-custom {
  margin-top: 30px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
}

/* =========================================================
   MOBILE BOTTOM BAR (MOBILE-FIRST ACCESS)
   ========================================================= */
.mobile-bottom-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.08);
  z-index: 100;
  padding: 6px 8px;
  justify-content: space-around;
}

.mobile-nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: transparent;
  border: none;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}

.mobile-nav-btn.active {
  color: var(--primary);
  background: var(--primary-light);
}

.mobile-nav-icon {
  font-size: 16px;
}

/* =========================================================
   RESPONSIVE ADJUSTMENTS
   ========================================================= */
@media (max-width: 768px) {
  header.app-header {
    padding: 10px 14px;
  }
  .brand-title {
    font-size: 15px;
  }
  .brand-badge {
    display: none;
  }
  .user-badge {
    max-width: 140px;
    font-size: 11px;
    padding: 4px 8px;
  }
  .main-nav {
    padding: 0 8px;
  }
  .nav-tab {
    padding: 10px 10px;
    font-size: 12px;
  }
  main.app-main {
    padding: 14px 10px 70px;
  }
  .card {
    padding: 16px;
  }
  .report-paper {
    padding: 20px 14px;
  }
  .mobile-bottom-bar {
    display: flex;
  }
}

/* =========================================================
   PRINT STYLES & PDF EXPORT
   ========================================================= */
@media print {
  @page {
    margin: 15mm 15mm 15mm 15mm;
    size: A4 portrait;
  }
  body {
    background: white !important;
    color: black !important;
    font-size: 11pt !important;
  }
  header.app-header, .main-nav, .no-print, .btn, .auth-overlay, .mobile-bottom-bar, .export-toolbar {
    display: none !important;
  }
  main.app-main {
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
  }
  .report-paper {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    max-width: 100% !important;
    overflow: visible !important;
  }
  .card {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
  }
  .report-table-responsive {
    overflow: visible !important;
  }
  .report-table {
    width: 100% !important;
    border-collapse: collapse !important;
    page-break-inside: avoid;
  }
  .report-table th, .report-table td {
    font-size: 10pt !important;
    padding: 5pt 7pt !important;
    border: 1pt solid #94a3b8 !important;
  }
  .report-table th {
    background: #f1f5f9 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .status-normal, .status-leve, .status-moderado, .status-severo {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  /* TEXTAREA ESCONDIDO E TEXTO FLUIDO VISÍVEL NO PRINT */
  #reportClinicalText {
    display: none !important;
  }
  .report-text-print {
    display: block !important;
    font-size: 10.5pt !important;
    line-height: 1.6 !important;
    color: #0f172a !important;
    white-space: pre-wrap !important;
    word-break: break-word !important;
    page-break-inside: auto !important;
  }
  .chart-container {
    border: 1pt solid #cbd5e1 !important;
    padding: 8pt !important;
    page-break-inside: avoid !important;
  }
  .svg-chart {
    max-height: 180px !important;
    width: 100% !important;
  }
  .signature-box {
    page-break-inside: avoid !important;
    margin-top: 25pt !important;
  }
}

/* ANIMATIONS */
@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* =========================================================
   ACCESSIBILITY & KEYBOARD FOCUS (WCAG 2.1 AA)
   ========================================================= */
:focus-visible {
  outline: 2px solid var(--primary) !important;
  outline-offset: 2px !important;
}

button:focus-visible, .nav-tab:focus-visible, .tool-card:focus-visible, .vintage-input:focus-visible, .form-input:focus-visible {
  outline: 2px solid var(--primary) !important;
  outline-offset: 2px !important;
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.25) !important;
}

/* =========================================================
   HMF & PORT FORM 4 SOA STYLES
   ========================================================= */
.hmf-stage-card {
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.hmf-stage-card:hover {
  transform: translateX(4px);
  box-shadow: var(--shadow-sm);
}
.port-item-row {
  transition: background 0.12s ease;
}
.port-item-row:hover {
  background: rgba(0, 0, 0, 0.02);
}


/* =========================================================
   MOBILE LIVE-HUD & TOAST NOTIFICATIONS (MOBILE 200% UX)
   ========================================================= */
.mobile-live-hud {
  position: sticky;
  top: 10px;
  z-index: 95;
  margin-bottom: 16px;
  animation: modalFadeIn 0.25s ease-out;
}

.hud-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: rgba(15, 30, 49, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  color: #f8fafc;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35), 0 0 12px rgba(13, 148, 136, 0.2);
}

.hud-metric {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.hud-label {
  font-size: 11px;
  font-weight: 800;
  background: var(--primary);
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

.hud-val {
  font-size: 20px;
  font-weight: 900;
  color: #38bdf8;
  font-family: 'Outfit', sans-serif;
}

.hud-unit {
  font-size: 10px;
  font-weight: 700;
  color: #94a3b8;
}

.hud-divider {
  width: 1px;
  height: 24px;
  background: rgba(255, 255, 255, 0.15);
}

.hud-details {
  display: flex;
  flex-direction: column;
  font-size: 11px;
  color: #cbd5e1;
  line-height: 1.25;
}

.hud-details strong {
  color: #ffffff;
}

.hud-ep {
  font-size: 11.5px;
  color: #fbbf24;
}

.btn-hud-save {
  background: linear-gradient(135deg, var(--primary), #0284c7);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.btn-hud-save:active {
  transform: scale(0.95);
}

.btn-whatsapp {
  background: #16a34a;
  color: white;
}
.btn-whatsapp:hover {
  background: #15803d;
  box-shadow: 0 4px 12px rgba(22, 163, 74, 0.3);
}

/* TOAST NOTIFICATION */
.toast-container {
  position: fixed;
  bottom: calc(75px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: 90%;
  max-width: 380px;
}

.toast {
  background: #0f172a;
  color: white;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(0,0,0,0.3);
  border: 1px solid var(--vintage-border);
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
  animation: toastSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  transition: opacity 0.3s, transform 0.3s;
}

.toast.toast-success {
  border-left: 4px solid var(--success);
}
.toast.toast-error {
  border-left: 4px solid var(--danger);
}

@keyframes toastSlideUp {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* =========================================================
   COMPREHENSIVE MOBILE OPTIMIZATIONS (SCREENS <= 768px & <= 480px)
   ========================================================= */
@media (max-width: 900px) {
  .hmf-container {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 768px) {
  /* Prevent iOS Safari Auto-Zoom on form focus */
  .form-input, .form-select, .form-textarea, .vintage-input {
    font-size: 16px !important;
  }

  main.app-main {
    padding: 12px 10px calc(80px + env(safe-area-inset-bottom, 0px)) !important;
  }

  /* Responsive Item Rows with thumb-friendly controls */
  .test-item-row {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px 14px;
  }

  .item-left {
    width: 100%;
  }

  .item-text {
    font-size: 14px;
    line-height: 1.45;
  }

  .score-selector {
    display: flex;
    width: 100%;
    gap: 8px;
    margin-top: 4px;
  }

  .score-btn {
    flex: 1;
    min-height: 44px;
    font-size: 14px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
  }

  /* Band Header Mobile Layout */
  .band-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px 14px;
  }

  .band-title-group {
    justify-content: space-between;
    width: 100%;
  }

  .band-actions {
    display: flex;
    width: 100%;
    gap: 6px;
  }

  .band-actions .btn {
    flex: 1;
    min-height: 38px;
    font-size: 12px;
    padding: 6px 4px;
    text-align: center;
    justify-content: center;
  }

  /* Phonology Cards on Mobile */
  .phonology-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .phon-card {
    padding: 14px;
  }

  .phon-btn-group {
    gap: 6px;
    margin-top: 6px;
  }

  .phon-btn {
    min-height: 42px;
    font-size: 13px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Export Toolbar on Mobile */
  .export-toolbar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 14px;
  }

  .export-toolbar span {
    grid-column: 1 / -1;
    font-size: 13px;
  }

  .export-toolbar .btn {
    width: 100%;
    min-height: 42px;
    font-size: 12px;
  }

  #btnShareWhatsApp {
    grid-column: 1 / -1;
    font-size: 13.5px;
    font-weight: 700;
  }

  /* Report Table Mobile Scroll */
  .report-table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 8px -6px;
    padding: 0 6px;
  }

  .report-table {
    min-width: 540px;
  }

  .report-paper {
    padding: 18px 12px;
    border-radius: var(--radius-sm);
  }

  .report-header {
    flex-direction: column;
    gap: 12px;
  }

  .report-header > div:last-child {
    text-align: left !important;
  }

  /* Mobile Bottom Navigation Bar */
  .mobile-bottom-bar {
    padding: calc(6px + env(safe-area-inset-bottom, 0px)) 6px env(safe-area-inset-bottom, 6px);
    height: auto;
  }

  .mobile-nav-btn {
    padding: 6px 10px;
    font-size: 11px;
    border-radius: 8px;
    min-width: 58px;
  }

  .mobile-nav-icon {
    font-size: 18px;
  }
}

@media (max-width: 480px) {
  .export-toolbar {
    grid-template-columns: 1fr;
  }
  .hud-content {
    padding: 6px 10px;
    gap: 6px;
  }
  .hud-val {
    font-size: 18px;
  }
  .hud-details {
    font-size: 10px;
  }
}

/* METRIC EP INPUT & CALIBRATION STYLES */
.metric-ep-container {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  background: var(--bg-surface);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.ep-badge-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
}

.metric-ep-input {
  width: 64px;
  padding: 4px 6px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 800;
  color: #0f172a;
  text-align: center;
  background: white;
  outline: none;
  transition: all 0.2s;
}

.metric-ep-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.2);
}
