/* Boräknaren – design tokens and styles. See docs/DESIGN.md. */

@font-face {
  font-family: "Schibsted Grotesk";
  src: url("/static/fonts/schibsted-grotesk-latin.woff2") format("woff2");
  font-weight: 400 800;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Colours from Swedish house paint and drawing paper */
  --kalkvit: #f6f7f5;
  --papper: #ffffff;
  --grafit: #1f2a30;
  --grafit-mjuk: #55636b;
  --skiffer: #2f5d73;
  --skiffer-mork: #234759;
  --linje: #c9d1d3;
  --signal: #b0322a;
  --signal-ljus: #f7e3e0;
  --signal-mork: #8e2822;
  /* Warnings that do not stop the purchase. Never as text colour (too little contrast). */
  --varning: #c8902e;
  --varning-ljus: #f4e8cf;

  /* Chart series, in this fixed order. Validated with the dataviz validator against
     --kalkvit (light): CVD and normal-vision separation pass. Four are below 3:1 against the
     background, so the chart always has a legend and a table (DESIGN.md). */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;

  --font: "Schibsted Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;

  /* Type scale, ratio 1.25 */
  --t-sm: 0.8125rem;
  --t-base: 1rem;
  --t-md: 1.25rem;
  --t-lg: 1.5625rem;
  --t-xl: 1.953rem;
  --t-hero: clamp(2.25rem, 5vw + 1rem, 3.815rem);

  --radius: 4px;
  --stroke: 1.5px;
  --gutter: clamp(1rem, 3vw, 2.5rem);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--kalkvit);
  color: var(--grafit);
  font-family: var(--font);
  font-size: var(--t-base);
  line-height: 1.5;
}


h1,
h2 {
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin: 0 0 0.5em;
}

h1 {
  font-size: var(--t-xl);
  font-weight: 750;
}

h2 {
  font-size: var(--t-lg);
  font-weight: 700;
}

p {
  margin: 0 0 1em;
}

a {
  color: var(--skiffer);
}

:focus-visible {
  outline: 2px solid var(--skiffer);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---- Frame ---------------------------------------------------------------- */

.site-header {
  display: flex;
  flex-wrap: wrap; /* only on the narrowest phones, where the links do not fit beside the name */
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding: 1rem var(--gutter);
  border-bottom: var(--stroke) solid var(--grafit);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--grafit);
  font-weight: 750;
  font-size: var(--t-md);
  text-decoration: none;
}

/* Pushes itself and what follows to the right, after the brand. */
.site-header .status {
  margin-left: auto;
}

.account-nav {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin-left: auto;
  font-size: var(--t-sm);
}

.site-header .status + .account-nav {
  margin-left: 0;
}

.account-nav form {
  margin: 0;
}

.account-nav a,
.account-nav .link-button {
  white-space: nowrap;
}

/* "Lämna förslag" is shortened on a phone, so the header stays on one line. */
.feedback-short {
  display: none;
}

.account-email {
  color: var(--grafit-mjuk);
}

/* A long address would crowd the header on a phone; "Logga ut" is enough there. */
@media (max-width: 40rem) {
  .account-email,
  .feedback-long {
    display: none;
  }

  .feedback-short {
    display: inline;
  }
}

.brand-mark .facade {
  width: 2.25rem;
  height: auto;
}

main {
  padding: 2rem var(--gutter) 4rem;
}

.site-footer {
  padding: 1.5rem var(--gutter) 2rem;
  border-top: 1px solid var(--linje);
  color: var(--grafit-mjuk);
  font-size: var(--t-sm);
}

.site-footer p {
  margin: 0;
  max-width: 60ch;
}

.site-footer p + p {
  margin-top: 0.4rem;
}

