/* form_kit.css -- the form kit: ONE look for every form (UX2, wave 1, 01/12/2026; docs/GUIDE_form_kit.md, docs/design/ux2/DESIGN_LANGUAGE.md).
   Narkis 01/12: "אחידות שיטה, לוגיקה זהה בטפסים". Loaded after style.css; it uses the application's own tokens (--bg --surface --border --text
   --muted --accent --success --danger --warning --radius) and adds only its own, prefixed --fk-*. Classes .fk-* only (the budget screen
   already has a .u-row of its own), so a page that does not use the kit is not touched.
   The one colour change of the language (DECISIONS 01/12, decision 2): the primary button is #2563eb -- white on it is 5.17:1 (#3b82f6 is 3.68:1).
   A colour never stands alone: every state has a sign (✓ ! ✕ 🔒) and words.
   Numbers, amounts, dates, codes: left to right inside the right-to-left page (.fk-num, and the kit sets dir="ltr" on such inputs). */

:root {
  --fk-primary: var(--primary, #2563eb);          /* ONE source: style.css --primary (T17 03/12, ח10); the fallback for a page without style.css */
  --fk-primary-h: var(--primary-h, #1d4ed8);
  --fk-on-primary: var(--on-primary, #ffffff);   /* ONE source: style.css --on-primary (T17 04/12, manager 14); the fallback for a page without style.css */
  --fk-ok: var(--success);
  --fk-warn: var(--warning);
  --fk-err: var(--danger);
  --fk-err-bg: var(--danger-bg);
  --fk-warn-bg: var(--warning-bg);
  --fk-ok-bg: var(--success-bg);
  --fk-focus: var(--focus);
  --fk-shadow: var(--shadow-lg);
}
/* the light theme: in style.css, the one place of both themes (UX2 03/12, ח1) -- the kit's tokens above follow it */

[hidden] { display: none !important; }
.fk-num { direction: ltr; unicode-bidi: isolate; font-variant-numeric: tabular-nums; }

/* ── the form and its rows ─────────────────────────────────────────────────────────────────────────────────────────────── */
.fk-form { display: flex; flex-direction: column; gap: 1rem; }
.fk-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .9rem 1rem; align-items: start; }
.fk-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius, 10px); padding: 1rem 1.1rem; }
.fk-section > h2, .fk-section > h3 { font-size: 1rem; margin: 0 0 .8rem; }

