/* v163: readable text everywhere, on every theme. Loaded after styles.css.
   Some older screens were coloured for dark themes only (white or bright text) and became unreadable on the light
   themes (NE1 Bold, Daylight, Paper, Mist, White-gold, Ocean, Forest, Ascent). Each rule below is a measured fix
   (WCAG contrast checked on every page). */

/* ZAPP colours as text: the bright brand greens/purples on dark themes, deeper shades on light ones. */
:root{--zap-green:#15803d;--zap-purple:#9333ea;--ok-fg:#166534;--warn-fg:#92400e;--bad-fg:#b91c1c}
html[data-theme="dark"],html[data-theme="Dark"],html[data-theme="midnight"],html[data-theme="graphite"],html[data-theme="onyx"]{--zap-green:#22c55e;--zap-purple:#c084fc;--ok-fg:#4ade80;--warn-fg:#fbbf24;--bad-fg:#f87171}

/* Buttons with no colour of their own follow the page text (browsers default them to black — invisible on dark themes). */
button,input[type="submit"],input[type="button"],input[type="reset"]{color:inherit}

/* Month calendar: today's date when it's also the selected day. */
.jb-mc.sel.today .n,.jb-mc.sel .n{color:var(--brand-2,#fff);border-color:var(--brand-2,#fff)}

/* NE1 Bold: muted text a touch darker so it stays readable on tinted cards. */
html[data-theme="ne1-bold"]{--muted:#4d5e63}

/* Light themes only */
html:not([data-theme="dark"]):not([data-theme="Dark"]):not([data-theme="midnight"]):not([data-theme="graphite"]):not([data-theme="onyx"]) .cb-comp-name,
html:not([data-theme="dark"]):not([data-theme="Dark"]):not([data-theme="midnight"]):not([data-theme="graphite"]):not([data-theme="onyx"]) .cb-comp-x{color:var(--fg)!important}
html:not([data-theme="dark"]):not([data-theme="Dark"]):not([data-theme="midnight"]):not([data-theme="graphite"]):not([data-theme="onyx"]) .c-l.c{color:#c2410c}
html:not([data-theme="dark"]):not([data-theme="Dark"]):not([data-theme="midnight"]):not([data-theme="graphite"]):not([data-theme="onyx"]) .c-l.r{color:#b45309}
html:not([data-theme="dark"]):not([data-theme="Dark"]):not([data-theme="midnight"]):not([data-theme="graphite"]):not([data-theme="onyx"]) .c-l.i{color:#dc2626}
html:not([data-theme="dark"]):not([data-theme="Dark"]):not([data-theme="midnight"]):not([data-theme="graphite"]):not([data-theme="onyx"]) .c-l.p2{color:#111827}
html:not([data-theme="dark"]):not([data-theme="Dark"]):not([data-theme="midnight"]):not([data-theme="graphite"]):not([data-theme="onyx"]) .c-l.e{color:#15803d}
html:not([data-theme="dark"]):not([data-theme="Dark"]):not([data-theme="midnight"]):not([data-theme="graphite"]):not([data-theme="onyx"]) .c-l.r2{color:#a16207}
html:not([data-theme="dark"]):not([data-theme="Dark"]):not([data-theme="midnight"]):not([data-theme="graphite"]):not([data-theme="onyx"]) .zap-count{color:#a16207}
html:not([data-theme="dark"]):not([data-theme="Dark"]):not([data-theme="midnight"]):not([data-theme="graphite"]):not([data-theme="onyx"]) .user-admin{color:#be185d}
html:not([data-theme="dark"]):not([data-theme="Dark"]):not([data-theme="midnight"]):not([data-theme="graphite"]):not([data-theme="onyx"]) .set-nav button.danger{color:#dc2626}
html:not([data-theme="dark"]):not([data-theme="Dark"]):not([data-theme="midnight"]):not([data-theme="graphite"]):not([data-theme="onyx"]) .rm-count.c2 .n,
html:not([data-theme="dark"]):not([data-theme="Dark"]):not([data-theme="midnight"]):not([data-theme="graphite"]):not([data-theme="onyx"]) .cmp-count.amber .n,
html:not([data-theme="dark"]):not([data-theme="Dark"]):not([data-theme="midnight"]):not([data-theme="graphite"]):not([data-theme="onyx"]) .cc-age.warn .n{color:#b45309}
html:not([data-theme="dark"]):not([data-theme="Dark"]):not([data-theme="midnight"]):not([data-theme="graphite"]):not([data-theme="onyx"]) .zl-g{color:#15803d!important}

/* Every theme: white text on mid-tone colour tiles needs the deeper shade. */
.it2-l[style*="#ca8a04"],.lp-l[style*="#ca8a04"]{background:#a16207!important}

/* Light themes: the theme colour is also used for links and headings, so it has to read as text on white.
   Each one is a slightly deeper shade of the same colour (≥4.5:1 on the page), with white text on its buttons. */
html[data-theme="white-gold"]{--brand:#8a6d00;--brand-2:#ffffff;--brand-rgb:138,109,0}
html[data-theme="ascent"]{--brand:#8a6d00;--brand-2:#ffffff;--brand-rgb:138,109,0}
html[data-theme="ocean"]{--brand:#0369a1;--brand-2:#ffffff;--brand-rgb:3,105,161}
html[data-theme="forest"]{--brand:#15803d;--brand-2:#ffffff;--brand-rgb:21,128,61}
html[data-theme="daylight"]{--brand:#1d4ed8;--brand-2:#ffffff;--brand-rgb:29,78,216}
html[data-theme="paper"]{--brand:#0f766e;--brand-2:#ffffff;--brand-rgb:15,118,110}
html[data-theme="mist"]{--brand:#4f46e5;--brand-2:#ffffff;--brand-rgb:79,70,229}
/* Grey "off" chips: muted text a shade darker on their grey pill. */
.cc-pill.off,.br-pill.grey,.rp-tag{color:var(--fg)!important}
/* Gold badges ("← Back to …") follow the theme colour, so their text colour always matches. */
.badge.gold,html a.badge.gold{background:var(--brand)!important;border-color:var(--brand)!important;color:var(--brand-2,#fff)!important}
/* Theme colour used as text on a pale tint of itself: nudge it towards the text colour so it stays crisp. */
.hb-badge.info,.sp-tag,.cp-chip,.cd-code,.badge.ai,.qf-chev,.ct-decide-h,.jb-long,.rs-qbtn{color:color-mix(in srgb,var(--brand) 72%,var(--fg))!important}
html[data-theme="white-gold"],html[data-theme="paper"]{--muted:#575e6b}

/* ---- v164: fixes for pages this update doesn't replace (so nothing on the server is overwritten) ---- */
/* Text on theme-coloured buttons and tabs. */
html #rsBtn[aria-expanded="true"],html #rsPanel .rs-actions .pri,html #rsPanel .rs-seg button[aria-pressed="true"],html #rsPanel .rs-voice button,
html .brx .brx-seg label:has(input:checked),html .ev-tabs a.on,html .it2-acts a.pri,html .it2-next,html .mx-pill.go,html .pf-tabs a.on,
html .sg-steps>li::before,html .tg-seq span,html .xl-chip.on,html .rs-tip-ic,html .rs-tip-go,html .it2-row .pri{color:var(--brand-2,#fff)!important}
html .it2-next small{color:var(--brand-2,#fff)!important;opacity:.85}
html .it2-next a.go{color:color-mix(in srgb,var(--brand,#1e40af) 55%,#000)!important}
html .it2-st{color:#475569!important}
/* Testing pages: example labels, EICR C2 tag, CRIPPER step letters (white on a deep colour on every theme). */
html .ct-ex-bad span{color:var(--bad-fg,#b91c1c)!important}
html .ct-ex-good span{color:var(--ok-fg,#15803d)!important}
html .ec-c2 .ec-tag,html .ec-cbtn.ec-c2 b{background:#c2410c!important}
.cripper-step>div:first-child{color:#fff!important}
.cripper-step>div[style*="#ff6a00"]{background:#c2410c!important}
.cripper-step>div[style*="#ff8c00"]{background:#b45309!important}
.cripper-step>div[style*="#ff0000"]{background:#dc2626!important}
.cripper-step>div[style*="#8000ff"]{background:#7c3aed!important}
.cripper-step>div[style*="#00c853"]{background:#15803d!important}
.cripper-step>div[style*="#14b8a6"]{background:#0f766e!important}
/* Circuit builder earth terminal, calculators category tags, quiz "Open" link, retest email preview, onboarding ticks. */
html .port-E{background:#15803d!important}
html .cx-tile .tag{color:color-mix(in srgb,var(--tint) 72%,var(--fg))!important}
html span[style*="color:#1d49bd"]{color:var(--brand,#1d49bd)!important}
html .rs-mf{color:#56656a!important}
html .bg-step.done .bg-num{background:#15803d!important;border-color:#15803d!important;color:#fff!important}
html .bg-tag.ok{color:var(--ok-fg,#15803d)!important}
html .cc-tag.warn{color:var(--warn-fg,#92400e)!important}

/* v165: on a laptop the Quick Help button is a small round "?" in the corner (it used to sit over buttons and
   plans); hovering or tabbing to it shows the words. */
@media (min-width:701px){
  html .izhb-btn{width:46px;padding:0;justify-content:center;gap:0}
  html .izhb-btn .izhb-btn-t{display:none}
  html .izhb-btn:hover,html .izhb-btn:focus-visible{width:auto;padding:0 16px 0 13px;gap:6px}
  html .izhb-btn:hover .izhb-btn-t,html .izhb-btn:focus-visible .izhb-btn-t{display:inline}
}

/* v171: stacked tables on phones never wider than the screen (an old rule gave every responsive table 640px) */
@media (max-width:700px){
  .table-responsive table.stack-table{min-width:0 !important;width:100% !important}
  /* line items (invoices, quotes, credit notes): a tidy card — description full width, then two to a row, labels on top */
  table.stack-table tr:has(input[name="item_description"]){display:grid !important;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:10px 12px;padding:12px !important}
  table.stack-table tr:has(input[name="item_description"]) > td{display:flex !important;flex-direction:column !important;align-items:stretch !important;gap:4px !important;padding:0 !important;min-width:0}
  table.stack-table tr:has(input[name="item_description"]) > td[data-label]:before{flex:none !important;font-size:12.5px !important}
  table.stack-table tr:has(input[name="item_description"]) > td:has(input[name="item_description"]){grid-column:1 / -1}
  table.stack-table tr:has(input[name="item_description"]) > td:not([data-label]),table.stack-table tr:has(input[name="item_description"]) > td:last-child:has(button){grid-column:1 / -1}
  table.stack-table tr:has(input[name="item_description"]) input,table.stack-table tr:has(input[name="item_description"]) select{width:100% !important;min-width:0 !important;min-height:46px;box-sizing:border-box;font-size:16px}
}

/* v173: quote and invoice line items on phones — description on top, "1 × £950.00 · VAT 20%" and the line total under it */
@media (max-width:640px){
  .table-responsive table.li-view{min-width:0 !important;width:100% !important}
  table.li-view thead{display:none}
  table.li-view,table.li-view tbody{display:block;width:100%}
  table.li-view tr{display:grid;grid-template-columns:auto auto auto 1fr;align-items:baseline;gap:3px 8px;padding:10px 0;border-bottom:1px solid var(--border)}
  table.li-view td{display:block;padding:0 !important;border:0 !important;font-size:14px;color:var(--muted);white-space:nowrap}
  table.li-view td:nth-child(1){grid-column:1 / -1;white-space:normal;color:var(--fg);font-weight:650;font-size:15px}
  table.li-view td:nth-child(2)::after{content:" ×"}
  table.li-view td:nth-child(4)::before{content:"· VAT "}
  table.li-view td:nth-child(5){justify-self:end;font-weight:800;color:var(--fg);font-variant-numeric:tabular-nums}
}

/* ── v178: one button size across the app ─────────────────────────────────────
   <button class="btn"> used the browser's 13px font and came out ~42px tall, while <a class="btn"> was 16px / 51px,
   so "Save" looked smaller than "+ New invoice" on the same screen. Both are now the same: 46px, same font. */
.btn{display:inline-flex;align-items:center;justify-content:center;gap:6px;min-height:46px;padding:10px 18px;font-family:inherit;font-size:15px;font-weight:700;line-height:1.2;text-align:center;vertical-align:middle;box-sizing:border-box;cursor:pointer}
.btn.btn-small,.btn.btn-sm{min-height:38px;padding:6px 12px;font-size:13.5px}
/* Back links ("‹ Money", "← Quotes"…): a finger-sized tap area without moving anything on the page */
a[class$="-back"],a[class*="-back "],.iz-backbar a{display:inline-block;padding:12px 6px 12px 0;margin:-12px 0}
