.calculations-page {
  max-width: 1480px;
  margin: 0 auto;
}

.calc-heading,
.calc-worksheet-heading,
.calc-receipt-heading,
.calc-input-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.calc-heading h1 {
  margin: 5px 0 9px;
  font-size: clamp(27px, 3vw, 36px);
  font-weight: 650;
}

.calc-heading p,
.calc-worksheet-heading p {
  margin: 0;
  color: #63727c;
  line-height: 1.6;
}

.calc-eyebrow,
.calc-category {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--wine-dark);
}

.calc-library-total {
  border: 1px solid #d9e2df;
  background: #ecf3f0;
  color: #366052;
  white-space: nowrap;
  border-radius: 20px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 650;
  margin-top: 8px;
}

.calc-notice {
  margin: 22px 0;
  padding: 14px 17px;
  border: 1px solid #dce4e7;
  border-left: 3px solid #73948b;
  border-radius: 7px;
  background: #f8faf9;
  color: #50625e;
  font-size: 13px;
  line-height: 1.6;
}

.calc-layout {
  display: grid;
  grid-template-columns: minmax(245px, 300px) minmax(0, 1fr);
  align-items: start;
  gap: 23px;
}

.calc-library,
.calc-worksheet {
  min-width: 0;
}

.calc-search-label,
.calc-library-filter label {
  display: block;
  font-size: 12px;
  font-weight: 650;
  margin-bottom: 8px;
}

.calculations-page input,
.calculations-page select {
  display: block;
  border: 1px solid #d2dadd;
  border-radius: 7px;
  background: white;
  color: var(--ink);
  padding: 11px 12px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.calc-library-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin: 18px 0;
}

.calc-library-tabs button {
  padding: 10px 9px;
  flex: 1;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 4px 4px 0 0;
  background: transparent;
  color: #66757e;
  font-size: 12px;
}

.calc-library-tabs button[aria-selected="true"] {
  color: var(--wine-dark);
  border-bottom-color: var(--wine);
  background: #f0e8eb;
}

.calc-library-filter .text-button {
  margin-top: 6px;
  font-size: 12px;
}

.calc-library-count {
  margin: 17px 0 10px;
  color: #65717a;
  font-size: 12px;
}

.calc-tool-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 9px;
}

.calc-tool-card {
  display: flex;
  align-items: flex-start;
  border: 1px solid #dfe4e6;
  border-radius: 9px;
  background: white;
  overflow: hidden;
}

.calc-tool-card.is-selected {
  background: #fbf5f7;
  border-color: #b87788;
  box-shadow: inset 3px 0 0 var(--wine);
}

.calc-tool-card:focus-within {
  outline: 2px solid #bf8696;
  outline-offset: 2px;
}

.calc-tool-open {
  display: flex;
  flex: 1;
  min-width: 0;
  flex-direction: column;
  align-items: flex-start;
  gap: 7px;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 14px 0 14px 15px;
}

.calc-tool-open:hover {
  background: transparent;
}

