/* Shared public + management theme system. Loaded last on both page shells. */
:root,[data-theme="light-green"]{
  --theme-primary:#19713a;--theme-primary-hover:#11572b;--theme-primary-soft:#e4f3e8;
  --theme-bg:#f6f8f6;--theme-surface:#fff;--theme-surface-2:#eef3ef;--theme-text:#17231b;
  --theme-muted:#647168;--theme-border:#dce5de;--theme-sidebar:#173c28;--theme-sidebar-text:#dcece1;
  --theme-shadow:rgba(18,50,30,.12);--theme-hero-a:#fbfdfb;--theme-hero-b:#e7f3e9;
}
[data-theme="light-blue"]{
  --theme-primary:#1769aa;--theme-primary-hover:#0f4f83;--theme-primary-soft:#e3f0fb;
  --theme-bg:#f5f8fb;--theme-surface:#fff;--theme-surface-2:#eaf1f7;--theme-text:#17232d;
  --theme-muted:#62717d;--theme-border:#d9e4ed;--theme-sidebar:#17364f;--theme-sidebar-text:#dcebf6;
  --theme-shadow:rgba(18,48,74,.13);--theme-hero-a:#fbfdff;--theme-hero-b:#e5f1fa;
}
[data-theme="light-purple"]{
  --theme-primary:#7151a8;--theme-primary-hover:#563b88;--theme-primary-soft:#eee8f8;
  --theme-bg:#f8f6fb;--theme-surface:#fff;--theme-surface-2:#f0ecf6;--theme-text:#251e2e;
  --theme-muted:#746b7c;--theme-border:#e5deeb;--theme-sidebar:#352a48;--theme-sidebar-text:#eee6f8;
  --theme-shadow:rgba(53,35,76,.13);--theme-hero-a:#fdfcff;--theme-hero-b:#efe9f7;
}
[data-theme="light-amber"]{
  --theme-primary:#a75d08;--theme-primary-hover:#7d4304;--theme-primary-soft:#f9ecd9;
  --theme-bg:#faf8f4;--theme-surface:#fff;--theme-surface-2:#f4eee5;--theme-text:#2c241a;
  --theme-muted:#786e61;--theme-border:#e9e0d4;--theme-sidebar:#493622;--theme-sidebar-text:#f5e9d9;
  --theme-shadow:rgba(70,48,23,.13);--theme-hero-a:#fffdfa;--theme-hero-b:#f7ead7;
}
[data-theme="dark-green"]{
  --theme-primary:#4fd47b;--theme-primary-hover:#78e49a;--theme-primary-soft:#183d27;
  --theme-bg:#0d1510;--theme-surface:#151f18;--theme-surface-2:#1b2920;--theme-text:#ecf5ee;
  --theme-muted:#a2b1a6;--theme-border:#2b3d30;--theme-sidebar:#0a110c;--theme-sidebar-text:#d8e9dc;
  --theme-shadow:rgba(0,0,0,.35);--theme-hero-a:#101a13;--theme-hero-b:#172b1d;
}
[data-theme="dark-blue"]{
  --theme-primary:#56a8ef;--theme-primary-hover:#83c1f5;--theme-primary-soft:#17344d;
  --theme-bg:#0c1219;--theme-surface:#141d26;--theme-surface-2:#1a2733;--theme-text:#edf4fa;
  --theme-muted:#9facb8;--theme-border:#2a3a48;--theme-sidebar:#080e14;--theme-sidebar-text:#dbe9f5;
  --theme-shadow:rgba(0,0,0,.38);--theme-hero-a:#0e1720;--theme-hero-b:#14293a;
}
[data-theme="dark-purple"]{
  --theme-primary:#b793f5;--theme-primary-hover:#cbb1f8;--theme-primary-soft:#352750;
  --theme-bg:#120f17;--theme-surface:#1d1825;--theme-surface-2:#292034;--theme-text:#f5effb;
  --theme-muted:#b1a5bb;--theme-border:#3c3048;--theme-sidebar:#0e0a13;--theme-sidebar-text:#eadff4;
  --theme-shadow:rgba(0,0,0,.4);--theme-hero-a:#17121e;--theme-hero-b:#2b2038;
}
[data-theme="dark-slate"]{
  --theme-primary:#9eabb8;--theme-primary-hover:#c0c9d1;--theme-primary-soft:#303942;
  --theme-bg:#111417;--theme-surface:#1b2025;--theme-surface-2:#252c32;--theme-text:#f0f2f4;
  --theme-muted:#a7afb6;--theme-border:#384149;--theme-sidebar:#0c0f11;--theme-sidebar-text:#e0e4e7;
  --theme-shadow:rgba(0,0,0,.4);--theme-hero-a:#15191d;--theme-hero-b:#242b31;
}