/* Line drawings: the one bold element */
.facade,
.street-drawing {
  fill: none;
  stroke: var(--skiffer);
  stroke-width: var(--stroke);
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.facade path,
.street-drawing path {
  vector-effect: non-scaling-stroke;
}

/* ---- Buttons and fields --------------------------------------------------- */

.button {
  display: inline-block;
  padding: 0.7rem 1.25rem;
  border: var(--stroke) solid var(--skiffer);
  border-radius: var(--radius);
  background: var(--skiffer);
  color: var(--papper);
  font: inherit;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
}

.button:hover {
  background: var(--skiffer-mork);
  border-color: var(--skiffer-mork);
}

.button-quiet {
  background: transparent;
  color: var(--skiffer);
}

/* Only for what cannot be undone, such as deleting a calculation. */
.button-danger {
  border-color: var(--signal);
  background: var(--signal);
}

.button-danger:hover {
  border-color: var(--signal-mork);
  background: var(--signal-mork);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.form-actions .button {
  margin-top: 0;
}

.button-quiet:hover {
  background: var(--papper);
  color: var(--skiffer-mork);
}

.link-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--skiffer);
  font: inherit;
  font-size: var(--t-sm);
  text-decoration: underline;
  text-underline-offset: 0.15em;
  cursor: pointer;
}

input[type="text"],
input[type="email"],
input[type="password"],
select,
textarea {
  width: 100%;
  min-width: 0;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--linje);
  border-radius: var(--radius);
  background: var(--papper);
  color: var(--grafit);
  font: inherit;
}

input[type="text"]:hover,
input[type="email"]:hover,
input[type="password"]:hover,
select:hover,
textarea:hover {
  border-color: var(--grafit-mjuk);
}

input[type="checkbox"],
input[type="radio"] {
  width: 1.15rem;
  height: 1.15rem;
  accent-color: var(--skiffer);
}

.input-unit {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
}

.input-unit input {
  text-align: right;
}

.input-unit > span {
  min-width: 1.6rem;
  color: var(--grafit-mjuk);
  font-size: var(--t-sm);
}

.hint {
  display: block;
  color: var(--grafit-mjuk);
  font-size: var(--t-sm);
  font-weight: 400;
  line-height: 1.35;
}

.form-error {
  padding: 0.75rem 1rem;
  border-left: 4px solid var(--signal);
  background: var(--signal-ljus);
  color: var(--grafit);
}

.form-error ul {
  margin: 0;
  padding-left: 1.2rem;
}

/* ---- Start page ----------------------------------------------------------- */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2rem;
  align-items: end;
  max-width: 72rem;
  padding: 2rem 0 3rem;
}

@media (min-width: 52rem) {
  .hero {
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    padding-top: 4rem;
  }
}

.hero h1 {
  font-size: var(--t-hero);
  font-weight: 800;
  letter-spacing: -0.025em;
  max-width: 12ch;
}

.lead {
  max-width: 34rem;
  font-size: var(--t-md);
  color: var(--grafit-mjuk);
}

.street {
  margin: 0;
}

.street-drawing {
  width: 100%;
  height: auto;
}

.street-drawing .dimension {
  stroke: var(--grafit-mjuk);
  stroke-width: 1px;
}

@media (prefers-reduced-motion: no-preference) {
  .street-drawing .draw {
    stroke-dasharray: 1600;
    stroke-dashoffset: 1600;
    animation: draw 2.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  }

  .street-drawing .draw:nth-child(3) { animation-delay: 0.3s; }
  .street-drawing .draw:nth-child(4) { animation-delay: 0.6s; }
  .street-drawing .draw:nth-child(5) { animation-delay: 0.9s; }
  .street-drawing .draw:nth-child(6) { animation-delay: 1.4s; }
}

@keyframes draw {
  to {
    stroke-dashoffset: 0;
  }
}

.explainer {
  max-width: 72rem;
  padding-top: 2rem;
  border-top: var(--stroke) solid var(--grafit);
}

.explainer dl {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1.5rem 2.5rem;
  margin: 1.5rem 0 0;
}

.explainer dt {
  font-weight: 700;
  font-size: var(--t-md);
}

.explainer dd {
  margin: 0.25rem 0 0;
  color: var(--grafit-mjuk);
  max-width: 34ch;
}

