/* style-b-sa-1030: ONE shared set of components, built only from src/styles/tokens.css values.
   Applies only inside class="ec-ui" (a page opts in by adding it to <body>). Today only Super Admin opts in.
   No !important. Base looks (plain button, input, label, table, link) use :where(.ec-ui) so they weigh no more than the bare
   element: a page's own class rule (a special button such as the Support tab or Manage) still wins. Variants (.pri, .ec-btn--danger,
   status chips, cards, tabs) keep the .ec-ui class weight so they win over old page rules.
   Colorblind rules: color is never the only signal. Status chips carry a word AND a shape (filled / outlined / dashed, plus a symbol);
   danger buttons say the action; links are underlined; keyboard focus = 2px orange ring plus 1px dark ring. */

/* ---------- buttons: .ec-btn (and plain <button> inside .ec-ui) ---------- */
:where(.ec-ui) :where(button,.ec-btn){box-sizing:border-box;min-height:var(--ec-btn-h);padding:0 var(--ec-s-16);border:1px solid var(--ec-c-muted);border-radius:var(--ec-r-btn);background:var(--ec-c-surface);color:var(--ec-c-ink);font-family:inherit;font-size:var(--ec-t-13);font-weight:600;line-height:1.2;cursor:pointer;box-shadow:none;opacity:1;text-decoration:none}
:where(.ec-ui) :where(button,.ec-btn):hover{background:var(--ec-c-subtle);opacity:1}
/* primary = the inactive-tab gray; selected tabs keep charcoal */
.ec-ui :is(button.blue,button.ec-pri,.ec-btn--primary){background:var(--ec-c-tab);border-color:var(--ec-c-tab);color:#fff}
.ec-ui :is(button.blue,button.ec-pri,.ec-btn--primary):hover{background:var(--ec-c-tab-hover);border-color:var(--ec-c-tab-hover)}
/* brand = orange, the one main action per screen ("+ Add Brokerage"; old class .pri); dark text 6:1 */
.ec-ui :is(button.pri,button.ec-ok,.ec-btn--brand){background:var(--ec-c-brand);border-color:var(--ec-c-brand);color:var(--ec-c-ink)}
.ec-ui :is(button.pri,button.ec-ok,.ec-btn--brand):hover{background:var(--ec-c-brand-text);border-color:var(--ec-c-brand-text);color:#fff}
/* danger = red, the label always names the action ("Disable brokerage") */
.ec-ui :is(button.ec-danger,.ec-btn--danger){background:var(--ec-c-danger);border-color:var(--ec-c-danger);color:#fff}
.ec-ui :is(button.ec-danger,.ec-btn--danger):hover{background:#912018;border-color:#912018}
/* secondary (ghost) = white with a gray outline, same as the default */
.ec-ui :is(button.ghost,.ec-btn--secondary){background:var(--ec-c-surface);border-color:var(--ec-c-muted);color:var(--ec-c-ink)}
/* link-looking button */
.ec-ui .ec-btn--link{background:none;border-color:transparent;color:var(--ec-c-ink);text-decoration:underline;padding:0 var(--ec-s-4)}
/* small */
.ec-ui :is(button.sm,.ec-btn--sm){min-height:var(--ec-btn-h-panel);padding:0 var(--ec-s-12);font-size:var(--ec-t-12)}
.ec-ui :is(button,.ec-btn):disabled{opacity:.5;cursor:not-allowed}
.ec-ui :is(button,.ec-btn,a,input,select,textarea,summary,[tabindex]):focus-visible{outline:2px solid var(--ec-c-brand);outline-offset:1px;box-shadow:0 0 0 3px var(--ec-c-ink)}

/* ---------- inputs ---------- */
:where(.ec-ui) :where(input:not([type=checkbox]):not([type=radio]):not([type=file]),select,textarea,.ec-input){box-sizing:border-box;min-height:var(--ec-btn-h);padding:var(--ec-s-4) var(--ec-s-8);border:1px solid var(--ec-c-muted);border-radius:var(--ec-r-btn);background:var(--ec-c-surface);color:var(--ec-c-ink);font-family:inherit;font-size:var(--ec-t-13)}
.ec-ui :is(input,select,textarea,.ec-input):focus{border-color:var(--ec-c-ink);outline:2px solid var(--ec-c-brand);outline-offset:0}
:where(.ec-ui) label{color:var(--ec-c-muted);font-size:var(--ec-t-12);font-weight:600}

/* ---------- tables: square ---------- */
.ec-ui :is(.tw,.ec-table-wrap){border:1px solid var(--ec-c-line);border-radius:var(--ec-r-table);background:var(--ec-c-surface)}
:where(.ec-ui) :where(table,.ec-table){border-collapse:collapse;width:100%;font-size:var(--ec-t-13)}
:where(.ec-ui) :where(table,.ec-table) th{background:var(--ec-c-subtle);color:var(--ec-c-ink);font-weight:700;font-size:var(--ec-t-12);text-align:left;padding:var(--ec-s-8);border-bottom:2px solid var(--ec-c-ink);border-radius:var(--ec-r-table)}
:where(.ec-ui) :where(table,.ec-table) td{padding:var(--ec-s-8);border-top:1px solid var(--ec-c-line);vertical-align:top}
.ec-ui :is(table,.ec-table) tr:is([onclick],.ec-click):hover td{background:var(--ec-c-brand-tint)}

/* ---------- cards ---------- */
.ec-ui :is(.panel,.ec-card){background:var(--ec-c-surface);border:1px solid var(--ec-c-line);border-radius:var(--ec-r-card);padding:var(--ec-s-12) var(--ec-s-16)}

/* ---------- pop-ups (dialog / .ec-modal) ---------- */
.ec-ui :is(dialog,.ec-modal){border:1px solid var(--ec-c-line);border-radius:var(--ec-r-card);background:var(--ec-c-surface);color:var(--ec-c-ink);box-shadow:var(--ec-sh-modal);padding:var(--ec-s-16) var(--ec-s-24)}
.ec-ui dialog::backdrop{background:rgba(31,35,40,.45)}

/* ---------- tabs: the same tab row as Admin / Agent / Portal (gray; selected = charcoal, bold, orange top line) ---------- */
.ec-ui :is(.views,.ec-tabs){display:flex;flex-wrap:wrap;gap:3px;border-bottom:1px solid var(--ec-c-muted);background:transparent;padding:0}
.ec-ui :is(.views,.ec-tabs) button{margin:0;min-height:var(--ec-btn-h);padding:6px 14px;border:0;border-radius:var(--ec-r-btn) var(--ec-r-btn) 0 0;background:var(--ec-c-tab);color:#fff;font-size:var(--ec-t-13);font-weight:400;line-height:20px;box-shadow:none}
.ec-ui :is(.views,.ec-tabs) button:hover:not(.on):not([aria-selected=true]){background:var(--ec-c-tab-hover);color:#fff}
.ec-ui :is(.views,.ec-tabs) button:is(.on,[aria-selected=true]){background:var(--ec-c-charcoal);color:#fff;font-weight:700;box-shadow:inset 0 3px 0 var(--ec-c-brand)}

/* ---------- chips (round) ---------- */
.ec-ui :is(.pill,.ec-pill,.ec-chip,.ec-n,.ec-badge){display:inline-block;border-radius:var(--ec-r-chip);font-size:var(--ec-t-12);font-weight:700;line-height:1.4;padding:1px var(--ec-s-8)}

/* ---------- status: word + shape, never color alone ---------- */
.ec-ui :is(.ec-status,.ec-pill,.pill){border:1px solid var(--ec-c-ink);background:var(--ec-c-surface);color:var(--ec-c-ink)}
.ec-ui :is(.ec-status--good,.ec-pill.on,.pill.p-on){background:var(--ec-c-ink);border-color:var(--ec-c-ink);color:#fff}
.ec-ui :is(.ec-status--good,.ec-pill.on,.pill.p-on)::before{content:"\2713\00a0"}
.ec-ui :is(.ec-status--off,.ec-pill.off,.pill.p-off){border-style:dashed;color:var(--ec-c-muted)}
.ec-ui :is(.ec-status--off,.ec-pill.off,.pill.p-off)::before{content:"\2013\00a0"}
.ec-ui :is(.ec-status--warn,.ec-pill.wait){background:var(--ec-c-warn-tint);border-color:var(--ec-c-warn);color:var(--ec-c-ink)}
.ec-ui :is(.ec-status--warn,.ec-pill.wait)::before{content:"!\00a0";font-weight:800}
.ec-ui :is(.ec-status--info,.ec-pill.tr,.pill.p-home){background:var(--ec-c-brand-tint);border-color:var(--ec-c-brand-text);color:var(--ec-c-ink)}

/* ---------- messages ---------- */
.ec-ui :is(.err,.ec-msg--bad){background:var(--ec-c-danger-tint);border:1px solid var(--ec-c-danger);border-left-width:4px;color:var(--ec-c-ink);border-radius:var(--ec-r-btn);padding:var(--ec-s-8) var(--ec-s-12)}
.ec-ui :is(.ok,.ec-msg--good){background:var(--ec-c-good-tint);border:1px solid var(--ec-c-good);border-left-width:4px;color:var(--ec-c-ink);border-radius:var(--ec-r-btn);padding:var(--ec-s-8) var(--ec-s-12)}

/* ---------- links ---------- */
:where(.ec-ui) a{color:var(--ec-c-ink);text-decoration:underline;font-weight:600}

/* ---------- shared pop-ups already on the pages: Manage pop-up (.ecm, src/ec-modal.js) and the Are-you-sure box (src/ec-confirm.js) ---------- */
.ec-ui .ecm{border-radius:var(--ec-r-card);overflow:hidden;box-shadow:var(--ec-sh-modal)}
.ec-ui .ecm-x{border-radius:var(--ec-r-btn)}
.ec-ui #ec-cf-ov>div{border-radius:var(--ec-r-card);box-shadow:var(--ec-sh-modal)}

/* ---------- Settings menu (gear button + panel, src/settings-gear.js): same buttons, rows and pop-up corners ---------- */
.ec-ui #ec-gear{border-radius:var(--ec-r-btn);min-height:var(--ec-btn-h-panel)}
.ec-ui #ec-setp{border-radius:var(--ec-r-card);box-shadow:var(--ec-sh-modal)}
.ec-ui #ec-setp :is(.so,.done){min-height:var(--ec-btn-h);border-radius:var(--ec-r-btn);font-size:var(--ec-t-13);font-weight:600}
.ec-ui #ec-setp .done{font-weight:700}
.ec-ui #ec-setp label{border-radius:var(--ec-r-btn)}
.ec-ui #ec-setp label:hover{background:var(--ec-c-subtle)}
html[data-theme=dark] .ec-ui #ec-setp label:hover{background:#2b2f36}
.ec-ui #ec-setp :is(select,input[type=range]){border-radius:var(--ec-r-btn)}

/* placeholder text follows the field's own text color, so it stays readable at every Light-Dark slider position (dark mode re-colors fields, not placeholders) */
.ec-ui :is(input,textarea)::placeholder{color:currentColor;opacity:.72}
html[data-theme=dark] .ec-ui :is(input,textarea)::placeholder{color:currentColor!important;opacity:.72} /* beats the fixed gray in dark-mode.js, which is unreadable on mid-gray fields at 50% */

/* ---------- dark mode (html[data-theme=dark], set by src/dark-mode.js) ----------
   dark-mode.js swaps light colors for dark ones itself; these rules only fix what it cannot:
   the dark focus halo would vanish on a dark page, and a filled dark "on" chip looks like an outlined one. */
html[data-theme=dark] .ec-ui :is(button,.ec-btn,a,input,select,textarea,summary,[tabindex]):focus-visible{outline-color:#ff9a4d;box-shadow:0 0 0 3px #f0f0f0}
html[data-theme=dark] .ec-ui :is(.ec-status--good,.ec-pill.on,.pill.p-on){border-width:2px;font-weight:800}
html[data-theme=dark] .ec-ui :is(.ec-status--off,.ec-pill.off,.pill.p-off){border-width:2px}
