/* ===========================================================================
   Form controls
   =========================================================================== */

.field { display: block }
.field + .field, .field__err + .field { margin-top: 16px }
/* What is wrong with the value in the field above, said in a few words. */
.field__err { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 12.5px; color: var(--bad) }
.field__err .ms { font-size: 16px }
.field__err:empty { display: none }
.field__label { font-size: 12.5px; font-weight: 500; color: var(--muted); margin-bottom: 6px; display: flex; align-items: baseline; justify-content: space-between; gap: 12px }
.field__label b { font-size: 12px; font-weight: var(--weight-strong); color: var(--text); cursor: pointer }

/* --- Soft fill ------------------------------------------------------------
   Fields are a grey well with a hairline, no border to speak of until you
   are in one; then white with a 1.5px deep-teal edge, and no glow (Rob,
   11 Nov 2026). Picked
   by Rob from six candidates on 11 Nov 2026 (design/inputs.html, "Soft fill
   v2"; Mobbin: Heidi, Lightfield, Attio). The states live in
   css/interaction.css ("fields"), with the other controls' states.

   - The focus edge is the accent darkened by 30% (#00897E on Candid's own
     teal, 4.3:1 on white), drawn 1.5px; the plain accent was 2.2:1.
   - On the page grey a grey well vanishes (1.08:1), so a field sitting on
     the grey turns white ("on the page grey" below).
   - Disabled loses the well for a dashed edge, so it is never mistaken for
     an empty field. */