/* ── one field: label, control, hint, message ──────────────────────────────────────────────────────────────────────────── */
.fk-field { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.fk-field > label, .fk-label { font-size: .88rem; font-weight: 600; color: var(--text); }
.fk-field.is-required > label::after { content: ' *'; color: var(--fk-err); }
.fk-field input:not([type=checkbox]):not([type=radio]), .fk-field select, .fk-field textarea, .fk-input {
  width: 100%; min-height: 40px; padding: .5rem .7rem; font: inherit; font-size: .95rem; color: var(--text);
  background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; outline: none;
}
.fk-field textarea { min-height: 72px; resize: vertical; }
.fk-field input:focus-visible, .fk-field select:focus-visible, .fk-field textarea:focus-visible,
.fk-btn:focus-visible, .fk-dialog button:focus-visible { outline: 2px solid var(--fk-focus); outline-offset: 2px; }
.fk-field input[readonly], .fk-field input:disabled, .fk-field select:disabled, .fk-field textarea[readonly] { opacity: .75; cursor: default; }
.fk-hint { font-size: .8rem; color: var(--muted); }
.fk-msg { font-size: .82rem; min-height: 0; display: flex; gap: .35rem; align-items: baseline; }
.fk-msg:empty { display: none; }
.fk-field.is-err input, .fk-field.is-err select, .fk-field.is-err textarea { border-color: var(--fk-err); background: var(--fk-err-bg); }
.fk-field.is-warn input, .fk-field.is-warn select { border-color: var(--fk-warn); }
.fk-field.is-ok input, .fk-field.is-ok select { border-color: var(--fk-ok); }
.fk-field.is-err .fk-msg { color: var(--fk-err); }
.fk-field.is-err .fk-msg::before { content: '✕'; font-weight: 700; }
.fk-field.is-warn .fk-msg { color: var(--fk-warn); }
.fk-field.is-warn .fk-msg::before { content: '!'; font-weight: 700; }
.fk-field.is-ok .fk-msg { color: var(--fk-ok); }
.fk-field.is-ok .fk-msg::before { content: '✓'; font-weight: 700; }
.fk-field.is-checking .fk-msg::before { content: '…'; }
/* a check (data-fk="check"): the box inside its label, on one line; the message under it, as in every field */
.fk-field.fk-check > label { display: inline-flex; align-items: center; gap: .5rem; font-weight: 500; cursor: pointer; min-height: 40px; }
.fk-field.fk-check input[type=checkbox] { width: 18px; height: 18px; margin: 0; accent-color: var(--fk-focus); cursor: pointer; flex: none; }
.fk-field.fk-check input[type=checkbox]:focus-visible { outline: 2px solid var(--fk-focus); outline-offset: 2px; }
.fk-field.fk-check.is-required > label::after { content: ' *'; color: var(--fk-err); }
.fk-field.fk-check.is-err > label { color: var(--fk-err); }

/* money: the ₪ sits on the physical left of the number, as it is printed */
.fk-affix { position: relative; display: block; }
.fk-affix > input { padding-left: 2rem !important; text-align: left; }
.fk-affix > .fk-cur { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; font-size: 1.1rem; font-weight: 600; }
.fk-affix.fk-unit > input { padding-left: 3.4rem !important; }       /* area "מ"ר" / percent "%": a word, wider than the ₪ (T5 02/12) */
.fk-affix.fk-unit > .fk-cur { font-size: .9rem; }
.fk-field[data-wide] .fk-affix > input, .fk-money-wide { font-size: 1.15rem; font-weight: 700; min-height: 46px; }

/* a period: ‹ MM/YYYY › */
.fk-period { display: flex; align-items: stretch; gap: .3rem; }
.fk-period > input { text-align: center; }
.fk-period > button { min-width: 40px; border: 1px solid var(--border); background: var(--surface2); color: var(--text); border-radius: 8px; cursor: pointer; font-size: 1.1rem; }
.fk-period > button:hover { background: var(--surface3, var(--surface2)); }

/* a consumer: the existing ConsumerPicker field (static/consumer_picker.js) inside, the choice as a chip */
.fk-field .cp-field { position: relative; }
.fk-field .cp-box { border-radius: 8px !important; box-shadow: var(--fk-shadow); }
@media (min-width: 641px) { .fk-field .cp-box { min-width: 440px; } }     /* a narrow column: the rows have room; on a phone the box is the field's width */
.fk-field .cp-row:focus, .fk-field .cp-row:hover { background: var(--surface3, var(--surface2)); outline: none; }
.fk-pick { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .7rem; font-size: .84rem; color: var(--muted); }
.fk-pick:empty { display: none; }
.fk-pick b { color: var(--text); }

/* ── buttons: ONE primary action per form; the rest are plain or under "עוד" ───────────────────────────────────────────── */
.fk-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }
.fk-actions .fk-spacer { flex: 1; }
/* ── ONE layout of buttons: the same button in the same place (Narkis 03/12; docs/GUIDE_form_kit.md §3a) ─────────────────────────────────────
   The bar orders itself by role, whatever the order in the markup (right to left): the primary -- secondary -- "עוד ▾" -- cancel at the left end.
   The same in the footer of every window of the kit (.fk-df: confirm, ask). */
.fk-actions > *, .fk-df > * { order: 2; }
.fk-actions > .fk-primary, .fk-df > .fk-primary { order: 1; }
.fk-actions > .kl-more, .fk-df > .kl-more { order: 3; }
.fk-actions > .fk-spacer { order: 4; }
.fk-actions > .fk-cancel, .fk-df > .fk-cancel { order: 5; margin-inline-start: auto; }
/* the page head: the title on the right; "עוד ▾" and "← לרשימת ה…" on the left, the back last -- its top-left corner */
.fk-page-head { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem; margin-bottom: 1rem; }
.fk-page-head > h1 { font-size: 1.35rem; margin: 0; }
.fk-page-head::after { content: ''; order: 89; flex: 1 1 0; }          /* the space between the title and the tools */
.fk-page-head > .kl-more { order: 90; }
.fk-page-head > .fk-back { order: 91; }
.fk-back { flex: 0 0 auto; white-space: nowrap; }
/* ── the receipt pattern (DECISIONS 03/12; GUIDE §3ב): the numbered step (.fk-step-num), and the supplier field ──────────────────────────────────────────── */
.fk-step-num { display: inline-flex; width: 1.6rem; height: 1.6rem; align-items: center; justify-content: center; flex: 0 0 auto; border-radius: 50%;
  background: var(--fk-primary); color: var(--fk-on-primary); font-size: .85rem; font-weight: 700; }      /* the receipt's .rn-step, now the kit's -- NOT .fk-step, which is a step of the bar (FormKit.steps) */
