/* Rehab Tools — Design tokens */
:root {
  /* Primary: navy istituzionale */
  --rt-navy-900: #0F1B33;
  --rt-navy-800: #1A2B4A;
  --rt-navy-700: #243a5e;
  --rt-navy-600: #34507a;
  --rt-navy-500: #4d6a96;
  --rt-navy-100: #E8ECF4;
  --rt-navy-50:  #F4F6FB;

  /* Accent / semantic */
  --rt-teal:    #0E7C6B;
  --rt-amber:   #B7791F;
  --rt-red:     #B42318;
  --rt-green:   #15803D;

  /* Neutrals */
  --rt-ink:     #0F172A;
  --rt-text:    #1F2937;
  --rt-muted:   #5B6678;
  --rt-line:    #D9DEE8;
  --rt-line-2:  #E7EAF1;
  --rt-bg:      #F8F9FC;
  --rt-card:    #FFFFFF;

  /* Type */
  --rt-serif: "Source Serif Pro", "Source Serif 4", Georgia, "Times New Roman", serif;
  --rt-sans:  "Inter Tight", "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --rt-mono:  "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Radii / shadow */
  --rt-r-sm: 4px;
  --rt-r:    6px;
  --rt-r-lg: 10px;
  --rt-shadow-sm: 0 1px 2px rgba(15,27,51,.06), 0 1px 1px rgba(15,27,51,.04);
  --rt-shadow:    0 1px 2px rgba(15,27,51,.06), 0 4px 12px rgba(15,27,51,.06);
  --rt-shadow-lg: 0 6px 24px rgba(15,27,51,.10), 0 2px 6px rgba(15,27,51,.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--rt-sans);
  color: var(--rt-text);
  background: var(--rt-bg);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
  font-family: var(--rt-serif);
  color: var(--rt-navy-900);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
  text-wrap: balance;
}

a { color: var(--rt-navy-700); text-decoration: none; }
a:hover { text-decoration: underline; }

button { font-family: inherit; cursor: pointer; }

/* App chrome */
.rt-app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.rt-topbar {
  position: sticky; top: 0; z-index: 30;
  background: var(--rt-navy-900);
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.rt-topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 32px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 32px;
}
.rt-logo {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--rt-serif);
  font-weight: 600;
  font-size: 18px;
  color: #fff;
  letter-spacing: 0.01em;
}
.rt-logo:hover { text-decoration: none; }
.rt-logo-mark {
  width: 28px; height: 28px;
  background: #fff;
  color: var(--rt-navy-900);
  border-radius: 4px;
  display: grid; place-items: center;
  font-family: var(--rt-serif);
  font-weight: 700;
  font-size: 15px;
}
.rt-nav { display: flex; gap: 4px; margin-left: auto; }
.rt-nav a {
  color: rgba(255,255,255,.78);
  font-size: 14px;
  padding: 8px 14px;
  border-radius: var(--rt-r);
  font-weight: 500;
}
.rt-nav a:hover { color: #fff; background: rgba(255,255,255,.06); text-decoration: none; }
.rt-nav a.active { color: #fff; background: rgba(255,255,255,.10); }

.rt-topbar-meta {
  display: flex; align-items: center; gap: 14px;
  color: rgba(255,255,255,.6);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  border-left: 1px solid rgba(255,255,255,.12);
  padding-left: 16px;
}
.rt-topbar-meta .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 0 3px rgba(74,222,128,.18);
}

/* Container */
.rt-container { max-width: 1280px; margin: 0 auto; padding: 0 32px; }
.rt-container-narrow { max-width: 980px; margin: 0 auto; padding: 0 32px; }

/* Footer */
.rt-footer {
  margin-top: auto;
  background: #fff;
  border-top: 1px solid var(--rt-line);
  padding: 32px 0;
  font-size: 13px;
  color: var(--rt-muted);
}
.rt-footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 32px;
  flex-wrap: wrap;
}
.rt-footer .links { display: flex; gap: 24px; }
.rt-footer .links a { color: var(--rt-muted); }

/* Buttons */
.rt-btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 18px;
  border-radius: var(--rt-r);
  border: 1px solid transparent;
  font-weight: 500;
  font-size: 14px;
  background: #fff;
  color: var(--rt-text);
  border-color: var(--rt-line);
  transition: all .15s ease;
  text-decoration: none;
}
.rt-btn:hover { text-decoration: none; border-color: var(--rt-navy-500); color: var(--rt-navy-800); }
.rt-btn.primary {
  background: var(--rt-navy-800);
  color: #fff;
  border-color: var(--rt-navy-800);
}
.rt-btn.primary:hover { background: var(--rt-navy-900); border-color: var(--rt-navy-900); color: #fff; }
.rt-btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--rt-navy-700);
}
.rt-btn.ghost:hover { background: var(--rt-navy-50); border-color: transparent; }
.rt-btn.sm { height: 32px; padding: 0 12px; font-size: 13px; }
.rt-btn.lg { height: 48px; padding: 0 22px; font-size: 15px; }

