/* Shared light surfaces. Loaded after vendor and legacy theme rules. */
html[data-theme="light"], body.theme-light {
    color-scheme: light;
    --border: #e2e8f0 !important;
    --border-color: #e2e8f0 !important;
    --text-secondary: #475569;
    --text-tertiary: #475569;
    --shadow-card: 0 2px 6px rgba(15, 23, 42, .035), 0 8px 24px rgba(15, 23, 42, .025);
    --shadow-card-hover: 0 8px 24px rgba(15, 23, 42, .075);
    --shadow-modal: 0 24px 64px rgba(15, 23, 42, .18);
    --fa-focus: #2563eb;
}

:is(html[data-theme="light"], body.theme-light) .security-bar {
    border-color: #e2e8f0 !important;
    box-shadow: 0 1px 8px rgba(15, 23, 42, .035) !important;
}
:is(html[data-theme="light"], body.theme-light) #sidebar {
    border-color: #e2e8f0 !important;
    box-shadow: none !important;
}
:is(html[data-theme="light"], body.theme-light) .sidebar .nav-category {
    color: #475569 !important;
    font-weight: 600 !important;
}
:is(html[data-theme="light"], body.theme-light) .sidebar .nav-item {
    font-weight: 500 !important;
    transition: background-color .18s, color .18s !important;
}
:is(html[data-theme="light"], body.theme-light) .sidebar .nav-item:hover {
    transform: none;
}
:is(html[data-theme="light"], body.theme-light) .sidebar .nav-item.active {
    background: #eff6ff !important;
    font-weight: 650 !important;
    box-shadow: inset 3px 0 #2563eb !important;
}
:is(html[data-theme="light"], body.theme-light) :is(.card-glass, .dashboard-card, .portal-card, .app-card, .bento-card, .kpi-card, .stat-card, .fin-card, .agro-card, .audit-table-wrapper) {
    border-color: #e2e8f0 !important;
    box-shadow: var(--shadow-card) !important;
}
:is(html[data-theme="light"], body.theme-light) :is(.page-title, h1, h2) {
    letter-spacing: -.025em;
}

/* Icon-bearing controls retain the gutters declared by their own components. */
:is(html[data-theme="light"], body.theme-light) :is(.bento-search-box, .uconsole-search-box, .webmail-search-box, .isabel-prompt-input-wrapper) {
    min-width: 0;
}
:is(html[data-theme="light"], body.theme-light) :is(.bento-search-box, .uconsole-search-box, .webmail-search-box, .isabel-prompt-input-wrapper) > input {
    box-sizing: border-box;
    min-width: 0;
}
:is(html[data-theme="light"], body.theme-light) :is(.webmail-search-box > i, .webmail-search-box .wm-search-adv-btn) {
    color: #475569;
}
:is(html[data-theme="light"], body.theme-light) :is(.wm-ribbon-people-search > i, .wm-comp-tellme > i) {
    color: #475569;
}
:is(html[data-theme="light"], body.theme-light) :is(.bento-search-box > i.search-icon, .uconsole-search-box > i.search-icon) {
    pointer-events: none;
}

/* Focus remains visible for keyboard users, including third-party controls. */
:is(html[data-theme="light"], body.theme-light) :is(button, a, input, select, textarea, [tabindex], [contenteditable="true"]):focus-visible {
    outline: 2px solid var(--fa-focus) !important;
    outline-offset: 3px !important;
}
:is(html[data-theme="light"], body.theme-light) :is(input, textarea)::placeholder {
    color: #475569 !important;
    opacity: 1;
}
:is(html[data-theme="light"], body.theme-light) :is(input, select, textarea):disabled {
    background: #f1f5f9 !important;
    color: #475569 !important;
    cursor: not-allowed;
}
:is(html[data-theme="light"], body.theme-light) input:read-only:not([type="checkbox"]):not([type="radio"]):not([type="button"]):not([type="submit"]) {
    background-color: #f8fafc !important;
}
:is(html[data-theme="light"], body.theme-light) input:is([type="checkbox"], [type="radio"]) {
    accent-color: #2563eb;
}
:is(html[data-theme="light"], body.theme-light) :is(button, .btn-act, .btn-primary):disabled {
    opacity: .55;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}
:is(html[data-theme="light"], body.theme-light) :is(input, select, textarea)[aria-invalid="true"] {
    border-color: #dc2626 !important;
}
:is(html[data-theme="light"], body.theme-light) :is(.audit-table, .fin-table, .agro-table) {
    font-variant-numeric: tabular-nums;
}
:is(html[data-theme="light"], body.theme-light) :is(.audit-table, .fin-table, .agro-table) th {
    background: #f8fafc !important;
    color: #475569 !important;
    letter-spacing: .035em;
}
:is(html[data-theme="light"], body.theme-light) dialog::backdrop {
    background: rgba(15, 23, 42, .32) !important;
    backdrop-filter: blur(4px);
}