html{background:var(--theme-bg)}
body{background:var(--theme-bg);color:var(--theme-text);transition:background-color .2s ease,color .2s ease}

/* Theme control */
.theme-picker{position:relative;flex:none;color:var(--theme-text);font-family:'Noto Sans','Noto Sans Devanagari',system-ui,sans-serif}
.theme-picker>summary{display:flex;align-items:center;justify-content:center;gap:7px;min-width:40px;height:40px;padding:0 11px;border:1px solid var(--theme-border);border-radius:999px;background:var(--theme-surface);color:var(--theme-text);cursor:pointer;list-style:none;font-size:.78rem;font-weight:700;transition:border-color .15s,background .15s}
.theme-picker>summary::-webkit-details-marker{display:none}.theme-picker>summary:hover{border-color:var(--theme-primary);background:var(--theme-primary-soft)}
.theme-picker>summary svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:1.7}
.theme-menu{position:absolute;z-index:100;top:calc(100% + 12px);right:0;width:min(340px,calc(100vw - 24px));padding:16px;background:var(--theme-surface);color:var(--theme-text);border:1px solid var(--theme-border);border-radius:16px;box-shadow:0 20px 55px var(--theme-shadow)}
.theme-menu-head{display:flex;align-items:flex-start;justify-content:space-between;margin-bottom:12px}.theme-menu-head div{display:flex;flex-direction:column}.theme-menu-head strong{font-size:.92rem}.theme-menu-head small,.theme-system-option small{color:var(--theme-muted);font-size:.7rem;margin-top:2px}
.theme-menu-close{display:grid!important;place-items:center;width:30px;height:30px;min-height:0!important;padding:0!important;border:0!important;border-radius:50%!important;background:var(--theme-surface-2)!important;color:var(--theme-text)!important;font-size:1.15rem!important;line-height:1!important}
.theme-system-option{display:flex!important;align-items:center!important;gap:10px;width:100%;min-height:52px;padding:8px 10px!important;text-align:left;border:1px solid var(--theme-border)!important;border-radius:10px!important;background:var(--theme-surface-2)!important;color:var(--theme-text)!important}
.theme-system-option>span:nth-child(2){display:flex;flex:1;flex-direction:column}.theme-system-icon{display:grid;place-items:center;width:28px;height:28px;border-radius:50%;background:var(--theme-surface);color:var(--theme-primary);font-size:1.1rem}.theme-check{opacity:0;color:var(--theme-primary);font-weight:800}.theme-system-option.is-selected .theme-check{opacity:1}
.theme-group-label{display:block;margin:15px 2px 7px;color:var(--theme-muted);font-size:.64rem;font-weight:700;letter-spacing:.11em;text-transform:uppercase}
.theme-options{display:grid;grid-template-columns:1fr 1fr;gap:7px}.theme-options button{display:flex!important;align-items:center!important;gap:8px;min-height:40px!important;padding:7px 9px!important;border:1px solid var(--theme-border)!important;border-radius:9px!important;background:var(--theme-surface)!important;color:var(--theme-text)!important;font-size:.75rem!important;text-align:left}.theme-options button:hover,.theme-options button.is-selected{border-color:var(--theme-primary)!important;background:var(--theme-primary-soft)!important}.theme-options i{display:block;width:17px;height:17px;border-radius:50%;background:var(--swatch);box-shadow:inset 0 0 0 3px rgba(255,255,255,.24)}.theme-options span{flex:1}.theme-options b{opacity:0;color:var(--theme-primary)}.theme-options button.is-selected b{opacity:1}