.fk-sup { position: relative; }
.fk-sup-box { position: absolute; inset-inline: 0; top: calc(100% + 2px); z-index: 10060; max-height: 240px; overflow: auto; background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--fk-shadow); }
.fk-sup-box > [data-i] { padding: .6rem .8rem; border-bottom: 1px solid var(--border); cursor: pointer; }
.fk-sup-box > [data-i]:hover, .fk-sup-box > [data-i]:focus { background: var(--surface2); outline: none; }
.fk-sup-box small { color: var(--muted); }
.fk-btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 40px; padding: .45rem 1rem; font: inherit; font-size: .92rem;
  font-weight: 600; color: var(--text); background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; cursor: pointer; text-decoration: none; }
.fk-btn:hover { background: var(--surface3, var(--surface2)); }
.fk-btn:disabled { opacity: .55; cursor: not-allowed; }
.fk-btn.fk-primary { background: var(--fk-primary); border-color: var(--fk-primary); color: var(--fk-on-primary); }
.fk-btn.fk-primary:hover:not(:disabled) { background: var(--fk-primary-h); }
.fk-btn.fk-ghost { background: transparent; border-color: transparent; color: var(--accent); }
.fk-btn.fk-danger { color: var(--fk-err); }
.fk-btn[aria-busy="true"]::before { content: ''; width: 1em; height: 1em; border-radius: 50%; border: 2px solid currentColor; border-left-color: transparent; animation: fk-spin .8s linear infinite; }
@keyframes fk-spin { to { transform: rotate(360deg); } }
.fk-kbd { font-size: .72rem; font-weight: 600; padding: .05rem .35rem; border: 1px solid currentColor; border-color: color-mix(in srgb, currentColor 55%, transparent);
          border-radius: 4px; direction: ltr; unicode-bidi: isolate; }   /* the text in the button's own colour (white on the primary 5.17:1); only the frame is quieter --
                                                                            not an opacity on the text: .7 made it 3.34 (T17's QA of round 22, #13) */
.fk-multi .fk-form:not(.fk-active) .fk-kbd-save { display: none; }       /* several forms on a page: "Ctrl S" only where Ctrl+S goes (ח6) */
/* "עוד ▾": the menu that exists (<details class="kl-more">, style.css; one closing script for the whole system in _topbar.html) -- not a second one */

/* ── the form's states: the list of what is missing, the error from the server ────────────────────────────────────────── */
.fk-alert { border: 1px solid var(--border); border-inline-start: 4px solid var(--fk-err); background: var(--fk-err-bg); border-radius: 8px; padding: .7rem .9rem; font-size: .9rem; }
.fk-alert:empty { display: none; }
.fk-alert.is-warn { border-inline-start-color: var(--fk-warn); background: var(--fk-warn-bg); }
.fk-alert b { display: block; margin-bottom: .3rem; }
.fk-alert ul { margin: 0; padding-inline-start: 1.1rem; }
.fk-alert li { margin: .15rem 0; }
.fk-alert button { background: none; border: 0; padding: 0; font: inherit; color: inherit; text-decoration: underline; cursor: pointer; }
.fk-form[aria-busy="true"] .fk-field { opacity: .8; }

/* ── the confirm window (an action that cannot be undone) ──────────────────────────────────────────────────────────────── */
dialog.fk-dialog { margin: auto; width: min(480px, calc(100vw - 32px)); padding: 0; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--fk-shadow); }
dialog.fk-dialog::backdrop, dialog.fk-palette::backdrop { background: rgba(0, 0, 0, .55); }
.fk-dialog .fk-dh { display: flex; align-items: center; gap: .6rem; padding: 1rem 1.1rem .4rem; }
.fk-dialog .fk-dh h2 { font-size: 1.05rem; margin: 0; }
.fk-dialog .fk-db { padding: .3rem 1.1rem 1rem; font-size: .92rem; line-height: 1.55; }
.fk-dialog .fk-df { display: flex; gap: .6rem; padding: .8rem 1.1rem; border-top: 1px solid var(--border); flex-wrap: wrap; }

/* ── after: the success message, and a produced document 🔒 ──────────────────────────────────────────────────────────── */
.fk-toast-box { position: fixed; inset-inline-start: 50%; transform: translateX(50%); bottom: 1.2rem; z-index: 10100; display: flex; flex-direction: column; gap: .5rem; width: min(520px, calc(100vw - 32px)); }
.fk-toast { display: flex; gap: .6rem; align-items: flex-start; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-inline-start: 4px solid var(--fk-ok);
  border-radius: 8px; padding: .7rem .9rem; box-shadow: var(--fk-shadow); font-size: .92rem; }