/* Webmail chrome only: message HTML and attachment previews keep their colors. */
:is(html[data-theme="light"], body.theme-light) #view-webmail {
    background: #f8fafc;
    color: #0f172a;
}
:is(html[data-theme="light"], body.theme-light) :is(#webmail-canvas, #webmail-vignette) {
    opacity: .06;
}
:is(html[data-theme="light"], body.theme-light) :is(.webmail-top-bar, .webmail-sidebar, .webmail-list-col, .webmail-reader, .wm-popover, .wm-ribbon-dropdown, .wm-comp-palette, .wm-compose-floating, .wm-thread-card, .wm-thread-card.expanded) {
    background: #fff !important;
    border-color: #e2e8f0 !important;
    color: #0f172a;
    box-shadow: var(--shadow-card) !important;
}
:is(html[data-theme="light"], body.theme-light) :is(.wm-ribbon-container, .wm-ribbon-toolbar, .wm-comp-ribbon, .wm-comp-toolbar, .wm-comp-tabs, .wm-reader-header, .wm-batch-bar, .wm-list-header, .wm-compose-main-header) {
    background: #f8fafc !important;
    border-color: #e2e8f0 !important;
    color: #334155 !important;
}
:is(html[data-theme="light"], body.theme-light) :is(.wm-reader-subject, .wm-card-name, .wm-item-sender-name, .wm-item-subject, .wm-popover-title, .webmail-user-info b) {
    color: #0f172a !important;
}
:is(html[data-theme="light"], body.theme-light) :is(.wm-item-date, .wm-item-snippet, .wm-card-email, .wm-card-date, .wm-nav-section-title, .wm-row-label, .webmail-reader-placeholder, .wm-popover-field label) {
    color: #475569 !important;
}
:is(html[data-theme="light"], body.theme-light) :is(.webmail-folder, .wm-tree-item, .wm-ribbon-btn, .wm-comp-btn, .wm-comp-btn-full, .wm-comp-tab, .wm-toggle-btn, .wm-btn-icon, .wm-icon-btn, .wm-mini-btn, .wm-row-btn, .wm-btn-action, .wm-ctx-item) {
    color: #475569;
    border-color: #e2e8f0;
}
:is(html[data-theme="light"], body.theme-light) :is(.webmail-item, .wm-compose-row) {
    border-color: #e2e8f0;
}
:is(html[data-theme="light"], body.theme-light) .webmail-item.unread {
    background: #f0f7ff;
}
:is(html[data-theme="light"], body.theme-light) :is(.webmail-folder.active, .wm-tree-item.active, .webmail-item.active, .wm-toggle-btn.active, .wm-comp-tab.active) {
    background: #eff6ff !important;
    color: #1d4ed8 !important;
    border-color: #bfdbfe;
}
:is(html[data-theme="light"], body.theme-light) :is(.webmail-item, .webmail-folder, .wm-tree-item, .wm-ribbon-btn, .wm-comp-btn, .wm-comp-btn-full, .wm-ctx-item, .wm-btn-action, .wm-icon-btn):hover {
    background: #f1f5f9;
    color: #0f172a;
}
:is(html[data-theme="light"], body.theme-light) :is(.wm-ribbon-btn.primary, .wm-btn-action.primary, .webmail-btn-compose, .wm-btn-send-vertical) {
    background: #2563eb !important;
    border-color: #2563eb !important;
    color: #fff !important;
}
:is(html[data-theme="light"], body.theme-light) :is(.wm-account-select, .wm-comp-select, .wm-account-select option) {
    background: #fff;
    color: #0f172a;
    border-color: #cbd5e1;
}

