/* ══════════════════════════════════════════════════════════════════════════
   THE KIT — one look for every settings screen (Alex 10/27, audit
   ~/soda-audit/ux-audit-1027/3-kit.md; COO build plan 10/27 6:17 PM).
   Owner: Tab 7. Other screens USE these classes; they never restyle them.

   Loaded by index.html and admin.html right after switch.css; uses only
   tokens.css / accent.css tokens (admin loads no components.css), so the
   user app and admin look the same (design rule 10).

   K1 section       .kit-sec > .kit-sec-h + .kit-sec-sub      Title Case, never caps
   K2 setting row   .kit-row > .kit-label · switch · value · .kit-help
                    fixed columns, so every switch and box lines up down a page;
                    a row with no switch keeps the empty column (.kit-sw-none)
   K3 value box     .kit-val > input + .kit-unit              number and unit in ONE box
   K4 chips         .kit-chips > .kit-chip                    2-6 choices; the group hugs
                    its content (no empty tail); picked = filled (js/kit.js)
   K5 switch        .toggle (css/switch.css, unchanged)
   K6 help          .kit-help                                 one muted line under the row
   K7 required /    js/required-fields.js draws them; here only their place in a row:
      not used      Required = red box edge + "Required"; greyed = "Not used ..." —
                    never both (a greyed box is never marked)
   Account Stop     js/kit.js SodaKit.acctStop: backtests = switch + % box,
   Loss row         bots and cards = % box only (a bot always needs a %)
   Harness page: tools/ui_checks/kit/kit-sheet.html (check: kit_2026_10_27.js).
   ══════════════════════════════════════════════════════════════════════════ */
:root {
  --kit-label-w: 300px;     /* K2 columns: label · switch · value */
  --kit-sw-col: 56px;
  --kit-val-w: 184px;
  --kit-val-h: 40px;
}

/* ── K1 section ── */
.kit-sec {
  background: var(--ds-surface); border: 1px solid var(--ds-border); border-radius: var(--ds-r-lg, 12px);
  padding: 20px 22px 8px; margin: 0 0 16px;
}
.kit-sec-h { margin: 0; font-size: var(--ds-fs-16, 16px); font-weight: 600; letter-spacing: -.2px; color: var(--ds-text);
             text-transform: none; }
.kit-sec-sub { margin: 4px 0 10px; font-size: 12.5px; line-height: 1.45; color: var(--ds-muted); }

/* ── K2 setting row ── */
.kit-row {
  display: grid; align-items: center; column-gap: 16px;
  grid-template-columns: var(--kit-label-w) var(--kit-sw-col) var(--kit-val-w) minmax(0, 1fr);
  padding: 12px 0; border-top: 1px solid var(--ds-border);
}
.kit-sec-h + .kit-row, .kit-sec-sub + .kit-row, .kit-row.kit-first { border-top: 0; }
.kit-label {
  grid-column: 1; min-width: 0; display: flex; align-items: center; gap: 2px;
  font-size: 13.5px; font-weight: 500; line-height: 1.35; color: var(--ds-text); text-transform: none; letter-spacing: normal;
}
.kit-row > .toggle, .kit-row > .kit-sw-none { grid-column: 2; justify-self: start; }
.kit-row > .kit-val, .kit-row > .kit-ro, .kit-row > .kit-select { grid-column: 3; }
.kit-row > .kit-chips { grid-column: 2 / -1; }          /* chips start where the switch column starts */
/* everything under the line: help, Required, "Not used ...", Off notes — full width */
.kit-row > .kit-help, .kit-row > .req-note, .kit-row > .req-grey-note, .kit-row > .kit-below { grid-column: 1 / -1; }
.kit-ro { font-size: 13.5px; color: var(--ds-text); }

/* ── K3 value box: number | unit ── */
.kit-val {
  display: flex; align-items: stretch; box-sizing: border-box; width: 100%; height: var(--kit-val-h);
  border: 1px solid var(--ds-field-edge); border-radius: var(--ds-r-sm, 8px); overflow: hidden;
  background: var(--ds-bg); transition: border-color .15s;
}
.kit-val > input {
  flex: 1 1 auto; min-width: 0; width: auto; height: auto; margin: 0; padding: 0 12px;
  border: 0; border-radius: 0; background: transparent; box-shadow: none; color: var(--ds-text);
  font: inherit; font-size: var(--ds-fs-14, 14px); font-variant-numeric: tabular-nums;
}
.kit-val > input:focus { outline: none; }
.kit-val:focus-within { border-color: var(--ds-accent); box-shadow: var(--ds-focus-ring); }
.kit-unit {
  display: flex; align-items: center; flex: 0 0 auto; padding: 0 12px; white-space: nowrap;
  font-size: var(--ds-fs-12, 12px); font-weight: 500; color: var(--ds-muted);
  background: var(--ds-hover); border-left: 1px solid var(--ds-border);
}
.kit-unit:empty { display: none; }
.kit-val:has(> input.bt-input-invalid) { border-color: var(--ds-danger); }      /* K7 Required (required-fields.js) */
.kit-val:has(> input:disabled) { opacity: .45; }
.kit-val:has(> input:disabled) > input { cursor: not-allowed; }
.req-greyed .kit-val:has(> input:disabled) { opacity: 1; }   /* a box INSIDE a greyed wrapper: one fade (the wrapper's), not two */
.kit-select {
  box-sizing: border-box; width: 100%; height: var(--kit-val-h); padding: 0 10px;
  border: 1px solid var(--ds-field-edge); border-radius: var(--ds-r-sm, 8px);
  background: var(--ds-bg); color: var(--ds-text); font: inherit; font-size: var(--ds-fs-14, 14px);
}

