/* Budget Setup's Charges, Credits, Info, Settings and Baseline tabs
   (js/topsheet-setup.js). They are drawn in the shared layout (setup.css,
   documented at its top: the strip, bands, tables and footer); what is
   here is their own: the tables' columns, the charges and credits lists in
   the rail, the chips, and the Settings rows. Uses only the app's :root
   tokens; every class here is prefixed with tss- or ts-. */

/* Each table's columns: the lead column (where the list tables keep their
   drag handle), then the cells in order. */

.sw-cols-charge-excl .sw-grid-head,
.sw-cols-charge-excl .sw-grid-row {
  grid-template-columns: 14px 96px minmax(120px, 1fr) minmax(160px, 2fr) 140px 32px;
}

.sw-cols-credit-rows .sw-grid-head,
.sw-cols-credit-rows .sw-grid-row {
  grid-template-columns:
    14px minmax(140px, 1.3fr) minmax(110px, 1.6fr) minmax(88px, 1fr)
    minmax(92px, 1fr) minmax(92px, 1fr) minmax(92px, 1fr) 132px
    minmax(88px, 1fr) 56px minmax(92px, 1fr) minmax(88px, 1fr) 32px;
}

.sw-cols-info .sw-grid-head,
.sw-cols-info .sw-grid-row {
  grid-template-columns: 14px minmax(140px, 1fr) 112px minmax(200px, 2.5fr) 32px;
}

/* A field's value reads from the left, a number too (the column mixes text,
   numbers and dates). */
.sw-cols-info .setup-input.sw-cell-input.setup-num {
  text-align: left;
}

.sw-cols-baseline .sw-grid-head,
.sw-cols-baseline .sw-grid-row {
  grid-template-columns: 14px minmax(160px, 260px) 150px 150px 150px;
}

/* An amount left out of a charge: its description spans Name and
   Description. */
.tss-span2 {
  grid-column: span 2;
}

/* Charges and credits: the list in the rail, then the add form. */

.tss-pick .sw-tree-count {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
}

.tss-pick-item.is-off .sw-tree-name {
  color: var(--text-muted);
}

.tss-pick-item.is-bad {
  box-shadow: inset 2px 0 0 var(--danger);
}

.tss-pick-empty {
  margin: 0;
  padding: 2px 6px;
  font-size: 12px;
  font-style: italic;
  color: var(--text-muted);
}

/* The add form in the rail: one field a line, its label above, as the
   rail's own fields. */
.setup-add.tss-rail-add {
  margin: 0;
  padding: 6px;
}

.tss-rail-add .setup-add-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.tss-rail-add .setup-fields {
  grid-template-columns: minmax(0, 1fr);
  gap: 4px;
}

.tss-rail-add .setup-add-actions {
  margin-top: 6px;
}

.tss-rail-add .setup-btn {
  height: 22px;
  padding: 0 10px;
  font-size: 12px;
}

/* The picked item's editor: its bands, then its table. */

.tss-ed[hidden] {
  display: none;
}

.tss-ed.setup-item-bad {
  box-shadow: inset 2px 0 0 var(--danger);
}

.tss-ed > .setup-empty,
.tss-body > .setup-empty,
.tss-editors > .setup-empty {
  margin: 6px 10px;
}

.tss-ed > .setup-issue,
.tss-ed > .setup-error,
.tss-ed > .setup-confirm,
.tss-body > .setup-error,
.tss-body > .setup-confirm,
.tss-body > .tss-note {
  margin: 6px 10px;
}

.sw-band .setup-input.tss-w-name {
  width: 220px;
}

.sw-band .setup-input.tss-w-num {
  width: 110px;
}

.sw-band .setup-input.tss-w-pct {
  width: 64px;
}

.sw-band .setup-input.tss-w-acct {
  width: 104px;
}

.sw-band .setup-check-label {
  font-size: 12px;
}

/* A pick that adds something reads as one of the band's buttons. */
.sw-band .setup-input.tss-picker,
.sw-band .setup-input.tss-chip-add {
  max-width: 180px;
  border-color: transparent;
  background: none;
  cursor: pointer;
}

.sw-band .setup-input.tss-picker:hover,
.sw-band .setup-input.tss-chip-add:hover {
  border-color: var(--border);
  background: var(--row-hover);
}

/* Chips: a credit's fringes left out of its spend. */

.tss-chipfield {
  flex: 1 1 auto;
}

.tss-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.tss-chips-empty {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

.tss-chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  max-width: 100%;
  height: 20px;
  padding: 0 2px 0 8px;
  font-size: 12px;
  border-radius: 10px;
  background: var(--selection);
  color: var(--text);
}

.tss-chip-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tss-chip-x {
  appearance: none;
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  padding: 0;
  font: inherit;
  font-size: 13px;
  line-height: 1;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.tss-chip-x:hover:not([aria-disabled="true"]) {
  color: var(--danger);
  background: var(--danger-bg);
}

.tss-chip-x:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.sw-band .setup-input.tss-chip-add {
  max-width: 140px;
}

/* Baseline: a change up or down */

.tss-up {
  color: var(--danger);
}

.tss-down {
  color: var(--accent);
}

/* Settings: groups of rows, each a fixed label column and the controls
   beside it, at the strip's control size. */

.ts-settings .tss-group {
  padding: 6px 10px 8px;
  border-bottom: 1px solid var(--border);
}

.tss-heading {
  margin: 0 0 2px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.ts-row {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  column-gap: 10px;
  align-items: center;
  min-height: 28px;
  padding: 1px 0;
}

.ts-row-label {
  font-size: 12.5px;
  color: var(--text);
  min-width: 0;
  overflow-wrap: anywhere;
}

.ts-row-label.ts-has-tip {
  cursor: help;
  text-decoration: underline dotted var(--text-muted);
  text-underline-offset: 3px;
}

.ts-row-ctl {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  min-width: 0;
}

.ts-row-ctl > .setup-field {
  gap: 4px;
}

.ts-settings .setup-input {
  height: 22px;
  font-size: 12px;
}

.ts-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.ts-inline-label {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.ts-hint {
  font-size: 11px;
  color: var(--text-muted);
  min-width: 0;
}

.ts-row-note {
  margin: 2px 0 0 230px !important;
}

.ts-pointer {
  min-height: 22px;
  display: flex;
  align-items: center;
  font-size: 12px;
}

.ts-row-ctl > .setup-input.ts-w-xs,
.ts-inline > .setup-input.ts-w-xs {
  width: 84px;
}

.ts-row-ctl > .setup-input.ts-w-s,
.ts-inline > .setup-input.ts-w-s {
  width: 110px;
}

.ts-row-ctl > .setup-input.ts-w-m {
  width: 180px;
}

.ts-row-ctl > .setup-input.ts-w-l {
  width: 280px;
}

.ts-settings .setup-hint-bad {
  margin-left: 230px;
}

.ts-settings .setup-error {
  margin-top: 2px;
}

.tss-example {
  font-size: 12px;
  white-space: nowrap;
}

.tss-example strong {
  font-weight: 600;
  margin-left: 4px;
}

@media (max-width: 560px) {
  .ts-row {
    grid-template-columns: minmax(0, 1fr);
    row-gap: 2px;
  }

  .ts-row-note,
  .ts-settings .setup-hint-bad {
    margin-left: 0 !important;
  }
}