.calc-tool-open strong {
  line-height: 1.4;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.calc-category {
  font-size: 9px;
  letter-spacing: 0.045em;
  color: #687980;
}

.calc-tool-description {
  font-size: 11px;
  font-weight: 400;
  line-height: 1.55;
  color: #67717a;
}

.calc-favorite {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-shrink: 0;
  padding: 8px;
  min-width: 38px;
  min-height: 38px;
  font-size: 12px;
  white-space: nowrap;
}

.calc-favorite > span:first-child {
  font-size: 21px;
  font-weight: 400;
  line-height: 1;
}

.calc-tool-card > .calc-favorite {
  margin: 6px 4px 0 2px;
  border: 0;
  background: transparent;
  color: #72828a;
}

.calc-favorite.is-favorite,
.calc-tool-card > .calc-favorite.is-favorite {
  color: #986b22;
}

.calc-library-note {
  margin-top: 16px;
  font-size: 11px;
  color: #66757d;
  line-height: 1.65;
}

.calc-worksheet {
  padding: 25px;
  border: 1px solid #dfe4e6;
  border-radius: 12px;
  background: white;
}

.calc-worksheet-heading h2 {
  margin: 7px 0 10px;
  font-size: clamp(21px, 2.4vw, 27px);
  font-weight: 650;
  line-height: 1.3;
}

.calc-worksheet-heading p {
  font-size: 13px;
}

.calc-applicability {
  margin: 18px 0 14px;
  line-height: 1.65;
  font-size: 12px;
  color: #53656c;
}

.calc-tool-disclosures {
  border: 1px solid #e2e6e7;
  border-radius: 7px;
  padding: 12px 14px;
  font-size: 12px;
  color: #59676e;
  line-height: 1.65;
}

.calc-tool-disclosures summary {
  cursor: pointer;
  font-weight: 650;
  color: #52616a;
}

.calc-tool-disclosures summary span {
  margin-left: 7px;
  color: #66747d;
  font-weight: 400;
  font-size: 11px;
}

.calc-tool-disclosures ul {
  padding-left: 18px;
}

.calc-form {
  margin-top: 26px;
}

.calc-input-heading {
  align-items: baseline;
  margin-bottom: 15px;
}

.calc-input-heading h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
}

.calc-input-heading > span {
  color: #66747d;
  font-size: 11px;
}

.calc-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 18px;
}

.calc-field label {
  display: block;
  margin-bottom: 7px;
  font-size: 12px;
  line-height: 1.5;
  font-weight: 600;
}

.calc-optional {
  font-weight: 400;
  color: #66747d;
}

.calc-form-actions,
.calc-receipt-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px;
}

.calc-form-actions {
  margin-top: 20px;
}

.calc-form-actions span {
  flex-basis: 100%;
  font-size: 11px;
  color: #66747d;
  margin-top: 3px;
}

.calc-error,
.calc-form-notice {
  padding: 11px 13px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.6;
}

.calc-error {
  background: #fbebec;
  color: #963f4a;
  border: 1px solid #e8c8ce;
}

.calc-form-notice {
  background: #f3f6f4;
  color: #4d6c5e;
}

.calculations-page [hidden] {
  display: none !important;
}

.calc-result-placeholder {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 20px;
  margin-top: 25px;
  border: 1px dashed #d9e0e2;
  border-radius: 9px;
  background: #fafbfb;
}

.calc-placeholder-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 9px;
  color: #819087;
  background: #eef2ef;
  font-size: 25px;
}

.calc-result-placeholder h3 {
  margin: 0 0 5px;
  font-size: 13px;
}

.calc-result-placeholder p {
  margin: 0;
  font-size: 12px;
  color: #66747d;
  line-height: 1.6;
}

.calc-receipt {
  margin-top: 28px;
  padding-top: 25px;
  border-top: 1px solid var(--line);
  overflow-wrap: anywhere;
}

.calc-receipt-heading {
  flex-wrap: wrap;
}

.calc-receipt h3 {
  margin: 6px 0 0;
  font-size: 18px;
}

.calc-receipt-actions button {
  padding: 7px 9px;
  font-size: 11px;
}

.calc-receipt-meta,
.calc-receipt-note {
  font-size: 11px;
  color: #66747d;
  line-height: 1.7;
}

.calc-outputs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr));
  gap: 10px;
  margin: 19px 0;
}

.calc-output {
  padding: 17px;
  border: 1px solid #d9e5df;
  background: #f4f8f5;
  border-radius: 9px;
}

.calc-output > span {
  display: block;
  color: #5a7466;
  font-size: 11px;
  line-height: 1.5;
  margin-bottom: 8px;
}

