/* Address IQ SaaS surfaces (admin dashboard, subscriber portal): shared base. Right-to-left, dark navy, the website's tokens (/shared/tokens.css) and font.
   Every text / background pair used here is listed in ui_common/contrast_pairs.json and checked by tests (WCAG AA 4.5:1; AAA where noted). No inline styles anywhere (the page policy forbids them). */
*, *::before, *::after { box-sizing: border-box; }
html { color-scheme: dark; }
body { margin: 0; background: var(--navy); color: var(--text); font-family: var(--font); font-size: 16px; line-height: 1.6; min-height: 100vh; }
h1, h2, h3 { margin: 0 0 .5rem; font-weight: 700; line-height: 1.3; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.05rem; }
p { margin: 0 0 .75rem; }
a { color: var(--text); text-decoration-line: underline; text-decoration-color: var(--brand); text-decoration-thickness: 2px; text-underline-offset: 4px; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
[hidden] { display: none !important; }
.muted { color: var(--text-2); }
.num { font-variant-numeric: tabular-nums; }
.ltr { direction: ltr; unicode-bidi: isolate; text-align: left; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* layout */
.app { display: grid; grid-template-columns: 220px minmax(0, 1fr); grid-template-rows: var(--header-h) 1fr; min-height: 100vh; }
.app-head { grid-column: 1 / -1; display: flex; align-items: center; gap: 1rem; padding: 0 1.25rem; background: linear-gradient(var(--navy), var(--navy)) padding-box, var(--brand-line) border-box; border-bottom: 2px solid transparent; }
.app-head .brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; }
.app-head .brand img { height: 36px; width: auto; }
.app-head .spacer { flex: 1; }
.app-nav { background: var(--navy-1); border-inline-end: 1px solid var(--line); padding: 1rem .75rem; display: flex; flex-direction: column; gap: .25rem; }
.app-nav a { display: block; padding: .5rem .75rem; border-radius: var(--r-s); color: var(--text); text-decoration: none; }
.app-nav a:hover { background: var(--navy-2); }
.app-nav a[aria-current="page"] { background: var(--sel-fill); box-shadow: inset 4px 0 0 var(--brand); }
.app-main { padding: 1.25rem 1.5rem 3rem; min-width: 0; }
.page-head { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head .spacer { flex: 1; }
@media (max-width: 800px) { .app { grid-template-columns: 1fr; grid-template-rows: var(--header-h) auto 1fr; } .app-nav { flex-direction: row; flex-wrap: wrap; border-inline-end: 0; border-bottom: 1px solid var(--line); } }

/* surfaces */
.card { background: linear-gradient(var(--navy-1), var(--navy-1)) padding-box, var(--brand-line) border-box; border: 1px solid var(--line); border-top: 2px solid transparent; border-radius: var(--r-m); padding: 1rem 1.1rem; margin-bottom: 1rem; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.stat { background: var(--navy-1); border: 1px solid var(--line); border-radius: var(--r-m); padding: .9rem 1rem; }
.stat .k { color: var(--text-2); font-size: .9rem; }
.stat .v { font-size: 1.7rem; font-weight: 700; }
.row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; }
.stack > * + * { margin-top: .75rem; }

/* buttons and fields */
.btn { font: inherit; cursor: pointer; min-height: var(--ctl-h); padding: 0 var(--ctl-px); border-radius: var(--r-s); border: 1.5px solid transparent; background: var(--btn-fill) padding-box, var(--brand-line) border-box; color: var(--text); }
.btn:hover { background: var(--btn-fill-hover) padding-box, var(--brand-line) border-box; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--sel-fill) padding-box, var(--brand-line) border-box; color: var(--text); border: 2px solid transparent; font-weight: 700; }
.btn.primary:hover { background: var(--btn-fill) padding-box, var(--brand-line) border-box; }
html[data-brand="A"] .btn.primary { background: var(--brand); border-color: var(--brand); color: var(--text); font-size: 1.2rem; font-weight: 800; }       /* variant A: white on red is 4.39:1 - only LARGE bold text (19 px) may sit on a red fill */
html[data-brand="A"] .btn.primary:hover { filter: brightness(.9); background: var(--brand); border-color: var(--brand); }
.btn.danger { background: var(--rose-bg); border-color: var(--rose); color: var(--text); }
.btn.link { background: none; border: 0; color: var(--text); text-decoration: underline; text-decoration-color: var(--brand); text-decoration-thickness: 2px; padding: 0 .25rem; min-height: 0; }
label.field { display: block; }
label.field > span { display: block; margin-bottom: .25rem; color: var(--text-2); font-size: .92rem; }
input, select, textarea { font: inherit; width: 100%; min-height: var(--input-h); padding: .35rem .7rem; border-radius: var(--r-s); border: 1px solid var(--line-strong); background: var(--navy); color: var(--text); }
textarea { min-height: 5.5rem; resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: auto; min-height: 0; }
.form { display: grid; gap: .8rem; max-width: 520px; }
.hint { color: var(--text-2); font-size: .88rem; }
.error { color: var(--rose); }
.ok { color: var(--green); }

/* tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-m); }
table { width: 100%; border-collapse: collapse; background: var(--navy-1); }
/* option panels (toggles, checkboxes, selects): equal cells, equal gaps, rows always full (the column count comes from K.cols as data-cols), RTL, one column on a phone */
.opt-panel { display: grid; gap: var(--sp-3); grid-template-columns: minmax(0, 1fr); grid-auto-rows: 1fr; align-items: stretch; margin: var(--sp-3) 0; }
.opt-panel[data-cols="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); } .opt-panel[data-cols="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.opt-panel[data-cols="4"] { grid-template-columns: repeat(4, minmax(0, 1fr)); } .opt-panel[data-cols="5"] { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.opt-panel > * { min-width: 0; margin: 0; }
.opt, .opt-panel > label:not(.field) { display: flex; align-items: center; gap: var(--sp-2); min-height: 44px; padding: var(--sp-2) var(--sp-3); border: 1px solid var(--line); border-radius: var(--r-s); background: var(--navy); cursor: pointer; }
.opt.locked { cursor: default; background: var(--navy-2); border-style: dashed; margin: 0 0 var(--sp-3); }
.opt input[type="checkbox"], .opt-panel > label input[type="checkbox"] { flex: 0 0 auto; width: 1.15rem; height: 1.15rem; margin: 0; }
.opt-panel > label.field { display: flex; flex-direction: column; justify-content: flex-start; }
.preview { background: var(--navy); border: 1px solid var(--line); border-radius: var(--r-s); padding: var(--sp-3) var(--sp-4); max-width: 440px; }
.preview p { margin: 0 0 var(--sp-2); } .preview p.sign { color: var(--text-2); margin: var(--sp-3) 0 0; }
@media (max-width: 700px) { .opt-panel, .opt-panel[data-cols] { grid-template-columns: minmax(0, 1fr); } }
th, td { text-align: start; padding: .55rem .75rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--text-2); font-weight: 600; font-size: .9rem; background: var(--navy); }
tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--navy-2); }