.my-calculations {
  max-width: 72rem;
  padding: 2rem 0 3rem;
  border-top: var(--stroke) solid var(--grafit);
}

.my-calculations ul {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
}

.my-calculations li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 1rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--linje);
}

/* The names in the list; other links keep the size of the text. */
.my-calculations .calculation-name {
  font-weight: 700;
  font-size: var(--t-md);
  color: var(--skiffer);
}

.my-calculations .delete-link {
  margin-left: auto;
  color: var(--grafit-mjuk);
  font-size: var(--t-sm);
}

.my-calculations .changed,
.my-calculations .note {
  font-size: var(--t-sm);
  color: var(--grafit-mjuk);
}

.my-calculations .note {
  margin: 1rem 0 0;
}

/* Tells visitors without an account that one keeps the calculation. */
.account-note {
  max-width: 34rem;
  margin: 1rem 0 0;
  color: var(--grafit-mjuk);
  font-size: var(--t-sm);
}

/* ---- Error page ----------------------------------------------------------- */

.error-page {
  max-width: 38rem;
  padding: 4rem 0;
}

/* ---- Sign up and in ------------------------------------------------------- */

.account-form {
  max-width: 28rem;
  padding: 1rem 0 2rem;
}

.account-field {
  display: block;
  margin: 0 0 1.25rem;
}

.account-field .label {
  display: block;
  margin-bottom: 0.3rem;
  font-weight: 650;
}

.account-field .hint {
  margin: -0.15rem 0 0.4rem;
}

.account-form .button {
  margin-top: 0.5rem;
}

/* A suggestion needs room for a few paragraphs. */
.feedback-form {
  max-width: 36rem;
}

.feedback-form textarea {
  min-height: 10rem;
  line-height: 1.45;
  resize: vertical;
}

.forgot-password {
  margin: -0.75rem 0 1.25rem;
  font-size: var(--t-sm);
}

.account-switch {
  margin: 1.5rem 0 0;
  padding-top: 1rem;
  border-top: 1px solid var(--linje);
  color: var(--grafit-mjuk);
}

/* ---- Start guide ---------------------------------------------------------- */

.guide {
  max-width: 38rem;
}

.guide fieldset {
  margin: 0 0 1.75rem;
  padding: 1.25rem 0 0;
  border: 0;
  border-top: 1px solid var(--linje);
}

.guide legend {
  /* Floated so the fieldset's top line stays above the question instead of through it */
  float: left;
  width: 100%;
  display: flex;
  gap: 0.75rem;
  align-items: baseline;
  padding: 0;
  font-size: var(--t-md);
  font-weight: 650;
}

.step {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 1.75rem;
  height: 1.75rem;
  border: var(--stroke) solid var(--skiffer);
  border-radius: 50%;
  color: var(--skiffer);
  font-size: var(--t-sm);
  font-weight: 700;
}

.choices {
  clear: both;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding-left: 2.5rem;
}

.choice {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--linje);
  border-radius: var(--radius);
  background: var(--papper);
  cursor: pointer;
}

.choice:has(input:checked) {
  border-color: var(--skiffer);
  box-shadow: inset 0 0 0 1px var(--skiffer);
}

.guide .field {
  clear: both;
  display: block;
  margin-top: 0.5rem;
  padding-left: 2.5rem;
  max-width: 24rem;
}

.guide .field .hint {
  margin-bottom: 0.5rem;
}

/* The name is not one of the numbered questions, so it stands on its own before the button. */
.guide-name {
  display: block;
  margin: 0 0 1.75rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--linje);
}

.guide-name .label {
  display: block;
  font-size: var(--t-md);
  font-weight: 650;
}

.guide-name .hint {
  margin: 0.25rem 0 0.5rem;
}

.guide-name input {
  max-width: 26.5rem;
}

/* ---- Calculation page ----------------------------------------------------- */

.status {
  margin: 0;
  color: var(--grafit-mjuk);
  font-size: var(--t-sm);
}