/* Authenticated application overrides */
:root{--primary:var(--theme-primary);--primary-hover:var(--theme-primary-hover);--primary-dark:var(--theme-primary);--primary-light:var(--theme-primary);--primary-soft:var(--theme-primary-soft);--background:var(--theme-bg);--surface:var(--theme-surface);--surface-muted:var(--theme-surface-2);--text:var(--theme-text);--text-muted:var(--theme-muted);--muted:var(--theme-muted);--border:var(--theme-border)}
.topbar{background:var(--theme-surface);color:var(--theme-text);border-color:var(--theme-border);box-shadow:0 2px 12px var(--theme-shadow)}
.topbar .brand,.topbar .page-title,.menu-toggle{color:var(--theme-text)}.topbar .brand img{background:var(--theme-surface-2)}
.header-actions{gap:10px}.header-actions .theme-picker{order:-1}
.sidebar{background:var(--theme-sidebar);color:var(--theme-sidebar-text);border-color:var(--theme-border)}
.sidebar a,.sidebar-nav>a,.sidebar-nav details a{color:var(--theme-sidebar-text)}.sidebar summary,.sidebar-nav summary,.sidebar .nav-icon{color:color-mix(in srgb,var(--theme-sidebar-text) 68%,transparent)}
.sidebar a:hover,.sidebar a.active,.sidebar .nav-link.active,.sidebar-nav>a:hover,.sidebar-nav details a:hover{background:color-mix(in srgb,var(--theme-primary) 22%,transparent);color:#fff}
.main{background-color:var(--theme-bg);background-image:linear-gradient(color-mix(in srgb,var(--theme-bg) 94%,transparent),color-mix(in srgb,var(--theme-bg) 94%,transparent)),url('../img/hyclogo.png')}
.card,.panel,.stat-card,.info-panel,.filter-panel,.form-section,.customer-table-wrap,table,.user-dropdown{background:var(--theme-surface);color:var(--theme-text);border-color:var(--theme-border)}
.customer-table th,th{background:var(--theme-surface-2);color:var(--theme-muted)}
tr:hover td{background:var(--theme-primary-soft)}
input,select,textarea{background:var(--theme-surface);color:var(--theme-text);border-color:var(--theme-border)}
.user-dropdown a,.dropdown-logout{color:var(--theme-text)}.user-dropdown a:hover,.dropdown-logout:hover{background:var(--theme-primary-soft);color:var(--theme-primary)}
.avatar,.sidebar-avatar,.profile-avatar-placeholder{background:var(--theme-primary-soft);color:var(--theme-primary)}

/* Public website overrides */
:root{--l-primary:var(--theme-primary);--l-primary-hover:var(--theme-primary-hover);--l-brand-green:var(--theme-primary);--l-surface:var(--theme-surface);--l-surface-warm:var(--theme-surface-2);--l-border:var(--theme-border);--l-ink:var(--theme-text);--l-muted:var(--theme-muted)}
.l-nav,.l-nav.is-scrolled,.l-nav.l-nav-interior{background:color-mix(in srgb,var(--theme-surface) 94%,transparent);border-color:var(--theme-border)}
.l-nav .theme-picker{margin-left:auto}.l-nav .theme-picker+.l-menu-toggle{margin-left:2px}
.l-hero{background:linear-gradient(135deg,var(--theme-hero-a),var(--theme-hero-a) 55%,var(--theme-hero-b))}
.l-hero-panel,.l-feature-body{background:var(--theme-sidebar);color:var(--theme-sidebar-text)}
.l-story,.l-footer{background:var(--theme-surface-2)}
.l-article-media{background:var(--theme-surface-2)}
.l-cta{background:var(--theme-primary)}
[data-theme^="dark-"] .l-btn-primary,[data-theme^="dark-"] .l-nav-login,[data-theme^="dark-"] .l-cta{color:#0c1410}
[data-theme^="dark-"] .l-btn-on-brand{background:var(--theme-text);color:var(--theme-bg)}
[data-theme^="dark-"] .l-hero:before{border-color:color-mix(in srgb,var(--theme-primary) 25%,transparent)}
[data-theme^="dark-"] .l-nav-links.is-open{background:var(--theme-surface)}

/* Legacy feature styles with literal light colors. */
[data-theme^="dark-"] .collection-page{color:var(--theme-text)}
[data-theme^="dark-"] :is(.collection-kpis article,.collection-kpi-grid article,.collection-tabs,.collection-filters,.collection-table-wrap,.financial-summary article,.collection-panel,.collection-form,.receipt,.ward-form-section,.ward-card,.crm-tabs,.dashboard-panel,.kpi-card,.customer-registration-layout,.customer-ward-empty,.invoice-search-results,.required-document-entry,.required-document-item,.service-detail-card,.crm-mini-list>div){background:var(--theme-surface);color:var(--theme-text);border-color:var(--theme-border)}
[data-theme^="dark-"] :is(.collection-primary,.collection-header-actions a,.collection-form-actions a,.receipt-actions a,.receipt-actions button,.secondary-action,.cancel-button,.save-another-button,.service-btn-draft){background:var(--theme-surface)!important;color:var(--theme-text)!important;border-color:var(--theme-border)!important}
[data-theme^="dark-"] :is(.collection-table th,.collection-tabs a.active,.receipt-amount,.required-document-list,.service-status-field,.crm-bar-track){background:var(--theme-surface-2);color:var(--theme-text)}
[data-theme^="dark-"] :is(.collection-header p,.collection-kpis span,.collection-kpi-grid span,.collection-kpi-grid small,.collection-tabs a,.collection-table td small,.financial-summary span,.collection-panel dt,.receipt dt){color:var(--theme-muted)}
[data-theme^="dark-"] .invoice-search-results button{background:var(--theme-surface);color:var(--theme-text);border-color:var(--theme-border)}
[data-theme^="dark-"] .invoice-search-results button:hover{background:var(--theme-primary-soft)}
[data-theme^="dark-"] .service-create-layout{--service-bg:var(--theme-bg);--service-surface:var(--theme-surface);--service-ink:var(--theme-text);--service-muted:var(--theme-muted);--service-line:var(--theme-border);--service-soft:var(--theme-primary-soft);--service-geruwa:var(--theme-primary);--service-geruwa-dark:var(--theme-primary-hover);background:var(--theme-surface);border-color:var(--theme-border)}
[data-theme^="dark-"] :is(.service-field input:not([type=checkbox]),.service-field select,.service-field textarea,.required-document-entry input){background:var(--theme-surface);color:var(--theme-text);border-color:var(--theme-border)}
[data-theme^="dark-"] :is(.service-field label,.required-document-item){color:var(--theme-text)}
[data-theme^="dark-"] .service-action-bar{background:color-mix(in srgb,var(--theme-surface) 94%,transparent);border-color:var(--theme-border)}
[data-theme^="dark-"] .login-page{background:var(--theme-bg);color:var(--theme-text)}
[data-theme^="dark-"] :is(.login-card,.login-box){background:var(--theme-surface);color:var(--theme-text);border-color:var(--theme-border)}
[data-theme^="dark-"] .login-card input{background:var(--theme-surface-2);color:var(--theme-text);border-color:var(--theme-border)}

/* High-specificity dark corrections for feature styles with local palettes. */
[data-theme^="dark-"]{
  --customer-geruwa:var(--theme-primary);--customer-geruwa-dark:var(--theme-primary-hover);
  --customer-ink:var(--theme-text);--customer-muted:var(--theme-muted);--customer-line:var(--theme-border);--customer-soft:var(--theme-primary-soft);
  --service-bg:var(--theme-bg);--service-surface:var(--theme-surface);--service-ink:var(--theme-text);
  --service-muted:var(--theme-muted);--service-line:var(--theme-border);--service-soft:var(--theme-primary-soft);
  --service-geruwa:var(--theme-primary);--service-geruwa-dark:var(--theme-primary-hover);
}
[data-theme^="dark-"] .crm-app{
  --crm-ink:var(--theme-text);--crm-muted:var(--theme-muted);--crm-border:var(--theme-border);
  --crm-surface:var(--theme-surface);--crm-canvas:var(--theme-bg);--crm-accent:var(--theme-primary);
  --crm-accent-dark:var(--theme-primary-hover);--crm-accent-soft:var(--theme-primary-soft);
  background:var(--theme-bg);color:var(--theme-text);
}
[data-theme^="dark-"] .crm-app :is(.topbar,.sidebar,.main){background-color:var(--theme-surface);color:var(--theme-text);border-color:var(--theme-border)}
[data-theme^="dark-"] .crm-app .main{background:var(--theme-bg)}
[data-theme^="dark-"] .crm-app .sidebar{background:var(--theme-sidebar);color:var(--theme-sidebar-text)}
[data-theme^="dark-"] .crm-app .sidebar :is(a,strong){color:var(--theme-sidebar-text)}
[data-theme^="dark-"] .crm-app .sidebar :is(small,.crm-nav-label,.nav-icon){color:color-mix(in srgb,var(--theme-sidebar-text) 68%,transparent)}
[data-theme^="dark-"] :is(.crm-global-search input,.crm-date-card,.crm-kpi-card,.crm-quick-actions,.crm-panel){background:var(--theme-surface);color:var(--theme-text);border-color:var(--theme-border)}
[data-theme^="dark-"] :is(.crm-dashboard-header h1,.crm-date-card strong,.crm-kpi-copy strong,.crm-section-heading h2,.crm-action-grid a,.crm-ward-row,.crm-service-row){color:var(--theme-text)}
[data-theme^="dark-"] :is(.crm-table th,.crm-action-grid a:hover,.crm-action-grid a:focus-visible,.crm-kpi-attention){background:var(--theme-primary-soft);color:var(--theme-text)}
[data-theme^="dark-"] :is(.crm-table th,.crm-table td,.crm-ward-row,.crm-service-row){border-color:var(--theme-border)}
[data-theme^="dark-"] :is(.kpi-card strong,.status-legend b,.system-panel li b){color:var(--theme-text)}
[data-theme^="dark-"] :is(.action-grid a:hover,.customer-preview,.customer-id-notice,.household-member-row,.customer-secure-note){background:var(--theme-surface-2);color:var(--theme-text)}
[data-theme^="dark-"] .customer-registration-page{color:var(--theme-text)}
[data-theme^="dark-"] :is(.customer-field label,.customer-preview dd,.customer-breadcrumb a){color:var(--theme-text)}
[data-theme^="dark-"] :is(.customer-field input,.customer-field select,.customer-field textarea,.contact-field input,.contact-field select,.contact-field textarea){background:var(--theme-surface);color:var(--theme-text);border-color:var(--theme-border)}
[data-theme^="dark-"] :is(.customer-action-bar,.customer-registration-layout){background:var(--theme-surface);border-color:var(--theme-border)}
[data-theme^="dark-"] :is(.customer-btn-cancel,.service-btn-cancel){color:var(--theme-text)}
[data-theme^="dark-"] :is(.customer-btn-cancel:hover,.service-btn-cancel:hover){background:var(--theme-surface-2)}
[data-theme^="dark-"] :is(.primary-action,.quick-actions a,.filter-panel button,.record-form>button,.contact-form-actions button,.customer-btn-primary,.service-btn-primary,.collection-primary,.collection-form-actions button){color:#09130d!important}

@media(max-width:768px){.theme-picker-label{display:none}.theme-picker>summary{width:38px;min-width:38px;padding:0}.l-nav .theme-picker{margin-left:auto}.l-nav-links .theme-picker{display:none}}
@media(prefers-reduced-motion:reduce){body{transition:none}}