/* badges */
.badge { display: inline-block; padding: 0 .55rem; border-radius: 999px; font-size: .85rem; border: 1px solid transparent; white-space: nowrap; }
.badge.green { background: var(--green-bg); color: var(--green); border-color: var(--green); }
.badge.blue { background: var(--blue-bg); color: var(--blue); border-color: var(--blue); }
.badge.orange { background: var(--orange-bg); color: var(--orange); border-color: var(--orange); }
.badge.rose { background: var(--rose-bg); color: var(--rose); border-color: var(--rose); }
.badge.violet { background: var(--violet-bg); color: var(--violet); border-color: var(--violet); }
.badge.plain { background: var(--navy-2); color: var(--text); border-color: var(--line-strong); }

/* toast and modal */
.toasts { position: fixed; inset-block-end: 1rem; inset-inline-start: 1rem; display: grid; gap: .5rem; z-index: 50; max-width: min(92vw, 420px); }
.toast { background: var(--navy-2); border: 1px solid var(--line-strong); border-inline-start: 4px solid var(--blue); border-radius: var(--r-s); padding: .6rem .9rem; }
.toast.err { border-inline-start-color: var(--rose); } .toast.good { border-inline-start-color: var(--green); }
.modal-back { position: fixed; inset: 0; background: rgba(0, 20, 30, .78); display: grid; place-items: center; z-index: 40; padding: 1rem; }
.modal { background: var(--navy-1); border: 1px solid var(--line-strong); border-radius: var(--r-l); padding: 1.25rem; width: min(92vw, 520px); max-height: 90vh; overflow: auto; }
.modal .actions { display: flex; gap: .6rem; justify-content: flex-start; margin-top: 1rem; }

