/*
 * SteuerWork base styles: element defaults and the page shell.
 *
 * Colours, sizes and fonts come only from the --sw-* tokens in tokens.css.
 * UI text keeps its natural sentence case: never add text-transform.
 */

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

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

body {
  margin: 0;
  background: var(--sw-canvas);
  color: var(--sw-text);
  font-family: var(--sw-font-sans);
  font-size: var(--sw-font-size-body);
  font-weight: var(--sw-font-weight-regular);
  line-height: var(--sw-line-height-body);
}

h1,
h2,
h3 {
  margin-block: 0 var(--sw-space-12);
  font-weight: var(--sw-font-weight-bold);
}

h1 {
  font-size: var(--sw-font-size-title);
  line-height: var(--sw-line-height-title);
}

h2 {
  font-size: var(--sw-font-size-subsection);
  line-height: var(--sw-line-height-subsection);
}

h3 {
  font-size: var(--sw-font-size-heading-small);
  line-height: var(--sw-line-height-heading-small);
}

p {
  margin-block: 0 var(--sw-space-16);
  max-inline-size: var(--sw-reading-width);
}

p:last-child {
  margin-block-end: 0;
}

a {
  color: var(--sw-link);
  text-underline-offset: 0.15em;
}

abbr[title] {
  text-decoration: none;
}

:focus-visible {
  outline: var(--sw-focus-ring-width) solid var(--sw-focus);
  outline-offset: var(--sw-focus-ring-offset);
}

/* Main receives focus from the skip link only; it needs no ring. */
main:focus {
  outline: none;
}

.skip-link {
  position: absolute;
  inset-block-start: var(--sw-space-8);
  inset-inline-start: var(--sw-space-8);
  z-index: 1;
  padding: var(--sw-space-8) var(--sw-space-16);
  border-radius: var(--sw-radius-control);
  background: var(--sw-primary);
  color: var(--sw-on-primary);
  font-weight: var(--sw-font-weight-bold);
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: none;
}

.visually-hidden {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.icon {
  flex: none;
  inline-size: var(--sw-icon-size-large);
  block-size: var(--sw-icon-size-large);
}

fieldset {
  margin: 0;
  padding: 0;
  border: 0;
  min-inline-size: 0;
}

legend {
  padding: 0;
  font-weight: var(--sw-font-weight-semibold);
}

button {
  font: inherit;
}

.button,
button[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-block-size: var(--sw-target-min);
  padding-inline: var(--sw-space-20);
  border: 0;
  border-radius: var(--sw-radius-control);
  background: var(--sw-primary);
  color: var(--sw-on-primary);
  font-weight: var(--sw-font-weight-bold);
  cursor: pointer;
  transition: background-color var(--sw-duration-fast) var(--sw-easing);
}

.button:hover,
button[type="submit"]:hover {
  background: var(--sw-primary-hover);
}

input[type="radio"] {
  inline-size: 1.25rem;
  block-size: 1.25rem;
  margin: 0;
  accent-color: var(--sw-primary);
}

/* Page shell. One column on small screens; from 64rem the navigation
   becomes a side column below the brand. */

.shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "head"
    "nav"
    "main"
    "foot";
  grid-template-rows: auto auto 1fr auto;
  min-block-size: 100vh;
}

.masthead {
  grid-area: head;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sw-space-8) var(--sw-space-16);
  padding: var(--sw-space-8) var(--sw-space-16);
  border-block-end: 1px solid var(--sw-border);
  background: var(--sw-surface);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--sw-space-8);
  min-block-size: var(--sw-target-min);
  color: var(--sw-text);
  font-size: var(--sw-font-size-heading-small);
  font-weight: var(--sw-font-weight-bold);
  text-decoration: none;
}

/* The logo exists once per theme; show the one that matches, by the same
   rules as tokens.css. It is decorative: the link text names it. */
.brand-logo {
  inline-size: var(--sw-logo-size);
  block-size: var(--sw-logo-size);
}

.brand-logo-dark {
  display: none;
}

@media screen and (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand-logo-light {
    display: none;
  }

  :root:not([data-theme="light"]) .brand-logo-dark {
    display: block;
  }
}

@media screen {
  :root[data-theme="dark"] .brand-logo-light {
    display: none;
  }

  :root[data-theme="dark"] .brand-logo-dark {
    display: block;
  }
}

.mainnav {
  grid-area: nav;
  padding: var(--sw-space-8) var(--sw-space-16);
  border-block-end: 1px solid var(--sw-border);
  background: var(--sw-surface);
}

.mainnav ul {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sw-space-8);
  margin: 0;
  padding: 0;
  list-style: none;
}

