/* Castlance Quality v15 — unified public / portal / admin visual system.
   Loaded last. Visual only; no billing, license or quota behavior. */

/* ---------- Shared theme tokens ---------- */
html[data-theme="light"]{
  --ux-bg:#f3f6fa;--ux-bg-soft:#eaf0f6;--ux-surface:#ffffff;--ux-surface2:#f7f9fc;--ux-surface3:#eef3f8;
  --ux-text:#102138;--ux-muted:#60748b;--ux-faint:#7d8fa3;--ux-line:#d7e2ed;--ux-line2:#c8d6e5;
  --ux-blue:#2f67e8;--ux-green:#087553;--ux-amber:#956000;--ux-red:#b4233f;
  --ux-shadow:0 12px 34px rgba(20,45,75,.075);color-scheme:light;
}
html[data-theme="dark"]{
  --ux-bg:#07111f;--ux-bg-soft:#0a1625;--ux-surface:#0f1b2b;--ux-surface2:#132238;--ux-surface3:#182a42;
  --ux-text:#eef4fb;--ux-muted:#9baec3;--ux-faint:#7f93aa;--ux-line:#263a50;--ux-line2:#35506d;
  --ux-blue:#7aa1ff;--ux-green:#62d6b0;--ux-amber:#f2c56d;--ux-red:#ff8ca3;
  --ux-shadow:0 14px 38px rgba(0,0,0,.22);color-scheme:dark;
}
html[data-admin-theme="light"]{
  --aux-bg:#f3f6fa;--aux-surface:#fff;--aux-surface2:#f7f9fc;--aux-surface3:#eef3f8;
  --aux-text:#102138;--aux-muted:#60748b;--aux-faint:#7d8fa3;--aux-line:#d7e2ed;--aux-line2:#c8d6e5;--aux-blue:#2f67e8;
  --aux-shadow:0 10px 28px rgba(20,45,75,.065);color-scheme:light;
}
html[data-admin-theme="dark"]{
  --aux-bg:#07111f;--aux-surface:#0f1b2b;--aux-surface2:#132238;--aux-surface3:#182a42;
  --aux-text:#eef4fb;--aux-muted:#9baec3;--aux-faint:#7f93aa;--aux-line:#263a50;--aux-line2:#35506d;--aux-blue:#7aa1ff;
  --aux-shadow:0 12px 34px rgba(0,0,0,.18);color-scheme:dark;
}

/* ---------- Public website ---------- */
html[data-theme] body.castlance-public-v8{
  background:var(--ux-bg)!important;background-color:var(--ux-bg)!important;color:var(--ux-text)!important;
}
html[data-theme] body.castlance-public-v8 main{background:var(--ux-bg)!important;color:var(--ux-text)!important}
html[data-theme] body.castlance-public-v8 main>section:not(.premium-hero),
html[data-theme] body.castlance-public-v8 .section:not(.premium-hero){background:var(--ux-bg)!important;background-color:var(--ux-bg)!important;color:var(--ux-text)!important}
html[data-theme] body.castlance-public-v8 .section.soft{background:var(--ux-bg-soft)!important;background-color:var(--ux-bg-soft)!important}
html[data-theme] body.castlance-public-v8 :is(h1,h2,h3,h4,h5,h6,b,strong,label,summary){color:var(--ux-text)!important;-webkit-text-fill-color:var(--ux-text)!important}
html[data-theme] body.castlance-public-v8 :is(p,small,.muted,.subtitle,.description,.hint,.help){color:var(--ux-muted)!important;-webkit-text-fill-color:var(--ux-muted)!important}
html[data-theme] body.castlance-public-v8 .eyebrow{color:var(--ux-blue)!important;-webkit-text-fill-color:var(--ux-blue)!important}

/* Public cards / panels */
html[data-theme] body.castlance-public-v8 :is(
 .card,.panel,.box,.checkout-card,.upgrade-current,.topup-summary,.opt,.notice,.blog-card-v5,.article-shell-v5,.article-content-v5,.article-side-v5,
 .pricing-card-v43,.pricing-hero-card,.pricing-compare-v43,.pricing-demo-box,
 .faq-content-v43,.faq-sidebar-v43,.faq-support-card,.faq-bottom-help,.faq-accordion-v43 details,
 .download-platform,.release-card,.requirements-grid>article,.os-detect,.release-meta>span,
 .cast-reference-card,.cast-video-card,.cast-review-card
){background:var(--ux-surface)!important;background-color:var(--ux-surface)!important;border-color:var(--ux-line)!important;color:var(--ux-text)!important;box-shadow:var(--ux-shadow)!important}
html[data-theme] body.castlance-public-v8 :is(.release-meta>span,.value-grid>div,.journey article,.premium-features article,.platform-cards article){border-color:var(--ux-line)!important}

