:root{
  color-scheme:light;
  --color-canvas:#f5f7fb;--color-surface:#ffffff;--color-surface-alt:#edf2f7;--color-surface-elevated:#ffffff;
  --color-text:#142033;--color-text-muted:#607087;--color-border:#d9e2ec;--color-border-strong:#bcc9d6;
  --color-primary:var(--primary,#11263d);--color-accent:var(--accent,#d9a441);--color-on-primary:#ffffff;
  --color-success:#176b47;--color-success-soft:#e7f6ee;--color-warning:#875d12;--color-warning-soft:#fff5d8;--color-danger:#9f2f35;--color-danger-soft:#fdecee;
  --shadow-soft:0 14px 38px rgba(17,38,61,.09);--focus-ring:0 0 0 3px color-mix(in srgb,var(--color-accent) 45%,transparent);
}
html[data-theme="dark"]{
  color-scheme:dark;
  --color-canvas:#0d1520;--color-surface:#151f2c;--color-surface-alt:#1d2937;--color-surface-elevated:#202d3c;
  --color-text:#edf4fb;--color-text-muted:#aab9c9;--color-border:#324255;--color-border-strong:#46596e;
  --color-on-primary:#ffffff;--color-success:#70d5a3;--color-success-soft:#153c2d;--color-warning:#f4c86f;--color-warning-soft:#3b2f16;--color-danger:#ff9aa0;--color-danger-soft:#452329;
  --shadow-soft:0 18px 46px rgba(0,0,0,.34);
}
html,body{background:var(--color-canvas);color:var(--color-text)}
body,.portal-main,.portal-content,.public-body{background:var(--color-canvas);color:var(--color-text)}
.card,.panel,.table-card,.filter-card,.hero-glass,.profile-dropdown,.modal-card,.action-menu-panel,.ai-widget,.ai-control-card{background:var(--color-surface)!important;color:var(--color-text);border-color:var(--color-border)!important;box-shadow:var(--shadow-soft)}
.card.soft,.notice,.empty,.empty-state,.section-tint,.field-help,.metric-subtitle{background:var(--color-surface-alt)!important;color:var(--color-text-muted);border-color:var(--color-border)!important}
h1,h2,h3,h4,h5,h6,strong,label,dt,th,.panel-head,.page-head{color:var(--color-text)}
p,small,.muted,dd,.help-text,.field-help{color:var(--color-text-muted)}
a{color:color-mix(in srgb,var(--color-primary) 72%,var(--color-text))}html[data-theme="dark"] a:not(.btn):not(.sidebar-link):not(.brand){color:#9fc8f2}
input,select,textarea,.mini-input{background:var(--color-surface-elevated)!important;color:var(--color-text)!important;border-color:var(--color-border-strong)!important}
input::placeholder,textarea::placeholder{color:var(--color-text-muted);opacity:.78}
input:focus,select:focus,textarea:focus,button:focus-visible,a:focus-visible,summary:focus-visible{outline:2px solid var(--color-accent);outline-offset:2px;box-shadow:var(--focus-ring)}
table{color:var(--color-text)}th{background:var(--color-surface-alt)!important}td,th{border-color:var(--color-border)!important}tbody tr:hover{background:color-mix(in srgb,var(--color-accent) 6%,var(--color-surface))}
.topbar,.public-header{background:color-mix(in srgb,var(--color-surface) 94%,transparent)!important;border-color:var(--color-border)!important;color:var(--color-text)}
.sidebar{background:#101d2b;color:#e9f0f6}.public-footer{background:#101d2b;color:#dce6ef}
.btn{background:var(--color-primary);color:var(--color-on-primary);border-color:transparent}.btn.btn-ghost{background:var(--color-surface-alt)!important;color:var(--color-text)!important;border-color:var(--color-border)!important}.btn.btn-success{background:var(--color-success);color:#07170f}.btn.btn-warning{background:var(--color-warning);color:#251b07}.btn.btn-danger{background:var(--color-danger);color:#fff}
.flash-success,.status-approved,.status-active,.status-sent{background:var(--color-success-soft)!important;color:var(--color-success)!important}.flash-warning,.status-pending,.status-expired{background:var(--color-warning-soft)!important;color:var(--color-warning)!important}.flash-danger,.status-declined,.status-failed,.status-voided{background:var(--color-danger-soft)!important;color:var(--color-danger)!important}
.document-preview-dialog::backdrop,.modal-backdrop{background:rgba(0,0,0,.66)}
.profile-dropdown a,.profile-dropdown button{color:var(--color-text)!important;background:transparent}.profile-dropdown a:hover,.profile-dropdown button:hover{background:var(--color-surface-alt)!important}
.theme-toggle{background:var(--color-surface-alt)!important;color:var(--color-text)!important;border-color:var(--color-border)!important}
@media(prefers-reduced-motion:reduce){*,*::before,*::after{scroll-behavior:auto!important;animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important}}

/* v6.1.1 dark-surface completeness for tables, forms and document review */
html[data-theme="dark"] .table-wrap,
html[data-theme="dark"] .table-responsive,
html[data-theme="dark"] .document-review-table tr,
html[data-theme="dark"] .form-card,
html[data-theme="dark"] .shift-card,
html[data-theme="dark"] .summary-box,
html[data-theme="dark"] .chat,
html[data-theme="dark"] .auth-card,
html[data-theme="dark"] .content-page .content,
body[data-theme="dark"] .table-wrap,
body[data-theme="dark"] .table-responsive,
body[data-theme="dark"] .document-review-table tr{
  background:var(--color-surface)!important;
  color:var(--color-text)!important;
  border-color:var(--color-border)!important;
}
html[data-theme="dark"] .table td,
html[data-theme="dark"] .document-review-table td,
body[data-theme="dark"] .table td,
body[data-theme="dark"] .document-review-table td{color:var(--color-text)!important;background:transparent!important}
html[data-theme="dark"] .card.soft,
html[data-theme="dark"] .notice,
html[data-theme="dark"] .document-review-bar,
body[data-theme="dark"] .card.soft,
body[data-theme="dark"] .notice,
body[data-theme="dark"] .document-review-bar{background:var(--color-surface-alt)!important;color:var(--color-text-muted)!important;border-color:var(--color-border)!important}
html[data-theme="dark"] .document-preview-state strong,
body[data-theme="dark"] .document-preview-state strong{color:var(--color-text)!important}
html[data-theme="dark"] .user-chip.profile-menu-toggle,
body[data-theme="dark"] .user-chip.profile-menu-toggle{background:var(--color-surface-elevated)!important;color:var(--color-text)!important;border-color:var(--color-border)!important}
html[data-theme="dark"] .user-avatar-fallback,
body[data-theme="dark"] .user-avatar-fallback{background:var(--color-surface-alt)!important;color:var(--color-text)!important}

/* v6.2.0 finance, live counters, chat and ticket polish */
.nav-badge{margin-left:auto;min-width:22px;height:22px;padding:0 7px;border-radius:999px;display:inline-flex;align-items:center;justify-content:center;background:#e8b447;color:#172333;font-size:.72rem;font-weight:900;line-height:1;box-shadow:0 5px 14px rgba(0,0,0,.18)}
.nav-badge[hidden]{display:none!important}.sidebar-subnav .nav-badge{min-width:20px;height:20px;font-size:.68rem}.notification-bell{position:relative;display:grid;place-items:center;width:42px;height:42px;border:1px solid var(--color-border);border-radius:13px;background:var(--color-surface-alt);text-decoration:none}.notification-bell [data-notification-count]{position:absolute;right:-4px;top:-5px;min-width:19px;height:19px;padding:0 5px;border-radius:999px;display:grid;place-items:center;background:var(--color-danger);color:#fff;font-size:.65rem;font-weight:900;border:2px solid var(--color-surface)}
.finance-summary{grid-template-columns:repeat(4,minmax(0,1fr));gap:14px}.finance-summary .summary-box{display:flex;min-height:116px;flex-direction:column;justify-content:center;border:1px solid var(--color-border);background:linear-gradient(145deg,var(--color-surface),color-mix(in srgb,var(--color-primary) 4%,var(--color-surface)))!important;box-shadow:0 12px 30px rgba(16,35,55,.07)}.finance-summary .summary-box span{color:var(--color-text-muted);font-size:.78rem;font-weight:800;text-transform:uppercase;letter-spacing:.06em}.finance-summary .summary-box strong{font-size:clamp(1.25rem,2.4vw,2rem);letter-spacing:-.04em}.finance-summary .summary-box small{margin-top:4px}.payment-state-card{text-align:center}.status-icon{width:58px;height:58px;margin:0 auto 14px;display:grid;place-items:center;border-radius:18px;background:var(--color-success-soft);color:var(--color-success);font-size:1.7rem;font-weight:900}.finance-due-banner{display:flex;align-items:center;justify-content:space-between;gap:18px;background:linear-gradient(135deg,color-mix(in srgb,var(--color-warning) 12%,var(--color-surface)),var(--color-surface))!important;border-color:color-mix(in srgb,var(--color-warning) 35%,var(--color-border))!important}.row-overdue{background:color-mix(in srgb,var(--color-danger) 7%,var(--color-surface))!important}.text-danger{color:var(--color-danger)!important;font-weight:800}.form-card,.summary-box,.table-wrap{background:var(--color-surface)!important;color:var(--color-text);border-color:var(--color-border)!important}.form-section{border-color:var(--color-border)!important}.quote-brand{background:linear-gradient(135deg,#10263c,#1c4365);color:#fff}.quote-brand strong{color:#fff}
.status-partially_paid,.status-partially-paid{background:var(--color-warning-soft)!important;color:var(--color-warning)!important}.status-pending_verification,.status-pending-verification{background:color-mix(in srgb,var(--color-warning) 16%,var(--color-surface))!important;color:var(--color-warning)!important}

/* Premium live site chat and ticket conversations */
[data-live-chat],.support-thread,.ticket-conversation{overflow:hidden;border-radius:22px!important}.chat-presence{display:flex;align-items:center;gap:8px;margin:-2px 0 12px;padding:9px 12px;border-radius:11px;background:var(--color-success-soft);color:var(--color-success);font-size:.8rem;font-weight:800}.chat-presence:before{content:"";width:8px;height:8px;border-radius:50%;background:currentColor;box-shadow:0 0 0 4px color-mix(in srgb,currentColor 16%,transparent)}.chat,.thread-list{display:flex;flex-direction:column;gap:10px;max-height:520px;overflow:auto;padding:18px;border:1px solid var(--color-border);border-radius:18px;background:linear-gradient(180deg,var(--color-surface-alt),var(--color-surface))!important;scrollbar-width:thin}.chat-message,.thread-message{align-self:flex-start;max-width:min(82%,720px);padding:12px 14px;border:1px solid var(--color-border);border-radius:16px 16px 16px 5px;background:var(--color-surface-elevated);color:var(--color-text);box-shadow:0 8px 22px rgba(13,28,44,.07);overflow-wrap:anywhere}.chat-message.mine,.thread-message.mine{align-self:flex-end;border-color:color-mix(in srgb,var(--color-primary) 35%,var(--color-border));border-radius:16px 16px 5px 16px;background:color-mix(in srgb,var(--color-primary) 88%,#fff);color:var(--color-on-primary)}.chat-message.mine .chat-meta,.thread-message.mine .chat-meta,.chat-message.mine a,.thread-message.mine a{color:color-mix(in srgb,var(--color-on-primary) 82%,transparent)!important}.chat-meta{margin-bottom:6px;color:var(--color-text-muted);font-size:.7rem;font-weight:750}.thread-message.internal-note{border-style:dashed;background:var(--color-warning-soft);color:var(--color-text)}[data-live-chat] form,.ticket-conversation form{padding-top:14px;border-top:1px solid var(--color-border)}[data-live-chat] form input[name="message"]{min-height:48px}.panel.highlight{border-color:var(--color-accent)!important;box-shadow:0 0 0 3px color-mix(in srgb,var(--color-accent) 18%,transparent),var(--shadow-soft)}

/* AI/chat launcher must remain visible in both themes */
.ai-assistant{--ai-primary:#17365d!important;--ai-surface:var(--color-surface)!important;--ai-text:var(--color-text)!important}.ai-assistant-toggle{background:linear-gradient(135deg,#10263c,#d09b36)!important;color:#fff!important;border:1px solid rgba(255,255,255,.2)}.ai-assistant-toggle>span:first-child{color:#fff!important;text-shadow:0 1px 5px rgba(0,0,0,.4)}.ai-assistant-panel,.ai-assistant-form,.ai-history{background:var(--color-surface)!important;color:var(--color-text)!important;border-color:var(--color-border)!important}.ai-assistant-messages{background:var(--color-surface-alt)!important}.ai-bubble:not(.user),.ai-suggestions button,.ai-work-card,.ai-secure-card,.ai-confirmation-card,.ai-assistant-form textarea{background:var(--color-surface-elevated)!important;color:var(--color-text)!important;border-color:var(--color-border)!important}

@media(max-width:980px){.finance-summary{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:620px){.finance-summary{grid-template-columns:1fr 1fr}.finance-summary .summary-box{min-height:96px;padding:14px}.finance-due-banner{align-items:stretch;flex-direction:column}.finance-due-banner .btn{width:100%}.chat-message,.thread-message{max-width:92%}.payment-shell,.quote-shell{margin-top:22px}.form-card{padding:18px}}
@media(max-width:430px){.finance-summary{grid-template-columns:1fr}.finance-summary .summary-box{min-height:auto}.nav-badge{min-width:20px;height:20px}}
