/**
 * Objekt-Finanzen (Finanzbuchhaltung) workbench styles.
 *
 * Built on the authored design tokens in legacy-design.css. Every text colour
 * used here was measured against its own background: the lowest pair is
 * --legacy-ink-soft on --legacy-paper at 5.18:1, over the 4.5:1 WCAG AA floor.
 * The status tones reuse --legacy-success (5.35:1) and --legacy-warning
 * (6.68:1); the danger edge is #9b1c1c (8.15:1 on white). Colour never carries
 * meaning alone — every status is stated as a text label first.
 */

.fw-root {
  --fw-gap: 20px;
  display: flex;
  flex-direction: column;
  gap: var(--fw-gap);
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 20px 56px;
  color: var(--legacy-ink, #232323);
  font-family: inherit;
}

/* The shell lives in authored-shell.css and is shared with the other authored
   screens, so all of them carry identical navigation. */

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

.fw-eyebrow {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--legacy-blue, #1300ff);
}

.fw-title {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.fw-lede {
  margin: 0;
  max-width: 68ch;
  font-size: 15px;
  line-height: 1.6;
  color: var(--legacy-ink-soft, #6b6560);
}

/* ---------- announce ---------- */

.fw-announce {
  margin: 0;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--legacy-ink-soft, #6b6560);
}

/* ---------- filters / pickers ---------- */

.fw-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px 16px;
  align-items: end;
  background: var(--legacy-surface, #fff);
  border: 1px solid var(--legacy-line, #e7e4e0);
  border-radius: var(--legacy-radius-md, 16px);
  padding: 16px 18px;
}

/* Inline section filters sit tighter than the top object/year picker. */
.fw-filters--inline {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  padding: 12px 14px;
}

.fw-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.fw-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--legacy-ink, #232323);
}

.fw-input {
  width: 100%;
  min-height: 42px;
  padding: 8px 12px;
  font: inherit;
  font-size: 14px;
  color: var(--legacy-ink, #232323);
  background: var(--legacy-surface, #fff);
  border: 1px solid var(--legacy-line-strong, #d8d4cf);
  border-radius: var(--legacy-radius-sm, 10px);
}

/* One visible focus treatment for every interactive element and region. */
.fw-input:focus-visible,
.fw-button:focus-visible,
.fw-tablewrap:focus-visible {
  outline: 3px solid var(--legacy-blue, #1300ff);
  outline-offset: 2px;
}

/* ---------- section ---------- */

.fw-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-top: 6px;
  border-top: 1px solid var(--legacy-line, #e7e4e0);
}

.fw-section__head {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.fw-section__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* The heading receives programmatic focus after a reload; keep the ring. */
.fw-section__title:focus-visible {
  outline: 3px solid var(--legacy-blue, #1300ff);
  outline-offset: 3px;
  border-radius: 4px;
}

.fw-section__lede {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--legacy-ink-soft, #6b6560);
}

/* ---------- metrics ---------- */

.fw-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin: 0;
}

.fw-metrics--tight {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.fw-metric {
  background: var(--legacy-surface, #fcfcfd);
  border: 1px solid var(--legacy-line, #e7e4e0);
  border-left: 4px solid var(--legacy-line-strong, #d8d4cf);
  border-radius: var(--legacy-radius-md, 16px);
  padding: 16px 18px;
}

.fw-metric--ok {
  border-left-color: var(--legacy-success, #087a55);
}

.fw-metric--warn {
  border-left-color: var(--legacy-warning, #855000);
}

.fw-metric--danger {
  border-left-color: #9b1c1c;
}

.fw-metric__label {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--legacy-ink-soft, #6b6560);
}

.fw-metric__value {
  margin: 0;
  font-size: 26px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.fw-metric__hint {
  margin: 6px 0 0;
  font-size: 12.5px;
  color: var(--legacy-ink-soft, #6b6560);
}

/* ---------- states ---------- */

.fw-state {
  margin: 0;
  background: var(--legacy-surface, #fcfcfd);
  border: 1px solid var(--legacy-line, #e7e4e0);
  border-radius: var(--legacy-radius-md, 16px);
  padding: 22px;
  font-size: 14.5px;
}

/* The error state colours the whole box, not one edge of it. */
.fw-state--error {
  border-color: #9b1c1c; /* 8.15:1 on white */
  background: #fdf5f5;
}

.fw-state__title {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
}

.fw-state__reason,
.fw-state__hint {
  margin: 0 0 8px;
  color: var(--legacy-ink-soft, #6b6560);
  line-height: 1.55;
}

.fw-button {
  margin-top: 6px;
  min-height: 42px;
  padding: 10px 18px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: var(--legacy-blue, #1300ff);
  border: 1px solid transparent;
  border-radius: var(--legacy-radius-sm, 10px);
  cursor: pointer;
}

.fw-button:hover {
  background: var(--legacy-blue-hover, #0f00cc);
}

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

/*
 * The wrapper is focusable so a keyboard-only user can scroll it — the exact
 * axe "scrollable-region-focusable" defect the recovered screens carry on
 * mobile.
 */
.fw-tablewrap {
  overflow-x: auto;
  background: var(--legacy-surface, #fcfcfd);
  border: 1px solid var(--legacy-line, #e7e4e0);
  border-radius: var(--legacy-radius-md, 16px);
}

.fw-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.fw-table__caption {
  padding: 16px 18px 12px;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  color: var(--legacy-ink-soft, #6b6560);
}

.fw-table thead th {
  position: sticky;
  top: 0;
  background: var(--legacy-paper, #f6f4f1);
  padding: 10px 14px;
  text-align: left;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--legacy-ink, #232323);
  border-bottom: 1px solid var(--legacy-line-strong, #d8d4cf);
  white-space: nowrap;
}

.fw-table thead th:last-child,
.fw-table td.fw-num,
.fw-table tfoot td {
  text-align: right;
}

.fw-table tbody td,
.fw-table tbody th,
.fw-table tfoot td,
.fw-table tfoot th {
  padding: 12px 14px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--legacy-line, #e7e4e0);
  font-weight: 400;
}

.fw-table tbody tr:last-child td,
.fw-table tbody tr:last-child th {
  border-bottom: 0;
}

.fw-table tfoot th,
.fw-table tfoot td {
  border-top: 2px solid var(--legacy-line-strong, #d8d4cf);
  border-bottom: 0;
  font-weight: 700;
}

.fw-row__title {
  display: block;
  font-weight: 600;
  font-size: 14.5px;
}

.fw-row__meta {
  display: block;
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--legacy-ink-soft, #6b6560);
}

.fw-num {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* The tag carries the meaning as text; the tint only repeats what it says. */
.fw-tag {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
  color: var(--legacy-ink, #232323);
  background: var(--legacy-line, #e7e4e0);
}

.fw-tag--ok {
  color: #fff;
  background: var(--legacy-success, #087a55);
}

.fw-tag--warn {
  color: #fff;
  background: var(--legacy-warning, #855000);
}

/* ---------- footnotes ---------- */

.fw-footnote,
.fw-page-footnote p {
  margin: 0;
  max-width: 76ch;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--legacy-ink-soft, #6b6560);
}

/* ---------- responsive ---------- */

@media (max-width: 720px) {
  .fw-root {
    padding: 20px 14px 44px;
  }

  .fw-filters {
    grid-template-columns: 1fr;
  }

  .fw-table thead th {
    position: static;
  }

  /*
   * The tables exceed a phone, so they scroll sideways. Pinning the first column
   * keeps every scrolled value attributable to a row — table semantics stay
   * intact, unlike a block-layout rewrite.
   */
  .fw-table thead th:first-child,
  .fw-table tbody th[scope="row"] {
    position: sticky;
    left: 0;
    z-index: 1;
    min-width: 168px;
    background: var(--legacy-surface, #fcfcfd);
    border-right: 1px solid var(--legacy-line, #e7e4e0);
  }

  .fw-table thead th:first-child {
    background: var(--legacy-paper, #f6f4f1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .fw-root * {
    transition: none !important;
    animation: none !important;
  }
}