.status .saving,
.status.htmx-request .saved {
  display: none;
}

.status.htmx-request .saving {
  display: inline;
}

.title-field {
  display: block;
  max-width: 40rem;
  margin-bottom: 1.5rem;
}

.title-field + .account-note {
  max-width: 40rem;
  margin: -0.75rem 0 2rem;
}

.title-label {
  display: block;
  color: var(--grafit-mjuk);
  font-size: var(--t-sm);
}

input.title-input {
  padding: 0.2rem 0;
  border: 0;
  border-bottom: 1px dashed var(--linje);
  border-radius: 0;
  background: transparent;
  font-size: var(--t-xl);
  font-weight: 750;
  letter-spacing: -0.01em;
}

/* Shows that the name is a field that can be written in. */
input.title-input:hover,
input.title-input:focus {
  border-bottom: 1px solid var(--skiffer);
}

/* The four parts of a calculation: household, sale, home, scenarios (ADR-0012) */
.part {
  margin-bottom: 2.5rem;
  padding-top: 1.5rem;
  border-top: var(--stroke) solid var(--grafit);
}

.part h2 {
  margin-bottom: 1rem;
}

/* One-time values (household, sale, home): a narrow list that reads top to bottom, with the
   label on the left and the value on the right */
.part-list {
  max-width: 40rem;
}

.part-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  margin-bottom: 1rem;
}

.part-head h2 {
  margin: 0;
}

.field-list {
  border-top: 1px solid var(--linje);
}

.field-list .field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 12rem;
  gap: 0.25rem 1rem;
  align-items: center;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--linje);
}

.field-list .field .label {
  margin: 0;
  font-weight: 500;
}

.field-list .hint {
  margin-top: 0.1rem;
}

/* Checkboxes line up with the right edge of the numbers above them */
.field-check {
  display: flex;
  justify-content: flex-end;
  padding-right: 1.95rem;
}

.part .intro {
  max-width: 40rem;
  margin: -0.5rem 0 1rem;
  color: var(--grafit-mjuk);
}

/* Hidden while they do not apply, without a reload. Without :has() they simply stay visible. */
.calculation-form:has(input[name="selling"]:not(:checked)) .when-selling,
.calculation-form:has(input[name="home-property_type"][value="house"]:checked) .only-apartment,
.calculation-form:has(input[name="home-property_type"][value="apartment"]:checked) .only-house,
/* With uppskov, the tax left is always reserved, so the choice does not apply (engine.py) */
.calculation-form:has(input[name="sale-apply_tax_deferral"]:checked)
  .field:has(input[name="sale-reserve_capital_gains_tax"]) {
  display: none;
}

.when-selling {
  margin-top: 1.25rem;
}

.fields-group {
  /* A fieldset is at least as wide as its content by default, which pushes the page wider
     than a phone screen */
  min-inline-size: 0;
  margin: 0 0 1.5rem;
  padding: 0;
  border: 0;
}

.fields-group legend {
  margin-bottom: 0.5rem;
  padding: 0;
  font-size: var(--t-base);
  font-weight: 700;
}

/* A collapsible explanation above a list of fields, closed from the start */
.info-box {
  margin-bottom: 0.75rem;
  border: 1px solid var(--linje);
  border-radius: var(--radius);
  background: var(--papper);
}

.info-box > summary {
  padding: 0.5rem 0.75rem;
  color: var(--skiffer);
  font-weight: 650;
  cursor: pointer;
}

.info-box-body {
  padding: 0.25rem 0.75rem 0.25rem;
}

.info-box-body p {
  margin-bottom: 0.75rem;
}

/* The gain as a sum, one term per line, with the operators in their own column */
.info-sum {
  margin: 0 0 0.75rem;
  padding: 0;
  list-style: none;
}

.info-sum li {
  display: grid;
  grid-template-columns: 1.25rem minmax(0, 1fr);
}

.info-sum .op {
  color: var(--grafit-mjuk);
}

.info-list {
  margin: 0 0 0.75rem;
  padding-left: 1.25rem;
}