/* Inputs */
.rt-field { display: flex; flex-direction: column; gap: 6px; }
.rt-field label {
  font-size: 12px;
  font-weight: 500;
  color: var(--rt-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.rt-input, .rt-select, .rt-textarea {
  font-family: inherit;
  font-size: 14px;
  height: 40px;
  border: 1px solid var(--rt-line);
  border-radius: var(--rt-r);
  padding: 0 12px;
  background: #fff;
  color: var(--rt-text);
  transition: border-color .15s, box-shadow .15s;
}
.rt-textarea { height: auto; padding: 10px 12px; resize: vertical; min-height: 80px; }
.rt-input:focus, .rt-select:focus, .rt-textarea:focus {
  outline: none;
  border-color: var(--rt-navy-600);
  box-shadow: 0 0 0 3px rgba(36,58,94,.12);
}

/* Card */
.rt-card {
  background: var(--rt-card);
  border: 1px solid var(--rt-line);
  border-radius: var(--rt-r-lg);
  box-shadow: var(--rt-shadow-sm);
}

/* Tags / chips */
.rt-tag {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 8px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  border-radius: 3px;
  background: var(--rt-navy-50);
  color: var(--rt-navy-700);
  border: 1px solid var(--rt-navy-100);
}
.rt-tag.teal { background: #E6F2EF; color: #0E7C6B; border-color: #C9E5DD; }
.rt-tag.amber { background: #FCF3DD; color: #8A5A0F; border-color: #F0DDA8; }
.rt-tag.gray { background: #F1F3F7; color: #5B6678; border-color: #E0E4EC; }

/* Eyebrow */
.rt-eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--rt-navy-700);
}

/* Divider */
.rt-rule { border: none; height: 1px; background: var(--rt-line); margin: 0; }

/* Utility */
.rt-muted { color: var(--rt-muted); }
.rt-mono  { font-family: var(--rt-mono); font-variant-numeric: tabular-nums; }
.rt-tnum  { font-variant-numeric: tabular-nums; }

/* Tables */
.rt-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.rt-table th {
  text-align: left;
  font-weight: 500;
  color: var(--rt-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 12px 16px;
  border-bottom: 1px solid var(--rt-line);
  background: var(--rt-navy-50);
}
.rt-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--rt-line-2);
  vertical-align: middle;
}
.rt-table tr:last-child td { border-bottom: none; }
.rt-table tr.row-link { cursor: pointer; transition: background .12s; }
.rt-table tr.row-link:hover td { background: var(--rt-navy-50); }

/* Section title */
.rt-section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 24px;
}

/* Form item */
.rt-item-row {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  gap: 18px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--rt-line-2);
  align-items: flex-start;
}
.rt-item-row:last-child { border-bottom: none; }
.rt-item-row .num {
  font-family: var(--rt-serif);
  font-size: 16px;
  color: var(--rt-navy-700);
  font-variant-numeric: tabular-nums;
  padding-top: 2px;
}
.rt-item-row .item-title {
  font-weight: 500;
  color: var(--rt-navy-900);
  font-size: 15px;
}
.rt-item-row .item-help {
  font-size: 13px;
  color: var(--rt-muted);
  margin-top: 4px;
  text-wrap: pretty;
}
.rt-item-row .item-score {
  font-family: var(--rt-mono);
  font-size: 13px;
  color: var(--rt-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.rt-item-row.required-missing {
  background: linear-gradient(90deg, #FFF8F2 0%, #fff 60%);
  border-left: 2px solid var(--rt-amber);
  padding-left: 18px;
}

/* Choice radio */
.rt-choices { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.rt-choice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--rt-line);
  border-radius: var(--rt-r);
  cursor: pointer;
  background: #fff;
  transition: all .12s;
}
.rt-choice:hover { border-color: var(--rt-navy-500); background: var(--rt-navy-50); }
.rt-choice.selected {
  border-color: var(--rt-navy-700);
  background: var(--rt-navy-50);
  box-shadow: inset 0 0 0 1px var(--rt-navy-700);
}
.rt-choice input[type="radio"] {
  margin: 3px 0 0 0;
  accent-color: var(--rt-navy-800);
}
.rt-choice .label-text {
  flex: 1;
  font-size: 14px;
  color: var(--rt-text);
  text-wrap: pretty;
}
.rt-choice .points {
  font-family: var(--rt-mono);
  font-size: 12px;
  color: var(--rt-muted);
  font-weight: 500;
  background: var(--rt-navy-50);
  padding: 2px 8px;
  border-radius: 3px;
  white-space: nowrap;
}
.rt-choice.selected .points { background: var(--rt-navy-700); color: #fff; }

/* Tooltip */
.rt-tip {
  display: inline-flex;
  align-items: center; justify-content: center;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--rt-navy-100);
  color: var(--rt-navy-700);
  font-size: 11px;
  font-weight: 600;
  cursor: help;
  margin-left: 6px;
  vertical-align: middle;
}
.rt-tip-wrap { position: relative; display: inline-block; }
.rt-tip-content {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--rt-navy-900);
  color: #fff;
  font-size: 12px;
  padding: 8px 12px;
  border-radius: var(--rt-r);
  width: 260px;
  text-transform: none;
  letter-spacing: normal;
  font-weight: 400;
  line-height: 1.45;
  z-index: 50;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s;
}
.rt-tip-content::after {
  content: '';
  position: absolute;
  top: 100%; left: 50%; transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--rt-navy-900);
}
.rt-tip-wrap:hover .rt-tip-content { opacity: 1; }