.calc-output > strong {
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  color: #345d49;
  font-size: 28px;
  line-height: 1.3;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.calc-output small {
  font-size: 13px;
  font-weight: 500;
}

.calc-output-text > strong {
  display: block;
  font-size: 17px;
  line-height: 1.5;
}

.calc-receipt-section {
  margin-top: 21px;
  font-size: 12px;
  line-height: 1.75;
  color: #5b6971;
}

.calc-receipt-section h4 {
  font-size: 12px;
  color: #34434c;
  margin: 0 0 9px;
}

.calc-receipt-section ul,
.calc-receipt-section ol,
.calc-interpretation {
  padding-left: 19px;
}

.calc-receipt-section li + li,
.calc-tool-disclosures li + li {
  margin-top: 5px;
}

.calc-formula {
  padding: 11px 13px;
  background: #f6f7f8;
  border: 1px solid #e7ebed;
  border-radius: 6px;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 11px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.calc-input-receipt {
  margin: 0;
  border: 1px solid #e3e8e9;
  border-radius: 7px;
}

.calc-input-receipt > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(90px, 1fr);
  gap: 14px;
  padding: 9px 12px;
}

.calc-input-receipt > div + div {
  border-top: 1px solid #edf0f1;
}

.calc-input-receipt dd {
  margin: 0;
  color: #354852;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.calc-interpretation {
  font-size: 13px;
  line-height: 1.7;
}

.calc-warnings {
  background: #fbf7ef;
  border: 1px solid #eee0bf;
  border-radius: 7px;
  color: #806332;
  padding: 13px 15px;
  font-size: 12px;
  line-height: 1.7;
}

.calc-warnings ul {
  padding-left: 18px;
  margin-bottom: 0;
}

.calc-empty {
  border: 1px dashed #d9e0e2;
  padding: 20px 15px;
  border-radius: 9px;
  text-align: center;
  line-height: 1.6;
  font-size: 12px;
  color: #6a7880;
}

.calc-empty h3 {
  color: #445760;
  font-size: 14px;
}

.calc-empty button {
  font-size: 12px;
}

@media (max-width: 1050px) {
  .calc-layout {
    grid-template-columns: minmax(210px, 250px) minmax(0, 1fr);
    gap: 16px;
  }

  .calc-worksheet {
    padding: 20px;
  }

  .calc-worksheet-heading {
    flex-wrap: wrap;
  }

  .calc-fields {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 760px) {
  .calc-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .calc-tool-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: 310px;
    overflow-y: auto;
    padding: 3px;
  }

  .calc-tool-description {
    display: none;
  }

  .calc-tool-open {
    padding: 12px 0 12px 11px;
  }

  .calc-tool-card > .calc-favorite {
    min-width: 32px;
    padding: 5px;
    margin-right: 1px;
  }

  .calc-tool-open strong {
    font-size: 12px;
  }

  .calc-worksheet {
    padding: 18px;
  }

  .calc-heading p {
    font-size: 13px;
  }

  .calc-library-total {
    font-size: 11px;
    padding: 6px 9px;
  }

  .calc-library-note {
    margin-bottom: 2px;
  }
}

@media print {
  body:has(.calculations-page) .sidebar,
  body:has(.calculations-page) .topbar,
  body:has(.calculations-page) .footer,
  body:has(.calculations-page) #toast,
  .calc-heading,
  .calc-notice,
  .calc-library,
  .calc-worksheet-heading,
  .calc-applicability,
  .calc-tool-disclosures,
  .calc-form,
  .calc-receipt-actions {
    display: none !important;
  }

  body:has(.calculations-page),
  body:has(.calculations-page) .shell,
  body:has(.calculations-page) .main-column,
  body:has(.calculations-page) .content,
  .calc-layout,
  .calc-worksheet {
    display: block;
    width: 100%;
    max-width: none;
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
    background: white;
  }

  .calc-receipt {
    border: 0;
    margin: 0;
    padding: 0;
  }

  .calc-output,
  .calc-input-receipt,
  .calc-warnings,
  .calc-receipt-section h4 {
    break-inside: avoid;
  }

  .calc-receipt h4 {
    break-after: avoid;
  }

  .calc-sources a::after {
    content: " (" attr(href) ")";
    font-size: 9px;
    color: #52616a;
  }
}