.info-list li + li {
  margin-top: 0.25rem;
}

.info-sum .total {
  margin-top: 0.2rem;
  padding-top: 0.2rem;
  border-top: 1px solid var(--linje);
  font-weight: 600;
}

.home-type {
  min-inline-size: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 0 0 1.25rem;
  padding: 0;
  border: 0;
}

.home-choice {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--linje);
  border-radius: var(--radius);
  background: var(--papper);
  cursor: pointer;
}

.home-choice:has(input:checked) {
  border-color: var(--skiffer);
  box-shadow: inset 0 0 0 1px var(--skiffer);
}

.home-choice:not(:has(input:checked)) .facade {
  stroke: var(--linje);
}

.table-scroll {
  /* Positioned so that absolutely positioned children (screen reader text) are clipped too */
  position: relative;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.persons {
  width: 100%;
  min-width: 30rem;
  border-collapse: collapse;
  margin-bottom: 1.25rem;
}

.persons th,
.persons td {
  padding: 0.35rem 0.75rem 0.35rem 0;
  text-align: left;
  vertical-align: bottom;
  font-weight: 600;
}

.persons td {
  font-weight: 400;
  min-width: 9rem;
}

.field .label {
  display: block;
  margin-bottom: 0.25rem;
  font-weight: 600;
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  align-self: center;
  font-weight: 600;
}

/* Comparison table: row labels on the left, one column per home, like the spreadsheet */
.grid {
  border-collapse: separate;
  border-spacing: 0;
}

.grid th,
.grid td {
  padding: 0.4rem 0.75rem;
  vertical-align: top;
  text-align: left;
}

.grid tbody th[scope="row"],
.grid tbody th[scope="rowgroup"] {
  position: sticky;
  left: 0;
  z-index: 1;
  width: 15rem;
  min-width: 13rem;
  background: var(--kalkvit);
  font-weight: 500;
}

.grid td,
.grid thead th {
  width: 15rem;
  min-width: 12rem;
}

.corner {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--kalkvit);
}

.scenario-head {
  padding-bottom: 1rem;
  border-bottom: var(--stroke) solid var(--grafit);
  font-weight: 400;
}

.facade-wrap .facade {
  display: block;
  width: 4rem;
  height: auto;
  margin-bottom: 0.5rem;
}

input.scenario-name {
  margin-bottom: 0.35rem;
  font-weight: 700;
  font-size: var(--t-md);
}

.scenario-actions {
  display: flex;
  gap: 1rem;
  margin-top: 0.5rem;
}

.grid tr.group th {
  padding-top: 1.5rem;
  font-size: var(--t-base);
  font-weight: 700;
}

.results-start > * {
  padding-top: 2.5rem;
  border-bottom: var(--stroke) solid var(--grafit);
}

.results-start th {
  font-size: var(--t-lg);
  font-weight: 750;
}

.grid td.number {
  text-align: right;
  white-space: nowrap;
}

.grid tbody tr:not(.group, .results-start) > * {
  border-bottom: 1px solid var(--linje);
}

.key-row th,
.key-row td.number {
  font-size: var(--t-md);
  font-weight: 750;
}

/* "Affären" reads as a calculation, top down: + − = in a column before the labels, and a
   graphite line above each sum, as under the terms of a sum on paper */
.grid th.in-calculation {
  padding-left: 1.85rem;
  text-indent: -1.1rem;
}

.grid th.in-calculation .hint {
  text-indent: 0;
}

.grid .op {
  display: inline-block;
  width: 1.1rem;
  text-indent: 0;
  color: var(--grafit-mjuk);
}

.grid tbody tr:has(+ .sum-row) > * {
  border-bottom-color: var(--grafit);
}

.grid tr.sum-row th,
.grid tr.sum-row td.number {
  font-weight: 700;
}

/* A little more space after the calculation, between "= Insats" and "Lån" */
.grid tbody tr.after-calculation > * {
  padding-top: 1.25rem;
}

