/* Opening-balance migration screen. One card per budget line / ToR line item,
   surfacing the stored terms for context above the editable opening fields.
   (The app has no global .form-control, so the inputs are styled here.) */
.opening-input {
  width: 7rem;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--md-sys-color-outline);
  border-radius: var(--md-sys-shape-corner-extra-small);
  font: var(--md-sys-typescale-body-large);
  letter-spacing: var(--md-sys-typescale-body-large-tracking);
  color: var(--md-sys-color-on-surface);
  background: transparent;
  transition:
    border-color var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard),
    box-shadow var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard);
  outline: none;
}

.opening-input:hover {
  border-color: var(--md-sys-color-on-surface);
}

.opening-input:focus {
  border-color: var(--md-sys-color-primary);
  box-shadow: inset 0 0 0 1px var(--md-sys-color-primary);
}

/* Type-only fields — drop the up/down spinner buttons. */
.opening-input {
  -moz-appearance: textfield;
  appearance: textfield;
}

.opening-input::-webkit-outer-spin-button,
.opening-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Group heading above the ToR sections, parallel to the direct-section title. */
.ob-group-title {
  margin: 0.5rem 0 0;
  font: var(--md-sys-typescale-title-large);
  letter-spacing: var(--md-sys-typescale-title-large-tracking);
  color: var(--md-sys-color-on-surface);
}

/* ── Rows ────────────────────────────────────────────────────────── */
/* Each section is already an outlined card, so its lines are list rows split
   by dividers — M3 doesn't nest cards in cards. */
.ob-cards {
  display: flex;
  flex-direction: column;
}

/* Single horizontal band: identity on the left, stored terms inline, then the
   editable fields + button pushed right. Wraps on narrow screens. */
.ob-card {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem 2.5rem;
  padding: 1rem 0;
}
.ob-card + .ob-card { border-top: 1px solid var(--md-sys-color-outline-variant); }

.ob-card-head {
  flex: 1 1 200px;
  min-width: 0;
}

.ob-card-title {
  font: var(--md-sys-typescale-title-medium);
  letter-spacing: var(--md-sys-typescale-title-medium-tracking);
  color: var(--md-sys-color-on-surface);
}

.ob-card-meta {
  margin-top: 0.2rem;
  font: var(--md-sys-typescale-body-small);
  letter-spacing: var(--md-sys-typescale-body-small-tracking);
  color: var(--md-sys-color-on-surface-variant);
}

/* Stored terms, surfaced read-only for context — inline label/value pairs. */
.ob-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.75rem;
  margin: 0;
  padding: 0;
}

.ob-facts > div { display: flex; flex-direction: column; }

.ob-facts dt {
  font: var(--md-sys-typescale-label-medium);
  letter-spacing: var(--md-sys-typescale-label-medium-tracking);
  color: var(--md-sys-color-on-surface-variant);
}

.ob-facts dd {
  margin: 0;
  font: var(--md-sys-typescale-body-medium);
  letter-spacing: var(--md-sys-typescale-body-medium-tracking);
  font-variant-numeric: tabular-nums;
  color: var(--md-sys-color-on-surface);
}

/* Spend already captured by the open-ToR rows — the admin subtracts it from the
   line total to reach the direct figure, so call it out with the help cursor. */
.ob-fact-subtract { cursor: help; }

.ob-fact-subtract dt { color: var(--md-sys-color-primary); }

.ob-fact-subtract dd { color: var(--md-sys-color-primary); font-weight: 500; }

/* Editable opening fields + button, pushed to the right edge of the band. */
.ob-form {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem 1rem;
  margin-left: auto;
}

.ob-inputs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
}

.ob-inputs label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font: var(--md-sys-typescale-label-medium);
  letter-spacing: var(--md-sys-typescale-label-medium-tracking);
  color: var(--md-sys-color-on-surface-variant);
}

.ob-actions {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* Fixed width so the row doesn't shift when the label flips Create ↔ Save edits. */
.ob-actions .btn {
  min-width: 6.5rem;
  text-align: center;
}

/* Floats above the button so it pops in without shifting the row. */
.ob-saved {
  position: absolute;
  bottom: 100%;
  right: 0;
  margin-bottom: 0.3rem;
  font: var(--md-sys-typescale-label-medium);
  letter-spacing: var(--md-sys-typescale-label-medium-tracking);
  color: var(--md-sys-color-primary);
  white-space: nowrap;
}
.ob-saved .icon { width: 16px; height: 16px; margin-right: 0.125rem; vertical-align: -4px; }

/* ── Overflow to the Flexible Remuneration line ──────────────────────── */

/* Direct rows wrap the editable form and the optional Allocate-overflow button
   together, pushed to the right edge of the band (the ToR row keeps using
   .ob-form's own margin-left:auto). */
.ob-form-wrap {
  margin-left: auto;
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
}

.ob-form-wrap .ob-form { margin-left: 0; }

/* button_to renders its own <form>; strip its block spacing so the button sits
   on the same baseline as the Save button beside it. */
.ob-inline-form { margin: 0; display: flex; align-items: flex-end; }

/* Allocate control: the info tooltip stacks above the button, both pinned to the
   band's right edge so the button stays level with Save beside it. */
.ob-allocate {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.3rem;
}

.ob-allocate-btn { white-space: nowrap; }

/* Shown instead of the allocate button when a row is over budget but carries no
   EUR cost yet — the flexible line can't be costed until Actual EUR is entered. */
.ob-allocate-hint {
  align-self: center;
  font: var(--md-sys-typescale-body-small);
  letter-spacing: var(--md-sys-typescale-body-small-tracking);
  color: var(--md-sys-color-on-surface-variant);
  cursor: help;
  white-space: nowrap;
}

/* Allocated state: the read-only overflow figure + Unallocate, right-aligned. */
.ob-overflow {
  margin-left: auto;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
}

.ob-overflow-note { display: flex; flex-direction: column; gap: 0.15rem; }

.ob-overflow-label {
  font: var(--md-sys-typescale-label-medium);
  letter-spacing: var(--md-sys-typescale-label-medium-tracking);
  color: var(--md-sys-color-primary);
}

.ob-overflow-figs {
  font: var(--md-sys-typescale-body-medium);
  letter-spacing: var(--md-sys-typescale-body-medium-tracking);
  font-variant-numeric: tabular-nums;
  color: var(--md-sys-color-on-surface);
}

/* A titled block header with a status badge beside the heading. Named for the
   controlling ToR section it came from, which is now a flat table; this page is
   its only remaining user, so the rule moved here out of controlling.css. */
.controlling-tor-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.controlling-tor-header h3 {
  margin: 0;
  font: var(--md-sys-typescale-title-medium);
  letter-spacing: var(--md-sys-typescale-title-medium-tracking);
}
