/*
 * Finish rules for every account, company and Operations page (Jason, 2026-11-22). Loaded LAST on
 * each of those pages, so a page's own style file cannot forget them:
 *   1. every control answers at once to hover, press and touch;
 *   2. even spacing: two things never sit right on top of each other;
 *   3. each section has its own edge and a ruled heading, so its start and end are plain to see;
 *   4. square corners on boxes, buttons, tabs and cards; form fields (typed boxes, drop-downs and
 *      text areas) rounded 6 px (section 4 below); round otherwise only for status dots;
 *   5. soft text on charcoal (the colors are in brand.css; headings are one step brighter);
 *   6. one small help box per page.
 */

/* ---- 5. Text ---------------------------------------------------------------------------------- */
h1, h2, h3, h4, strong, b, th, dt, legend, label, summary { color: var(--ink-strong); }
th, dt { color: var(--muted); }
h1 { font-weight: 600; }

/* ---- 1. Controls answer at once --------------------------------------------------------------- */
:is(button, .button, a, summary, select, input, textarea, label, tr, li, [role="tab"], [role="button"]) {
  transition: background-color 70ms linear, border-color 70ms linear, color 70ms linear, box-shadow 70ms linear, transform 50ms linear;
  -webkit-tap-highlight-color: rgb(227 183 110 / .22);
}
:is(button, .button):not(:disabled) { cursor: pointer; }
:is(button, .button):not(:disabled, .primary, .sd-primary):hover { background: var(--surface-raised); border-color: var(--accent); color: var(--ink-strong); }
:is(button, .button):not(:disabled):active { transform: translateY(1px); background: var(--page); border-color: var(--focus); box-shadow: inset 0 2px 5px rgb(0 0 0 / .5); }
:is(button, .button).primary:not(:disabled):hover { background: var(--focus); border-color: var(--focus); box-shadow: 0 0 0 2px rgb(227 183 110 / .25); }
:is(button, .button).primary:not(:disabled):active { background: #c79a52; border-color: #c79a52; box-shadow: inset 0 2px 5px rgb(0 0 0 / .35); }
/* A button that cannot be used now is faded to 60 %, never further, so its words stay readable on the charcoal (the
   pages' own rules faded it to 40-55 %: shared/base.css, the Salesdesk, Company settings' builder rules). It says why
   in its tip (ui.mjs `unavailable`). The body in front lets this win over every page's own rule. */
body :is(button, .button):is(:disabled, [aria-disabled="true"]) { opacity: .6; cursor: not-allowed; }
button.danger:not(:disabled):hover { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); }
button.quiet:not(:disabled):hover { border-color: var(--line); }

a:not(.button):hover { color: var(--focus); }
a:not(.button):active { color: var(--ink-strong); }

summary { cursor: pointer; }
summary:hover { color: var(--accent); }
summary:active { color: var(--focus); }

:is(select, textarea, input:not([type="checkbox"], [type="radio"], [type="range"], [type="color"], [type="file"])):not(:disabled):hover { border-color: var(--muted); }
:is(select, textarea, input:not([type="checkbox"], [type="radio"], [type="range"], [type="color"], [type="file"])):focus { border-color: var(--accent); background: var(--page); }
:is(input[type="checkbox"], input[type="radio"]) { accent-color: var(--accent); cursor: pointer; }
label:has(> input[type="checkbox"], > input[type="radio"]):hover { color: var(--accent); }

/* Menus: the row under the pointer lights up and gets the gold edge; a pressed row sinks. */
:is(.workspace-navigation, .workspace-nav, .company-nav) a { border-left: 3px solid transparent; }
:is(.workspace-navigation, .workspace-nav, .company-nav) a:hover { background: var(--surface-raised); border-left-color: var(--accent); color: var(--ink-strong); }
:is(.workspace-navigation, .workspace-nav, .company-nav) a:active { background: var(--page); }

/* Rows that open something. */
tbody tr:has(a):hover { background: var(--surface-raised); }
tbody tr:has(a):active { background: var(--page); }