/* A value that causes a warning: red when the scenario cannot be done (e.g. a loan above the
   lånelöfte), yellow when it is risky (e.g. a high debt-to-income ratio) */
.grid td.blocking,
.grid td.caution {
  font-weight: 700;
}

.grid td.blocking {
  background: var(--signal-ljus);
  box-shadow: inset 0 -3px 0 var(--signal);
}

.grid td.caution {
  background: var(--varning-ljus);
  box-shadow: inset 0 -3px 0 var(--varning);
}

.marks-legend {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-top: 0.35rem;
  color: var(--grafit-mjuk);
  font-size: var(--t-sm);
  font-weight: 400;
  letter-spacing: 0;
}

.swatch {
  display: inline-block;
  width: 0.8rem;
  height: 0.8rem;
  margin-right: 0.4rem;
  border-radius: 2px;
  vertical-align: -0.1rem;
}

.swatch.blocking {
  background: var(--signal-ljus);
  box-shadow: inset 0 -3px 0 var(--signal);
}

.swatch.caution {
  background: var(--varning-ljus);
  box-shadow: inset 0 -3px 0 var(--varning);
}

.warnings ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.warnings li {
  padding-left: 0.75rem;
  border-left: 3px solid var(--signal);
  margin-bottom: 0.5rem;
  max-width: 26ch;
}

.warnings li.caution {
  border-left-color: var(--varning);
}

.warnings .ok {
  color: var(--grafit-mjuk);
}

/* ---- Interest rate chart -------------------------------------------------- */

.rate-sensitivity {
  max-width: 60rem;
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--linje);
}

.rate-sensitivity > summary {
  color: var(--skiffer);
  font-weight: 650;
  cursor: pointer;
}

.series-1 { --series: var(--series-1); }
.series-2 { --series: var(--series-2); }
.series-3 { --series: var(--series-3); }
.series-4 { --series: var(--series-4); }
.series-5 { --series: var(--series-5); }
.series-6 { --series: var(--series-6); }

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.5rem;
  margin: 1.25rem 0 1rem;
  padding: 0;
  list-style: none;
  font-weight: 600;
}

.chart-legend .hint {
  display: inline;
  margin-left: 0.25rem;
}

/* A short stroke in the series colour, like the line it stands for */
.line-key {
  display: inline-block;
  width: 1.1rem;
  margin-right: 0.45rem;
  border-top: 2px solid var(--series);
  vertical-align: middle;
}

.chart-frame {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas: "y plot" ". x";
  column-gap: 0.6rem;
  /* Room for half of the last x label, which is centred on the plot's right edge */
  padding: 0.75rem 1.5rem 0 0;
}

/* Tick labels are zero-size flex items spread over the plot, so each one is centred exactly on
   its gridline whatever the plot's size. */
.y-ticks,
.x-ticks {
  display: flex;
  justify-content: space-between;
  color: var(--grafit-mjuk);
  font-size: var(--t-sm);
  white-space: nowrap;
}

.y-ticks {
  grid-area: y;
  flex-direction: column;
  align-items: flex-end;
}

.y-ticks span {
  display: flex;
  align-items: center;
  height: 0;
}

.x-ticks {
  grid-area: x;
  margin-top: 0.75rem;
}

.x-ticks span {
  display: flex;
  justify-content: center;
  width: 0;
}

.plot {
  grid-area: plot;
  position: relative;
  height: 18rem;
  border-bottom: 1px solid var(--grafit-mjuk);
}

.plot:focus-visible {
  outline: 2px solid var(--skiffer);
  outline-offset: 4px;
}

.plot svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.grid-line {
  stroke: var(--linje);
  stroke-width: 1px;
  vector-effect: non-scaling-stroke;
}