.mainnav a {
  display: flex;
  align-items: center;
  min-block-size: var(--sw-target-min);
  padding-inline: var(--sw-space-12);
  border-radius: var(--sw-radius-control);
  color: var(--sw-text);
  font-weight: var(--sw-font-weight-semibold);
  text-decoration: none;
}

.mainnav a:hover {
  background: var(--sw-surface-muted);
}

.mainnav a[aria-current="page"] {
  background: var(--sw-primary-soft);
  color: var(--sw-on-primary-soft);
}

main {
  grid-area: main;
  inline-size: 100%;
  max-inline-size: var(--sw-content-max);
  padding: var(--sw-space-24) var(--sw-space-16) var(--sw-space-48);
}

.site-footer {
  grid-area: foot;
  padding: var(--sw-space-16);
  border-block-start: 1px solid var(--sw-border);
  color: var(--sw-text-muted);
  font-size: var(--sw-font-size-compact);
  line-height: var(--sw-line-height-compact);
}

@media (min-width: 64rem) {
  .shell {
    grid-template-columns: var(--sw-nav-width) minmax(0, 1fr);
    grid-template-areas:
      "head head"
      "nav main"
      "nav foot";
    grid-template-rows: auto 1fr auto;
  }

  .masthead {
    padding-inline: var(--sw-space-24);
  }

  .mainnav {
    padding: var(--sw-space-16);
    border-block-end: 0;
    border-inline-end: 1px solid var(--sw-border);
  }

  .mainnav ul {
    flex-direction: column;
  }

  main {
    padding: var(--sw-space-40) var(--sw-space-40) var(--sw-space-64);
  }

  .site-footer {
    padding-inline: var(--sw-space-40);
  }
}

/* Theme switcher: three icon buttons that each submit the choice at once,
   so it needs neither JavaScript nor a separate apply button. It stays
   quiet: no frame or background. The chosen mode is marked by aria-pressed
   and a filled icon in the primary colour, so not by colour alone. */

.theme-options {
  display: flex;
  gap: var(--sw-space-4);
}

.theme-switch .theme-option {
  display: inline-grid;
  place-items: center;
  min-block-size: var(--sw-target-min);
  min-inline-size: var(--sw-target-min);
  padding: 0;
  border: 0;
  border-radius: var(--sw-radius-control);
  background: transparent;
  color: var(--sw-text-muted);
}

.theme-switch .theme-option:hover {
  background: var(--sw-surface-muted);
  color: var(--sw-text);
}

.theme-switch .theme-option[aria-pressed="true"] {
  color: var(--sw-primary);
}

