/* Bondify — investment-banking visual language: deep navy, muted gold,
   serif display type paired with tabular monospace figures. Palette is
   deliberately fixed (not inherited from generic Telegram theme colors) for
   a consistent brand identity in both light and dark contexts. */

:root {
  --navy-950: #0A1424;
  --navy-900: #0F2038;
  --navy-800: #16304F;
  --navy-700: #204064;
  --gold-600: #A9813F;
  --gold-500: #BF9752;
  --gold-300: #E4CFA0;
  --paper: #F6F5F1;
  --panel: #FFFFFF;
  --ink: #14181F;
  --ink-muted: #626B78;
  --hairline: rgba(10, 20, 36, 0.12);
  --positive: #1B5E3F;
  --negative: #8C2A28;
  --radius: 3px;

  --font-serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  --font-mono: 'IBM Plex Mono', 'SF Mono', Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --navy-950: #070D18;
    --paper: #0B1220;
    --panel: #121B2B;
    --ink: #E8E6DF;
    --ink-muted: #8B94A3;
    --hairline: rgba(228, 207, 160, 0.14);
    --gold-600: #C9A15A;
    --gold-500: #D4B36A;
    --gold-300: #E9D6A8;
    --positive: #4CA97C;
    --negative: #E17572;
  }
}

:root[data-theme="dark"] {
  --navy-950: #070D18;
  --paper: #0B1220;
  --panel: #121B2B;
  --ink: #E8E6DF;
  --ink-muted: #8B94A3;
  --hairline: rgba(228, 207, 160, 0.14);
  --gold-600: #C9A15A;
  --gold-500: #D4B36A;
  --gold-300: #E9D6A8;
  --positive: #4CA97C;
  --negative: #E17572;
}

:root[data-theme="light"] {
  --navy-950: #0A1424;
  --paper: #F6F5F1;
  --panel: #FFFFFF;
  --ink: #14181F;
  --ink-muted: #626B78;
  --hairline: rgba(10, 20, 36, 0.12);
  --gold-600: #A9813F;
  --gold-500: #BF9752;
  --gold-300: #E4CFA0;
  --positive: #1B5E3F;
  --negative: #8C2A28;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

#app { max-width: 640px; margin: 0 auto; padding-bottom: 40px; }

.screen.hidden { display: none; }

/* ---------------------------------------------------------------- header */

.hero {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--navy-950);
  color: #F1EEE6;
  padding: 26px 20px 22px;
  border-bottom: 2px solid var(--gold-500);
}

.hero-mark {
  width: 42px;
  height: 42px;
  min-width: 42px;
  border: 1px solid var(--gold-500);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 20px;
  color: var(--gold-300);
}

.hero-title {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 26px;
  letter-spacing: 0.01em;
  line-height: 1.1;
}

.hero-subtitle {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--gold-300);
  margin-top: 4px;
}

.section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-muted);
  padding: 20px 20px 8px;
}

.footer-note {
  text-align: center;
  font-size: 11px;
  color: var(--ink-muted);
  padding: 18px 20px 4px;
  letter-spacing: 0.02em;
}

/* ---------------------------------------------------------- screen body */

.screen:not(#screen-home) { padding: 0 20px 20px; }

h2 {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 20px;
  margin: 14px 0 4px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--hairline);
  position: relative;
}

h2::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 42px;
  height: 2px;
  background: var(--gold-500);
}

.hint { color: var(--ink-muted); font-size: 12.5px; margin: 10px 0 14px; line-height: 1.5; }

.back-btn {
  background: none;
  border: none;
  color: var(--ink-muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 14px 0 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-sans);
}

.back-btn:active { color: var(--gold-600); }

/* --------------------------------------------------------------- cards */

.menu-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--hairline);
  border: 1px solid var(--hairline);
  margin: 0 20px 4px;
}

.menu-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  background: var(--panel);
  border: none;
  padding: 16px 14px;
  text-align: left;
  cursor: pointer;
  color: var(--ink);
  font-family: inherit;
  position: relative;
  transition: background 0.15s ease;
}

.menu-card:active { background: var(--paper); }

.menu-icon {
  width: 22px;
  height: 22px;
  color: var(--gold-600);
}

.menu-label {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 13.5px;
  line-height: 1.25;
}

.menu-desc {
  font-size: 10.5px;
  color: var(--ink-muted);
  line-height: 1.3;
  letter-spacing: 0.01em;
}

/* --------------------------------------------------------------- forms */

.form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--panel);
  padding: 18px;
  border: 1px solid var(--hairline);
  border-top: 2px solid var(--navy-900);
}

.form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  flex: 1;
}

.form-row { display: flex; gap: 12px; }

.form input, .form select {
  font-family: var(--font-mono);
  font-size: 14.5px;
  padding: 9px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--hairline);
  background: var(--paper);
  color: var(--ink);
}

.form input:focus, .form select:focus {
  outline: none;
  border-color: var(--gold-500);
}

.form-actions { display: flex; gap: 10px; }

.primary-btn, .secondary-btn {
  border: none;
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 12.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
  flex: 1;
  font-family: var(--font-sans);
}

