/* Term-Sheet Doctor module styles. Scoped to body.tsd. */

body.tsd .content {
  max-width: 1100px;
}

body.tsd .eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0 0 0.5rem;
  font-weight: 600;
}

body.tsd h1 {
  font-size: 2.25rem;
  margin: 0 0 0.5rem;
  letter-spacing: -0.01em;
}

body.tsd h2 {
  font-size: 1.4rem;
  margin: 0 0 0.5rem;
  letter-spacing: -0.005em;
}

body.tsd .small {
  font-size: 0.875rem;
}

body.tsd .lede {
  font-size: 1.15rem;
  color: var(--fg);
  max-width: 60ch;
  margin: 0 0 2rem;
}

body.tsd .btn {
  display: inline-block;
  padding: 0.7rem 1.4rem;
  border-radius: 8px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  text-decoration: none;
  font-size: 0.95rem;
  background: var(--accent);
  color: #fff;
}
body.tsd .btn:hover {
  filter: brightness(1.08);
  text-decoration: none;
}
body.tsd .btn-outline {
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--border);
}
body.tsd .btn-outline:hover {
  background: #fff;
}
body.tsd .btn-link {
  background: transparent;
  color: var(--accent);
  padding: 0.7rem 0;
}

/* ---------- Form ---------- */

body.tsd-form .tsd-hero {
  margin-bottom: 1.5rem;
}

body.tsd-form .tsd-error {
  background: #fff3f0;
  border: 1px solid #f1b6a8;
  border-left: 4px solid #c0392b;
  padding: 1rem 1.25rem;
  border-radius: 8px;
  margin: 0 0 1.5rem;
  color: #6b2417;
}