/* Rich text, spreadsheet menus and chart tooltips are part of the same theme. */
:is(html[data-theme="light"], body.theme-light) :is(.wm-context-menu, .wm-ctx-submenu, .wm-autocomplete-dropdown, .wm-floating-popover, .wm-rules-quick-menu, .wm-wizard-picker-modal, .wm-rules-table-container, .wm-rules-preview-box, .wm-editor-wrapper) {
    background: #fff !important;
    border-color: #e2e8f0 !important;
    color: #334155 !important;
    box-shadow: var(--shadow-card) !important;
}
:is(html[data-theme="light"], body.theme-light) :is(.wm-compose-header, .wm-compose-footer, .wm-rules-tabs, .wm-attachment-card) {
    background: #f8fafc;
    border-color: #e2e8f0;
}
:is(html[data-theme="light"], body.theme-light) :is(.wm-compose-title, .wm-att-name, .wm-ctx-label, .wm-popover-item strong) {
    color: #0f172a;
}
:is(html[data-theme="light"], body.theme-light) :is(.wm-rules-quick-item, .wm-rules-tab, .wm-rules-preview-label, .wm-priority-badge, .wm-win-btn, .wm-tool-btn, .wm-btn-wizard, .wm-btn-wizard-sm, .wm-toolbar-btn, .wm-popover-item, .wm-popover-item small, .wm-contact-item, .wm-att-size, .wm-compose-from-badge) {
    color: #475569;
    border-color: #e2e8f0;
}
:is(html[data-theme="light"], body.theme-light) :is(.wm-rules-quick-item, .wm-contact-item, .wm-popover-item, .wm-rules-tab, .wm-win-btn, .wm-tool-btn, .wm-btn-wizard, .wm-btn-wizard-sm, .wm-toolbar-btn):hover {
    color: #0f172a;
    background: #eff6ff;
}
:is(html[data-theme="light"], body.theme-light) :is(.wm-toolbar-btn.primary, .wm-btn-wizard.primary) {
    background: #2563eb;
    color: #fff;
}
:is(html[data-theme="light"], body.theme-light) .wm-rules-table tr.selected-rule {
    background: #dbeafe !important;
}
:is(html[data-theme="light"], body.theme-light) .wm-rules-tab.active {
    color: #1d4ed8;
    background: #eff6ff;
}
:is(html[data-theme="light"], body.theme-light) :is(.ql-toolbar.ql-snow, .ql-container.ql-snow, .ql-snow .ql-picker-options, .ql-snow .ql-tooltip, .jodit-container:not(.jodit_inline), .jodit-toolbar__box, .jexcel_contextmenu, .jdropdown-container) {
    background: #fff !important;
    color: #0f172a !important;
    border-color: #e2e8f0 !important;
}
:is(html[data-theme="light"], body.theme-light) .ql-snow .ql-picker { color: #475569; }
:is(html[data-theme="light"], body.theme-light) .ql-snow .ql-stroke { stroke: #475569; }
:is(html[data-theme="light"], body.theme-light) .ql-snow .ql-fill { fill: #475569; }
:is(html[data-theme="light"], body.theme-light) .ql-editor.ql-blank::before { color: #475569; }
:is(html[data-theme="light"], body.theme-light) .ql-editor { color: #0f172a; background: #fff; }
:is(html[data-theme="light"], body.theme-light) .jexcel > :is(thead, tbody) > tr > td {
    /* Compact grid geometry must not inherit the portal's large table cells. */
    padding: 4px 6px !important;
    font-size: 13px !important;
}
:is(html[data-theme="light"], body.theme-light) .apexcharts-menu {
    background: #fff;
    border-color: #e2e8f0;
    color: #334155;
    box-shadow: var(--shadow-card);
}
@media (max-width: 768px) {
    :is(html[data-theme="light"], body.theme-light) .main-content {
        /* Keep room for the portal's mobile navigation toggle. */
        padding: 4rem 12px 32px !important;
    }
    :is(html[data-theme="light"], body.theme-light) #view-webmail {
        margin: 0;
        padding: 8px;
    }
}
:is(html[data-theme="light"], body.theme-light) {
    color-scheme: light;
}
:is(html[data-theme="light"], body.theme-light) input:-webkit-autofill,
:is(html[data-theme="light"], body.theme-light) textarea:-webkit-autofill,
:is(html[data-theme="light"], body.theme-light) select:-webkit-autofill {
    -webkit-text-fill-color: #0f172a !important;
    -webkit-box-shadow: 0 0 0px 1000px #ffffff inset !important;
    transition: background-color 5000s ease-in-out 0s;
    caret-color: #0f172a;
}
:is(html[data-theme="light"], body.theme-light) :is(input, select, textarea, button, [tabindex]):focus-visible {
    outline: 2px solid #2563eb !important;
    outline-offset: 2px !important;
}
@media (prefers-reduced-motion: reduce) {
    :is(html[data-theme="light"], body.theme-light) :is(.sidebar .nav-item, .dashboard-card, .portal-card, .app-card, .bento-card, .stat-card) {
        transition: none !important;
        transform: none !important;
    }
    *, ::before, ::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    .boot-halo-ring, .unit-transition-glow-halo, .login-btn-shimmer, .pulse {
        animation: none !important;
    }
}