/* Progress */
.rt-progress {
  height: 4px;
  background: var(--rt-line-2);
  border-radius: 2px;
  overflow: hidden;
}
.rt-progress > div {
  height: 100%;
  background: var(--rt-navy-700);
  border-radius: 2px;
  transition: width .3s ease;
}

/* Score gauge in sidebar */
.rt-gauge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.rt-gauge-num {
  font-family: var(--rt-serif);
  font-size: 56px;
  font-weight: 600;
  color: var(--rt-navy-900);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.rt-gauge-of {
  font-family: var(--rt-mono);
  font-size: 13px;
  color: var(--rt-muted);
}

/* Print / report */
.rt-report {
  width: 210mm;
  min-height: 297mm;
  padding: 16mm 18mm;
  background: #fff;
  margin: 24px auto;
  box-shadow: var(--rt-shadow);
  color: var(--rt-text);
  font-size: 11px;
  line-height: 1.45;
}
@media print {
  body { background: #fff; }
  .rt-no-print { display: none !important; }
  .rt-report { box-shadow: none; margin: 0; width: 100%; min-height: 100vh; padding: 14mm; }
  @page { size: A4; margin: 0; }
}

/* Scale icon glyph */
.rt-glyph {
  width: 40px; height: 40px;
  border-radius: 8px;
  background: var(--rt-navy-50);
  border: 1px solid var(--rt-navy-100);
  display: grid; place-items: center;
  color: var(--rt-navy-800);
  font-family: var(--rt-serif);
  font-weight: 600;
  font-size: 16px;
  flex-shrink: 0;
}

/* Hero */
.rt-hero { padding: 80px 0 64px; }
.rt-hero h1 { font-size: 64px; line-height: 1.05; letter-spacing: -0.02em; }
.rt-hero .lead {
  font-size: 19px;
  color: var(--rt-muted);
  max-width: 560px;
  margin-top: 22px;
  line-height: 1.55;
  text-wrap: pretty;
}
.rt-hero .actions { display: flex; gap: 12px; margin-top: 32px; }

/* Stat card */
.rt-stat {
  padding: 20px;
  border: 1px solid var(--rt-line);
  border-radius: var(--rt-r-lg);
  background: #fff;
}
.rt-stat .num {
  font-family: var(--rt-serif);
  font-size: 32px;
  font-weight: 600;
  color: var(--rt-navy-900);
  line-height: 1.1;
}
.rt-stat .label {
  font-size: 12px;
  color: var(--rt-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 4px;
}

/* Step card */
.rt-step {
  padding: 24px;
  border: 1px solid var(--rt-line);
  border-radius: var(--rt-r-lg);
  background: #fff;
}
.rt-step .step-num {
  font-family: var(--rt-mono);
  font-size: 12px;
  color: var(--rt-navy-700);
  letter-spacing: 0.08em;
  font-weight: 500;
}
.rt-step h3 { margin-top: 8px; font-size: 18px; }
.rt-step p { color: var(--rt-muted); font-size: 14px; margin: 8px 0 0; line-height: 1.55; }