/* ---- 2. Even spacing -------------------------------------------------------------------------- */
/* These are floors, written so that any page rule with a class still wins: a page may space its own
   parts differently, but nothing is left touching because a page forgot. */
:where(.actions, [class*="actions"]) { display: flex; flex-wrap: wrap; gap: var(--gap-2) var(--gap-3); align-items: center; }
/* A button, a note, a table or a folded part that follows text or another block never touches it. */
:where(p, ul, ol, dl, table, .table-wrap, .notice, .error, details, fieldset, .field, .hint) + :is(button, details, fieldset, form, table) { margin-top: var(--gap-3); }
:where(p, ul, ol, dl, table, .table-wrap, .notice, .error, details, fieldset, .field, .hint) + :where(.button, .actions, .notice, .error, .table-wrap) { margin-top: var(--gap-3); }
:where(button, .button, .actions) + :is(p, details, fieldset, form, table, h2, h3, h4) { margin-top: var(--gap-3); }
:where(button, .button, .actions) + :where(.notice, .error, .field, .table-wrap, .hint) { margin-top: var(--gap-3); }
:where(.hint) + :is(label), :where(.hint) + :where(.field) { margin-top: var(--gap-3); }
/* Two buttons in a row that no box spaces apart. */
:where(p, li, td, dd, summary) > :is(button, a.button) + :is(button, a.button) { margin-left: var(--gap-2); }
fieldset { border: 1px solid var(--line); padding: var(--gap-3) var(--gap-4); margin: var(--gap-3) 0; }
legend { padding: 0 var(--gap-2); font-weight: 600; }