.theme-option .icon {
  inline-size: var(--sw-icon-size);
  block-size: var(--sw-icon-size);
  fill: none;
  stroke: currentColor;
  stroke-width: var(--sw-icon-stroke);
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-option[aria-pressed="true"] .icon {
  fill: currentColor;
}

/* Content building blocks. */

.lead {
  color: var(--sw-text-muted);
  font-size: var(--sw-font-size-heading-small);
  line-height: var(--sw-line-height-heading-small);
  margin-block-end: var(--sw-space-32);
}

.card {
  margin-block-end: var(--sw-space-24);
  padding: var(--sw-space-16);
  border-radius: var(--sw-radius-card);
  background: var(--sw-surface);
  box-shadow: var(--sw-shadow-card);
}

.card h2 {
  font-size: var(--sw-font-size-heading-small);
  line-height: var(--sw-line-height-heading-small);
}

@media (min-width: 40rem) {
  .card {
    padding: var(--sw-space-24);
  }
}

/* A neutral notice. The heading carries the meaning; colour only groups. */
.notice {
  background: var(--sw-info-bg);
  box-shadow: none;
}

.notice h2 {
  color: var(--sw-info);
}

/* Forms. Labels sit above their fields; help and errors sit between the
   label and the field, so screen magnifier users find them. */

.stack {
  display: grid;
  gap: var(--sw-space-16);
  justify-items: start;
  margin-block-start: var(--sw-space-24);
}

.stack > * {
  margin-block: 0;
}

.field {
  display: grid;
  gap: var(--sw-space-4);
  inline-size: 100%;
  max-inline-size: var(--sw-reading-width);
}

.field label {
  font-weight: var(--sw-font-weight-semibold);
}

.field-required,
.field-help {
  color: var(--sw-text-muted);
  font-weight: var(--sw-font-weight-regular);
}

.field-help,
.field-error {
  margin: 0;
}

.field-error {
  color: var(--sw-danger);
  font-weight: var(--sw-font-weight-semibold);
}

input[type="text"] {
  inline-size: 100%;
  min-block-size: var(--sw-target-min);
  padding-inline: var(--sw-space-12);
  border: 1px solid var(--sw-control-border);
  border-radius: var(--sw-radius-control);
  background: var(--sw-surface);
  color: var(--sw-text);
  font: inherit;
}

/* A field for a few characters, such as a year, looks the part. */
.field-short input {
  max-inline-size: 8rem;
}

input[aria-invalid="true"] {
  border: 2px solid var(--sw-danger);
}

/* Shown at the top of the page after a failed submit, and focused. */
.error-summary {
  margin-block-end: var(--sw-space-24);
  padding: var(--sw-space-16);
  border: 1px solid var(--sw-border);
  border-inline-start: var(--sw-space-4) solid var(--sw-danger);
  border-radius: var(--sw-radius-card);
  background: var(--sw-surface);
}

.error-summary h2 {
  color: var(--sw-danger);
  font-size: var(--sw-font-size-heading-small);
  line-height: var(--sw-line-height-heading-small);
}

.error-summary ul {
  margin: 0;
  padding-inline-start: var(--sw-space-20);
}

.case-list {
  margin-block: 0;
  padding-inline-start: var(--sw-space-20);
}

/* Case context: which case and year every page of a case is about. */
.case-context {
  margin-block-end: var(--sw-space-16);
  color: var(--sw-text-muted);
}

.case-context strong {
  color: var(--sw-text);
}

.actions {
  margin-block: 0 var(--sw-space-24);
}

.button {
  text-decoration: none;
}

/* Status: text and icon carry the meaning; colour only supports them. */
.status-icon {
  flex: none;
  inline-size: var(--sw-icon-size);
  block-size: var(--sw-icon-size);
  vertical-align: -0.2em;
}

.status-panel {
  margin-block-end: var(--sw-space-24);
  padding: var(--sw-space-16);
  border-radius: var(--sw-radius-card);
}

.status-panel h2 {
  display: flex;
  align-items: center;
  gap: var(--sw-space-8);
  font-size: var(--sw-font-size-heading-small);
  line-height: var(--sw-line-height-heading-small);
}

.status-panel a {
  color: inherit;
}

.status-success {
  background: var(--sw-success-bg);
}

.status-success h2 {
  color: var(--sw-success);
}

.status-warning {
  background: var(--sw-warning-bg);
}

.status-warning h2 {
  color: var(--sw-warning);
}

.status-danger {
  background: var(--sw-danger-bg);
}

.status-danger h2 {
  color: var(--sw-danger);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: var(--sw-space-4);
  font-weight: var(--sw-font-weight-semibold);
}

.status.tone-success {
  color: var(--sw-success);
}

.status.tone-warning {
  color: var(--sw-warning);
}

.status.tone-danger {
  color: var(--sw-danger);
}

.status.tone-neutral {
  color: var(--sw-text-muted);
}

.answer-list {
  display: grid;
  gap: var(--sw-space-12);
  margin: 0;
  padding-inline-start: var(--sw-space-24);
}

.answer-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sw-space-4) var(--sw-space-16);
}

.answer-list a {
  font-weight: var(--sw-font-weight-semibold);
}

.answer-list a,
.answer-list li > span:first-child {
  flex: 1 1 16rem;
}

.answer-value {
  color: var(--sw-text-muted);
}

/* One interview question: the form first, help beside it on wide screens
   and below it on narrow ones. */

.question-progress,
.saved-answer {
  color: var(--sw-text-muted);
}

.with-help {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--sw-space-24);
  align-items: start;
}

@media (min-width: 64rem) {
  .with-help {
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  }
}

.question-form {
  display: grid;
  gap: var(--sw-space-24);
  justify-items: start;
}

.question-form fieldset {
  display: grid;
  gap: var(--sw-space-12);
  inline-size: 100%;
}

.question-form legend {
  margin-block-end: var(--sw-space-8);
}

.question-form legend h1 {
  margin: 0;
  font-size: var(--sw-font-size-subsection);
  line-height: var(--sw-line-height-subsection);
}

.choices {
  display: grid;
  gap: var(--sw-space-8);
}

.choice {
  display: flex;
  align-items: center;
  gap: var(--sw-space-12);
  min-block-size: var(--sw-target-min);
  padding-inline: var(--sw-space-12);
  border: 1px solid var(--sw-control-border);
  border-radius: var(--sw-radius-control);
  background: var(--sw-surface);
  cursor: pointer;
}

.choice:hover {
  background: var(--sw-surface-muted);
}

.choice:has(input:checked) {
  border: 2px solid var(--sw-primary);
}

