:root {
  --navy: #0b1f4d;
  --blue: #0f4db8;
  --blue-2: #2568d9;
  --green: #0b8f5b;
  --green-soft: #eaf8f2;
  --ink: #13213d;
  --muted: #68758d;
  --line: #dfe5ef;
  --line-2: #edf1f6;
  --surface: #ffffff;
  --surface-alt: #f7f9fc;
  --danger: #b42318;
  --shadow: 0 12px 34px rgba(31, 52, 89, 0.08);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 80% 12%, rgba(36, 191, 132, 0.08), transparent 23rem),
    linear-gradient(180deg, #fbfcfe 0, #fff 34rem);
  line-height: 1.5;
}
button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
.shell { width: min(1180px, calc(100% - 40px)); margin: 0 auto; }

.site-header {
  height: 72px;
  padding: 0 max(24px, calc((100vw - 1180px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid rgba(223, 229, 239, 0.85);
  background: rgba(255,255,255,.88);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { text-decoration: none; font-weight: 800; font-size: 24px; letter-spacing: -0.6px; color: var(--navy); }
.brand strong { color: var(--green); }
.header-nav { display: flex; align-items: center; gap: 26px; }
.header-nav > a:not(.github-button) { text-decoration: none; font-size: 14px; color: #42506a; font-weight: 650; }
.github-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  background: var(--navy);
  color: #fff;
  padding: 9px 13px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 750;
}
.github-button svg { width: 18px; height: 18px; fill: currentColor; }

.hero { padding: 54px 0 26px; }
.hero-copy { text-align: center; margin-bottom: 30px; }
.hero-copy h1 { margin: 0; color: var(--navy); font-size: clamp(38px, 5vw, 58px); line-height: 1.06; letter-spacing: -2px; }
.hero-copy p { margin: 14px auto 0; color: #53627c; font-size: clamp(16px, 2vw, 19px); }

.calculator-grid { display: grid; grid-template-columns: 1.05fr .95fr; gap: 18px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.input-panel, .summary-panel { min-height: 520px; }
.input-panel { padding: 24px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.panel-heading h2, .section-heading-row h2, .info-panel h2 { margin: 3px 0 0; font-size: 20px; letter-spacing: -0.4px; color: var(--navy); }
.eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px; font-weight: 800; color: var(--green); }
.heading-with-tabs { align-items: flex-end; }
.mode-tabs { display: inline-flex; padding: 4px; background: #f2f5fa; border: 1px solid var(--line); border-radius: 11px; }
.mode-tab { border: 0; background: transparent; color: #5d6980; padding: 8px 11px; border-radius: 8px; font-size: 12px; font-weight: 750; cursor: pointer; }
.mode-tab.is-active { background: #fff; color: var(--blue); box-shadow: 0 2px 8px rgba(25, 64, 125, .12); }

.sleeve-list { display: grid; gap: 9px; }
.sleeve { border: 1px solid var(--line-2); border-radius: 14px; background: #fbfcfe; overflow: hidden; }
.sleeve-main { padding: 11px 12px; display: grid; grid-template-columns: 38px minmax(0, 1fr) 112px 36px 32px; gap: 8px; align-items: center; }
.sleeve-badge { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: linear-gradient(135deg, var(--blue), #1e77de); color: #fff; font-weight: 850; font-size: 13px; }
.sleeve:nth-child(2) .sleeve-badge { background: linear-gradient(135deg, #4d35dd, #2767df); }
.sleeve:nth-child(3) .sleeve-badge { background: linear-gradient(135deg, #0a8958, #20a16d); }
.sleeve:nth-child(4) .sleeve-badge { background: linear-gradient(135deg, #202734, #0f1724); }
.field-input { width: 100%; border: 1px solid #d7dfeb; background: #fff; color: var(--ink); border-radius: 9px; padding: 9px 10px; outline: none; }
.field-input:focus, .holdings-textarea:focus { border-color: #87aee9; box-shadow: 0 0 0 3px rgba(37,104,217,.1); }
.allocation-wrap { position: relative; }
.allocation-wrap .field-input { padding-right: 28px; text-align: right; }
.allocation-wrap span { position: absolute; right: 10px; top: 50%; translate: 0 -50%; color: var(--muted); font-size: 12px; }
.icon-button { border: 0; background: transparent; color: #71809b; border-radius: 8px; width: 34px; height: 34px; cursor: pointer; display: grid; place-items: center; }
.icon-button:hover { background: #eef3f9; color: var(--blue); }
.delete-button:hover { color: var(--danger); background: #fff0ee; }
.sleeve-editor { padding: 0 12px 12px 58px; display: none; }
.sleeve.is-open .sleeve-editor { display: block; }
.editor-label { display: flex; justify-content: space-between; gap: 12px; align-items: center; color: #5b6880; font-size: 12px; margin-bottom: 6px; }
.editor-label code { background: #eef2f7; padding: 2px 5px; border-radius: 4px; }
.holdings-textarea { width: 100%; min-height: 104px; resize: vertical; border: 1px solid #d7dfeb; border-radius: 10px; padding: 10px 12px; outline: none; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; line-height: 1.55; }
.add-button { margin-top: 10px; width: 100%; border: 1px dashed #bfc9d9; background: #fff; color: var(--blue); border-radius: 11px; padding: 11px; cursor: pointer; font-weight: 750; }
.portfolio-total-row { display: flex; justify-content: space-between; padding-top: 16px; margin-top: 10px; border-top: 1px solid var(--line-2); font-size: 13px; }
.validation { min-height: 22px; color: var(--danger); font-size: 12px; padding: 4px 0; }
.primary-button { width: 100%; border: 0; color: white; background: linear-gradient(135deg, #0b3f9e, #125dcf); border-radius: 12px; padding: 14px 16px; font-weight: 850; cursor: pointer; box-shadow: 0 9px 22px rgba(15,77,184,.2); }
.primary-button:hover { filter: brightness(1.04); }

.summary-panel { overflow: hidden; }
.summary-top { padding: 27px 28px 22px; min-height: 172px; display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; background: linear-gradient(125deg, #f4fbf8 0, #edf9f4 70%, #f9fdfb 100%); border-bottom: 1px solid #dcece5; }
.metric-label { font-size: 14px; color: #31475d; font-weight: 750; }
.metric-value { color: var(--green); font-weight: 900; font-size: 48px; line-height: 1; margin-top: 8px; letter-spacing: -1.8px; }
.metric-description { color: #698076; font-size: 12px; margin: 10px 0 0; max-width: 330px; }
.overlap-ring { --value: 0deg; width: 80px; height: 80px; border-radius: 50%; background: conic-gradient(var(--green) var(--value), #cde9dc 0); display: grid; place-items: center; flex: 0 0 auto; box-shadow: inset 0 0 0 1px rgba(7, 131, 83, .08); }
.overlap-ring span { width: 56px; height: 56px; background: #f4fbf8; border-radius: 50%; }
.summary-stats { display: grid; grid-template-columns: repeat(3, 1fr); padding: 16px 26px; border-bottom: 1px solid var(--line); }
.summary-stats > div { padding: 0 14px; border-right: 1px solid var(--line); }
.summary-stats > div:first-child { padding-left: 0; }
.summary-stats > div:last-child { border-right: 0; }
.summary-stats span { display: block; color: #748198; font-size: 11px; }
.summary-stats strong { display: block; margin-top: 3px; font-size: 17px; color: var(--navy); }
.summary-body { padding: 20px 26px 24px; }
.section-heading-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.section-heading-row h2, .section-heading-row h3 { margin: 0; color: var(--navy); letter-spacing: -.3px; }
.section-heading-row h3 { font-size: 15px; }
.section-heading-row > span { color: #8a95a8; font-size: 11px; white-space: nowrap; margin-top: 4px; }
.exposure-list { margin-top: 10px; }
.exposure-row { display: grid; grid-template-columns: 35px 1fr auto; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line-2); }
.ticker-avatar { width: 29px; height: 29px; border-radius: 8px; background: #f0f3f8; display: grid; place-items: center; color: var(--navy); font-weight: 850; font-size: 10px; }
.exposure-row span { font-size: 13px; font-weight: 700; }
.exposure-row strong { font-size: 13px; color: var(--navy); }
.text-link { display: inline-block; margin-top: 13px; color: var(--blue); font-size: 12px; text-decoration: none; font-weight: 750; }

.results-section { padding: 0 0 24px; }
.results-grid { display: grid; grid-template-columns: 1.05fr .95fr .95fr; gap: 16px; }
.result-card { padding: 20px; min-height: 334px; }
.matrix-wrap { overflow-x: auto; margin-top: 14px; }
.matrix { width: 100%; border-collapse: separate; border-spacing: 2px; min-width: 330px; }
.matrix th { color: #61708a; font-size: 10px; font-weight: 800; padding: 7px; }
.matrix td { text-align: center; padding: 10px 6px; border-radius: 6px; font-size: 11px; font-weight: 800; color: #1a3f76; }
.matrix .row-head { background: transparent !important; color: #41516a; text-align: left; }
.heat-legend { margin-top: 13px; display: grid; grid-template-columns: auto 1fr auto; gap: 7px; align-items: center; color: #7c899e; font-size: 9px; }
.heat-legend i { height: 7px; border-radius: 20px; background: linear-gradient(90deg, #e8f1ff, #1764c9); }
.bar-list { margin-top: 12px; }
.bar-row { display: grid; grid-template-columns: 58px minmax(90px, 1fr) 50px; gap: 9px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line-2); font-size: 11px; }
.bar-row strong { color: var(--navy); }
.bar-track { height: 9px; border-radius: 10px; background: #edf2f7; overflow: hidden; }
.bar-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, #099c63, #31b77f); }
.addition-list { margin-top: 12px; display: grid; gap: 9px; }
.addition-card { border: 1px solid var(--line); border-radius: 11px; padding: 11px; }
.addition-card h3 { margin: 0 0 8px; font-size: 12px; color: var(--navy); }
.addition-stats { display: grid; grid-template-columns: 1fr 1px 1fr; align-items: center; gap: 10px; }
.addition-stats i { width: 1px; height: 34px; background: var(--line); }
.addition-stats span { display: block; color: #8290a6; font-size: 9px; }
.addition-stats strong { display: block; margin-top: 2px; font-size: 14px; }
.addition-stats .positive { color: var(--green); }
.wide-result { margin-top: 16px; padding: 22px; }
.contributors-table { margin-top: 14px; }
.contributor-head, .contributor-row { display: grid; grid-template-columns: 1fr 120px 120px; gap: 12px; align-items: center; }
.contributor-head { color: #7f8ba0; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; padding: 0 10px 7px; }
.contributor-row { border-top: 1px solid var(--line-2); padding: 10px; font-size: 12px; }
.contributor-row strong { color: var(--navy); }
.empty-state { padding: 24px 10px; color: var(--muted); font-size: 12px; text-align: center; }

.features { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); margin-top: 4px; overflow: hidden; }
.features article { display: flex; gap: 14px; padding: 20px 24px; border-right: 1px solid var(--line); }
.features article:last-child { border-right: 0; }
.features h2 { margin: 0; font-size: 15px; color: var(--navy); }
.features p { margin: 4px 0 0; color: #718098; font-size: 11px; }
.feature-icon { width: 44px; height: 44px; flex: 0 0 44px; background: #eef4fe; border: 1px solid #d9e5f7; border-radius: 12px; display: grid; place-items: center; color: var(--blue); font-size: 24px; font-weight: 850; }
.overlapping-circles { position: relative; }
.overlapping-circles::before, .overlapping-circles::after { content: ""; position: absolute; width: 18px; height: 18px; border: 2px solid var(--blue); border-radius: 50%; top: 11px; }
.overlapping-circles::before { left: 8px; }
.overlapping-circles::after { right: 8px; }

.info-grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: 16px; padding: 24px 0 56px; }
.info-panel { padding: 24px; }
.steps { margin-top: 16px; display: grid; gap: 14px; }
.steps > div { display: grid; grid-template-columns: 28px 1fr; gap: 10px; }
.steps b { width: 25px; height: 25px; background: var(--blue); color: #fff; border-radius: 50%; display: grid; place-items: center; font-size: 11px; }
.steps p { margin: 0; color: #69778d; font-size: 12px; }
.steps strong { color: var(--ink); }
.formula { margin-top: 17px; background: #f5f8fc; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; color: #42536c; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.info-panel details { border-top: 1px solid var(--line); padding: 12px 0; }
.info-panel details:first-of-type { margin-top: 12px; }
.info-panel summary { cursor: pointer; font-size: 12px; font-weight: 800; color: var(--navy); }
.info-panel details p { margin: 8px 0 0; color: #6f7e94; font-size: 11px; }
.info-panel code { background: #eef2f7; border-radius: 4px; padding: 2px 4px; }

footer { border-top: 1px solid var(--line); padding: 24px 20px 30px; color: #8792a5; text-align: center; font-size: 11px; }

@media (max-width: 980px) {
  .calculator-grid, .info-grid { grid-template-columns: 1fr; }
  .results-grid { grid-template-columns: 1fr 1fr; }
  .matrix-card { grid-column: 1 / -1; }
  .input-panel, .summary-panel { min-height: 0; }
}

@media (max-width: 720px) {
  .shell { width: min(100% - 24px, 1180px); }
  .site-header { height: 64px; padding: 0 12px; }
  .brand { font-size: 20px; }
  .header-nav { gap: 10px; }
  .header-nav > a:not(.github-button) { display: none; }
  .github-button { padding: 8px 10px; }
  .hero { padding-top: 36px; }
  .hero-copy { text-align: left; margin-bottom: 20px; }
  .hero-copy h1 { font-size: 38px; letter-spacing: -1.3px; }
  .hero-copy p { margin-top: 10px; font-size: 15px; }
  .heading-with-tabs { align-items: stretch; flex-direction: column; }
  .mode-tabs { width: 100%; }
  .mode-tab { flex: 1; }
  .sleeve-main { grid-template-columns: 34px minmax(0, 1fr) 88px 32px; }
  .delete-button { grid-column: 4; grid-row: 1; }
  .edit-button { grid-column: 4; grid-row: 2; display: none; }
  .sleeve-editor { padding-left: 12px; }
  .summary-top { padding: 22px; }
  .metric-value { font-size: 43px; }
  .overlap-ring { width: 68px; height: 68px; }
  .overlap-ring span { width: 48px; height: 48px; }
  .summary-stats { padding: 14px 18px; }
  .summary-stats > div { padding: 0 8px; }
  .summary-body { padding: 18px; }
  .results-grid, .features { grid-template-columns: 1fr; }
  .matrix-card { grid-column: auto; }
  .features article { border-right: 0; border-bottom: 1px solid var(--line); }
  .features article:last-child { border-bottom: 0; }
  .contributor-head, .contributor-row { grid-template-columns: 1fr 80px; }
  .contributor-head span:nth-child(2), .contributor-row span:nth-child(2) { display: none; }
}