/* ---- 3. Sections ------------------------------------------------------------------------------ */
.card { border: 1px solid var(--line); border-top: 3px solid #7d6a45; margin-bottom: var(--gap-5); box-shadow: 0 1px 0 rgb(0 0 0 / .35); }
.card > :is(h2, h3):first-child { padding-bottom: var(--gap-2); margin-bottom: var(--gap-4); border-bottom: 1px solid var(--line); }
details.card > summary { font-weight: 600; }
details.card[open] > summary { border-bottom: 1px solid var(--line); margin-bottom: var(--gap-4); }
/* A section that follows loose buttons or text keeps clear of them. */
:where(.actions, button, .button, p, .notice, .hint) + .card { margin-top: var(--gap-3); }

/* ---- 4. Form fields are rounded 6 px ------------------------------------------------------------
   Jason, 2026-11-26, a REVERSAL for form fields only: "I want form inputs in sign in and in 3d builder
   and in any page to have rounded borders." Every typed box, drop-down (and its open list) and text area
   has the same 6 px corner; buttons, tabs, boxes, cards and check boxes stay square. `!important`
   because many page rules set a field's corner, several of them in files loaded after this one
   (company.css, the builder's), so this one rule decides it in every state: hover, focus, error,
   disabled, filled in by the browser, inside a table or a box. The builder (apps/builder/form-
   controls.css) and the public website (apps/landing/landing-r2.css) have the same rule. Left square on
   purpose, in all three: the number between the two buttons of a joined stepper (QR stickers, How
   many), one control whose ends are square buttons. The plan's sheet menu on a phone is a drop-down
   like any other since the builder version of November 28, 2026 (packages/plan-viewer/styles.mjs gives
   it 6 px too). */
:is(select, textarea, input:not([type="checkbox"], [type="radio"], [type="range"], [type="color"], [type="file"], [type="button"], [type="submit"], [type="reset"], [type="image"], [type="hidden"])):not(.qs-count input) { border-radius: 6px !important; }
@supports (appearance: base-select) { select::picker(select) { border-radius: 6px !important; } }

/* ---- 6. The help box -------------------------------------------------------------------------- */
.help-box { max-width: 46rem; margin: var(--gap-3) 0 var(--gap-5); border: 1px solid var(--line); border-left: 3px solid var(--accent); background: rgb(0 0 0 / .18); font-size: .9rem; }
.help-box > summary { display: flex; align-items: center; gap: var(--gap-2); min-height: 34px; padding: 4px var(--gap-3); font-weight: 600; line-height: 1.3; color: var(--ink-strong); list-style: none; }
.help-box > summary::-webkit-details-marker { display: none; }
details.help-box > summary::before, .workspace details.help-box[open] > summary::before { content: "?"; flex: none; width: 18px; height: 18px; display: grid; place-items: center; font-size: .75rem; font-weight: 700; color: var(--accent-ink); background: var(--accent); }
.help-box > summary::after { content: "Show"; margin-left: auto; font-size: .8rem; font-weight: 500; color: var(--muted); }
.help-box[open] > summary::after { content: "Hide"; }
.help-box[open] > summary { border-bottom: 1px solid var(--line); }
.help-box > ol { margin: 0; padding: var(--gap-2) var(--gap-3) var(--gap-3) calc(var(--gap-3) + 1.4rem); color: var(--ink); }
.help-box > ol > li { padding-left: 2px; line-height: 1.5; }
.help-box > ol > li + li { margin-top: var(--gap-1); }
.help-box > ol > li::marker { color: var(--accent); font-weight: 700; }
@media (pointer: coarse) { .help-box > summary { min-height: 44px; } }

/* ---- Numbered steps inside a long form or record ---------------------------------------------- */
.quote-step, .numbered-step { margin: var(--gap-5) 0 0; padding: var(--gap-4) 0 0; border-top: 1px solid var(--line); }
.quote-step-title, .numbered-step-title { display: flex; align-items: center; gap: var(--gap-3); margin: 0 0 var(--gap-3); font-size: 1rem; }
.quote-step-number, .step-number { flex: none; width: 22px; height: 22px; display: grid; place-items: center; font-size: .8rem; font-weight: 700; color: var(--accent-ink); background: var(--accent); }
/* The Operations pages style every fold line as a gold link with an arrow; the help box keeps its own look. */
.workspace details.help-box > summary { color: var(--ink-strong); text-decoration: none; min-height: 34px; padding: 4px var(--gap-3); line-height: 1.3; }
.workspace details.help-box > summary::before { margin: 0; }
.workspace details.help-box > summary:hover { color: var(--accent); text-decoration: none; }

/* A fold line that stands alone on a company page is a ruled row with its own edge, never loose text. */
.company-page details:not([class]):not(.sd-bar *, .card details, .help-box) { border: 1px solid var(--line); background: var(--surface); }
.company-page details:not([class]):not(.sd-bar *, .card details, .help-box) > summary { padding: var(--gap-2) var(--gap-3); font-weight: 600; }
.company-page details:not([class]):not(.sd-bar *, .card details, .help-box)[open] > summary { border-bottom: 1px solid var(--line); }
.company-page details:not([class]):not(.sd-bar *, .card details, .help-box)[open] { padding-bottom: var(--gap-3); }
.company-page details:not([class]):not(.sd-bar *, .card details, .help-box)[open] > :not(summary) { margin-left: var(--gap-3); margin-right: var(--gap-3); }
.company-page details:not([class]):not(.sd-bar *, .card details, .help-box)[open] > summary + * { margin-top: var(--gap-3); }

/* Pressed and hover looks for the controls a feel test found without one (2026-11-22). */
.help-box > summary:hover, .workspace details.help-box > summary:hover { color: var(--accent); background: var(--surface-raised); }
.help-box > summary:active, .workspace details.help-box > summary:active { color: var(--focus); background: var(--page); }
:is(select, textarea, input:not([type="checkbox"], [type="radio"], [type="range"], [type="color"], [type="file"])):not(:disabled):active { border-color: var(--accent); background: var(--page); box-shadow: inset 0 0 0 1px var(--accent); }
main a:not(.button):active, .workspace a:not(.button):active { color: var(--focus); transform: translateY(1px); }
td a { display: inline-block; }