.help-panel {
  padding: var(--sw-space-16);
  border-radius: var(--sw-radius-card);
  background: var(--sw-surface);
  box-shadow: var(--sw-shadow-card);
}

.help-panel h2 {
  font-size: var(--sw-font-size-heading-small);
  line-height: var(--sw-line-height-heading-small);
}

.help-review {
  color: var(--sw-text-muted);
  font-size: var(--sw-font-size-compact);
  line-height: var(--sw-line-height-compact);
}

.question-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sw-space-8) var(--sw-space-24);
  margin: var(--sw-space-32) 0 0;
  padding: 0;
  list-style: none;
}

.question-nav a {
  display: inline-flex;
  align-items: center;
  min-block-size: var(--sw-target-min);
}

/* Receipts and expenses. */

/* Amounts line up digit by digit. */
.amount {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.totals {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: var(--sw-space-16);
  margin: 0 0 var(--sw-space-16);
}

.totals dt {
  color: var(--sw-text-muted);
}

.totals dd {
  margin: 0;
}

.totals .amount {
  display: block;
  font-size: var(--sw-font-size-subsection);
  line-height: var(--sw-line-height-subsection);
  font-weight: var(--sw-font-weight-bold);
}

.totals-note {
  color: var(--sw-text-muted);
}

/* A table wider than the screen scrolls on its own, not the page. */
.table-scroll {
  overflow-x: auto;
}

table {
  inline-size: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: var(--sw-space-8) var(--sw-space-12);
  border-block-end: 1px solid var(--sw-border);
  text-align: start;
  vertical-align: top;
}

th {
  font-weight: var(--sw-font-weight-semibold);
}

th:first-child,
td:first-child {
  padding-inline-start: 0;
}

th:last-child,
td:last-child {
  padding-inline-end: 0;
}

.numeric {
  text-align: end;
}

.choices-inline {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sw-space-8) var(--sw-space-12);
}

.choices-inline .choice {
  min-inline-size: 9rem;
}

.money-input {
  display: flex;
  align-items: center;
  gap: var(--sw-space-8);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sw-space-16) var(--sw-space-24);
}

.form-actions a {
  display: inline-flex;
  align-items: center;
  min-block-size: var(--sw-target-min);
}

button.button-danger {
  background: var(--sw-danger-action);
  color: var(--sw-on-danger-action);
}

button.button-danger:hover {
  background: var(--sw-danger-action-hover);
}

/* The values of one entry: term above value on narrow screens, beside it
   on wide ones. */
.entry-values {
  display: grid;
  gap: var(--sw-space-8);
  margin: 0 0 var(--sw-space-16);
}

.entry-values div {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 40rem) {
  .entry-values div {
    grid-template-columns: 10rem minmax(0, 1fr);
    gap: var(--sw-space-16);
  }
}

.entry-values dt {
  color: var(--sw-text-muted);
}

.entry-values dd {
  margin: 0;
  overflow-wrap: anywhere;
}

/* A cancelled entry's amount no longer counts. The "Storniert" text says
   so; the line through it only repeats that. */
tr.cancelled .amount {
  text-decoration: line-through;
}

.status-neutral {
  background: var(--sw-surface-muted);
}

/* Calculation. The total row stands out by weight and a stronger rule,
   not by colour. */
.reasons li + li {
  margin-block-start: var(--sw-space-8);
}

.line-detail {
  color: var(--sw-text-muted);
  font-weight: var(--sw-font-weight-regular);
}

table.calculation tfoot th,
table.calculation tfoot td {
  border-block-start: 2px solid var(--sw-text);
  border-block-end: none;
  font-weight: var(--sw-font-weight-bold);
}

.trace summary {
  min-block-size: var(--sw-target-min);
  padding-block: var(--sw-space-8);
  cursor: pointer;
  color: var(--sw-link);
}

.trace ol {
  padding-inline-start: var(--sw-space-24);
}

.trace li + li {
  margin-block-start: var(--sw-space-16);
}

.trace p {
  margin-block: var(--sw-space-4);
}

.trace-source {
  color: var(--sw-text-muted);
  overflow-wrap: anywhere;
}

@media (forced-colors: active) {
  .card,
  .notice,
  .status-panel,
  .help-panel {
    border: 1px solid CanvasText;
  }

  .theme-switch .theme-option[aria-pressed="true"] {
    color: Highlight;
  }
}

@media print {
  .skip-link,
  .mainnav,
  .theme-switch,
  .question-nav {
    display: none;
  }

  .card {
    box-shadow: none;
    border: 1px solid var(--sw-border);
  }
}