.fk-toast.is-err { border-inline-start-color: var(--fk-err); }
.fk-toast > span:first-child { font-weight: 700; color: var(--fk-ok); }
.fk-toast.is-err > span:first-child { color: var(--fk-err); }
.fk-toast a { color: var(--accent); }
.fk-doc { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius, 10px); }
.fk-doc-lock { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .8rem; padding: .6rem .9rem; background: var(--surface2); border-bottom: 1px solid var(--border);
  border-radius: var(--radius, 10px) var(--radius, 10px) 0 0; font-size: .86rem; color: var(--muted); }
.fk-doc-lock b { color: var(--text); }
.fk-doc-body { padding: .9rem 1rem; }

/* ── find a consumer from anywhere: Ctrl+K, "/" or F2 ─────────────────────────────────────────────────────────────────── */
dialog.fk-palette { margin: 10vh auto auto; width: min(620px, calc(100vw - 32px)); padding: 0; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--fk-shadow); }
.fk-palette input { width: 100%; border: 0; border-bottom: 1px solid var(--border); background: transparent; color: var(--text); font: inherit; font-size: 1.05rem; padding: .9rem 1rem; outline: none; }
.fk-palette .fk-list { max-height: 50vh; overflow: auto; padding: .3rem; }
.fk-palette .fk-opt { display: flex; justify-content: space-between; gap: .6rem; padding: .6rem .7rem; border-radius: 8px; cursor: pointer; }
.fk-palette .fk-opt[aria-selected="true"] { background: var(--surface2); outline: 1px solid var(--fk-focus); }
.fk-palette .fk-opt small { color: var(--muted); }
.fk-palette .fk-empty { padding: 1rem; text-align: center; color: var(--muted); font-size: .9rem; }
.fk-palette .fk-foot { display: flex; flex-wrap: wrap; gap: .4rem 1rem; padding: .5rem .9rem; border-top: 1px solid var(--border); font-size: .78rem; color: var(--muted); }

@media (max-width: 640px) {
  .fk-row { grid-template-columns: 1fr; }
  .fk-actions > .fk-btn.fk-primary { flex: 1 1 100%; }
  .fk-page-head::before { content: ''; order: -1; flex-basis: 100%; }      /* 390: the back on a first line of its own, on the left; the title under it */
  .fk-page-head > .fk-back { order: -2; margin-inline-start: auto; }
  .fk-kbd { display: none; }
}
@media (prefers-reduced-motion: reduce) { .fk-btn[aria-busy="true"]::before { animation: none; } }
/* the steps of a process (DESIGN_LANGUAGE component 13 -- .u-steps of docs/design/ux2, on the kit's own tokens; manager 14, 02/12: ONE steps component in
   the system -- .kl-steps of style.css goes once nothing uses it). FormKit.steps draws it: a sign AND a word per state (✓ ! ✕), the current step
   aria-current="step", a step that can be opened is a button (Tab, Enter / Space). .fk-steps-sm: the thin line above the tabs of a screen. */
.fk-steps { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; list-style: none; margin: 0; padding: 0; }
.fk-steps li { display: flex; }
.fk-steps li > .fk-step { display: inline-flex; align-items: center; gap: 8px; padding: .35rem .65rem; border-radius: 8px; background: var(--surface);
  border: 1px solid var(--border); color: var(--muted); font: inherit; font-size: .82rem; font-weight: 600; white-space: nowrap; }
.fk-steps button.fk-step { cursor: pointer; }
.fk-steps button.fk-step:hover { border-color: var(--accent); color: var(--text); }
.fk-steps button.fk-step:focus-visible { outline: 2px solid var(--fk-focus); outline-offset: 2px; }
.fk-step-d { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--surface2); color: var(--text);
  font-size: .75rem; font-weight: 700; flex: none; }
.fk-steps li[aria-current="step"] > .fk-step { border-color: var(--fk-primary); color: var(--text); }
.fk-steps li[aria-current="step"] .fk-step-d { background: var(--fk-primary); color: var(--fk-on-primary); }
.fk-steps li.is-done > .fk-step { color: var(--fk-ok); }
.fk-steps li.is-done .fk-step-d { background: var(--fk-ok-bg); color: var(--fk-ok); }
.fk-steps li.is-warn .fk-step-d { background: var(--fk-warn-bg); color: var(--fk-warn); }
.fk-steps li.is-block > .fk-step { color: var(--fk-err); border-color: var(--fk-err); }
.fk-steps li.is-block .fk-step-d { background: var(--fk-err-bg); color: var(--fk-err); }
.fk-steps li.is-off > .fk-step { opacity: .65; }
.fk-steps-sm li > .fk-step { padding: .1rem .5rem; gap: 6px; font-size: .76rem; }
.fk-steps-sm .fk-step-d { width: 17px; height: 17px; font-size: .66rem; }