/* ── K4 chips: the group hugs its content, never stretches (Alex 6:30 PM: no empty tail) ──
   Two sources, one look: SodaKit.chipsFromSelect (a <select>) and SodaKit.dressGroup (an existing button
   group, e.g. .bt-toggle-grp / .bt-toggle-opt with .active, its "Not set" = .unset on the group). The
   doubled class (.kit-chips.kit-chips) outranks the older group rules (components.css / ds-components.css)
   without !important. */
.kit-chips.kit-chips {
  display: inline-flex; flex-wrap: wrap; gap: 6px;
  width: fit-content; max-width: 100%; justify-self: start; align-self: center;
  margin: 0; padding: 0; border: 0; border-radius: 0; overflow: visible; background: transparent; outline: none; box-shadow: none;
}
.kit-chips.kit-chips .kit-chip {
  flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box;
  height: 32px; min-height: 0; padding: 0 14px; margin: 0; min-width: 0; width: auto;
  border: 1px solid var(--ds-border-strong); border-radius: var(--ds-r-pill, 999px);
  background: transparent; color: var(--ds-text); font: inherit; font-size: var(--ds-fs-13, 13px); font-weight: 500;
  white-space: nowrap; cursor: pointer; position: relative;
  transition: background-color .15s, border-color .15s, color .15s, transform .1s;
}
.kit-chips.kit-chips .kit-chip:hover { background: var(--ds-hover); }
.kit-chips.kit-chips .kit-chip:active { transform: scale(.97); }
.kit-chips.kit-chips .kit-chip:is([aria-checked="true"], .active) {
  background: var(--ds-sel-fill); border-color: var(--ds-sel-fill); color: var(--ds-on-sel-fill); font-weight: 600;
}
.kit-chips.kit-chips .kit-chip:focus { outline: none; }
.kit-chips.kit-chips .kit-chip:focus-visible { box-shadow: var(--ds-focus-ring); }
/* 40px tap target around a 32px chip (invisible) */
.kit-chips.kit-chips .kit-chip::before { content: ''; position: absolute; left: 0; right: 0; top: 50%; width: auto;
  height: max(100%, var(--ds-tap, 40px)); transform: translateY(-50%); }
.kit-chips.kit-chips[aria-disabled="true"] { opacity: .45; }
.kit-chips.kit-chips[aria-disabled="true"] .kit-chip { cursor: not-allowed; }
/* K7 on chips: nothing picked and required -> every chip dashed red (never a box around the group) */
.kit-chips.kit-chips:is(.bt-input-invalid, .unset) .kit-chip { border-color: var(--ds-danger); border-style: dashed; }

/* ── K6 help ── */
.kit-help { margin-top: 6px; font-size: var(--ds-fs-12, 12px); line-height: 1.45; color: var(--ds-muted); }
.kit-row > .req-note, .kit-row > .req-grey-note { margin-top: 6px; }

/* ── Account Stop Loss row (SodaKit.acctStop): switch + % on one line ── */
.kit-acct { display: flex; align-items: center; gap: 16px; }
.kit-acct > .toggle { flex: 0 0 auto; }
.kit-acct > .kit-val, .kit-acct > :is(.bt-input-wrap, .s-input-wrap, .abt-input-wrap, .sm-inwrap) { flex: 0 1 var(--kit-val-w); min-width: 0; }
/* inside a kit row it takes the switch + value columns, so it lines up with every other row */
.kit-row > .kit-acct { grid-column: 2 / 4; display: grid; grid-template-columns: var(--kit-sw-col) minmax(0, 1fr); column-gap: 16px; }
.kit-row > .kit-acct > .toggle { justify-self: start; }
/* Off: the box greyed (value kept), the switch stays bright and clickable */
.kit-acct.is-off > :not(.toggle) { opacity: .45; }
.kit-acct.is-off > .kit-val:has(> input:disabled) { opacity: .45; }

@media (prefers-reduced-motion: reduce) {
  .kit-chips.kit-chips .kit-chip, .kit-val { transition: none; }
  .kit-chips.kit-chips .kit-chip:active { transform: none; }
}

/* Phones: label + switch on line 1, the box (or chips) full width on line 2 */
@media (max-width: 600px) {
  .kit-sec { padding: 16px 16px 6px; }
  .kit-row { grid-template-columns: minmax(0, 1fr) auto; row-gap: 10px; column-gap: 12px; }
  .kit-row > .toggle, .kit-row > .kit-sw-none { grid-column: 2; justify-self: end; }
  .kit-row > .kit-val, .kit-row > .kit-ro, .kit-row > .kit-select, .kit-row > .kit-chips { grid-column: 1 / -1; }
  .kit-row > .kit-val, .kit-row > .kit-select { width: 100%; }
  .kit-acct > .kit-val, .kit-acct > :is(.bt-input-wrap, .s-input-wrap, .abt-input-wrap, .sm-inwrap) { flex: 1 1 auto; }
  /* the Account Stop row lays out like every other row: switch on line 1, the % box full width on line 2 */
  .kit-row > .kit-acct { display: contents; }
  .kit-row > .kit-acct > .toggle { grid-column: 2; grid-row: 1; justify-self: end; }
  .kit-row > .kit-acct > :not(.toggle) { grid-column: 1 / -1; width: 100%; }
}