.primary-btn { background: var(--navy-950); color: #F1EEE6; }
.primary-btn:active { background: var(--navy-800); }

.secondary-btn { background: transparent; color: var(--navy-900); border: 1px solid var(--hairline); }
.secondary-btn:active { border-color: var(--gold-500); color: var(--gold-600); }

:root[data-theme="dark"] .secondary-btn { color: var(--gold-300); }
@media (prefers-color-scheme: dark) {
  .secondary-btn { color: var(--gold-300); }
}

/* -------------------------------------------------------------- result */

.result-area { margin-top: 18px; }

.result-area img {
  width: 100%;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
}

.spinner {
  text-align: center;
  color: var(--ink-muted);
  padding: 30px 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.error-box {
  background: rgba(140, 42, 40, 0.08);
  color: var(--negative);
  border-left: 3px solid var(--negative);
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.5;
}

/* ------------------------------------------------------ tombstone cards */

.card {
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-left: 3px solid var(--gold-500);
  padding: 14px 16px;
  margin-bottom: 10px;
}

.card-title {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 2px;
}

.card-sub {
  color: var(--ink-muted);
  font-size: 11px;
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
  margin-bottom: 10px;
}

.card-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 12.5px;
  padding: 4px 0;
  border-bottom: 1px dotted var(--hairline);
}

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

.card-row .k { color: var(--ink-muted); }
.card-row .v { font-family: var(--font-mono); font-weight: 600; letter-spacing: 0.01em; }

.v.positive { color: var(--positive); }
.v.negative { color: var(--negative); }

.totals-card { background: var(--paper); }

/* ----------------------------------------------------------------- table */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--hairline);
  border-top: 2px solid var(--navy-900);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  min-width: 480px;
}

table.data-table th {
  background: var(--navy-950);
  color: #F1EEE6;
  font-weight: 600;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  text-align: right;
  padding: 9px 8px;
  white-space: nowrap;
}

table.data-table th:first-child { text-align: left; }

table.data-table td {
  border-bottom: 1px solid var(--hairline);
  padding: 8px;
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

table.data-table td:first-child {
  text-align: left;
  font-family: var(--font-sans);
  white-space: normal;
  min-width: 160px;
}

table.data-table tbody tr:nth-child(even) { background: rgba(10, 20, 36, 0.025); }
table.data-table tfoot td {
  font-weight: 700;
  background: var(--paper);
  border-top: 1px solid var(--gold-500);
  border-bottom: none;
}

table.data-table tfoot td:first-child { font-family: var(--font-serif); font-style: italic; }

/* --------------------------------------------------------- hoverable rows */

tr.row-hoverable, .card-clickable {
  cursor: pointer;
  transition: background 0.12s ease;
}

tr.row-hoverable:hover, tr.row-hoverable:focus-visible {
  background: rgba(191, 151, 82, 0.12) !important;
}

.card-clickable:hover, .card-clickable:focus-visible {
  border-left-color: var(--navy-900);
  background: rgba(191, 151, 82, 0.06);
  outline: none;
}

tr.row-hoverable:focus-visible { outline: 1px solid var(--gold-500); outline-offset: -1px; }

/* ------------------------------------------------------------- tooltip */

.bond-tooltip {
  position: fixed;
  z-index: 1000;
  max-width: 240px;
  background: var(--navy-950);
  color: #F1EEE6;
  border: 1px solid var(--gold-500);
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.5;
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

.bond-tooltip.hidden { display: none; }

.bond-tooltip-title {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 2px;
}

.bond-tooltip-sub {
  font-family: var(--font-mono);
  color: var(--gold-300);
  font-size: 10.5px;
  margin-bottom: 6px;
}

.bond-tooltip-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 1px 0;
}

.bond-tooltip-row span { color: #B9C0CC; }
.bond-tooltip-row b { font-family: var(--font-mono); font-weight: 600; }

.bond-tooltip-hint {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dotted rgba(228, 207, 160, 0.3);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gold-300);
}

/* --------------------------------------------------------- interactive chart */

.chart-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.chart-count {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
}

.chart-toolbar .secondary-btn { flex: none; padding: 8px 12px; font-size: 11px; }

.chart-wrap {
  border: 1px solid var(--hairline);
  border-top: 2px solid var(--navy-900);
  background: var(--panel);
}

svg.chart-svg { width: 100%; height: auto; display: block; }

.chart-grid line { stroke: var(--hairline); stroke-width: 1; }
.chart-axis { stroke: var(--ink-muted); stroke-width: 1.2; }
.chart-tick { fill: var(--ink-muted); font-size: 12px; font-family: var(--font-sans); }
.chart-axis-label { fill: var(--ink-muted); font-size: 12px; font-family: var(--font-sans); }
.chart-curve { fill: none; stroke: var(--negative); stroke-width: 2.5; }
.chart-yearpoint { fill: var(--negative); }
.chart-yearpoint-label { fill: var(--negative); font-size: 11px; font-family: var(--font-sans); font-weight: 600; }

.chart-point {
  fill: var(--navy-900);
  fill-opacity: 0.72;
  stroke: var(--panel);
  stroke-width: 1;
  cursor: pointer;
  transition: r 0.1s ease, fill-opacity 0.1s ease;
}

.chart-point:hover, .chart-point.active, .chart-point:focus-visible {
  r: 6.5;
  fill: var(--gold-600);
  fill-opacity: 1;
  outline: none;
}