/* Download center: fixes mixed light/dark surfaces shown in QA screenshots. */
html[data-theme] body.castlance-public-v8 .download-hero,
html[data-theme] body.castlance-public-v8 .download-hero .container,
html[data-theme] body.castlance-public-v8 .download-intro,
html[data-theme] body.castlance-public-v8 .release-section,
html[data-theme] body.castlance-public-v8 .release-layout,
html[data-theme] body.castlance-public-v8 .requirements-section{background:var(--ux-bg)!important;background-color:var(--ux-bg)!important}
html[data-theme] body.castlance-public-v8 .download-hero .download-intro h1,
html[data-theme] body.castlance-public-v8 .download-hero .download-intro h2,
html[data-theme] body.castlance-public-v8 .release-section h2,
html[data-theme] body.castlance-public-v8 .requirements-section h2{color:var(--ux-text)!important;-webkit-text-fill-color:var(--ux-text)!important}
html[data-theme] body.castlance-public-v8 .download-hero .download-intro p,
html[data-theme] body.castlance-public-v8 .release-section p,
html[data-theme] body.castlance-public-v8 .requirements-section p{color:var(--ux-muted)!important;-webkit-text-fill-color:var(--ux-muted)!important}
html[data-theme] body.castlance-public-v8 .download-platform{min-height:0!important;padding:28px!important}
html[data-theme] body.castlance-public-v8 .download-platform :is(h2,h3,b,strong){color:var(--ux-text)!important;-webkit-text-fill-color:var(--ux-text)!important}
html[data-theme] body.castlance-public-v8 .download-platform :is(p,small,.platform-foot){color:var(--ux-muted)!important;-webkit-text-fill-color:var(--ux-muted)!important}
html[data-theme] body.castlance-public-v8 .release-meta{grid-template-columns:repeat(3,minmax(0,1fr))!important}
html[data-theme] body.castlance-public-v8 .release-meta>span{min-width:0!important;padding:14px!important}
html[data-theme] body.castlance-public-v8 .release-meta small{color:var(--ux-muted)!important;-webkit-text-fill-color:var(--ux-muted)!important}
html[data-theme] body.castlance-public-v8 .release-meta b{color:var(--ux-text)!important;-webkit-text-fill-color:var(--ux-text)!important;overflow-wrap:anywhere}
html[data-theme="light"] body.castlance-public-v8 .recommended-pill{background:#eef4ff!important;color:#2b62dc!important;-webkit-text-fill-color:#2b62dc!important}
html[data-theme="dark"] body.castlance-public-v8 .recommended-pill{background:#172b48!important;color:#a9c0ff!important;-webkit-text-fill-color:#a9c0ff!important}
html[data-theme="light"] body.castlance-public-v8 .platform-icon{background:#edf3ff!important;color:#2f67e8!important}
html[data-theme="dark"] body.castlance-public-v8 .platform-icon{background:#172b48!important;color:#a9c0ff!important}

/* Buttons and nav stay readable in both modes. */
html[data-theme] body.castlance-public-v8 .btn:not(.primary){background:var(--ux-surface)!important;border-color:var(--ux-line2)!important;color:var(--ux-text)!important;-webkit-text-fill-color:var(--ux-text)!important}
html[data-theme] body.castlance-public-v8 .btn.primary{background:linear-gradient(135deg,#2f67e8,#6d4ee8)!important;color:#fff!important;-webkit-text-fill-color:#fff!important;border-color:transparent!important}
html[data-theme="light"] body.castlance-public-v8 .site-header{background:rgba(255,255,255,.96)!important;border-color:var(--ux-line)!important}
html[data-theme="dark"] body.castlance-public-v8 .site-header{background:rgba(7,17,31,.96)!important;border-color:var(--ux-line)!important}
html[data-theme] body.castlance-public-v8 .site-header :is(.brand b,.site-nav a.active,.site-nav a:hover){color:var(--ux-text)!important;-webkit-text-fill-color:var(--ux-text)!important}
html[data-theme] body.castlance-public-v8 .site-nav a{color:var(--ux-muted)!important;-webkit-text-fill-color:var(--ux-muted)!important}

/* ---------- Customer portal ---------- */
html[data-theme] body.castlance-portal-v8{background:var(--ux-bg)!important;background-color:var(--ux-bg)!important;color:var(--ux-text)!important}
html[data-theme] body.castlance-portal-v8 :is(.wrap,.shell){color:var(--ux-text)!important}
html[data-theme] body.castlance-portal-v8 :is(h1,h2,h3,h4,h5,h6,b,strong,label,summary,code){color:var(--ux-text)!important;-webkit-text-fill-color:var(--ux-text)!important}
html[data-theme] body.castlance-portal-v8 :is(p,small,.muted,.subtitle,.description,.hint,.help){color:var(--ux-muted)!important;-webkit-text-fill-color:var(--ux-muted)!important}
html[data-theme] body.castlance-portal-v8 .eyebrow{color:var(--ux-blue)!important;-webkit-text-fill-color:var(--ux-blue)!important}
html[data-theme] body.castlance-portal-v8 :is(
 .card,.saas-card,.panel,.stat,.release-center,.download-card,.portal-v64-title,.portal-v64-quick,
 .portal-pop,.portal-accordion,.portal-new-ticket,.profile-collapse,.profile-collapse-body,.setup-guide,.setup-step,
 .quota-overview,.premium-quota,.table-wrap,.portal-invoice-row,.portal-invoice-summary>div
){background:var(--ux-surface)!important;background-color:var(--ux-surface)!important;border-color:var(--ux-line)!important;color:var(--ux-text)!important;box-shadow:var(--ux-shadow)!important}
html[data-theme] body.castlance-portal-v8 :is(.row,.download-card,.release-meta>div,.quota-saas-grid>div,.profile-collapse-body,.portal-accordion-body,.portal-chat,.portal-pop a,.portal-new-ticket form){background:var(--ux-surface2)!important;background-color:var(--ux-surface2)!important;border-color:var(--ux-line)!important;color:var(--ux-text)!important}

/* Portal KPI cards: legacy v10 forced white text even in light mode. */
html[data-theme] body.castlance-portal-v8 .stats{display:grid!important;grid-template-columns:repeat(4,minmax(0,1fr))!important;gap:12px!important;margin:14px 0 18px!important}
html[data-theme] body.castlance-portal-v8 .stats>.stat,
html[data-theme] body.castlance-portal-v8 .stats>div{min-height:112px!important;padding:17px!important;background:var(--ux-surface)!important;border:1px solid var(--ux-line)!important;border-radius:15px!important;box-shadow:var(--ux-shadow)!important}
html[data-theme] body.castlance-portal-v8 .stats>div:last-child{background:var(--ux-surface)!important;border-color:var(--ux-line)!important}
html[data-theme] body.castlance-portal-v8 .stats>div b{display:block!important;margin-top:8px!important;font-size:18px!important;line-height:1.25!important;color:var(--ux-text)!important;-webkit-text-fill-color:var(--ux-text)!important;white-space:normal!important;overflow-wrap:anywhere}
html[data-theme] body.castlance-portal-v8 .stats>div small,
html[data-theme] body.castlance-portal-v8 .stats>div span{color:var(--ux-muted)!important;-webkit-text-fill-color:var(--ux-muted)!important}

/* Portal header / menu */
html[data-theme="light"] body.castlance-portal-v8 .topbar{background:rgba(255,255,255,.96)!important;border-bottom:1px solid var(--ux-line)!important;color:var(--ux-text)!important}
html[data-theme="dark"] body.castlance-portal-v8 .topbar{background:rgba(7,17,31,.96)!important;border-bottom:1px solid var(--ux-line)!important;color:var(--ux-text)!important}
html[data-theme] body.castlance-portal-v8 .topbar :is(.brand,b,a,button){color:var(--ux-text)!important;-webkit-text-fill-color:var(--ux-text)!important}
html[data-theme] body.castlance-portal-v8 :is(.langs,.portal-bell summary,.portal-theme-toggle,.portal-menu-btn){background:var(--ux-surface2)!important;border-color:var(--ux-line)!important;color:var(--ux-text)!important}
html[data-theme] body.castlance-portal-v8 .portal-mobile-nav{background:var(--ux-surface)!important;color:var(--ux-text)!important;border-color:var(--ux-line)!important}
html[data-theme] body.castlance-portal-v8 .portal-mobile-head{background:var(--ux-surface)!important;border-color:var(--ux-line)!important;color:var(--ux-text)!important}
html[data-theme] body.castlance-portal-v8 .portal-mobile-group{background:var(--ux-surface2)!important;border-color:var(--ux-line)!important}
html[data-theme] body.castlance-portal-v8 .portal-mobile-group a{color:var(--ux-text)!important;-webkit-text-fill-color:var(--ux-text)!important}

/* Forms */
html[data-theme] body.castlance-portal-v8 :is(input:not([type="radio"]):not([type="checkbox"]),select,textarea){background:var(--ux-surface2)!important;color:var(--ux-text)!important;-webkit-text-fill-color:var(--ux-text)!important;border:1px solid var(--ux-line2)!important}
html[data-theme] body.castlance-portal-v8 :is(input,textarea)::placeholder{color:var(--ux-faint)!important;-webkit-text-fill-color:var(--ux-faint)!important;opacity:1!important}

/* Top-up history / general portal tables: never crush columns together. */
html[data-theme] body.castlance-portal-v8 .table-wrap{overflow:auto!important;max-width:100%!important;border-radius:14px!important;scrollbar-gutter:stable}
html[data-theme] body.castlance-portal-v8 .table-wrap table{width:100%!important;border-collapse:separate!important;border-spacing:0!important;color:var(--ux-text)!important}
html[data-theme] body.castlance-portal-v8 .table-wrap th{padding:12px 14px!important;text-align:left!important;white-space:nowrap!important;background:var(--ux-surface2)!important;color:var(--ux-muted)!important;-webkit-text-fill-color:var(--ux-muted)!important;border-color:var(--ux-line)!important}
html[data-theme] body.castlance-portal-v8 .table-wrap td{padding:13px 14px!important;text-align:left!important;vertical-align:middle!important;background:var(--ux-surface)!important;color:var(--ux-text)!important;-webkit-text-fill-color:var(--ux-text)!important;border-color:var(--ux-line)!important}
html[data-theme] body.castlance-portal-v8 .table-wrap td small{display:block!important;color:var(--ux-muted)!important;-webkit-text-fill-color:var(--ux-muted)!important;margin-top:3px!important}
html[data-theme] body.castlance-portal-v8 #portal-topups .table-wrap table{min-width:790px!important;table-layout:auto!important}
html[data-theme] body.castlance-portal-v8 #portal-topups .table-wrap th:nth-child(1),
html[data-theme] body.castlance-portal-v8 #portal-topups .table-wrap td:nth-child(1){min-width:220px!important;white-space:normal!important}
html[data-theme] body.castlance-portal-v8 #portal-topups .table-wrap th:nth-child(4),
html[data-theme] body.castlance-portal-v8 #portal-topups .table-wrap td:nth-child(4){min-width:190px!important;white-space:normal!important}
html[data-theme] body.castlance-portal-v8 #portal-topups .table-wrap td .btn{white-space:nowrap!important}
html[data-theme] body.castlance-portal-v8 .pill.good{background:color-mix(in srgb,var(--ux-green) 16%,var(--ux-surface))!important;color:var(--ux-green)!important;-webkit-text-fill-color:var(--ux-green)!important}

/* ---------- Admin ---------- */
html[data-admin-theme] body.castlance-admin-v8.cast-ui-v2{background:var(--aux-bg)!important;background-color:var(--aux-bg)!important;color:var(--aux-text)!important}
html[data-admin-theme] body.castlance-admin-v8.cast-ui-v2 .main{background:var(--aux-bg)!important;color:var(--aux-text)!important}
html[data-admin-theme] body.castlance-admin-v8.cast-ui-v2 :is(h1,h2,h3,h4,h5,h6,b,strong,label,summary,dt,dd,li){color:var(--aux-text)!important;-webkit-text-fill-color:var(--aux-text)!important}
html[data-admin-theme] body.castlance-admin-v8.cast-ui-v2 :is(p,small,.subtitle,.muted,.description,.hint,.help,.lang-note){color:var(--aux-muted)!important;-webkit-text-fill-color:var(--aux-muted)!important}
html[data-admin-theme] body.castlance-admin-v8.cast-ui-v2 .eyebrow{color:var(--aux-blue)!important;-webkit-text-fill-color:var(--aux-blue)!important}
html[data-admin-theme] body.castlance-admin-v8.cast-ui-v2 :is(.section,.card,.saas-card,.an-card,.kpi,.health,.finance-kpi,.an-kpi,.table,.table-wrap,.panel,.box){background:var(--aux-surface)!important;background-color:var(--aux-surface)!important;border-color:var(--aux-line)!important;color:var(--aux-text)!important;box-shadow:var(--aux-shadow)!important}
html[data-admin-theme] body.castlance-admin-v8.cast-ui-v2 :is(.mini,.an-row,.an-health>div,.ticket-item,.lang-block,.section-note,.review-admin-card,.experience-preview){background:var(--aux-surface2)!important;background-color:var(--aux-surface2)!important;border-color:var(--aux-line)!important;color:var(--aux-text)!important}

/* v10 accordion was hard-coded dark. Theme it explicitly. */
html[data-admin-theme] body.castlance-admin-v8.cast-ui-v2 .v10-accordion{background:var(--aux-surface)!important;border:1px solid var(--aux-line)!important;border-radius:13px!important;overflow:hidden!important;box-shadow:none!important}
html[data-admin-theme] body.castlance-admin-v8.cast-ui-v2 .v10-accordion>summary{background:var(--aux-surface2)!important;color:var(--aux-text)!important;-webkit-text-fill-color:var(--aux-text)!important;border:0!important;padding:14px 16px!important}
html[data-admin-theme] body.castlance-admin-v8.cast-ui-v2 .v10-accordion>summary::after{color:var(--aux-blue)!important}
html[data-admin-theme] body.castlance-admin-v8.cast-ui-v2 .v10-accordion-body{background:var(--aux-surface)!important;border-top:1px solid var(--aux-line)!important;padding:12px!important}

/* Admin tables. */
html[data-admin-theme] body.castlance-admin-v8.cast-ui-v2 :is(.table,.table-wrap){overflow:auto!important;max-width:100%!important;border-radius:14px!important;scrollbar-gutter:stable}
html[data-admin-theme] body.castlance-admin-v8.cast-ui-v2 table{width:100%!important;border-collapse:separate!important;border-spacing:0!important;color:var(--aux-text)!important}
html[data-admin-theme] body.castlance-admin-v8.cast-ui-v2 th{padding:11px 13px!important;white-space:nowrap!important;background:var(--aux-surface2)!important;color:var(--aux-muted)!important;-webkit-text-fill-color:var(--aux-muted)!important;border-color:var(--aux-line)!important}
html[data-admin-theme] body.castlance-admin-v8.cast-ui-v2 td{padding:12px 13px!important;vertical-align:middle!important;background:var(--aux-surface)!important;color:var(--aux-text)!important;-webkit-text-fill-color:var(--aux-text)!important;border-color:var(--aux-line)!important}
html[data-admin-theme] body.castlance-admin-v8.cast-ui-v2 td small{color:var(--aux-muted)!important;-webkit-text-fill-color:var(--aux-muted)!important}

/* Admin controls / checkboxes. */
html[data-admin-theme] body.castlance-admin-v8.cast-ui-v2 :is(input:not([type="checkbox"]):not([type="radio"]),select,textarea){background:var(--aux-surface2)!important;border:1px solid var(--aux-line2)!important;color:var(--aux-text)!important;-webkit-text-fill-color:var(--aux-text)!important;box-shadow:none!important}
html[data-admin-theme] body.castlance-admin-v8.cast-ui-v2 :is(input,textarea)::placeholder{color:var(--aux-faint)!important;-webkit-text-fill-color:var(--aux-faint)!important;opacity:1!important}
html[data-admin-theme] body.castlance-admin-v8.cast-ui-v2 label.check{background:var(--aux-surface2)!important;border-color:var(--aux-line)!important;color:var(--aux-text)!important}
html[data-admin-theme] body.castlance-admin-v8.cast-ui-v2 .btn:not(.primary){background:var(--aux-surface2)!important;border-color:var(--aux-line2)!important;color:var(--aux-text)!important;-webkit-text-fill-color:var(--aux-text)!important}
html[data-admin-theme] body.castlance-admin-v8.cast-ui-v2 .btn.primary{background:linear-gradient(135deg,#2f67e8,#6d4ee8)!important;color:#fff!important;-webkit-text-fill-color:#fff!important;border-color:transparent!important}

/* Checkout / upgrade / renew pages share public theme tokens. */
html[data-theme] body.castlance-public-v8 :is(.checkout-card,.upgrade-current,.topup-summary,.opt,.notice){background:var(--ux-surface)!important;background-color:var(--ux-surface)!important;border-color:var(--ux-line)!important;color:var(--ux-text)!important}
html[data-theme] body.castlance-public-v8 :is(.checkout-card,.upgrade-current,.topup-summary,.opt,.notice) :is(b,strong,label,h1,h2,h3,span){color:var(--ux-text)!important;-webkit-text-fill-color:var(--ux-text)!important}
html[data-theme] body.castlance-public-v8 :is(.checkout-card,.upgrade-current,.topup-summary,.opt,.notice) :is(p,small){color:var(--ux-muted)!important;-webkit-text-fill-color:var(--ux-muted)!important}
html[data-theme] body.castlance-public-v8 .checkout-grid{align-items:start!important}
html[data-theme] body.castlance-public-v8 .btn.wide{width:100%!important}

/* ---------- Responsive geometry ---------- */
@media(max-width:980px){
 html[data-theme] body.castlance-public-v8 .container{width:min(100% - 28px,1180px)!important}
 html[data-theme] body.castlance-public-v8 .release-meta{grid-template-columns:1fr 1fr!important}
 html[data-theme] body.castlance-portal-v8 .stats{grid-template-columns:repeat(2,minmax(0,1fr))!important}
 html[data-admin-theme] body.castlance-admin-v8.cast-ui-v2 .main{padding:16px!important}
 html[data-admin-theme] body.castlance-admin-v8.cast-ui-v2 .top{align-items:flex-start!important;gap:12px!important}
 html[data-admin-theme] body.castlance-admin-v8.cast-ui-v2 .top-actions{max-width:58%!important;justify-content:flex-end!important}
}
@media(max-width:640px){
 html[data-theme] body.castlance-public-v8 .section{padding:52px 0!important}
 html[data-theme] body.castlance-public-v8 .download-platform{padding:20px!important;border-radius:16px!important}
 html[data-theme] body.castlance-public-v8 .release-meta{grid-template-columns:1fr!important}
 html[data-theme] body.castlance-public-v8 .download-intro h1{font-size:clamp(2rem,11vw,3rem)!important}
 html[data-theme] body.castlance-portal-v8 .wrap{width:min(100% - 20px,1180px)!important;padding-top:18px!important}
 html[data-theme] body.castlance-portal-v8 .stats{grid-template-columns:1fr!important;gap:9px!important}
 html[data-theme] body.castlance-portal-v8 .stats>.stat,html[data-theme] body.castlance-portal-v8 .stats>div{min-height:88px!important;padding:14px!important}
 html[data-theme] body.castlance-portal-v8 .stats>div b{font-size:16px!important}
 html[data-theme] body.castlance-portal-v8 .card{padding:14px!important;border-radius:14px!important}
 html[data-theme] body.castlance-portal-v8 .table-wrap{margin-inline:-4px!important;width:calc(100% + 8px)!important}
 html[data-admin-theme] body.castlance-admin-v8.cast-ui-v2 .main{padding:12px!important}
 html[data-admin-theme] body.castlance-admin-v8.cast-ui-v2 .top{display:flex!important;flex-direction:column!important}
 html[data-admin-theme] body.castlance-admin-v8.cast-ui-v2 .top-actions{max-width:none!important;width:100%!important;justify-content:flex-start!important;overflow-x:auto!important;padding-bottom:4px!important}
 html[data-admin-theme] body.castlance-admin-v8.cast-ui-v2 .section,html[data-admin-theme] body.castlance-admin-v8.cast-ui-v2 .card{border-radius:14px!important}
}


/* =========================================================
   v15.0.1 — screenshot-driven final contrast + geometry pass
   ========================================================= */

/* Global overflow discipline. */
html[data-theme] body.castlance-public-v8 :is(main,section,article,div,nav,header,footer),
html[data-theme] body.castlance-portal-v8 :is(main,section,article,div,nav,header,aside),
html[data-admin-theme] body.castlance-admin-v8.cast-ui-v2 :is(main,section,article,div,nav,header,aside){min-width:0}
html[data-theme] body.castlance-public-v8 :is(h1,h2,h3,h4,p,span,b,strong,a),
html[data-theme] body.castlance-portal-v8 :is(h1,h2,h3,h4,p,span,b,strong,a),
html[data-admin-theme] body.castlance-admin-v8.cast-ui-v2 :is(h1,h2,h3,h4,p,span,b,strong,a,td,th){overflow-wrap:anywhere}
html[data-theme] body.castlance-public-v8 :is(img,video,iframe),
html[data-theme] body.castlance-portal-v8 :is(img,video,iframe){max-width:100%}

/* Keep intentional brand-dark sections dark in BOTH user themes. */
html[data-theme] body.castlance-public-v8 :is(.premium-hero,.labs,.try-card){
  --ux-brand-text:#f5f8fc;--ux-brand-muted:#b4c6d9;
  color:#f5f8fc!important;
}
html[data-theme] body.castlance-public-v8 main>section.labs,
html[data-theme] body.castlance-public-v8 .section.labs{background:#061426!important;background-color:#061426!important}
html[data-theme] body.castlance-public-v8 :is(.premium-hero,.labs,.try-card) :is(h1,h2,h3,h4,b,strong,label,summary){color:#f5f8fc!important;-webkit-text-fill-color:#f5f8fc!important}
html[data-theme] body.castlance-public-v8 :is(.premium-hero,.labs,.try-card) :is(p,small,.muted,.description){color:#b4c6d9!important;-webkit-text-fill-color:#b4c6d9!important}
html[data-theme] body.castlance-public-v8 :is(.premium-hero,.labs,.try-card) .eyebrow{color:#66ddf0!important;-webkit-text-fill-color:#66ddf0!important}

/* Product mockup is intentionally a light preview even when site theme is dark. */
html[data-theme] body.castlance-public-v8 .app-shot{background:#fff!important;color:#102138!important}
html[data-theme] body.castlance-public-v8 .app-shot :is(h1,h2,h3,h4,b,strong){color:#102138!important;-webkit-text-fill-color:#102138!important}
html[data-theme] body.castlance-public-v8 .app-shot :is(p,small,span){color:#64758b!important;-webkit-text-fill-color:#64758b!important}
html[data-theme] body.castlance-public-v8 .app-shot aside :is(strong,.sel){color:#fff!important;-webkit-text-fill-color:#fff!important}
html[data-theme] body.castlance-public-v8 .floating{background:#fff!important;color:#102138!important}
html[data-theme] body.castlance-public-v8 .floating b{color:#102138!important;-webkit-text-fill-color:#102138!important}
html[data-theme] body.castlance-public-v8 .floating span{color:#6f8196!important;-webkit-text-fill-color:#6f8196!important}

/* Public footer + mobile drawer remain deliberate dark navigation surfaces. */
html[data-theme] body.castlance-public-v8 :is(.site-footer,.c11-mobile-drawer){background:#071426!important;color:#eef4fb!important}
html[data-theme] body.castlance-public-v8 :is(.site-footer,.c11-mobile-drawer) :is(h1,h2,h3,b,strong,a){color:#eef4fb!important;-webkit-text-fill-color:#eef4fb!important}
html[data-theme] body.castlance-public-v8 :is(.site-footer,.c11-mobile-drawer) :is(p,small,span){color:#a9bdd4!important;-webkit-text-fill-color:#a9bdd4!important}
html[data-theme] body.castlance-public-v8 .c11-mobile-group{background:#0f1d2e!important;border-color:#263b52!important}
html[data-theme] body.castlance-public-v8 .c11-mobile-theme{background:#13243a!important;border-color:#304862!important;color:#eef4fb!important}

/* Portal hero is a brand card; don't let generic light-theme text overrides wash it out. */
html[data-theme] body.castlance-portal-v8 .hero-license{background:linear-gradient(135deg,#07182b,#123d70 65%,#392e8b)!important;border-color:rgba(255,255,255,.10)!important;color:#fff!important}
html[data-theme] body.castlance-portal-v8 .hero-license :is(h1,h2,h3,b,strong,code){color:#fff!important;-webkit-text-fill-color:#fff!important}
html[data-theme] body.castlance-portal-v8 .hero-license :is(p,small){color:#b9cde0!important;-webkit-text-fill-color:#b9cde0!important}
html[data-theme] body.castlance-portal-v8 .hero-license .license-code{background:rgba(255,255,255,.075)!important;border-color:rgba(255,255,255,.14)!important}
html[data-theme] body.castlance-portal-v8 .hero-license .copy{background:rgba(255,255,255,.10)!important;border-color:rgba(255,255,255,.18)!important;color:#fff!important;-webkit-text-fill-color:#fff!important}

/* Portal login follows selected theme instead of always presenting a white card. */
html[data-theme="light"] body.castlance-portal-v8 .login-shell{background:radial-gradient(circle at 50% 0,#e9f1ff 0,#f3f6fa 52%,#e9eef5 100%)!important}
html[data-theme="dark"] body.castlance-portal-v8 .login-shell{background:radial-gradient(circle at 50% 0,#173c69 0,#07182b 45%,#050e19 100%)!important}
html[data-theme] body.castlance-portal-v8 .login-card{background:var(--ux-surface)!important;border:1px solid var(--ux-line)!important;color:var(--ux-text)!important}
html[data-theme] body.castlance-portal-v8 .login-note{background:var(--ux-surface2)!important;color:var(--ux-muted)!important}
html[data-theme] body.castlance-portal-v8 .field label{color:var(--ux-muted)!important;-webkit-text-fill-color:var(--ux-muted)!important}

/* Portal data cards: compact, visible values and stable height. */
html[data-theme] body.castlance-portal-v8 .stats>.stat{display:flex!important;flex-direction:column!important;justify-content:flex-start!important;gap:0!important}
html[data-theme] body.castlance-portal-v8 .stats>.stat small:first-child{margin:0!important}
html[data-theme] body.castlance-portal-v8 .stats>.stat b{min-height:23px!important}
html[data-theme] body.castlance-portal-v8 .stats>.stat small:last-child:not(:first-child){margin-top:auto!important;padding-top:8px!important}

/* Top-up history: real independent columns, no header/data collisions. */
html[data-theme] body.castlance-portal-v8 #portal-topups .table-wrap{border:1px solid var(--ux-line)!important}
html[data-theme] body.castlance-portal-v8 #portal-topups .table-wrap table{min-width:920px!important;table-layout:fixed!important}
html[data-theme] body.castlance-portal-v8 #portal-topups .table-wrap th:nth-child(1),
html[data-theme] body.castlance-portal-v8 #portal-topups .table-wrap td:nth-child(1){width:27%!important;min-width:230px!important}
html[data-theme] body.castlance-portal-v8 #portal-topups .table-wrap th:nth-child(2),
html[data-theme] body.castlance-portal-v8 #portal-topups .table-wrap td:nth-child(2){width:12%!important;min-width:105px!important;text-align:center!important}
html[data-theme] body.castlance-portal-v8 #portal-topups .table-wrap th:nth-child(3),
html[data-theme] body.castlance-portal-v8 #portal-topups .table-wrap td:nth-child(3){width:12%!important;min-width:105px!important;text-align:center!important}
html[data-theme] body.castlance-portal-v8 #portal-topups .table-wrap th:nth-child(4),
html[data-theme] body.castlance-portal-v8 #portal-topups .table-wrap td:nth-child(4){width:22%!important;min-width:190px!important}
html[data-theme] body.castlance-portal-v8 #portal-topups .table-wrap th:nth-child(5),
html[data-theme] body.castlance-portal-v8 #portal-topups .table-wrap td:nth-child(5){width:12%!important;min-width:105px!important;text-align:center!important}
html[data-theme] body.castlance-portal-v8 #portal-topups .table-wrap th:nth-child(6),
html[data-theme] body.castlance-portal-v8 #portal-topups .table-wrap td:nth-child(6){width:15%!important;min-width:135px!important;text-align:center!important}
html[data-theme] body.castlance-portal-v8 #portal-topups .table-wrap th+th,
html[data-theme] body.castlance-portal-v8 #portal-topups .table-wrap td+td{border-left:1px solid color-mix(in srgb,var(--ux-line) 72%,transparent)!important}
html[data-theme] body.castlance-portal-v8 #portal-topups .table-wrap td{line-height:1.35!important}

/* Portal notification/support surfaces also follow theme. */
html[data-theme] body.castlance-portal-v8 .portal-pop{box-shadow:0 18px 45px rgba(0,0,0,.18)!important}
html[data-theme] body.castlance-portal-v8 :is(.chat-bubble,.portal-new-ticket){background:var(--ux-surface2)!important;border-color:var(--ux-line)!important;color:var(--ux-text)!important}
html[data-theme] body.castlance-portal-v8 .chat-bubble.customer{background:color-mix(in srgb,var(--ux-blue) 13%,var(--ux-surface))!important}

/* Admin: never convert desktop tables into opaque legacy accordions. */
@media(min-width:761px){html[data-admin-theme] body.castlance-admin-v8.cast-ui-v2 .v10-accordion{display:contents!important}}
html[data-admin-theme] body.castlance-admin-v8.cast-ui-v2 .admin-auto-collapse{display:block!important}
html[data-admin-theme] body.castlance-admin-v8.cast-ui-v2 .admin-auto-collapse>summary{display:none!important}

/* Admin top bar/sidebar and navigation are explicitly themed. */
html[data-admin-theme="light"] body.castlance-admin-v8.cast-ui-v2 .top{background:color-mix(in srgb,var(--aux-bg) 94%,transparent)!important;border-color:var(--aux-line)!important}
html[data-admin-theme="dark"] body.castlance-admin-v8.cast-ui-v2 .top{background:color-mix(in srgb,var(--aux-bg) 94%,transparent)!important;border-color:var(--aux-line)!important}
html[data-admin-theme] body.castlance-admin-v8.cast-ui-v2 .side{background:var(--aux-surface)!important;border-color:var(--aux-line)!important;color:var(--aux-text)!important}
html[data-admin-theme] body.castlance-admin-v8.cast-ui-v2 .side :is(.brand,b,strong){color:var(--aux-text)!important;-webkit-text-fill-color:var(--aux-text)!important}
html[data-admin-theme] body.castlance-admin-v8.cast-ui-v2 .nav a{color:var(--aux-muted)!important;-webkit-text-fill-color:var(--aux-muted)!important}
html[data-admin-theme] body.castlance-admin-v8.cast-ui-v2 .nav a:hover,
html[data-admin-theme] body.castlance-admin-v8.cast-ui-v2 .nav a.active{background:var(--aux-surface2)!important;color:var(--aux-text)!important;-webkit-text-fill-color:var(--aux-text)!important}

/* Admin tables: readable at desktop, scrollable instead of crushed on smaller screens. */
html[data-admin-theme] body.castlance-admin-v8.cast-ui-v2 .table table,
html[data-admin-theme] body.castlance-admin-v8.cast-ui-v2 .table-wrap table{min-width:720px!important}
html[data-admin-theme] body.castlance-admin-v8.cast-ui-v2 th+th,
html[data-admin-theme] body.castlance-admin-v8.cast-ui-v2 td+td{border-left:1px solid color-mix(in srgb,var(--aux-line) 68%,transparent)!important}
html[data-admin-theme] body.castlance-admin-v8.cast-ui-v2 tbody tr:hover td{background:var(--aux-surface2)!important}

/* Native controls: remove browser-dependent giant/black checkbox appearance. */
html[data-admin-theme] body.castlance-admin-v8.cast-ui-v2 input[type="checkbox"],
html[data-admin-theme] body.castlance-admin-v8.cast-ui-v2 input[type="radio"],
html[data-theme] body.castlance-portal-v8 input[type="checkbox"],
html[data-theme] body.castlance-portal-v8 input[type="radio"]{width:17px!important;height:17px!important;min-width:17px!important;min-height:17px!important;margin:0 7px 0 0!important;accent-color:#356dff!important;vertical-align:-3px!important}

/* Public cards/forms that were left hard-coded white by individual pages. */
html[data-theme] body.castlance-public-v8 :is(input,select,textarea){background:var(--ux-surface2)!important;border-color:var(--ux-line2)!important;color:var(--ux-text)!important;-webkit-text-fill-color:var(--ux-text)!important}
html[data-theme] body.castlance-public-v8 :is(input,textarea)::placeholder{color:var(--ux-faint)!important;-webkit-text-fill-color:var(--ux-faint)!important;opacity:1!important}

/* Clear focus states for keyboard/touch accessibility. */
html[data-theme] body.castlance-public-v8 :is(a,button,input,select,textarea):focus-visible,
html[data-theme] body.castlance-portal-v8 :is(a,button,input,select,textarea,summary):focus-visible,
html[data-admin-theme] body.castlance-admin-v8.cast-ui-v2 :is(a,button,input,select,textarea,summary):focus-visible{outline:3px solid color-mix(in srgb,#356dff 38%,transparent)!important;outline-offset:2px!important}

/* Mobile: one clean geometry system across public, portal and admin. */
@media(max-width:760px){
 html[data-theme] body.castlance-public-v8 .container{width:min(100% - 24px,1180px)!important}
 html[data-theme] body.castlance-public-v8 :is(.platform-cards,.premium-features,.journey,.labs-grid,.value-grid){grid-template-columns:1fr!important}
 html[data-theme] body.castlance-public-v8 .platform-cards article{grid-template-columns:auto minmax(0,1fr)!important;align-items:start!important}
 html[data-theme] body.castlance-public-v8 .platform-cards article .btn{grid-column:1/-1!important;width:100%!important}
 html[data-theme] body.castlance-public-v8 .try-card{flex-direction:column!important;align-items:flex-start!important;padding:22px!important}
 html[data-theme] body.castlance-public-v8 .try-card .btn{width:100%!important}
 html[data-theme] body.castlance-public-v8 .cast-video-grid{grid-template-columns:1fr!important}
 html[data-theme] body.castlance-public-v8 .cast-carousel-track{padding-inline:10vw!important}
 html[data-theme] body.castlance-public-v8 .cast-carousel-item{flex-basis:80vw!important}

 html[data-theme] body.castlance-portal-v8 .top-inner{width:calc(100% - 20px)!important;gap:7px!important}
 html[data-theme] body.castlance-portal-v8 .portal-pop{width:min(340px,calc(100vw - 24px))!important;right:12px!important}
 html[data-theme] body.castlance-portal-v8 .actions,
 html[data-theme] body.castlance-portal-v8 .quota-actions{display:grid!important;grid-template-columns:1fr!important}
 html[data-theme] body.castlance-portal-v8 .actions .btn,
 html[data-theme] body.castlance-portal-v8 .quota-actions .btn{width:100%!important}
 html[data-theme] body.castlance-portal-v8 .row{flex-direction:column!important;align-items:stretch!important}
 html[data-theme] body.castlance-portal-v8 .row-side{text-align:left!important;max-width:none!important;width:100%!important}
 html[data-theme] body.castlance-portal-v8 #portal-topups .table-wrap{margin-inline:0!important;width:100%!important}

 html[data-admin-theme] body.castlance-admin-v8.cast-ui-v2 .top-actions{display:flex!important;width:100%!important;max-width:none!important;flex-wrap:nowrap!important;overflow-x:auto!important}
 html[data-admin-theme] body.castlance-admin-v8.cast-ui-v2 .table,
 html[data-admin-theme] body.castlance-admin-v8.cast-ui-v2 .table-wrap{width:100%!important;overflow-x:auto!important;-webkit-overflow-scrolling:touch!important}
 html[data-admin-theme] body.castlance-admin-v8.cast-ui-v2 .section-head{align-items:flex-start!important;gap:12px!important}
 html[data-admin-theme] body.castlance-admin-v8.cast-ui-v2 .actions{display:flex!important;flex-wrap:wrap!important}
}

@media(max-width:430px){
 html[data-theme] body.castlance-public-v8 .section{padding:44px 0!important}
 html[data-theme] body.castlance-public-v8 .download-platform{padding:17px!important}
 html[data-theme] body.castlance-public-v8 .recommended-pill{position:static!important;display:inline-flex!important;align-self:flex-start!important;margin-bottom:16px!important}
 html[data-theme] body.castlance-public-v8 .platform-head{align-items:flex-start!important}
 html[data-theme] body.castlance-public-v8 .download-intro h1{font-size:clamp(1.9rem,10vw,2.6rem)!important}
 html[data-theme] body.castlance-portal-v8 .stats{grid-template-columns:1fr!important}
 html[data-theme] body.castlance-portal-v8 .wrap{width:calc(100% - 16px)!important}
 html[data-theme] body.castlance-portal-v8 .card{padding:13px!important}
 html[data-admin-theme] body.castlance-admin-v8.cast-ui-v2 .main{padding:10px!important}
}