/* login */
.center-card { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.center-card .card { width: min(94vw, 440px); }
.center-card img.logo { display: block; margin: 0 auto 1rem; height: 56px; width: auto; }
.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: .4rem; font-family: ui-monospace, monospace; direction: ltr; background: var(--navy); border: 1px dashed var(--line-strong); padding: .75rem; border-radius: var(--r-s); }
.tabs { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tabs button { font: inherit; min-height: var(--tab-h); padding: 0 var(--tab-px); background: var(--navy-2); color: var(--text); border: 1px solid var(--line); border-radius: var(--r-s); cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--navy-3); border-color: var(--yellow); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; }
.kv dt { color: var(--text-2); } .kv dd { margin: 0; }
pre.json { background: var(--navy); border: 1px solid var(--line); border-radius: var(--r-s); padding: .6rem; overflow: auto; direction: ltr; text-align: left; max-height: 300px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------------------------------------------------------------- design pass with the skills (frontend-design, design-system, build-dashboard), inside the owner's rules
   rhythm: a 4 px base; type: one family (Cairo), a short scale; line length under 80 characters in text blocks; structure carries meaning (no decoration); one motion moment (none here);
   states: loading (skeleton), empty (an invitation), error (what happened and what to do), success (a toast named like the action); focus always visible; skip link; reduced motion respected. */
:root { --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px; --fs-s: .875rem; --fs-m: 1rem; --fs-l: 1.25rem; --fs-xl: 1.6rem; --measure: 68ch; }
.skip-link { position: absolute; inset-inline-start: var(--sp-2); top: -64px; z-index: 100; padding: var(--sp-2) var(--sp-4); background: var(--navy-2); color: var(--text); border: 2px solid var(--brand); border-radius: var(--r-s); }
.skip-link:focus { top: var(--sp-2); }
.app-main:focus { outline: none; }
.app-main > * + * { margin-top: var(--sp-4); }
.page-head h1 { font-size: var(--fs-xl); }
.card > h2, .card .page-head > h2 { font-size: var(--fs-l); }
.card p, .hint, .muted { max-width: var(--measure); }
.table-wrap { max-height: 70vh; overflow: auto; }
thead th { position: sticky; top: 0; z-index: 1; }
th .sort { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; font-weight: 700; }
th .sort::after { content: '\2195'; margin-inline-start: var(--sp-1); color: var(--text-2); }
th[aria-sort="ascending"] .sort::after { content: '\2191'; color: var(--text); }
th[aria-sort="descending"] .sort::after { content: '\2193'; color: var(--text); }
td.num, .num { text-align: end; }
.req { color: var(--text-2); font-size: var(--fs-s); }
.empty { padding: var(--sp-5) var(--sp-4); text-align: center; }
.empty .empty-title { font-weight: 700; margin: 0 auto var(--sp-2); }
.skeleton { display: grid; gap: var(--sp-2); padding: var(--sp-3) 0; }
.skeleton .sk-row { height: 1.6rem; border-radius: var(--r-s); background: var(--navy-2); border: 1px solid var(--line); }
.skeleton .sk-row:nth-child(odd) { width: 92%; }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--rose); box-shadow: 0 0 0 2px var(--rose-bg); }
.toast { display: grid; grid-template-columns: auto 1fr; gap: var(--sp-2); }
.toast::before { content: '\2139'; color: var(--blue); font-weight: 700; }
.toast.good::before { content: '\2713'; color: var(--green); }
.toast.err::before { content: '\0021'; color: var(--rose); border: 1.5px solid var(--rose); border-radius: 50%; width: 1.25em; height: 1.25em; text-align: center; line-height: 1.15em; font-size: .9em; }
.badge.green::before { content: '\2713 '; } .badge.rose::before { content: '\2715 '; } .badge.orange::before { content: '\25B2 '; } .badge.blue::before { content: '\25CF '; } .badge.violet::before { content: '\2260 '; }          /* the status is never colour alone: a mark in front of the word */
/* a form inside a card fills the card (one measure for the fields, not a narrow card floating on one side); a stand-alone form (sign-in) keeps its narrow width */
.card.form { max-width: none; }
.card.form input, .card.form select, .card.form textarea { max-width: 560px; }
.card.form .row, .card.form > .btn { max-width: 560px; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--sp-3); margin-bottom: var(--sp-4); }
.toasts { pointer-events: none; }
.toast { pointer-events: auto; }

/* the red blended into the navy, widely (owner decision 2026-10-09): lines, borders, fills without small text on the red end, heading bars, dividers, focus glow. Text colours are unchanged. */
.card > h2, .page-head > h2, .page-head > h1, .center-card h1 { background: var(--brand-line) no-repeat right bottom / 56px 3px; padding-bottom: .4rem; }
hr { border: 0; height: 2px; background: var(--brand-line); }
.btn:focus-visible, .app-nav a:focus-visible { box-shadow: 0 0 0 6px rgba(225, 54, 54, .22); }
th { border-bottom-color: var(--line-strong); }