:root {
  --field: #EEF1F0;
  --field-hover: color-mix(in srgb, var(--field), var(--ink-fixed) 5%);
  --field-edge: rgba(16, 33, 31, .08);
  --field-edge-hover: rgba(16, 33, 31, .16);
  --field-focus: color-mix(in srgb, var(--teal) 70%, #000);
  --field-ph: #5F6564;
}

.input, .textarea, .select {
  width: 100%;
  border: 1px solid var(--field-edge);
  border-radius: var(--r-input);
  padding: 11px 14px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
  color: var(--text);
  background: var(--field);
  outline: none;
}
.input[aria-invalid="true"], .textarea[aria-invalid="true"], .select[aria-invalid="true"] {
  border-color: var(--bad); background: color-mix(in srgb, var(--bad) 7%, var(--card));
}

/* On the page grey: a drawer's grey body and the rows that sit in it
   (.dealsbar, the Contacts tab's finder). */
:is(.dealsbar, .notesbar) :is(.input, .select, .textarea),
.drawer__body > :is(.input, .select, .textarea) {
  --field: var(--card);
  --field-hover: var(--card);
  --field-edge: rgba(16, 33, 31, .10);
  --field-edge-hover: rgba(16, 33, 31, .20);
}

/* --- dropdowns ------------------------------------------------------------
   Every select.select / select.input becomes a button drawn as the field and
   a listbox drawn as the app's menus (app/select-menu.js). The native select
   stays in the page, hidden, holding the value. */
.selnative { display: none !important }
.selbtn {
  display: flex; align-items: center; gap: 8px;
  text-align: left; cursor: pointer;
}
/* The select's name, for aria-labelledby only: the visible label says it. */
.selbtn__name { display: none }
.selbtn__val { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
/* "Any stage", "Pick a stage": the empty choice reads as a placeholder. */
.selbtn.is-empty .selbtn__val { color: var(--field-ph) }
.selbtn__chev.ms { margin-right: -4px; font-size: 18px; color: var(--muted); transition: transform .16s ease-out }
.selbtn[aria-expanded="true"] .selbtn__chev { transform: rotate(180deg) }
/* A filter that is on is tinted, so the set ones stand out in a row of
   "Any …" (Companies; the order picker beside them always has a value and
   is left plain). */
.table__filters > .selbtn:not(.is-empty):not([aria-expanded="true"]):not(:focus) {
  background-color: color-mix(in srgb, var(--teal) 16%, var(--card));
  border-color: color-mix(in srgb, var(--teal) 30%, transparent);
  font-weight: 500;
}
.selmenu { max-height: min(60vh, 360px); overflow-y: auto; outline: none; max-width: min(360px, calc(100vw - 16px)) }
.selmenu__item { font-weight: 500 }
.selmenu__item[aria-selected="true"] { font-weight: var(--weight-strong) }
.selmenu__item.is-active { background: var(--page) }
.selmenu__item[aria-disabled="true"] { opacity: .4; cursor: default; background: none }
.selmenu__word { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.latermenu__item .selmenu__tick.ms { margin-left: auto; padding-left: 16px; color: var(--text) }
.selmenu__head { padding: 8px 10px 4px; font-size: 12px; font-weight: 500; color: var(--muted) }
@media (pointer: coarse) { .selmenu__item { height: 44px } }
@media (prefers-reduced-motion: reduce) { .selbtn__chev.ms { transition: none } }
/* A password box with an eye at its end (passwordInput in app/auth.js). The
   eye is the full height of the box and 44px wide, so it is easy to hit. */
.pwfield { position: relative }
.pwfield .input { padding-right: 48px }
.pwfield .input::-ms-reveal { display: none }
.pwfield__eye {
  position: absolute; top: 0; right: 0; width: 44px; height: 100%;
  display: grid; place-items: center; padding: 0; border: 0; background: none;
  border-radius: var(--r-input); color: var(--muted); cursor: pointer;
  transition: color .16s ease;
}
.pwfield__eye:hover { color: var(--text) }
.pwfield__eye:focus-visible { outline: 2px solid var(--teal); outline-offset: -4px }
.pwfield__eye .ms { font-size: 20px }
/* No scrollbar and no grab handle: the field is sized to its text by autosize()
   in app.js, so a scrollbar would only ever appear mid-keystroke and dragging
   the corner would be undone by the next one. min-height still sets the floor. */
.textarea { min-height: 120px; resize: none; overflow-y: hidden; line-height: 1.6 }

/* --- a field beside a button ---------------------------------------------
   A field left alone is as tall as its padding makes it, with squarer corners
   than a button, so the two never matched in a row. A one-line field that
   shares a row with a button takes the button's height and corner, found
   from the markup so a new row gets it without a rule of its own. A stacked
   form (each field in its .field wrapper) and a textarea keep their own. */
:is(.input, .select):not(textarea):is(
  :has(~ :is(.btn, .iconbtn, .filterbtn):not(.btn--block)),
  :is(.btn, .iconbtn, .filterbtn):not(.btn--block) ~ *
),
.editinfo__affix:is(
  :has(~ :is(.btn, .iconbtn, .filterbtn):not(.btn--block)),
  :is(.btn, .iconbtn, .filterbtn):not(.btn--block) ~ *
) > .input,
.salestep__pick > .select:not(textarea) {
  height: var(--control-h);
  padding-block: 0;
  border-radius: var(--r-btn);
}
/* A select the app hasn't upgraded (the platform console, data-native)
   keeps the browser's list, but not its arrow: the browser's sits too close
   to the end of the field and doesn't match the upgraded ones, so draw one
   with room around it. */
select:is(.input, .select) {
  appearance: none; -webkit-appearance: none;
  padding-right: 34px;
  /* A file-free chevron in --muted, which a background image cannot read. */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%236B6B6B' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-position: right 13px center;
  background-size: 16px 16px;
  background-repeat: no-repeat;
  cursor: pointer;
}

/* --- checkbox ------------------------------------------------------------
   A <button role="checkbox"> rather than a div with a click handler: Space,
   Enter, a focus ring and a state a screen reader can announce all come free,
   and none of them are worth re-implementing by hand.

   The tick is drawn here rather than set in Material Symbols. The icon font is
   requested with its weight axis pinned at 400, so at 14px the glyph is a
   hairline that antialiases to grey against the filled box — the tick in the
   sign-in form read as smudged rather than as checked. Two borders on a
   rotated box give a stroke thick enough to survive at that size, and one that
   can be sprung in rather than faded.
   ------------------------------------------------------------------------- */
.check {
  display: inline-flex; align-items: center; gap: 10px;
  margin: 16px 0 0 -7px; padding: 7px;
  border: 0; border-radius: 10px; background: none;
  font: inherit; color: inherit; text-align: left;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: background .16s ease;
}
.check:hover { background: color-mix(in srgb, var(--ink) 5%, transparent) }
.check:focus-visible { outline: 2px solid var(--teal); outline-offset: 1px }

.check__box {
  width: 20px; height: 20px; flex: 0 0 20px;
  border: 1.5px solid var(--line); border-radius: 6px;
  display: grid; place-items: center;
  background: var(--card); color: var(--on-ink);
  transition: background .16s ease, border-color .16s ease, transform .16s ease;
}
.check:hover .check__box { border-color: var(--ink) }
.check:active .check__box { transform: scale(.92) }
.check[data-on="1"] .check__box { background: var(--ink); border-color: var(--ink) }

/* The tick: a 5×9 box turned 45°, keeping only the two borders that make the
   stroke. Rotating puts the ink's centre 2.3px below the element's, which the
   negative margin takes back out — otherwise the tick sits low in the box. */
.check__box::after {
  content: ""; width: 5px; height: 9px; margin-top: -2px;
  border: 2px solid currentColor; border-top: 0; border-left: 0;
  border-radius: 1px;
  transform: rotate(45deg) scale(.4); opacity: 0;
  transition: transform .2s cubic-bezier(.2, 1.4, .4, 1), opacity .1s ease;
}
.check[data-on="1"] .check__box::after { transform: rotate(45deg) scale(1); opacity: 1 }

.check > span:last-child { font-size: 12.5px; color: var(--muted); transition: color .16s ease }
.check[data-on="1"] > span:last-child { color: var(--text) }

/* --- buttons ------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--r-btn);
  /* Height is set, not inferred from padding. A button with an 18px icon in it
     is otherwise two pixels taller than the same button without one, which is
     why these never lined up. --control-h matches .iconbtn and the top bar's
     own controls, so any of them can share a row.

     The transparent border is load-bearing too: it keeps a ghost button exactly
     as tall as a solid one, which the design itself gets wrong by 2px. */
  height: var(--control-h);
  padding: 0 24px;
  line-height: 1;
  font-family: inherit;
  font-size: 13px;
  font-weight: var(--weight-strong);
  letter-spacing: -.005em;
  white-space: nowrap;
  cursor: pointer;
  background-color: var(--ink);
  color: var(--on-ink);
  transition: opacity .16s ease, border-color .16s ease, background .16s ease;
}
/* A leading icon carries optical weight of its own, so the side it sits on
   needs less air for the label to look centred. A channel logo (liMark,
   waMark: an svg or .mark) counts as the icon. */
.btn:has(> :is(.ms, svg, .mark):first-child) { padding-left: 20px }
/* A trailing icon (a chevron, an arrow) takes the same off its own side. */
.btn:has(> :is(.ms, svg, .mark):last-child:not(:first-child)) { padding-right: 20px }
.btn:disabled { opacity: .45; cursor: not-allowed }
/* Three sizes on the 4px grid (design/corners-and-spacing.md, "Buttons"):
   the side with the icon has 4px less air than the other, because the icon
   carries weight of its own.
     standard  --control-h  24 / 20  icon 18  gap 8   --r-btn
     small     --control-h  20 / 16  icon 16  gap 6   --r-btn  (toolbars and
               rows, where it stands beside fields and icon buttons, so it
               keeps their height and is smaller in its padding and type)
     large     44           28 / 24  icon 20  gap 8   --r-btn  (dialog
               footers, the save bar: the one decision on the screen) */
.btn--lg { height: max(44px, var(--control-h)); padding: 0 28px; font-size: 14px }
.btn--lg:has(> :is(.ms, svg, .mark):first-child) { padding-left: 24px }
.btn--lg:has(> :is(.ms, svg, .mark):last-child:not(:first-child)) { padding-right: 24px }
.btn.btn--lg .ms { font-size: 20px }
.btn--block { width: 100%; height: 46px; padding: 0 22px; font-size: 14px }
.btn--ghost {
  background-color: var(--card); color: var(--text); border-color: var(--btn-edge);
}
.btn--teal { background-color: var(--teal); color: var(--on-teal) }
.btn--sm { height: var(--control-h); padding: 0 20px; gap: 6px; font-size: 12.5px }
.btn--sm:has(> :is(.ms, svg, .mark):first-child) { padding-left: 16px }
.btn--sm:has(> :is(.ms, svg, .mark):last-child:not(:first-child)) { padding-right: 16px }
.btn.btn--sm .ms { font-size: 16px }
/* Two labels live in the markup and exactly one is ever displayed, so a
   screen reader reads one. The short one waits for the phone breakpoint. */
.btn__short { display: none }
.btn .ms { font-size: 18px }
/* On a white button the icon sits a step under the label, so the word leads. */
.btn--ghost .ms { color: color-mix(in srgb, currentColor 72%, var(--card)) }

.btn__spin {
  width: 15px; height: 15px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: var(--r-pill);
  animation: cdSpin .7s linear infinite;
}

/* The field being written in place (inField in app/shared-pieces.js), as
   Lovable's edit bar and Zoho's note box hold their actions: one box with
   the field's own fill, edge and focus, the controls bare inside it, and
   two small icon buttons at its end. The tick
   stays quiet until something has changed, then fills in ink, so the box
   says whether there is anything to keep; the cross stays quiet.
   One geometry everywhere, set by two numbers: --in-h, the height of the
   field and of the tick and cross (square, the same height, so the space
   round them is the box's padding on every side), and --in-pad, that
   padding. A place sets those two and nothing else about the box's inside;
   the box sits on its container's content edges, never hung past them. */
.infield {
  --in-h: 30px; --in-pad: 3px;
  display: flex; align-items: center; gap: 2px; flex: 1 1 auto; min-width: 0;
  padding: var(--in-pad); border: 1px solid var(--field-edge); border-radius: var(--r-btn);
  background: var(--field); transition: border-color .16s ease, box-shadow .16s ease, background-color .16s ease;
}
.infield:hover:not(:focus-within) { background-color: var(--field-hover); border-color: var(--field-edge-hover) }
.infield:focus-within { background-color: var(--card); border-color: var(--field-focus); box-shadow: inset 0 0 0 .5px var(--field-focus) }
.infield:has(.input[aria-invalid="true"]) { border-color: var(--bad); box-shadow: inset 0 0 0 .5px var(--bad) }
/* The box carries the red; the bare field inside never draws its own edge. */
.infield .input.input[aria-invalid="true"], .infield .editinfo__affix .input[aria-invalid="true"] { border: 0; background: none; box-shadow: none }
/* What is wrong, under the box (fieldFail): its mark and a few words in red. */
.infield__err {
  display: flex; align-items: center; gap: 6px; flex-basis: 100%; width: 100%; margin-top: 6px;
  color: var(--bad); font-size: 12.5px; font-weight: 500;
}
.infield__err .ms { font-size: 16px }
.infield .input { flex: 1 1 auto; min-width: 0; min-height: 0; width: auto; height: var(--in-h); padding: 0 6px; border-radius: 0 }
/* Bare in every state: the box carries the fill, edge and focus. Only the
   look is reset here, never a size, so a hover never resizes a field. */
.infield .input, .infield .input:hover:not(:focus):not(:disabled), .infield .input:focus { border: 0; background: none; box-shadow: none }
.infield > .editinfo__affix { flex: 1 1 auto; min-width: 0; display: flex }
.infield .editinfo__affix .input { padding-left: 24px }
.infield .editinfo__affix .editinfo__mark { left: 7px }
/* The date beside the step's words, split from them by a hairline. */
.infield .input[type="date"], .infield .input[type="date"]:focus { flex: 0 0 150px; border-left: 1px solid var(--field-edge) }
/* A textarea is one row that grows with what is written in it: its words,
   then the tick and cross at the end of its last line, so the box is only
   ever as tall as the text (no empty block on opening). */
.infield--multi { align-items: flex-end; flex-basis: auto; width: 100% }
/* One line of it is exactly --in-h tall, so a one-line box is the same
   height as a one-line field and its words sit level with the tick and cross. */
.infield--multi .input {
  width: 100%; height: auto; min-height: var(--in-h); max-height: 320px;
  padding: max(0px, calc((var(--in-h) - 1lh) / 2)) 6px;
  resize: none; field-sizing: content; line-height: 1.5;
}
/* Where the browser sizes a textarea to its words itself, that wins over the
   height the app's autosize measured as it landed (shared/dom.js), which
   could come out short and show scroll arrows on one line. */
@supports (field-sizing: content) {
  .infield--multi textarea.input { height: auto !important }
}
.infield__acts { display: flex; gap: 2px; flex: 0 0 auto }
.infield__btn {
  display: grid; place-items: center; width: var(--in-h); height: var(--in-h); padding: 0;
  border: 0; border-radius: var(--r-btn-sm); background: none; color: var(--muted); cursor: pointer;
  transition: background-color .15s ease, color .15s ease;
}
.infield__btn .ms { font-size: 18px }
.infield__btn:hover { background: var(--btn-wash); color: var(--text) }
.infield__btn:focus-visible { outline: 2px solid var(--teal); outline-offset: 1px }
.infield.is-changed .infield__btn--keep { background: var(--ink); color: var(--on-ink) }
.infield.is-changed .infield__btn--keep:hover { background: color-mix(in srgb, var(--ink), var(--on-ink) 14%) }
/* A finger's size on touch, the box growing round them. */
@media (pointer: coarse) { .infield { --in-h: 36px } }
