@layer components {
  /* Accounting (Financeiro): transactions, shed and the DRE report
  /* ------------------------------------------------------------------------ */

  /* Transactions toolbar specifics (the row itself is .toolbar, see toolbar.css) */
  .acct-filters__category {
    inline-size: 200px;
    max-inline-size: 100%;
  }

  .acct-filters__dates {
    align-items: center;
    display: flex;
    gap: 0.5rem;
    max-inline-size: 100%;

    .input {
      min-inline-size: 0;
    }
  }

  .acct-filters__until {
    color: var(--color-ink-dark);
    font-size: var(--text-small);
  }

  /* Transaction form (transactions + shed modals)
   *
   *   .modal__body.acct-form
   *     .acct-form__grid           1 column, 3 from 768px
   *       .acct-form__kind         Receita / Despesa radios
   *       .field[.acct-form__wide] spans 2 columns from 768px
   *     .field.acct-form__row      full-width row below the grid
   *     .modal__footer
   */
  .acct-form__grid {
    align-items: center;
    display: grid;
    gap: 1rem;
    grid-template-columns: minmax(0, 1fr);

    @media (min-width: 768px) {
      grid-template-columns: repeat(3, minmax(0, 1fr));
    }
  }

  .acct-form__wide {
    @media (min-width: 768px) {
      grid-column: span 2;
    }
  }

  .acct-form__row {
    margin-block-start: 1rem;
  }

  .acct-form__kind {
    align-items: center;
    border: 0;
    display: flex;
    flex-direction: column;
    margin: 0;
    min-inline-size: 0;
    padding: 0;
  }

  .acct-form__kind-options {
    align-items: center;
    display: flex;
    gap: 1rem;
  }

  .acct-form__radio {
    align-items: center;
    cursor: pointer;
    display: inline-flex;
    gap: 0.5rem;

    input {
      margin: 0;
    }
  }

  /* DRE */
  .dre { text-align: start; }
  .dre-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
  .dre-stepper { display: inline-flex; align-items: center; gap: 8px; }
  .dre-stepper__label { min-width: 11ch; text-align: center; font-weight: 700; color: #243b53; font-size: 0.9375rem; }
  .dre-shed { margin-left: auto; }
  .dre-note { margin: 0; text-align: start; font-size: 0.8125rem; color: #627d98; line-height: 1.5; max-width: 80ch; }
  .dre .dre__section td { background: #f7f9fc; }
  .dre .dre__section .dt__cell { font-weight: 700; color: #243b53; min-height: 36px; }
  .dre .dre__section--revenue .dt__cell { box-shadow: inset 3px 0 0 var(--color-success-500, #1f9d6b); }
  .dre .dre__section--expense .dt__cell { box-shadow: inset 3px 0 0 var(--color-danger-400, #e25c66); }
  .dre .dre__total td { background: #fbfcfe; }
  .dre .dre__total .dt__cell { font-weight: 700; }
  .dre .dre__result td { background: #f1f5ff; border-top: 2px solid #d7dfee; }
  /* Page rules beat the components.tables layer, so restate the row hover over the tinted rows. */
  .dre tbody tr:hover td { background: #f8f9fc; }
  .dre .dre__result .dt__cell { font-weight: 800; font-size: 0.875rem; min-height: 48px; }
  .dre .dre__result .dt__cell.is-negative { color: var(--color-danger-600, #d64550); }
  .dre .dre__result .dt__cell.is-positive { color: var(--color-success-700, #0a7d55); }
  .dre__link { color: #243b53; text-decoration: none; font-weight: 500; }
  .dre__link:hover { color: var(--color-primary-500, #2251cc); text-decoration: underline; }
  .dre__previous { color: #829ab1; }
  .dre__none { color: #829ab1; font-style: italic; }
  .dre__delta { flex-direction: column; align-items: flex-end; justify-content: center; gap: 0; line-height: 1.2; }
  .dre__delta small { font-size: 0.6875rem; font-weight: 600; }
  .dre__delta--good { color: var(--color-success-700, #0a7d55); }
  .dre__delta--bad { color: var(--color-danger-600, #d64550); }
  .dre__delta--flat { color: #9fb3c8; }

  /* Period column header: full label on wide screens, "Valor" on phones */
  .dre__label-narrow { @media (min-width: 640px) { display: none; } }
  .dre__label-wide { @media (max-width: 639px) { display: none; } }
  .dre col.dre__col-current, .dre col.dre__col-previous { width: 22%; }
  .dre col.dre__col-delta { width: 18%; }
  @media (max-width: 639px) {
    .dre-shed { margin-left: 0; }
    /* A hidden <col> still takes its share in a fixed layout, so phones use
       the automatic one and let category names wrap. */
    .dre.dt { table-layout: auto; }
    .dre col.dre__col-current, .dre col.dre__col-delta { width: auto; }
    .dre .dt__cell:not(.dt__cell--num) { white-space: normal; }
    .dre .dre__link.dt__truncate { white-space: normal; overflow: visible; }
    .dre .dt__cell { padding: 0 8px; }
    .dre .dt__cell--num { font-size: 0.75rem; }
    .dre__delta small { font-size: 0.625rem; }
  }
}