.series-line {
  fill: none;
  stroke: var(--series);
  stroke-width: 2px;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.marker,
.marker-ring {
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.marker {
  stroke: var(--series);
  stroke-width: 9px;
}

.marker-ring {
  stroke: var(--kalkvit);
  stroke-width: 13px;
}

.crosshair {
  stroke: var(--grafit-mjuk);
  stroke-width: 1px;
  vector-effect: non-scaling-stroke;
}

.chart-tooltip {
  position: absolute;
  top: 0.5rem;
  z-index: 2;
  min-width: 11rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--linje);
  border-radius: var(--radius);
  background: var(--papper);
  box-shadow: 0 2px 10px rgb(31 42 48 / 12%);
  font-size: var(--t-sm);
  pointer-events: none;
}

.tooltip-rate {
  margin-bottom: 0.25rem;
  color: var(--grafit-mjuk);
}

.tooltip-row {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.tooltip-row strong {
  font-size: var(--t-base);
}

.chart-note {
  margin: 0.75rem 0 0;
}

.chart-table {
  margin-top: 1rem;
}

.chart-table summary {
  color: var(--skiffer);
  cursor: pointer;
}

.chart-table table {
  margin-top: 0.75rem;
  border-collapse: collapse;
}

.chart-table th,
.chart-table td {
  padding: 0.25rem 1rem 0.25rem 0;
  border-bottom: 1px solid var(--linje);
  text-align: right;
  white-space: nowrap;
}

.chart-table th[scope="row"],
.chart-table thead th:first-child {
  text-align: left;
}

.compare-actions {
  display: flex;
  gap: 1rem;
  margin-top: 1.5rem;
}

/* Narrow screens: a slimmer label column so more of each scenario is visible */
@media (max-width: 40rem) {
  .field-list .field {
    grid-template-columns: minmax(0, 1fr) 9.5rem;
  }

  /* Persons: the name on top, the two incomes side by side below it, each with its label */
  .persons {
    min-width: 0;
  }

  .persons thead {
    display: none;
  }

  .persons tbody,
  .persons tr {
    display: block;
  }

  .persons tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 0.35rem 0.75rem;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--linje);
  }

  .persons td {
    min-width: 0;
    padding: 0;
  }

  .persons td.person-name {
    grid-column: 1 / -1;
  }

  .persons td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 0.2rem;
    color: var(--grafit-mjuk);
    font-size: var(--t-sm);
  }

  .grid tbody th[scope="row"],
  .grid tbody th[scope="rowgroup"] {
    width: 8.5rem;
    min-width: 8.5rem;
  }

  .grid td,
  .grid thead th {
    min-width: 10.5rem;
  }

  .key-row th {
    font-size: var(--t-base);
  }

  .plot {
    height: 14rem;
  }
}

/* ---- Notices and deleting --------------------------------------------------- */

/* A message after something was done, such as deleting a calculation. Shown once. */
.notice {
  max-width: 40rem;
  margin: 0 0 1.5rem;
  padding: 0.75rem 1rem;
  border-left: 4px solid var(--skiffer);
  background: var(--papper);
}

.delete-calculation {
  margin: 0;
  font-size: var(--t-sm);
}

.delete-calculation a {
  color: var(--grafit-mjuk);
}

/* ---- Terms of use ------------------------------------------------------------ */

.text-page {
  max-width: 40rem;
  padding: 1rem 0 2rem;
}

.text-page h2 {
  margin: 2rem 0 0.5rem;
  font-size: var(--t-md);
}

.text-page ul {
  padding-left: 1.2rem;
}

.text-page li + li {
  margin-top: 0.4rem;
}

.text-page .effective {
  color: var(--grafit-mjuk);
  font-size: var(--t-sm);
}

/* Where the user starts using the service, and under the results. */
.terms-note,
.results-disclaimer {
  max-width: 40rem;
  color: var(--grafit-mjuk);
  font-size: var(--t-sm);
}

.terms-note {
  margin: 0.75rem 0 0;
}

/* A button that looks like a link, in a sentence of normal size. */
.account-switch .link-button {
  font-size: inherit;
}

.account-check {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  margin: 0 0 1rem;
}

.account-check input {
  flex: none;
  margin-top: 0.15rem;
}

.results-disclaimer {
  margin: 0.75rem 0 0;
}