body.tsd-form .tsd-form-grid {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

body.tsd-form .tsd-fieldset {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  padding: 1.5rem 1.75rem 1.75rem;
  margin: 0;
}

body.tsd-form .tsd-fieldset legend {
  padding: 0 0.5rem;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

body.tsd-form .field-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
  margin-top: 1rem;
}
body.tsd-form .field-row:first-of-type {
  margin-top: 0.5rem;
}
@media (max-width: 720px) {
  body.tsd-form .field-row {
    grid-template-columns: 1fr;
  }
}

body.tsd-form .field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
body.tsd-form .field-narrow {
  max-width: 180px;
}

body.tsd-form .field label {
  font-weight: 500;
  font-size: 0.95rem;
}

body.tsd-form .field input[type="text"],
body.tsd-form .field input[type="number"],
body.tsd-form .field select {
  padding: 0.65rem 0.85rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fff;
  font-family: inherit;
}
body.tsd-form .field input:focus,
body.tsd-form .field select:focus {
  border-color: var(--accent);
  outline: 2px solid rgba(31, 77, 139, 0.18);
}

body.tsd-form .field-help {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

body.tsd-form .checkbox {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  padding-top: 1.6rem;
}
body.tsd-form .checkbox input {
  width: 18px;
  height: 18px;
}

body.tsd-form .tsd-actions {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}

/* ---------- Result ---------- */

body.tsd-result .tsd-result-header {
  margin: 0 0 1.5rem;
}
body.tsd-result .tsd-result-header h1 {
  font-size: 1.6rem;
  font-weight: 600;
}
body.tsd-result .result-deal-summary {
  font-size: 1.05rem;
  margin-top: 0.4rem;
  color: var(--fg);
}
body.tsd-result .result-bank {
  font-size: 0.95rem;
  margin-top: 0.2rem;
}

body.tsd-result .tsd-verdict {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1.75rem;
  align-items: center;
  padding: 1.75rem 2rem;
  border-radius: 14px;
  margin: 0 0 2.25rem;
  border: 1px solid var(--border);
  background: #fff;
}
body.tsd-result .tsd-verdict-green {
  border-color: #c6e6c9;
  background: linear-gradient(180deg, #f0faf1 0%, #fff 60%);
}
body.tsd-result .tsd-verdict-amber {
  border-color: #f3d9a4;
  background: linear-gradient(180deg, #fdf5e6 0%, #fff 60%);
}
body.tsd-result .tsd-verdict-red {
  border-color: #f1c5be;
  background: linear-gradient(180deg, #fcefec 0%, #fff 60%);
}

body.tsd-result .verdict-score {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 110px;
  padding: 1rem 1.25rem;
  border-radius: 16px;
  background: #fff;
  border: 2px solid var(--border);
}
body.tsd-result .tsd-verdict-green .verdict-score { border-color: #6cb56e; color: #1d6b22; }
body.tsd-result .tsd-verdict-amber .verdict-score { border-color: #d29331; color: #7a4f08; }
body.tsd-result .tsd-verdict-red .verdict-score { border-color: #c0392b; color: #7c1c12; }

body.tsd-result .score-number {
  font-size: 2.75rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
body.tsd-result .score-denom {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

body.tsd-result .verdict-band {
  margin: 0 0 0.5rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.85rem;
}
body.tsd-result .tsd-verdict-green .verdict-band { color: #1d6b22; }
body.tsd-result .tsd-verdict-amber .verdict-band { color: #7a4f08; }
body.tsd-result .tsd-verdict-red .verdict-band { color: #7c1c12; }

body.tsd-result .verdict-headline {
  margin: 0 0 0.75rem;
  font-size: 1.25rem;
  line-height: 1.45;
  font-weight: 600;
}

body.tsd-result .verdict-numbers {
  margin: 0;
  font-size: 0.95rem;
  color: var(--fg);
}
body.tsd-result .verdict-numbers .metric {
  font-weight: 500;
}
body.tsd-result .verdict-numbers .metric-sep {
  margin: 0 0.5rem;
  color: var(--muted);
}

/* ---------- Band visualisation ---------- */

body.tsd-result .tsd-band {
  margin: 0 0 2.5rem;
}

body.tsd-result .band-strip {
  margin: 1.5rem 0 0.75rem;
  padding: 2rem 1rem 3rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
}

body.tsd-result .band-track {
  position: relative;
  height: 6px;
  background: #ede9df;
  border-radius: 3px;
}

body.tsd-result .band-fair-zone {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 6px;
  background: linear-gradient(90deg, #b6dab8 0%, #d8e4f0 50%, #f3d9a4 100%);
  border-radius: 3px;
}

body.tsd-result .band-mark {
  position: absolute;
  top: -6px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 0.78rem;
  color: var(--muted);
}
body.tsd-result .band-tick {
  width: 2px;
  height: 18px;
  background: var(--muted);
  border-radius: 1px;
}
body.tsd-result .band-label {
  margin-top: 0.5rem;
  white-space: nowrap;
  font-weight: 500;
}

body.tsd-result .band-user {
  position: absolute;
  top: -22px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 0.85rem;
  color: var(--fg);
}
body.tsd-result .user-tick {
  width: 3px;
  height: 36px;
  background: var(--accent);
  border-radius: 1px;
}
body.tsd-result .user-label {
  margin-top: 0.4rem;
  white-space: nowrap;
  font-weight: 600;
  color: var(--accent);
  background: #fff;
  padding: 0.15rem 0.5rem;
  border-radius: 12px;
  border: 1px solid var(--accent);
}

/* ---------- Suggestions ---------- */

body.tsd-result .tsd-suggestions {
  margin: 0 0 2.5rem;
}

body.tsd-result .suggestion-list {
  list-style: none;
  counter-reset: suggestion;
  padding: 0;
  margin: 1.25rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

body.tsd-result .suggestion {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.1rem 1.35rem 1.2rem 3rem;
  position: relative;
  counter-increment: suggestion;
}

body.tsd-result .suggestion::before {
  content: counter(suggestion);
  position: absolute;
  top: 1.05rem;
  left: 1.05rem;
  width: 1.4rem;
  height: 1.4rem;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
}

body.tsd-result .suggestion-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

body.tsd-result .suggestion-tag {
  display: inline-block;
  padding: 0.12rem 0.55rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  border-radius: 4px;
  background: #f1efe9;
  color: var(--muted);
}
body.tsd-result .suggestion-tag-pricing { background: #d8e9fb; color: #2a4b7c; }
body.tsd-result .suggestion-tag-fees    { background: #fdebd4; color: #7a4d12; }
body.tsd-result .suggestion-tag-structure { background: #e1e9da; color: #3f5d2a; }

body.tsd-result .suggestion-headline {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 600;
  flex: 1 1 auto;
}

body.tsd-result .suggestion-impact {
  font-weight: 600;
  font-size: 0.88rem;
  color: #1d6b22;
  background: #ecf6ec;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
}
.suggestion-impact-horizon {
  display: inline-block;
  margin-left: 0.3rem;
  font-size: 0.78rem;
  font-weight: 400;
  color: #4a6b4d;
}

body.tsd-result .suggestion-detail {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.55;
}

/* ---------- Math toggle ---------- */

body.tsd-result .tsd-math {
  margin: 0 0 2.5rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
}

body.tsd-result .tsd-math summary {
  list-style: none;
  cursor: pointer;
  padding: 1rem 1.35rem;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}
body.tsd-result .tsd-math summary::-webkit-details-marker { display: none; }
body.tsd-result .summary-icon {
  display: inline-block;
  width: 1.1rem;
  height: 1.1rem;
  line-height: 1.05rem;
  text-align: center;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.85rem;
  transition: transform 0.15s ease;
}
body.tsd-result .tsd-math[open] .summary-icon { transform: rotate(45deg); }
body.tsd-result .summary-label {
  font-weight: 600;
  font-size: 1rem;
}
body.tsd-result .summary-hint {
  font-size: 0.88rem;
}

body.tsd-result .math-body {
  padding: 0 1.35rem 1.5rem;
}

body.tsd-result .math-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.85rem;
  margin: 1rem 0 1.75rem;
}

body.tsd-result .math-card {
  background: var(--code-bg);
  border-radius: 8px;
  padding: 0.85rem 1rem;
}
body.tsd-result .math-label {
  margin: 0 0 0.35rem;
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}
body.tsd-result .math-sub {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
}
body.tsd-result .math-value {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--fg);
}

body.tsd-result .bank-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  margin: 0.75rem 0;
}
body.tsd-result .bank-table th,
body.tsd-result .bank-table td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
body.tsd-result .bank-table th {
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  background: var(--code-bg);
}
body.tsd-result .bank-table td.num,
body.tsd-result .bank-table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
body.tsd-result .bank-table tr.row-cheaper td {
  background: rgba(108, 181, 110, 0.06);
}

body.tsd-result .tsd-cta {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 2rem;
}

/* ---------- Confirm extracted (Task 3.4) ---------- */

body.tsd-confirm .tsd-extracted-meta {
  margin: 0 0 1.5rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fcfcfa;
  color: var(--muted);
  font-size: 0.9rem;
}
body.tsd-confirm .tsd-extracted-meta summary {
  cursor: pointer;
  user-select: none;
}
body.tsd-confirm .tsd-extracted-meta ul {
  margin: 0.5rem 0 0;
  padding-left: 1.25rem;
}
body.tsd-confirm .tsd-extracted-meta .warn {
  color: #c0392b;
}

body.tsd-confirm .field-confirm-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
body.tsd-confirm .field-confirm .chip {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.2;
}
body.tsd-confirm .field-confirm .chip-high {
  background: #e8f5e9;
  color: #1b5e20;
  border: 1px solid #a5d6a7;
}
body.tsd-confirm .field-confirm .chip-medium {
  background: #fff8e1;
  color: #7a5e00;
  border: 1px solid #ffd54f;
}
body.tsd-confirm .field-confirm .chip-low {
  background: #fbe9e7;
  color: #6b1c10;
  border: 1px solid #ffab91;
}
body.tsd-confirm .field-confirm .field-evidence {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0.35rem 0 0;
  font-style: italic;
}
body.tsd-confirm .field-confirm .field-warning {
  font-size: 0.8rem;
  color: #c0392b;
  margin: 0.35rem 0 0;
}

body.tsd-confirm .tsd-covenants {
  margin: 0 0 0.5rem;
  padding: 0.6rem 0.8rem;
  background: #f6f7f1;
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  font-size: 0.95rem;
}

/* ---------- Upload band on the form page (Task 3.4) ---------- */

body.tsd-form .tsd-upload {
  margin: 0 0 2rem;
  padding: 1rem 1.25rem;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: #fafaf6;
}
body.tsd-form .tsd-upload h2 {
  margin: 0 0 0.4rem;
  font-size: 1.1rem;
}
body.tsd-form .tsd-upload-form {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 0.6rem;
}
body.tsd-form .tsd-upload-form input[type="file"] {
  flex: 1 1 auto;
  min-width: 240px;
}
body.tsd-form .tsd-upload-divider {
  margin: 1.2rem 0 -0.6rem;
  text-align: center;
  position: relative;
  color: var(--muted);
  font-size: 0.85rem;
}
body.tsd-form .tsd-upload-divider span {
  background: var(--bg, #fff);
  padding: 0 0.6rem;
}

/* ---------- /try save-this-analysis banner (Task 2.6c) ---------- */

body.tsd-try-result .tsd-save-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  margin: 0 0 2rem;
  padding: 1.1rem 1.4rem;
  background: linear-gradient(135deg, #ecf2ff 0%, #f6f7f1 100%);
  border: 1px solid #c4d4f0;
  border-left: 4px solid var(--accent);
  border-radius: 10px;
}
body.tsd-try-result .save-banner-copy {
  flex: 1 1 auto;
  min-width: 0;
}
body.tsd-try-result .save-banner-headline {
  margin: 0 0 0.2rem;
  font-weight: 600;
  font-size: 1.05rem;
}
body.tsd-try-result .save-banner-detail {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.4;
}
body.tsd-try-result .save-banner-cta {
  flex: 0 0 auto;
  white-space: nowrap;
}
@media (max-width: 640px) {
  body.tsd-try-result .tsd-save-banner {
    flex-direction: column;
    align-items: stretch;
  }
  body.tsd-try-result .save-banner-cta {
    text-align: center;
  }
}

/* ── Top alternatives table — wedge moment ─────────────────────── */
.tsd-alternatives {
  margin: 2rem 0;
  padding: 1.25rem 1.25rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #fff;
}
.tsd-alternatives h2 {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
}
.tsd-alternatives .muted { margin: 0 0 1rem; }
.alternatives-table-wrap {
  width: 100%;
  overflow-x: auto;
}
.alternatives-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
.alternatives-table th,
.alternatives-table td {
  padding: 0.55rem 0.6rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.alternatives-table th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 600;
  background: #fafaf8;
}
.alternatives-table td.num,
.alternatives-table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.alternatives-table tr.alt-better {
  background: rgba(31, 77, 139, 0.04);
}
.alternatives-table tr.alt-better:hover {
  background: rgba(31, 77, 139, 0.07);
}
.alt-delta-better {
  color: #0f7a3b;
  font-weight: 600;
}
.alt-delta-worse {
  color: #6b6b6b;
}
.tsd-alternatives .small {
  font-size: 0.8rem;
  margin: 0.75rem 0 0;
}

/* Region pill in the alternatives section header */
.tsd-region-pill {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.15rem 0.55rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #1f4d8b;
  background: #e6efff;
  border-radius: 999px;
  vertical-align: 0.15em;
}
