/*
 * OPTODEV UI fixes (loaded last on every page)
 * 1. No underlined links/buttons anywhere.
 * 2. Production report banner restyled for the dark theme.
 * 3. Header + sidebar stay in place while the page scrolls (desktop),
 *    drawer navigation on tablet/mobile.
 * 4. Header icon buttons removed (bell / help) – spacing tidied.
 * 5. Desktop + tablet responsiveness hardening.
 * Visual only: no data, workflow or calculation changes.
 */

/* =========================================================
   1. REMOVE UNDERLINES
   ========================================================= */
a,
a:link,
a:visited,
a:hover,
a:focus,
a:active,
button,
button:hover,
.oir-trigger,
.oir-trigger:hover,
.barrel-link:hover,
.nav-link,
.nav-link:hover {
    text-decoration: none !important;
}

a:focus-visible,
button:focus-visible {
    outline: 2px solid #4b91ff;
    outline-offset: 2px;
}

/* =========================================================
   2. PRODUCTION REPORTS BANNER (Production Schedule)
   ========================================================= */
.opto-production-issues {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px 16px;
    flex-wrap: wrap;
    margin: 14px 0;
    padding: 14px 18px;
    border-radius: 14px;
    border: 1px solid #d3dfea;
    background: #f4f8fc;
}

.opto-production-issues__label {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    font-weight: 650;
    color: #223b55;
}

.opto-production-issues__icon {
    flex: 0 0 38px;
    width: 38px;
    height: 38px;
    border-radius: 11px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(54, 120, 237, .14);
    color: #3678ed;
    font-size: 15px;
}

.opto-production-issues__count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    height: 24px;
    padding: 0 8px;
    margin-left: 4px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    background: rgba(54, 120, 237, .14);
    color: #2563eb;
}

.opto-production-issues__count.has-pending {
    background: rgba(245, 158, 11, .18);
    color: #b45309;
}

.opto-production-issues .oir-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 9px 16px !important;
    border-radius: 11px !important;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
}

/* Dark theme version */
body.opto-ui-v2 .opto-production-issues {
    background: linear-gradient(140deg, #10233a, #0d1c2f) !important;
    border: 1px solid #263e5b !important;
    box-shadow: 0 5px 18px rgba(0, 0, 0, .16);
}

body.opto-ui-v2 .opto-production-issues__label {
    color: #e8f0fb !important;
}

body.opto-ui-v2 .opto-production-issues__icon {
    background: rgba(54, 120, 237, .18);
    color: #8fc0ff;
}

body.opto-ui-v2 .opto-production-issues__count {
    background: rgba(54, 120, 237, .2);
    color: #9cc9ff;
}

body.opto-ui-v2 .opto-production-issues__count.has-pending {
    background: rgba(245, 158, 11, .2);
    color: #fbbf24;
}

/* Small "Review report" links inside tables stay compact. */
body.opto-ui-v2 td .oir-trigger,
body.opto-ui-v2 .notification-list .oir-trigger {
    display: inline-flex;
    margin-top: 6px;
    padding: 4px 10px !important;
    border-radius: 8px !important;
    font-size: 11.5px;
}

/* =========================================================
   3. HEADER (bell / help removed)
   ========================================================= */
.header-icon {
    display: none !important;
}

.header-right {
    gap: 12px !important;
}

/* =========================================================
   4. STICKY HEADER + SIDEBAR
   `overflow-x: hidden` on BOTH html and body turns <body> into its own
   scroll box, which silently disables every `position: sticky` element.
   Clip horizontally on <html> only, so the header and sidebar can stick.
   ========================================================= */
html {
    overflow-x: hidden !important;
    max-width: 100%;
}

html body {
    overflow-x: visible !important;
    max-width: 100%;
}

/* Lock page scrolling only while a drawer is open. The lock goes on <html>
   (the real scroller) so <body> never becomes a scroll box and the sticky
   header stays visible behind the drawer. */
html body:is(.sa-nav-open, .admin-nav-open, .operator-nav-open) {
    overflow: visible !important;
}

html:has(body:is(.sa-nav-open, .admin-nav-open, .operator-nav-open)) {
    overflow: hidden !important;
}

html body .dashboard-header {
    position: sticky !important;
    top: 0 !important;
    z-index: 2400 !important;
}

/* Desktop: sidebar is pinned under the header and never scrolls away. */
@media (min-width: 1025px) {
    html body:not(.opto-login-v2) .container {
        display: flex !important;
        align-items: flex-start !important;
    }

    html body:not(.opto-login-v2) .container > nav:not(.opto-none) {
        position: sticky !important;
        top: var(--opto-header-h, 78px) !important;
        align-self: flex-start !important;
        height: calc(100vh - var(--opto-header-h, 78px)) !important;
        height: calc(100dvh - var(--opto-header-h, 78px)) !important;
        max-height: calc(100dvh - var(--opto-header-h, 78px)) !important;
        min-height: 0 !important;
        overflow: hidden !important;
        display: flex !important;
        flex-direction: column !important;
        transform: none !important;
        z-index: 1200;
    }

    html body:not(.opto-login-v2) .container > nav:not(.opto-none) > ul {
        flex: 1 1 auto !important;
        min-height: 0 !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        overscroll-behavior: contain;
        scrollbar-width: thin;
        scrollbar-color: #2b4a6d transparent;
    }

    html body:not(.opto-login-v2) .container > nav:not(.opto-none) .sidebar-logo,
    html body:not(.opto-login-v2) .container > nav:not(.opto-none) .sidebar-footer {
        flex: 0 0 auto !important;
    }

    html body:not(.opto-login-v2) .container > nav:not(.opto-none) .sidebar-footer {
        margin-top: auto !important;
    }

    html body:not(.opto-login-v2) .container > :is(main, .main-content, .dashboard-container, .reports-container, .barrel-page, section) {
        flex: 1 1 auto;
        min-width: 0 !important;
    }
}

/* Short desktop screens (e.g. 1366x768 laptops): tighter menu. */
@media (min-width: 1025px) and (max-height: 820px) {
    html body:not(.opto-login-v2) .container > nav:not(.opto-none) .sidebar-logo {
        padding-top: 14px !important;
        padding-bottom: 14px !important;
    }

    html body:not(.opto-login-v2) .container > nav:not(.opto-none) > ul {
        padding-top: 10px !important;
        padding-bottom: 10px !important;
    }

    html body:not(.opto-login-v2) .container > nav:not(.opto-none) .nav-link {
        min-height: 42px !important;
        padding-top: 9px !important;
        padding-bottom: 9px !important;
    }

    html body:not(.opto-login-v2) .container > nav:not(.opto-none) .sidebar-footer {
        padding-top: 10px !important;
        padding-bottom: 10px !important;
    }
}

/* Tablet + mobile: sidebar becomes a fixed slide-in drawer (existing JS). */
@media (max-width: 1024px) {
    html body:not(.opto-login-v2) .container > nav:not(.opto-none) {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        bottom: 0 !important;
        width: min(300px, 86vw) !important;
        min-width: 0 !important;
        height: 100vh !important;
        height: 100dvh !important;
        max-height: 100dvh !important;
        min-height: 0 !important;
        z-index: 3000 !important;
        overflow: hidden !important;
        display: flex !important;
        flex-direction: column !important;
    }

    html body:not(.opto-login-v2) .container > nav:not(.opto-none) > ul {
        flex: 1 1 auto !important;
        min-height: 0 !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    html body:not(.opto-login-v2) .container > nav:not(.opto-none) .sidebar-footer {
        margin-top: auto !important;
        flex: 0 0 auto !important;
        padding-bottom: max(14px, env(safe-area-inset-bottom)) !important;
    }

    /* Drawer keeps its full brand block on every screen size. */
    html body:not(.opto-login-v2) .container > nav:not(.opto-none) .sidebar-logo {
        justify-content: flex-start !important;
        gap: 12px;
    }

    html body:not(.opto-login-v2) .container > nav:not(.opto-none) .logo-text {
        display: block !important;
        min-width: 0;
    }

    /* Drawer must sit above the sticky header. */
    html body :is(.sa-nav-overlay, .admin-nav-overlay, .operator-nav-overlay) {
        z-index: 2900 !important;
    }
}

/* =========================================================
   5. RESPONSIVE HARDENING (desktop + tablet)
   ========================================================= */

/* Media never forces horizontal scrolling. */
img,
canvas,
svg,
video {
    max-width: 100%;
}

/* Wide tables scroll inside their own card, never the whole page. */
:is(.schedule-table-container, .table-wrap, .table-scroll, .detail-table-wrap,
    .performance-table-wrapper, .employee-table-card, .table-container,
    .table-responsive, .oir-list) {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ---------- Large desktop (>= 1600px): use the space ---------- */
@media (min-width: 1600px) {
    html body:not(.opto-login-v2) .container > nav:not(.opto-none) {
        width: 280px !important;
        min-width: 280px !important;
        flex: 0 0 280px !important;
    }
}

/* ---------- Standard desktop / laptop (1025–1366px) ---------- */
@media (min-width: 1025px) and (max-width: 1366px) {
    html body:not(.opto-login-v2) .container > nav:not(.opto-none) {
        width: 240px !important;
        min-width: 240px !important;
        flex: 0 0 240px !important;
    }

    .dashboard-header {
        padding-left: 22px !important;
        padding-right: 22px !important;
    }

    .header-title h2,
    .header-left h2 {
        font-size: 20px !important;
    }

    .page-header h1,
    .page-heading h1,
    .schedule-page h1 {
        font-size: clamp(26px, 2.4vw, 34px) !important;
    }

    :is(.stats, .schedule-stats, .kpi-grid, .stats-grid) {
        gap: 14px !important;
    }

    .performance-kpi-grid {
        grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)) !important;
    }
}

/* ---------- Tablet landscape + portrait (<= 1024px) ---------- */
@media (max-width: 1024px) {
    .dashboard-header {
        min-height: 64px !important;
        height: auto !important;
        padding: 10px 16px !important;
        gap: 10px !important;
    }

    .header-left {
        gap: 10px !important;
        min-width: 0;
        flex: 1 1 auto;
    }

    .header-divider {
        display: none !important;
    }

    .header-title h2,
    .header-left h2 {
        font-size: 18px !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .header-right {
        flex: 0 0 auto;
        gap: 8px !important;
    }

    .header-right .date-card {
        display: none !important;
    }

    #user-profile {
        padding: 6px 10px !important;
        gap: 8px !important;
        min-width: 0 !important;
    }

    #user-profile img {
        width: 36px !important;
        height: 36px !important;
    }

    /* Main content fills the screen width when the sidebar is a drawer. */
    html body:not(.opto-login-v2) .container > :is(main, .main-content, .dashboard-container, .reports-container, .barrel-page) {
        width: 100% !important;
        max-width: 100% !important;
        margin-left: 0 !important;
    }

    .page-header h1,
    .page-heading h1,
    .schedule-page h1 {
        font-size: clamp(24px, 3.6vw, 30px) !important;
        line-height: 1.15 !important;
    }

    /* Action rows wrap instead of overflowing. */
    :is(.schedule-top-bar, .schedule-actions, .page-header, .page-heading,
        .table-header, .card-header, .section-header, .filter-actions,
        .report-buttons, .export-buttons-row, .load-analytics-row,
        .performance-panel-header, .performance-filter-bar) {
        flex-wrap: wrap !important;
        gap: 10px !important;
    }

    /* Stat cards: 2 per row on tablet. */
    :is(.stats, .schedule-stats, .kpi-grid, .stats-grid, .overview-grid) {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    .performance-kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    /* Filter panels: 2 columns of full-width touch controls. */
    .performance-filter-grid {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 10px 12px !important;
        width: 100%;
    }

    .performance-filter-grid :is(select, input) {
        width: 100% !important;
        min-width: 0 !important;
    }

    .performance-filter-actions {
        width: 100%;
        display: flex !important;
        flex-wrap: wrap;
        align-items: center;
        gap: 10px;
    }

    /* Production reports banner stacks neatly. */
    .opto-production-issues {
        padding: 12px 14px;
    }

    /* Touch-friendly controls. */
    :is(select, input[type="text"], input[type="search"], input[type="date"],
        input[type="month"], input[type="number"], input[type="time"]) {
        min-height: 40px;
    }

    /* Modals never wider/taller than the screen. */
    :is(.modal-content, .modal-content-schedule, .modal-box, .product-modal-card,
        .confirm-card, .oir-dialog, .employee-credential-dialog, .delete-confirm-dialog) {
        width: min(94vw, 820px) !important;
        max-width: 94vw !important;
        max-height: 90dvh !important;
        overflow-y: auto !important;
    }
}

/* ---------- Small tablet / large phone (<= 760px) ---------- */
@media (max-width: 760px) {
    .dashboard-header {
        padding: 8px 12px !important;
    }

    .header-title h2,
    .header-left h2 {
        font-size: 16px !important;
    }

    /* Profile shows only the avatar + chevron to save space. */
    #user-profile .user-info {
        display: none !important;
    }

    :is(.stats, .schedule-stats, .kpi-grid, .stats-grid, .overview-grid,
        .performance-kpi-grid, .performance-filter-grid) {
        grid-template-columns: 1fr !important;
    }

    .opto-production-issues {
        flex-direction: column;
        align-items: stretch;
    }

    .opto-production-issues .oir-trigger {
        justify-content: center;
        width: 100%;
    }

    :is(.btn-add-schedule, .apply-performance-filter) {
        width: 100%;
        justify-content: center;
    }
}

/* Respect reduced motion for the drawer. */
@media (prefers-reduced-motion: reduce) {
    nav {
        transition: none !important;
    }
}

/* The page-load slide animation on .container used a transform, which
   temporarily turns the fixed mobile drawer into a scrolling element.
   Keep the fade, drop the movement. */
html body:not(.opto-login-v2) .container {
    animation-name: optoContainerFade !important;
}

@keyframes optoContainerFade {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Page eyebrow label ("PRODUCTION OPERATIONS") hugs its text instead of
   stretching into a long empty bar. */
.opto-eyebrow {
    display: inline-flex !important;
    width: auto !important;
    max-width: 100%;
    padding: 4px 10px !important;
    border-radius: 999px !important;
    margin-bottom: 8px !important;
}

/* =========================================================
   6. PERSONNEL PERFORMANCE – show every record
   The operator detail panel lives inside the page, but an older rule
   capped it to one screen height and hid the overflow, so the
   Schedules / Processed Monomers / Attendance tables were cut off.
   ========================================================= */
html body #operatorPerformancePanel {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
}

html body #operatorPerformancePanel .detail-table-wrap {
    overflow-x: auto !important;
    overflow-y: visible !important;
    max-height: none !important;
}

/* =========================================================
   7. CONTRAST + DARK-THEME CONSISTENCY
   Text that was dark-on-dark, and leftover white surfaces that
   carried light text, are brought onto the dark palette.
   Text #e8f0fb / muted #a9bcd4 on surfaces #0d1c2f – #17304d.
   ========================================================= */

/* --- Generic safety net: headings, labels and emphasis inside dark
       cards and tables are always light. Status/badge colours keep
       their own palette. --- */
body.opto-ui-v2 :is(main, .dashboard-container, .main-content, .reports-container, .barrel-page,
    .modal-content, .modal-content-schedule, .product-modal-card, .operator-performance-panel)
    :is(h1, h2, h3, h4, h5, strong, b, dt, th, label):not([class*="status"]):not([class*="badge"]):not([class*="pill"]):not([class*="score"]):not([class*="positive"]):not([class*="negative"]):not([class*="success"]):not([class*="danger"]):not([class*="warning"]):not([class*="error"]):not([class*="tag"]):not(.card-state strong) {
    color: #e8f0fb !important;
}

body.opto-ui-v2 :is(.chart-header h3, .chart-card h3, .table-header h2, .card-header h2, .card-header h3) {
    color: #eef5ff !important;
}

/* Muted helper text that was too faint. */
body.opto-ui-v2 :is(.table-header p, .section-title p, .chart-header p, .card-header p, .page-subtitle,
    .schedule-title-card p, .performance-subsection-title p, .notification-description) {
    color: #a9bcd4 !important;
}

/* --- Personnel Performance score cards --- */
body.opto-ui-v2 .performance-kpi > span small,
body.opto-ui-v2 .score-kpi small {
    background: rgba(54, 120, 237, .16) !important;
    color: #9cc9ff !important;
    border: 1px solid rgba(83, 151, 235, .35) !important;
    border-radius: 999px !important;
    padding: 3px 9px !important;
    font-size: 10.5px !important;
    font-weight: 750 !important;
    white-space: nowrap;
}

body.opto-ui-v2 .performance-kpi em {
    color: #7fb3ff !important;
    font-style: normal;
    font-weight: 700;
}

body.opto-ui-v2 .performance-kpi p {
    color: #c3d2e5 !important;
}

body.opto-ui-v2 .performance-eyebrow {
    color: #7fb3ff !important;
}

body.opto-ui-v2 .total-score-kpi {
    border-color: rgba(83, 151, 235, .5) !important;
    background: linear-gradient(150deg, #173558, #10243c) !important;
}

/* Five score cards on one row on desktop. */
@media (min-width: 1280px) {
    body.opto-ui-v2 .performance-kpi-grid.performance-score-kpis {
        grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
    }
}

@media (min-width: 761px) and (max-width: 1279px) {
    body.opto-ui-v2 .performance-kpi-grid.performance-score-kpis {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    }
}

/* --- Supervisor dashboard notifications --- */
body.opto-ui-v2 .notification-count {
    background: #2563eb !important;
    color: #fff !important;
}

body.opto-ui-v2 .notification-title {
    color: #e8f0fb !important;
}

.opto-inline-warning {
    color: #fdba74;
    font-weight: 600;
}

/* --- Dispatch scheduling table --- */
body.opto-ui-v2 .schedule-table :is(strong, .product-text) {
    color: #e8f0fb !important;
}

/* --- Barrel analytics --- */
body.opto-ui-v2 .barrel-page .notice.error {
    background: rgba(239, 68, 68, .12) !important;
    border: 1px solid rgba(239, 68, 68, .35) !important;
    color: #fca5a5 !important;
}

body.opto-ui-v2 .barrel-page .notice.error * {
    color: #fca5a5 !important;
}

body.opto-ui-v2 .barrel-page :is(.insight-item, .insight-card) :is(strong, span, small) {
    color: #dce9f8 !important;
}

body.opto-ui-v2 .barrel-page .analytics-table tbody tr,
body.opto-ui-v2 .barrel-page .analytics-table tbody td {
    background: transparent !important;
    color: #e3edf9 !important;
}

body.opto-ui-v2 .barrel-page .analytics-table tbody tr:hover td,
body.opto-ui-v2 .barrel-page .analytics-table tbody tr.is-selected td,
body.opto-ui-v2 .barrel-page .analytics-table tbody tr[aria-selected="true"] td {
    background: #18324f !important;
}

body.opto-ui-v2 .barrel-page .analytics-table .subline {
    color: #93a9c5 !important;
}

/* --- Shift Leader attendance page --- */
body.opto-ui-v2 :is(.attendance-method-selector button, .scan-btn[data-face-action])[aria-pressed="false"] {
    background: #16304d !important;
    color: #dce9f8 !important;
    border: 1px solid #365575 !important;
}

body.opto-ui-v2 :is(.attendance-method-selector button, .scan-btn[data-face-action])[aria-pressed="true"] {
    background: linear-gradient(112deg, #225bc8, #347fe9 65%, #168fb8) !important;
    color: #fff !important;
    border: 1px solid rgba(113, 178, 255, .3) !important;
}

body.opto-ui-v2 #extraShiftApprovals {
    background: #10233a !important;
    border: 1px solid #263e5b !important;
    color: #dce9f8 !important;
}

body.opto-ui-v2 #extraShiftApprovals summary {
    color: #9cc9ff !important;
}

body.opto-ui-v2 #extraShiftApprovals :is(p, div) {
    color: #c3d2e5 !important;
}

body.opto-ui-v2 :is(.scanner-label, .page-label) {
    background: rgba(54, 120, 237, .16) !important;
    color: #9cc9ff !important;
    border: 1px solid rgba(83, 151, 235, .3) !important;
}

body.opto-ui-v2 .scanner-status {
    color: #c3d2e5 !important;
}

body.opto-ui-v2 .table-header {
    background: transparent !important;
}

body.opto-ui-v2 .attendance-table strong {
    color: #e8f0fb !important;
}

/* --- Shift Leader biweekly schedule --- */
body.opto-ui-v2 .operator-row .operator-info {
    background: #10233a !important;
    border-color: #263e5b !important;
}

body.opto-ui-v2 .operator-row .operator-info .operator-id {
    color: #9cc9ff !important;
}

/* --- Operator dashboard --- */
body.opto-ui-v2 :is(.schedule-card, .summary-item) strong {
    color: #e8f0fb !important;
}

body.opto-ui-v2 .summary-item a,
body.opto-ui-v2 .schedule-card a:not(.btn):not([class*="btn"]) {
    color: #8fc0ff !important;
    font-weight: 700;
}

body.opto-ui-v2 .weight-accounting-item {
    background: #10233a !important;
    border-color: #263e5b !important;
}

body.opto-ui-v2 .weight-accounting-item :is(small, span) {
    color: #a9bcd4 !important;
}

body.opto-ui-v2 .weight-accounting-item strong {
    color: #f2f7ff !important;
}

/* Required markers stay readable on dark headers. */
body.opto-ui-v2 .required-star {
    color: #f87171 !important;
}

/* =========================================================
   8. FORM CONTROLS + BUTTONS – one consistent style
   ========================================================= */
body.opto-ui-v2 :is(input[type="text"], input[type="search"], input[type="number"], input[type="email"],
    input[type="password"], input[type="date"], input[type="month"], input[type="time"],
    input[type="datetime-local"], input[type="tel"], select, textarea):not(.oir-form *) {
    background-color: #0a1828 !important;
    color: #eef5ff !important;
    border: 1px solid #35557a !important;
    border-radius: 10px !important;
    box-shadow: none !important;
}

body.opto-ui-v2 :is(input, select, textarea):not([type="checkbox"]):not([type="radio"]):focus {
    outline: none !important;
    border-color: #4b91ff !important;
    box-shadow: 0 0 0 3px rgba(75, 145, 255, .22) !important;
}

body.opto-ui-v2 :is(input, textarea)::placeholder {
    color: #7189a8 !important;
    opacity: 1;
}

body.opto-ui-v2 select option {
    background: #0d1c2f;
    color: #eef5ff;
}

body.opto-ui-v2 :is(input[readonly], input:disabled, select:disabled, textarea:disabled) {
    background-color: #132741 !important;
    color: #a9bcd4 !important;
}

body.opto-ui-v2 :is(input[type="date"], input[type="month"], input[type="time"], input[type="datetime-local"])::-webkit-calendar-picker-indicator {
    filter: invert(.85);
    cursor: pointer;
}

body.opto-ui-v2 :is(input[type="checkbox"], input[type="radio"]) {
    accent-color: #3678ed;
}

body.opto-ui-v2 button:disabled {
    opacity: .55;
    cursor: not-allowed;
}

/* Light/white buttons left from the old theme become dark "secondary" buttons. */
body.opto-ui-v2 :is(.btn-reset, .btn-secondary, .secondary-btn, .btn-cancel, .cancel-btn, .btn-light,
    .btn-outline, .clear-btn, .btn-clear, .pagination-buttons button, .pagination-page,
    .sa-page-btn, .modal-close, .btn-close) {
    background: #16304d !important;
    color: #dce9f8 !important;
    border: 1px solid #365575 !important;
    box-shadow: none !important;
}

body.opto-ui-v2 :is(.btn-reset, .btn-secondary, .secondary-btn, .btn-cancel, .cancel-btn, .btn-light,
    .btn-outline, .clear-btn, .btn-clear, .pagination-buttons button, .pagination-page,
    .sa-page-btn, .modal-close, .btn-close):hover:not(:disabled) {
    background: #1e3d61 !important;
    border-color: #4b83c0 !important;
    color: #fff !important;
}

body.opto-ui-v2 .pagination-page.is-active {
    background: #2563eb !important;
    border-color: #2563eb !important;
    color: #fff !important;
}

body.opto-ui-v2 :is(.pagination-summary, .sa-page-info) {
    color: #a9bcd4 !important;
}

/* Detail tables in the performance panel. */
body.opto-ui-v2 .detail-table th {
    background: #17304d !important;
    color: #cfe0f4 !important;
}

body.opto-ui-v2 .detail-table td {
    color: #e3edf9 !important;
    border-color: #1f3550 !important;
}

body.opto-ui-v2 .empty-detail-state {
    background: #0f2034 !important;
    border-color: #2b4566 !important;
    color: #a9bcd4 !important;
}

body.opto-ui-v2 .history-item {
    background: #10233a !important;
    border-color: #263e5b !important;
}

body.opto-ui-v2 .history-item :is(span, small, p) {
    color: #a9bcd4 !important;
}

body.opto-ui-v2 .operator-row .operator-info .operator-name {
    color: #e8f0fb !important;
}

/* Remaining light surfaces from the original light theme. */
body.opto-ui-v2 :is(.period-toolbar, .next-week-helper, .schedule-scroll) {
    background: #10233a !important;
    border-color: #263e5b !important;
    color: #dce9f8 !important;
}

body.opto-ui-v2 #save-all-btn {
    background: #16304d !important;
    color: #9cc9ff !important;
    border: 1px solid #3d77b7 !important;
}

body.opto-ui-v2 #save-all-btn:hover:not(:disabled) {
    background: #1e3d61 !important;
    color: #fff !important;
}

body.opto-ui-v2 .waiting-btn {
    background: #16304d !important;
    border-color: #365575 !important;
    color: #a9bcd4 !important;
}

body.opto-ui-v2 .phase-message {
    background: rgba(245, 158, 11, .12) !important;
    border-color: rgba(245, 158, 11, .35) !important;
    color: #fcd34d !important;
}

body.opto-ui-v2 .phase-message.missed-message {
    background: rgba(239, 68, 68, .12) !important;
    border-color: rgba(239, 68, 68, .35) !important;
    color: #fca5a5 !important;
}

body.opto-ui-v2 .phase-message.completed-message {
    background: rgba(34, 197, 94, .12) !important;
    border-color: rgba(34, 197, 94, .35) !important;
    color: #86efac !important;
}

body.opto-ui-v2 :is(.period-toolbar, .next-week-helper) :is(span, p, small, div) {
    color: #dce9f8 !important;
}

/* Score card header: title on top, weight badge underneath – never clipped. */
body.opto-ui-v2 .performance-score-kpis .score-kpi > span {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    justify-content: flex-start !important;
    gap: 6px !important;
    min-height: 52px;
}

body.opto-ui-v2 .performance-score-kpis .score-kpi strong {
    font-size: clamp(24px, 2vw, 30px) !important;
}

/* Older Shift Leader / Operator layouts reserved space for a FIXED header
   (margin-top) and a FIXED sidebar (margin-left). The header and sidebar
   are now sticky and part of the layout, so those offsets are removed. */
html body:not(.opto-login-v2) .container {
    margin-top: 0 !important;
}

@media (min-width: 1025px) {
    html body:not(.opto-login-v2) .container > :is(main, .dashboard-container, .main-content) {
        margin-left: 0 !important;
        width: auto !important;
        flex: 1 1 auto !important;
        min-width: 0 !important;
    }
}

@media (max-width: 1024px) {
    html body:not(.opto-login-v2) .container > :is(main, .dashboard-container, .main-content) {
        margin-left: 0 !important;
        width: 100% !important;
    }
}

/* =========================================================
   9. CALENDAR (flatpickr) – allowed vs. not-allowed dates
   Allowed:   bright text, blue outline, bold
   Not allowed: dim, struck through, no hover
   Selected:  solid blue · Today: cyan ring
   ========================================================= */
body.opto-ui-v2 .flatpickr-calendar {
    padding: 6px 6px 0;
    border-radius: 14px !important;
}

body.opto-ui-v2 .flatpickr-calendar .flatpickr-months .flatpickr-prev-month,
body.opto-ui-v2 .flatpickr-calendar .flatpickr-months .flatpickr-next-month {
    color: #dceaff !important;
    fill: #dceaff !important;
}

body.opto-ui-v2 .flatpickr-calendar .flatpickr-months :is(.flatpickr-prev-month, .flatpickr-next-month) svg {
    fill: #dceaff !important;
}

body.opto-ui-v2 .flatpickr-calendar .flatpickr-monthDropdown-months,
body.opto-ui-v2 .flatpickr-calendar .numInputWrapper input {
    background: #0a1828 !important;
    color: #eef5ff !important;
    border-radius: 8px !important;
    min-height: 0 !important;
}

body.opto-ui-v2 .flatpickr-calendar .flatpickr-weekday {
    color: #8ea6c4 !important;
    font-weight: 700 !important;
}

body.opto-ui-v2 .flatpickr-calendar .flatpickr-day {
    background: transparent !important;
    border: 1px solid transparent !important;
    border-radius: 10px !important;
    color: #c7d9ee !important;
    box-shadow: none !important;
    max-width: 39px;
    height: 37px;
    line-height: 35px;
    margin: 1px 0;
}

body.opto-ui-v2 .flatpickr-calendar .flatpickr-day:is(.prevMonthDay, .nextMonthDay) {
    opacity: .55;
}

/* Allowed dates for the chosen cycle. */
body.opto-ui-v2 .flatpickr-calendar .flatpickr-day.cycle-allowed-day:not(.selected):not(.flatpickr-disabled),
body.opto-ui-v2 .flatpickr-calendar .flatpickr-day:not(.flatpickr-disabled):not(.selected):not(.prevMonthDay):not(.nextMonthDay) {
    background: rgba(54, 120, 237, .16) !important;
    border-color: rgba(96, 165, 250, .65) !important;
    color: #ffffff !important;
    font-weight: 700 !important;
    cursor: pointer;
}

body.opto-ui-v2 .flatpickr-calendar .flatpickr-day:not(.flatpickr-disabled):not(.selected):hover {
    background: #2a5aa8 !important;
    border-color: #60a5fa !important;
    color: #fff !important;
}

/* Dates that cannot be chosen. */
body.opto-ui-v2 .flatpickr-calendar .flatpickr-day.flatpickr-disabled,
body.opto-ui-v2 .flatpickr-calendar .flatpickr-day.flatpickr-disabled:hover {
    background: transparent !important;
    border-color: transparent !important;
    color: #4d6584 !important;
    font-weight: 400 !important;
    text-decoration: line-through !important;
    text-decoration-color: rgba(122, 148, 180, .55) !important;
    cursor: not-allowed !important;
    opacity: 1;
}

body.opto-ui-v2 .flatpickr-calendar .flatpickr-day.today:not(.selected) {
    box-shadow: inset 0 0 0 2px #22d3ee !important;
}

body.opto-ui-v2 .flatpickr-calendar .flatpickr-day.selected,
body.opto-ui-v2 .flatpickr-calendar .flatpickr-day.selected:hover {
    background: #2563eb !important;
    border-color: #2563eb !important;
    color: #fff !important;
    font-weight: 800 !important;
    text-decoration: none !important;
    box-shadow: 0 4px 12px rgba(37, 99, 235, .45) !important;
}

/* Legend under the calendar. */
body.opto-ui-v2 .flatpickr-calendar .flatpickr-innerContainer {
    flex-wrap: wrap;
}

body.opto-ui-v2 .flatpickr-calendar:not(.hasTime) .flatpickr-innerContainer::after {
    content: "Bold blue box = available   \00B7   Crossed out = not available";
    display: block;
    width: 100%;
    padding: 8px 6px 10px;
    margin-top: 4px;
    border-top: 1px solid #263e5b;
    color: #a9bcd4;
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    white-space: pre;
}

/* =========================================================
   10. SHIFT LEADER ATTENDANCE – balanced top grid
   Scanner (face / QR / manual) on the left, current shift and the
   four attendance counters in the middle, latest activity on the
   right, so no column is left half empty.
   ========================================================= */
body.opto-ui-v2 .attendance-header {
    display: grid !important;
    grid-template-columns: minmax(340px, 1.05fr) minmax(0, 1fr) minmax(0, .95fr) !important;
    grid-template-rows: auto 1fr !important;
    grid-template-areas:
        "scan shift latest"
        "scan stats latest" !important;
    gap: 18px !important;
    align-items: stretch !important;
    margin-bottom: 24px !important;
}

body.opto-ui-v2 .attendance-header > .scanner-card {
    grid-area: scan !important;
    min-height: 0 !important;
    height: auto !important;
    margin: 0 !important;
}

/* Only the visible attendance method becomes a flex column; the page's
   own inline display:none still hides the other two methods. */
body.opto-ui-v2 .attendance-header > .scanner-card:not([style*="display: none"]):not([style*="display:none"]) {
    display: flex !important;
    flex-direction: column !important;
}

body.opto-ui-v2 .attendance-header > .today-shift-card {
    grid-area: shift !important;
    margin: 0 !important;
    min-height: 0 !important;
}

body.opto-ui-v2 .attendance-header > .latest-scan-card {
    grid-area: latest !important;
    margin: 0 !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
}

body.opto-ui-v2 .attendance-header > .attendance-stats-grid {
    grid-area: stats !important;
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 14px !important;
    margin: 0 !important;
    align-content: stretch;
}

body.opto-ui-v2 .attendance-header > .attendance-stats-grid .stat-card {
    min-height: 0 !important;
    padding: 16px !important;
    margin: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 10px !important;
}

body.opto-ui-v2 .attendance-header > .attendance-stats-grid .stat-card .icon {
    width: 40px !important;
    height: 40px !important;
    font-size: 16px !important;
    border-radius: 11px !important;
}

body.opto-ui-v2 .attendance-header > .attendance-stats-grid .stat-content h2 {
    font-size: 28px !important;
    margin: 2px 0 !important;
}

body.opto-ui-v2 .attendance-header > .attendance-stats-grid .stat-content span {
    font-size: 12px !important;
    font-weight: 700 !important;
    color: #c3d2e5 !important;
}

body.opto-ui-v2 .attendance-header > .attendance-stats-grid .stat-content small {
    font-size: 11px !important;
    color: #93a9c5 !important;
    line-height: 1.35;
}

/* Scanner cards: the camera area grows to use the full height. */
body.opto-ui-v2 .attendance-header > .attendance-stats-grid .stat-card {
    justify-content: center !important;
}

body.opto-ui-v2 .attendance-header > .scanner-card .face-card-actions {
    margin-top: auto;
}

/* Manual attendance: give the form some presence instead of a short box. */
body.opto-ui-v2 #adminManualAttendance > div:last-child {
    margin-top: 22px !important;
    padding: 18px;
    border-radius: 14px;
    background: #0f2034;
    border: 1px solid #243b57;
}

body.opto-ui-v2 #adminManualAttendance label {
    color: #c3d2e5 !important;
}

/* Latest activity list fills its column. */
body.opto-ui-v2 .latest-scan-card .scan-history {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

body.opto-ui-v2 .latest-scan-card .history-item {
    margin: 0 !important;
}

/* QR card controls in the dark palette (were inline light styles). */
body.opto-ui-v2 #adminQrAttendance #adminQrCamera,
body.opto-ui-v2 #adminQrAttendance button[data-qr-action] {
    background: #16304d !important;
    color: #dce9f8 !important;
    border: 1px solid #365575 !important;
    border-radius: 10px !important;
    font-weight: 700;
}

body.opto-ui-v2 #adminQrAttendance button[data-qr-action="time_in"] {
    background: linear-gradient(112deg, #225bc8, #347fe9 65%, #168fb8) !important;
    color: #fff !important;
    border-color: transparent !important;
}

body.opto-ui-v2 #adminQrIdentity {
    background: #0f2034 !important;
    border-color: #2b4a6d !important;
    color: #e8f0fb !important;
}

body.opto-ui-v2 #adminQrAttendance label {
    color: #c3d2e5 !important;
}

/* Laptop / tablet landscape: two columns, activity underneath. */
@media (max-width: 1280px) {
    body.opto-ui-v2 .attendance-header {
        grid-template-columns: minmax(320px, 1fr) minmax(0, 1fr) !important;
        grid-template-rows: auto auto auto !important;
        grid-template-areas:
            "scan shift"
            "scan stats"
            "latest latest" !important;
    }

    body.opto-ui-v2 .latest-scan-card .scan-history {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* Phone / small tablet: one column. */
@media (max-width: 760px) {
    body.opto-ui-v2 .attendance-header {
        grid-template-columns: 1fr !important;
        grid-template-rows: auto !important;
        grid-template-areas:
            "shift"
            "scan"
            "stats"
            "latest" !important;
    }

    body.opto-ui-v2 .latest-scan-card .scan-history {
        grid-template-columns: 1fr;
    }
}

body.opto-ui-v2 #adminQrAttendance :is(#adminQrCamera, button[data-qr-action]) {
    flex: 1 1 120px;
    min-height: 44px;
}

body.opto-ui-v2 #adminManualAttendance .manual-attendance-action[data-action="time_out"] {
    background: #16304d !important;
    color: #dce9f8 !important;
    border: 1px solid #365575 !important;
    box-shadow: none !important;
}

/* =========================================================
   11. LOGOUT CONFIRMATION
   ========================================================= */
.opto-logout-overlay[hidden] { display: none !important; }

.opto-logout-overlay {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(2, 8, 17, .72);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}

.opto-logout-card {
    width: min(400px, 100%);
    padding: 26px 24px 22px;
    border-radius: 18px;
    text-align: center;
    background: linear-gradient(160deg, #132840, #0d1c2f);
    border: 1px solid #2f4b6c;
    box-shadow: 0 28px 80px rgba(0, 0, 0, .55);
    color: #e8f0fb;
    font-family: inherit;
    animation: optoLogoutIn .18s ease-out;
}

.opto-logout-icon {
    width: 54px;
    height: 54px;
    margin: 0 auto 14px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 21px;
    color: #fca5a5;
    background: rgba(239, 68, 68, .14);
    border: 1px solid rgba(239, 68, 68, .35);
}

.opto-logout-card h3 {
    margin: 0 0 8px;
    font-size: 20px;
    font-weight: 800;
    color: #f2f7ff !important;
}

.opto-logout-card p {
    margin: 0 0 20px;
    font-size: 13.5px;
    line-height: 1.55;
    color: #a9bcd4 !important;
}

.opto-logout-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.opto-logout-actions button {
    min-height: 44px;
    border-radius: 11px;
    font: inherit;
    font-size: 13.5px;
    font-weight: 700;
    cursor: pointer;
}

.opto-logout-cancel {
    background: #16304d !important;
    color: #dce9f8 !important;
    border: 1px solid #365575 !important;
}

.opto-logout-cancel:hover { background: #1e3d61 !important; color: #fff !important; }

.opto-logout-confirm {
    background: linear-gradient(112deg, #c2323f, #e2475a) !important;
    color: #fff !important;
    border: 1px solid transparent !important;
    box-shadow: 0 6px 16px rgba(194, 50, 63, .3);
}

.opto-logout-confirm:hover:not(:disabled) { filter: brightness(1.08); }

@keyframes optoLogoutIn {
    from { opacity: 0; transform: translateY(8px) scale(.98); }
    to { opacity: 1; transform: none; }
}

/* =========================================================
   12. ACCOUNT SETTINGS POPOVER (Supervisor, Shift Leader, Operator)
   ========================================================= */
html body .opto-account-popover,
html body.opto-ui-v2 .profile-menu {
    position: fixed !important;
    z-index: 99000 !important;
    width: min(360px, calc(100vw - 20px)) !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
    padding: 18px 18px 16px !important;
    border-radius: 16px !important;
    background: linear-gradient(160deg, #132840, #0d1c2f) !important;
    border: 1px solid #2f4b6c !important;
    box-shadow: 0 24px 70px rgba(0, 0, 0, .55) !important;
    color: #e8f0fb !important;
    font-family: inherit !important;
    font-size: 13.5px !important;
    scrollbar-width: thin;
    scrollbar-color: #35577d transparent;
}

/* Operator menu lives inside the header; keep it anchored there. */
html body.opto-ui-v2 .profile-menu {
    position: absolute !important;
    top: calc(100% + 6px) !important;
    right: 14px !important;
    max-height: calc(100dvh - 90px) !important;
}

html body .opto-account-popover:not(.open),
html body.opto-ui-v2 .profile-menu:not(.open) {
    display: none !important;
}

html body .opto-account-popover.open,
html body.opto-ui-v2 .profile-menu.open {
    display: block !important;
    animation: optoPopIn .16s ease-out;
}

@keyframes optoPopIn {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: none; }
}

html body .opto-account-popover > div:first-child {
    padding-bottom: 12px;
    margin-bottom: 4px;
    border-bottom: 1px solid #263e5b;
}

html body .opto-account-popover > div:first-child strong {
    font-size: 16px;
    font-weight: 800;
    color: #f2f7ff !important;
}

html body :is(.opto-account-popover, .profile-menu) label {
    display: block;
    margin: 12px 0 6px !important;
    font-size: 12px !important;
    font-weight: 700 !important;
    color: #c3d2e5 !important;
}

html body :is(.opto-account-popover, .profile-menu) :is(input[type="text"], input[type="password"], input:not([type])) {
    width: 100% !important;
    min-height: 42px !important;
    padding: 10px 44px 10px 12px !important;
    background: #0a1828 !important;
    color: #eef5ff !important;
    border: 1px solid #35557a !important;
    border-radius: 10px !important;
    box-sizing: border-box;
}

html body :is(.opto-account-popover, .profile-menu) input[readonly] {
    background: #132741 !important;
    color: #a9bcd4 !important;
    padding-right: 12px !important;
}

html body :is(.opto-account-popover, .profile-menu) input::placeholder {
    color: #7189a8 !important;
}

html body :is(.opto-account-popover, .profile-menu) input[type="file"] {
    width: 100% !important;
    padding: 6px !important;
    background: #0a1828 !important;
    color: #c3d2e5 !important;
    border: 1px dashed #35557a !important;
    border-radius: 10px !important;
    font-size: 12.5px !important;
    cursor: pointer;
}

html body :is(.opto-account-popover, .profile-menu) input[type="file"]::file-selector-button {
    margin-right: 10px;
    padding: 8px 12px;
    border: 1px solid #3d77b7;
    border-radius: 8px;
    background: #16304d;
    color: #dce9f8;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

html body :is(.opto-account-popover, .profile-menu) img {
    border: 3px solid #2f4b6c !important;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .35);
}

/* Show/hide password eye. */
html body :is(.opto-account-popover, .profile-menu) :is(.profile-pass-toggle, .password-eye-btn) {
    position: absolute !important;
    right: 5px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    width: 34px !important;
    height: 34px !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    border: 0 !important;
    border-radius: 8px !important;
    background: transparent !important;
    color: #8fb6e6 !important;
    font-size: 15px !important;
    cursor: pointer;
}

html body :is(.opto-account-popover, .profile-menu) :is(.profile-pass-toggle, .password-eye-btn):hover {
    background: #1a3552 !important;
    color: #fff !important;
}

html body :is(.opto-account-popover, .profile-menu) :is(.profile-pass-wrap, .password-field-wrap) {
    position: relative;
}

html body :is(.opto-account-popover, .profile-menu) small,
html body :is(.opto-account-popover, .profile-menu) p {
    color: #a9bcd4 !important;
    font-size: 12px !important;
    line-height: 1.5;
}

/* Close (×) button. */
html body .opto-account-popover [data-account-close]:not([type="button"][id$="Cancel"]) {
    width: 34px !important;
    height: 34px !important;
    padding: 0 !important;
    border-radius: 10px !important;
    background: #1a3552 !important;
    color: #dce9f8 !important;
    border: 1px solid #385879 !important;
    font-size: 18px !important;
    line-height: 1 !important;
    cursor: pointer;
}

html body :is(.opto-account-popover .sp-actions, .profile-menu form) button:is([type="submit"], [id$="Cancel"]),
html body.opto-ui-v2 .profile-menu form > button {
    min-height: 44px !important;
    padding: 10px 14px !important;
    border-radius: 11px !important;
    font: inherit !important;
    font-weight: 700 !important;
    cursor: pointer;
}

html body :is(.opto-account-popover, .profile-menu) button[type="submit"] {
    background: linear-gradient(112deg, #225bc8, #347fe9 65%, #168fb8) !important;
    color: #fff !important;
    border: 1px solid transparent !important;
    box-shadow: 0 6px 16px rgba(22, 93, 201, .25) !important;
}

html body :is(.opto-account-popover, .profile-menu) button[type="submit"]:disabled {
    opacity: .5 !important;
    box-shadow: none !important;
}

html body .opto-account-popover button[id$="Cancel"] {
    background: #16304d !important;
    color: #dce9f8 !important;
    border: 1px solid #365575 !important;
}

html body .opto-account-popover .sp-actions {
    display: grid !important;
    grid-template-columns: 1.4fr 1fr;
    gap: 10px !important;
    margin-top: 16px !important;
}

/* Password checklist under the fields. */
html body .profile-live-rules {
    padding: 10px 12px;
    border-radius: 10px;
    background: #0f2034;
    border: 1px solid #243b57;
}

html body .profile-live-rules span { color: #fca5a5 !important; }
html body .profile-live-rules span.pass { color: #4ade80 !important; }
html body .profile-validation-note { color: #fca5a5 !important; }

html body :is(#spAccountFlash, #slAccountFlash) {
    margin-top: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(54, 120, 237, .14);
    border: 1px solid rgba(83, 151, 235, .35);
    color: #cfe0f4 !important;
}

/* Profile button feedback. */
#user-profile {
    cursor: pointer;
    user-select: none;
}

#user-profile .fa-chevron-down {
    transition: transform .2s ease;
}

#user-profile.is-open .fa-chevron-down,
#user-profile[aria-expanded="true"] .fa-chevron-down {
    transform: rotate(180deg);
}

#user-profile:focus-visible {
    outline: 2px solid #4b91ff;
    outline-offset: 2px;
}

/* =========================================================
   13. BRAND LOGO (sidebar + login)
   The eye logo sits on a soft dark tile so its blue reads well
   against the navy sidebar.
   ========================================================= */
body.opto-ui-v2 nav .logo-circle.opto-logo-mark {
    width: 54px !important;
    height: 46px !important;
    min-width: 54px !important;
    flex: 0 0 54px !important;
    padding: 7px 6px !important;
    border-radius: 14px !important;
    background: linear-gradient(150deg, #f4f8ff, #dfe9fb) !important;
    border: 1px solid rgba(255, 255, 255, .7) !important;
    box-shadow: 0 8px 22px rgba(0, 0, 0, .35), 0 0 0 4px rgba(54, 120, 237, .12) !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

body.opto-ui-v2 nav .logo-circle.opto-logo-mark img {
    display: block;
    width: 100%;
    height: auto;
    object-fit: contain;
}

body.opto-ui-v2 nav .sidebar-logo {
    gap: 12px !important;
}

body.opto-ui-v2 nav .logo-text h3 {
    letter-spacing: .02em !important;
}

.opto-login-logo {
    display: block;
    width: 96px;
    height: auto;
    margin: 0 0 18px;
    padding: 12px 14px;
    border-radius: 18px;
    background: linear-gradient(150deg, #f4f8ff, #dfe9fb);
    box-shadow: 0 12px 30px rgba(0, 0, 0, .35);
    box-sizing: content-box;
}

/* Biweekly schedule bulk tools bar (was a white strip with invisible label). */
body.opto-ui-v2 .bulk-toolbar {
    background: #10233a !important;
    border: 1px solid #263e5b !important;
    color: #dce9f8 !important;
}

body.opto-ui-v2 .bulk-toolbar strong {
    color: #e8f0fb !important;
}

/* Live Monitoring status pills */
body.opto-ui-v2 .attendance-table .status {
    display: inline-flex !important;
    align-items: center;
    gap: 7px;
    padding: 6px 13px !important;
    border-radius: 999px !important;
    font-weight: 700 !important;
    white-space: nowrap;
    border: 1px solid transparent !important;
}

body.opto-ui-v2 .attendance-table .status.present {
    background: rgba(34, 197, 94, .14) !important;
    border-color: rgba(34, 197, 94, .45) !important;
    color: #4ade80 !important;
}

body.opto-ui-v2 .attendance-table .status.not-present,
body.opto-ui-v2 .attendance-table .status.absent {
    background: rgba(239, 68, 68, .14) !important;
    border-color: rgba(239, 68, 68, .5) !important;
    color: #fca5a5 !important;
}

body.opto-ui-v2 .attendance-table .status.leave,
body.opto-ui-v2 .attendance-table .status.late {
    background: rgba(245, 158, 11, .14) !important;
    border-color: rgba(245, 158, 11, .45) !important;
    color: #fbbf24 !important;
}

body.opto-ui-v2 .attendance-table .status.not-scheduled {
    background: rgba(148, 163, 184, .12) !important;
    border-color: rgba(148, 163, 184, .35) !important;
    color: #cbd5e1 !important;
}

body.opto-ui-v2 .attendance-table .status i {
    color: inherit !important;
}

/* Employee initial avatar (was a white tile with low-contrast letter). */
body.opto-ui-v2 .attendance-table .employee-avatar {
    background: rgba(54, 120, 237, .18) !important;
    color: #9cc9ff !important;
    border: 1px solid rgba(83, 151, 235, .35) !important;
}

/* Pop-ups always clear the header and fit the screen. */
body.opto-ui-v2 .scanner-modal {
    z-index: 9000 !important;
    padding: 16px;
    box-sizing: border-box;
}

body.opto-ui-v2 .scanner-modal .modal-box {
    max-height: calc(100dvh - 32px) !important;
    overflow-y: auto !important;
}

body.opto-ui-v2 .face-enrollment-box .face-preview-placeholder,
body.opto-ui-v2 .face-enrollment-box .face-preview {
    max-height: min(320px, 38dvh);
}

/* =========================================================
   14. OPERATOR – Report Issue (red, next to the role badge)
   ========================================================= */
body.opto-ui-v2 .production-toolbar {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    gap: 12px !important;
    flex-wrap: wrap;
}

body.opto-ui-v2 .production-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-left: auto;
}

body.opto-ui-v2 :is(.report-issue-btn, .open-btn.report-issue-link) {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 8px 16px !important;
    border-radius: 999px !important;
    background: linear-gradient(112deg, #c2323f, #e2475a) !important;
    color: #fff !important;
    border: 1px solid rgba(255, 140, 150, .35) !important;
    font-weight: 800 !important;
    font-size: 13px !important;
    box-shadow: 0 6px 16px rgba(194, 50, 63, .3);
    cursor: pointer;
}

body.opto-ui-v2 :is(.report-issue-btn, .open-btn.report-issue-link):hover {
    filter: brightness(1.08);
}

body.opto-ui-v2 :is(.report-issue-btn, .open-btn.report-issue-link) i {
    color: #fff !important;
}

body.opto-ui-v2 .open-btn.report-issue-link {
    width: 100%;
    border-radius: 10px !important;
    margin-top: 8px;
}

/* Role badge in the dark palette. */
body.opto-ui-v2 .production-role {
    background: rgba(54, 120, 237, .16) !important;
    color: #9cc9ff !important;
    border: 1px solid rgba(83, 151, 235, .4) !important;
    padding: 8px 14px !important;
}

/* Report dialog window */
body.opto-ui-v2 .issue-modal-backdrop {
    background: rgba(2, 8, 17, .72) !important;
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}

body.opto-ui-v2 .issue-modal-window {
    width: min(680px, 100%) !important;
    background: #0d1c2f !important;
    border: 1px solid #2f4b6c !important;
    border-radius: 18px !important;
    box-shadow: 0 28px 80px rgba(0, 0, 0, .55) !important;
}

body.opto-ui-v2 .issue-modal-header {
    padding: 18px 20px 14px !important;
    background: linear-gradient(160deg, #152c46, #11253c) !important;
    border-bottom: 1px solid #263e5b !important;
    color: #f2f7ff !important;
}

body.opto-ui-v2 .issue-modal-header strong {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    color: #f2f7ff !important;
}

body.opto-ui-v2 .issue-modal-header strong::before {
    content: "";
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ef4444;
    box-shadow: 0 0 0 4px rgba(239, 68, 68, .2);
}

body.opto-ui-v2 .issue-modal-header button {
    width: 38px;
    height: 38px;
    border-radius: 10px !important;
    background: #1a3552 !important;
    border: 1px solid #385879 !important;
    color: #dce9f8 !important;
    font-size: 22px !important;
}

body.opto-ui-v2 #issueModalFrame {
    background: #0d1c2f !important;
    height: 560px;
    max-height: calc(100dvh - 120px);
}

/* Partial refresh: the section being reloaded dims briefly. */
.opto-partial-loading {
    opacity: .45;
    pointer-events: none;
    transition: opacity .15s ease;
}

/* =========================================================
   15. LOGIN – attempts left / cooldown banner
   ========================================================= */
.opto-login-security[hidden] { display: none !important; }

.opto-login-security {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    margin-top: 14px;
    padding: 12px 14px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.5;
    text-align: left;
}

.opto-login-security i {
    margin-top: 3px;
    font-size: 15px;
}

.opto-login-security strong {
    display: block;
    font-size: 13.5px;
}

.opto-login-security span {
    display: block;
}

.opto-login-security.warn {
    background: rgba(245, 158, 11, .12);
    border: 1px solid rgba(245, 158, 11, .45);
    color: #fcd34d;
}

.opto-login-security.warn strong { color: #fbbf24; }

.opto-login-security.cooldown {
    background: rgba(239, 68, 68, .12);
    border: 1px solid rgba(239, 68, 68, .45);
    color: #fecaca;
}

.opto-login-security.cooldown strong { color: #fca5a5; }

.opto-login-security.cooldown b {
    color: #fff;
    font-variant-numeric: tabular-nums;
}

body.opto-login-v2 .login-btn:disabled {
    opacity: .55;
    cursor: not-allowed;
}

/* Page flash messages (e.g. employee created / could not be created) */
.opto-flash {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0 0 18px;
    padding: 13px 16px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.5;
}

.opto-flash i { margin-top: 3px; }

.opto-flash.error {
    background: rgba(239, 68, 68, .12);
    border: 1px solid rgba(239, 68, 68, .45);
    color: #fecaca;
}

.opto-flash.error i { color: #f87171; }

.opto-flash.success {
    background: rgba(34, 197, 94, .12);
    border: 1px solid rgba(34, 197, 94, .4);
    color: #bbf7d0;
}

.opto-flash.success i { color: #4ade80; }

/* ============================================================
   20. Personnel: clear delete selection + password eye toggle
   ============================================================ */
body.opto-ui-v2 .delete-profile-btn.is-active {
  background: #ef4444 !important;
  color: #fff !important;
  border-color: #fca5a5 !important;
  box-shadow: 0 0 0 4px rgba(239, 68, 68, .28), 0 14px 30px rgba(239, 68, 68, .35) !important;
}

/* Every card shows a clear, high-contrast checkbox while in delete mode. */
body.opto-ui-v2.profile-delete-mode .profile-card {
  outline: 2px dashed rgba(148, 178, 214, .35);
  outline-offset: -2px;
  transition: outline-color .15s ease, box-shadow .15s ease, transform .15s ease, background .15s ease;
}
body.opto-ui-v2.profile-delete-mode .profile-card:hover {
  outline-color: rgba(252, 165, 165, .75);
}
body.opto-ui-v2 .profile-delete-selector { width: 34px; height: 34px; top: 12px; right: 12px; }
body.opto-ui-v2 .profile-delete-checkmark {
  width: 34px !important;
  height: 34px !important;
  border-radius: 10px !important;
  background: #0b1a2c !important;
  border: 2px solid #cfe0f5 !important;
  color: transparent !important;
  font-size: 15px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .35) !important;
}
body.opto-ui-v2 .profile-delete-checkbox:checked + .profile-delete-checkmark {
  background: #ef4444 !important;
  border-color: #fff !important;
  color: #fff !important;
}
body.opto-ui-v2 .profile-delete-checkbox:focus-visible + .profile-delete-checkmark {
  outline: 3px solid #93c5fd;
  outline-offset: 2px;
}

/* Selected card: red border, red tint and a "Selected" tag. */
body.opto-ui-v2 .profile-card.delete-selected {
  outline: 3px solid #ef4444 !important;
  outline-offset: -3px;
  background: linear-gradient(160deg, rgba(239, 68, 68, .22), rgba(127, 29, 29, .18)) !important;
  box-shadow: 0 0 0 4px rgba(239, 68, 68, .18), 0 16px 34px rgba(0, 0, 0, .35) !important;
  transform: translateY(-2px);
}
body.opto-ui-v2 .profiles-container .profile-card.delete-selected::after {
  display: block !important;
  content: "Selected";
  position: absolute;
  top: 14px;
  left: 14px;
  right: auto;
  bottom: auto;
  width: auto !important;
  height: auto !important;
  opacity: 1 !important;
  transform: none !important;
  filter: none !important;
  line-height: 1.2;
  padding: 4px 10px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .02em;
  z-index: 7;
}
/* Unselected cards fade back slightly once something is picked. */
body.opto-ui-v2.profile-delete-mode .profiles-container:has(.delete-selected) .profile-card:not(.delete-selected) {
  opacity: .62;
}
body.opto-ui-v2 .profile-card { position: relative; }

/* Selection bar floats at the bottom so it is always visible. */
body.opto-ui-v2 .delete-selection-bar {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  z-index: 900;
  width: min(760px, calc(100vw - 32px));
  margin: 0 !important;
  padding: 14px 16px !important;
  border-radius: 16px !important;
  background: linear-gradient(150deg, #2a1220, #1a0f1d) !important;
  border: 1px solid rgba(248, 113, 113, .6) !important;
  box-shadow: 0 22px 50px rgba(0, 0, 0, .55) !important;
  animation: optoBarIn .2s ease-out;
}
@keyframes optoBarIn { from { opacity: 0; transform: translate(-50%, 14px); } to { opacity: 1; transform: translate(-50%, 0); } }
body.opto-ui-v2 .delete-selection-info { gap: 12px !important; min-width: 0; }
body.opto-ui-v2 .delete-selection-icon {
  flex: 0 0 auto;
  width: 38px; height: 38px;
  border-radius: 11px;
  display: grid; place-items: center;
  background: rgba(239, 68, 68, .2);
  color: #fecaca;
}
body.opto-ui-v2 .delete-selection-text { display: flex; flex-direction: column; min-width: 0; }
body.opto-ui-v2 .delete-selection-title { color: #fff; font-size: 15px; }
body.opto-ui-v2 .delete-selection-title strong { color: #fca5a5; font-size: 17px; }
body.opto-ui-v2 .delete-selection-names {
  color: #fecaca; font-size: 13px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
body.opto-ui-v2 .delete-selection-cancel {
  background: #1e3350 !important; color: #e8f0fb !important;
  border: 1px solid #3d5c80 !important;
}
body.opto-ui-v2 .delete-selection-confirm { background: #ef4444 !important; color: #fff !important; }
body.opto-ui-v2 .delete-selection-confirm:disabled { opacity: .45; cursor: not-allowed; }
/* Leave room so the last row of cards is not hidden behind the bar. */
body.opto-ui-v2.profile-delete-mode .container > main,
body.opto-ui-v2.profile-delete-mode .main-content { padding-bottom: 120px; }
@media (max-width: 640px) {
  body.opto-ui-v2 .delete-selection-bar { bottom: 12px; flex-direction: column; align-items: stretch !important; }
  body.opto-ui-v2 .delete-selection-actions { justify-content: stretch; }
  body.opto-ui-v2 .delete-selection-actions > button { flex: 1; }
}

/* Password field with show/hide eye button. */
.opto-password-field { position: relative; margin: 5px 0; }
.opto-password-field input {
  width: 100%;
  padding: 10px 46px 10px 12px !important;
  margin: 0 !important;
  box-sizing: border-box;
}
.opto-password-field .opto-password-toggle,
.modal-content .opto-password-field .opto-password-toggle {
  position: absolute !important;
  top: 50% !important;
  right: 6px !important;
  left: auto !important;
  transform: translateY(-50%) !important;
  width: 36px !important; height: 32px !important;
  min-width: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 8px !important;
  background: transparent !important;
  box-shadow: none !important;
  color: #a9bcd4 !important;
  cursor: pointer;
  display: grid !important; place-items: center;
  font-size: 15px !important;
}
.opto-password-field .opto-password-toggle:hover { color: #fff !important; background: rgba(54, 120, 237, .22) !important; transform: translateY(-50%) !important; }
.opto-password-toggle:focus-visible { outline: 2px solid #3678ed; outline-offset: 1px; }
.opto-password-field .opto-password-toggle[aria-pressed="true"] { color: #60a5fa !important; }

/* ============================================================
   21. System Notifications (superadmin dashboard): one consistent look
   ============================================================ */
body.opto-ui-v2 .notifications-card .notification-table-scroll {
  background: #0f2136 !important;
  border: 1px solid #22405f !important;
  border-radius: 12px !important;
  overflow-x: hidden !important;
}
body.opto-ui-v2 .notifications-card .notification-table-heading {
  position: sticky; top: 0; z-index: 2;
  background: #132a44 !important;
  border-bottom: 1px solid #22405f !important;
  padding: 9px 12px !important;
}
body.opto-ui-v2 .notifications-card .notification-table-heading span:first-child {
  color: #e8f0fb !important; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; font-size: 11px;
}
body.opto-ui-v2 .notifications-card .notification-count {
  background: #2563eb !important; color: #fff !important;
  border-radius: 999px; padding: 1px 8px; font-size: 11px; font-weight: 700;
}
body.opto-ui-v2 .notifications-card .notification-compact-table {
  min-width: 0 !important; width: 100% !important; table-layout: fixed;
  background: transparent !important;
}
body.opto-ui-v2 .notifications-card .notification-compact-table th:first-child { width: 58% !important; }
body.opto-ui-v2 .notifications-card .notification-compact-table th:nth-child(2) { width: 22% !important; }
body.opto-ui-v2 .notifications-card .notification-compact-table th:nth-child(3) { width: 20% !important; }
body.opto-ui-v2 .notifications-card .notification-compact-table thead th {
  background: #0f2136 !important; color: #a9bcd4 !important;
  font-size: 11px !important; font-weight: 700 !important; text-transform: uppercase; letter-spacing: .04em;
  border-bottom: 1px solid #22405f !important; padding: 8px 12px !important;
}
/* Same background for every row regardless of type; type is shown only by the left bar and icon colour. */
body.opto-ui-v2 .notifications-card .notification-compact-table tbody tr,
body.opto-ui-v2 .notifications-card .notification-compact-table tbody tr:is(.warning, .info, .success, .danger, .error) {
  background: #11253c !important;
  color: #c3d2e5 !important;
  border: 0 !important;
}
body.opto-ui-v2 .notifications-card .notification-compact-table tbody tr:nth-child(even) { background: #0f2136 !important; }
body.opto-ui-v2 .notifications-card .notification-compact-table tbody tr:hover { background: #17304d !important; }
body.opto-ui-v2 .notifications-card .notification-compact-table tbody td {
  background: transparent !important;
  color: #c3d2e5 !important;
  border-bottom: 1px solid #1d3753 !important;
  padding: 11px 12px !important;
  font-size: 12.5px;
}
body.opto-ui-v2 .notifications-card .notification-row td:first-child { box-shadow: inset 3px 0 0 #f59e0b; }
body.opto-ui-v2 .notifications-card .notification-row.info td:first-child { box-shadow: inset 3px 0 0 #3b82f6; }
body.opto-ui-v2 .notifications-card .notification-row.success td:first-child { box-shadow: inset 3px 0 0 #22c55e; }
body.opto-ui-v2 .notifications-card .notification-compact-table .notification-title {
  color: #f1f6fd !important; font-weight: 700; font-size: 13px;
}
body.opto-ui-v2 .notifications-card .notification-compact-table .notification-title i { color: #f59e0b !important; }
body.opto-ui-v2 .notifications-card .notification-row.info .notification-title i { color: #60a5fa !important; }
body.opto-ui-v2 .notifications-card .notification-row.success .notification-title i { color: #4ade80 !important; }
body.opto-ui-v2 .notifications-card .notification-compact-table .notification-description { color: #a9bcd4 !important; font-size: 12px; }
body.opto-ui-v2 .notifications-card .notification-compact-table .notification-when { color: #a9bcd4 !important; font-size: 12px; }
body.opto-ui-v2 .notifications-card .notification-table-empty { color: #a9bcd4 !important; background: transparent !important; }
body.opto-ui-v2 .notifications-card a.oir-trigger {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 7px; padding: 5px 11px;
  border-radius: 8px;
  background: #1d3a5c !important; color: #dbeafe !important;
  border: 1px solid #3b6390 !important;
  font-size: 12px; font-weight: 600;
}
body.opto-ui-v2 .notifications-card a.oir-trigger:hover { background: #2563eb !important; border-color: #2563eb !important; color: #fff !important; }

/* ============================================================
   22. Shift Leader: attendance needing review (missing Time Out, extra shifts)
   ============================================================ */
.opto-shift-review {
  margin: 0 0 16px;
  background: #0f2136;
  border: 1px solid #22405f;
  border-radius: 14px;
  overflow: hidden;
}
.opto-shift-review.needs-attention { border-color: rgba(239, 68, 68, .55); box-shadow: 0 0 0 1px rgba(239, 68, 68, .15); }
.opto-shift-review__head {
  width: 100%;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  background: transparent !important;
  border: 0 !important;
  color: #e8f0fb !important;
  text-align: left;
  cursor: pointer;
  box-shadow: none !important;
}
.opto-shift-review__head:hover { background: #132a44 !important; }
.opto-shift-review__head:focus-visible { outline: 2px solid #3678ed; outline-offset: -2px; }
.opto-shift-review__icon {
  flex: 0 0 auto; width: 38px; height: 38px; border-radius: 11px;
  display: grid; place-items: center;
  background: rgba(54, 120, 237, .18); color: #93c5fd;
}
.opto-shift-review.needs-attention .opto-shift-review__icon { background: rgba(239, 68, 68, .18); color: #fca5a5; }
.opto-shift-review__title { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.opto-shift-review__title strong { font-size: 15px; color: #f1f6fd; }
.opto-shift-review__title small { font-size: 12.5px; color: #a9bcd4; }
.opto-shift-review__counts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.opto-count-pill, .opto-status-pill {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700; white-space: nowrap;
}
.opto-count-pill.is-danger, .opto-status-pill.is-danger { background: rgba(239, 68, 68, .18); color: #fecaca; border: 1px solid rgba(239, 68, 68, .45); }
.opto-count-pill.is-warn, .opto-status-pill.is-warn { background: rgba(245, 158, 11, .16); color: #fde68a; border: 1px solid rgba(245, 158, 11, .45); }
.opto-count-pill.is-ok, .opto-status-pill.is-ok { background: rgba(34, 197, 94, .14); color: #bbf7d0; border: 1px solid rgba(34, 197, 94, .4); }
.opto-shift-review__chev { color: #a9bcd4; transition: transform .2s ease; }
.opto-shift-review.is-open .opto-shift-review__chev { transform: rotate(180deg); }
.opto-shift-review__body { padding: 0 16px 16px; border-top: 1px solid #1d3753; }
.opto-shift-review__hint { margin: 12px 0 4px; font-size: 13px; color: #a9bcd4; }
.opto-shift-review__subhead {
  margin: 16px 0 8px; font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: #8fa6c2;
}
.opto-review-list { display: flex; flex-direction: column; gap: 8px; }
.opto-review-empty { margin: 0; padding: 10px 12px; border-radius: 10px; background: #11253c; color: #a9bcd4; font-size: 13px; }
.opto-review-item {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 14px;
  background: #11253c;
  border: 1px solid #1d3753;
  border-left: 4px solid #22c55e;
  border-radius: 10px;
}
.opto-review-item.is-danger { border-left-color: #ef4444; }
.opto-review-item.is-warn { border-left-color: #f59e0b; }
.opto-review-item__main { flex: 1; min-width: 220px; }
.opto-review-item__name { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 700; color: #f1f6fd; font-size: 14px; }
.opto-review-item__meta { margin-top: 3px; color: #a9bcd4; font-size: 12.5px; }
.opto-review-item__actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Buttons used by this panel and its dialog. */
.opto-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 0 14px;
  border-radius: 9px;
  font-size: 13px; font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent !important;
  box-shadow: none !important;
  transition: filter .15s ease, background .15s ease;
}
.opto-btn:disabled { opacity: .5; cursor: not-allowed; }
.opto-btn--primary { background: #2563eb !important; color: #fff !important; }
.opto-btn--success { background: #16a34a !important; color: #fff !important; }
.opto-btn--danger { background: #dc2626 !important; color: #fff !important; }
.opto-btn--ghost { background: #1d3a5c !important; color: #dbeafe !important; border-color: #3b6390 !important; }
.opto-btn--outline-danger { background: transparent !important; color: #fca5a5 !important; border-color: rgba(239, 68, 68, .6) !important; }
.opto-btn:not(:disabled):hover { filter: brightness(1.12); }
.opto-btn--outline-danger:not(:disabled):hover { background: rgba(239, 68, 68, .12) !important; }

.opto-review-dialog {
  position: fixed; inset: 0; z-index: 12000;
  display: grid; place-items: center;
  padding: 16px;
  background: rgba(3, 10, 20, .7);
}
.opto-review-dialog[hidden] { display: none; }
.opto-review-dialog__card {
  width: min(460px, 100%);
  background: #10233a;
  border: 1px solid #2a4a6e;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .55);
}
.opto-review-dialog__card h3 { margin: 0 0 8px; color: #f1f6fd; font-size: 18px; }
.opto-review-dialog__card p { margin: 0 0 14px; color: #c3d2e5; font-size: 14px; line-height: 1.5; }
.opto-review-dialog__field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; color: #dbe7f6; font-size: 13px; font-weight: 600; }
.opto-review-dialog__field small { color: #a9bcd4; font-weight: 400; }
.opto-review-dialog__field textarea {
  width: 100%; box-sizing: border-box; resize: vertical;
  background: #0b1a2c !important; color: #e8f0fb !important;
  border: 1px solid #2f4f75 !important; border-radius: 10px; padding: 10px 12px; font: inherit; font-weight: 400;
}
.opto-review-dialog__field textarea:focus { outline: 2px solid #3678ed; border-color: #3678ed !important; }
.opto-review-dialog__counter { align-self: flex-end; }
.opto-review-dialog__actions { display: flex; justify-content: flex-end; gap: 10px; }
@media (max-width: 640px) {
  .opto-shift-review__head { flex-wrap: wrap; }
  .opto-shift-review__counts { width: 100%; justify-content: flex-start; }
  .opto-review-item__actions { width: 100%; }
  .opto-review-item__actions .opto-btn { flex: 1; }
}

/* ============================================================
   23. Personnel Performance: new score breakdown
   ============================================================ */
.opto-att-chips {
  display: inline-flex; align-items: baseline; flex-wrap: wrap; gap: 2px;
  margin: 6px 0 2px; font-size: 18px; font-weight: 800; color: #6b819c;
  font-variant-numeric: tabular-nums;
}
.opto-att-chips b, .opto-att-mini b { font-weight: 800; }
.opto-att-extra { color: #c4b5fd; }      /* violet: approved extra shifts */
.opto-att-attended { color: #4ade80; }   /* green: scheduled shifts attended */
.opto-att-scheduled { color: #93c5fd; }  /* blue: scheduled shifts */
.opto-att-legend { flex-basis: 100%; margin-top: 2px; font-size: 11px; font-weight: 600; color: #8fa6c2; }
.opto-att-legend i { font-style: normal; }
.opto-att-mini { font-variant-numeric: tabular-nums; white-space: nowrap; }
.opto-att-summary {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px 16px;
  margin: 8px 0 16px; padding: 12px 14px;
  background: #11253c; border: 1px solid #22405f; border-radius: 10px;
  color: #c3d2e5; font-size: 13px;
}
.opto-att-summary .opto-att-chips { margin: 0; }
body.opto-ui-v2 .schedule-state.partial { background: rgba(245, 158, 11, .16) !important; color: #fde68a !important; border-color: rgba(245, 158, 11, .4) !important; }
body.opto-ui-v2 .schedule-performance-table .schedule-state { white-space: normal; line-height: 1.35; }
.opto-role-pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.opto-role-pill.is-dispatch { background: rgba(54, 120, 237, .18); color: #bfdbfe; }
.opto-role-pill.is-collect { background: rgba(20, 184, 166, .18); color: #99f6e4; }
body.opto-ui-v2 .leader-card .score.score-na { color: #8fa6c2 !important; font-size: 18px; }

/* ============================================================
   24. Personnel Performance: tidy score cards and production table
   ============================================================ */
body.opto-ui-v2 .performance-score-kpis .score-kpi { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.opto-kpi-rows { margin: 4px 0 2px; display: flex; flex-direction: column; gap: 4px; }
.opto-kpi-rows > div {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  padding: 5px 8px; border-radius: 8px; background: rgba(255, 255, 255, .03);
}
.opto-kpi-rows dt { margin: 0; color: #a9bcd4; font-size: 12.5px; font-weight: 600; }
.opto-kpi-rows dd { margin: 0; color: #f1f6fd; font-size: 13.5px; font-weight: 800; text-align: right; font-variant-numeric: tabular-nums; }
.opto-kpi-rows dd small { display: block; color: #8fa6c2; font-size: 11px; font-weight: 600; }
.opto-kpi-rows .is-good dd { color: #86efac; }
.opto-kpi-rows .is-warn dd { color: #fde68a; }
.opto-kpi-rows .is-bad dd { color: #fca5a5; }
.opto-kpi-note { margin: 0; color: #a9bcd4; font-size: 12.5px; }
body.opto-ui-v2 .opto-att-chips { font-size: 17px; margin: 2px 0 0; }
.opto-att-legend { font-size: 11px !important; font-weight: 600; color: #8fa6c2; background: none !important; border: 0 !important; padding: 0 !important; }

body.opto-ui-v2 .schedule-performance-table { table-layout: auto; }
body.opto-ui-v2 .schedule-performance-table td { vertical-align: middle; padding-top: 10px; padding-bottom: 10px; }
.opto-cell-main { display: inline-flex; align-items: center; gap: 7px; color: #e8f0fb; font-weight: 700; font-size: 13px; white-space: nowrap; }
.opto-cell-main.is-good::before, .opto-cell-main.is-warn::before, .opto-cell-main.is-bad::before, .opto-cell-main.is-na::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto;
}
.opto-cell-main.is-good::before { background: #22c55e; }
.opto-cell-main.is-warn::before { background: #f59e0b; }
.opto-cell-main.is-bad::before { background: #ef4444; }
.opto-cell-main.is-na { color: #8fa6c2; font-weight: 600; }
.opto-cell-main.is-na::before { background: #4b6584; }
.opto-cell-sub { display: block; margin-top: 2px; color: #8fa6c2; font-size: 11.5px; white-space: nowrap; }
body.opto-ui-v2 .performance-score-kpis .opto-kpi-rows small {
  display: block !important; background: none !important; border: 0 !important; padding: 0 !important;
  margin: 1px 0 0 !important; border-radius: 0 !important; box-shadow: none !important;
  color: #8fa6c2 !important; font-size: 11px !important; font-weight: 600 !important; white-space: nowrap;
}
body.opto-ui-v2 .performance-score-kpis .opto-kpi-rows > div { flex-wrap: wrap; }
body.opto-ui-v2 .performance-score-kpis .opto-kpi-rows dt { flex: 1 1 auto; min-width: 0; }
body.opto-ui-v2 .performance-score-kpis .opto-kpi-rows dd { flex: 0 0 auto; }
/* Narrow cards: label on its own line, value and detail on the next. */
body.opto-ui-v2 .performance-score-kpis .opto-kpi-rows > div { display: block; padding: 6px 9px; }
body.opto-ui-v2 .performance-score-kpis .opto-kpi-rows dt { display: block; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; }
body.opto-ui-v2 .performance-score-kpis .opto-kpi-rows dd { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; text-align: left; margin-top: 1px; }
body.opto-ui-v2 .performance-score-kpis .opto-kpi-rows dd small { display: inline !important; margin: 0 !important; }

/* Login: attempt dots (3 tries before the account is locked for a few minutes). */
.opto-login-security .opto-tries { display: inline-flex !important; gap: 5px; margin-left: 8px; vertical-align: middle; }
.opto-login-security .opto-try { display: inline-block !important; flex: 0 0 auto; width: 10px; height: 10px; border-radius: 50%; background: rgba(255, 255, 255, .25); border: 1px solid rgba(255, 255, 255, .45); }
.opto-login-security .opto-try.used { background: #ef4444; border-color: #fca5a5; }

/* ============================================================
   25. Update Employee Photo: take a photo with the camera
   ============================================================ */
.opto-visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0; margin: -1px; }
.opto-photo-label { display: block; margin: 4px 0 6px; color: #dbe7f6; font-weight: 700; font-size: 14px; }
.opto-photo-source { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.opto-photo-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 16px; border-radius: 12px; cursor: pointer;
  background: #1d3a5c !important; color: #e8f0fb !important; border: 1px solid #3b6390 !important;
  font-weight: 700; font-size: 14px; box-shadow: none !important; margin: 0 !important;
}
.opto-photo-btn:hover { filter: brightness(1.12); }
.opto-photo-btn.primary { background: #2563eb !important; border-color: #2563eb !important; color: #fff !important; }
.opto-photo-btn.ghost { background: transparent !important; }
.opto-photo-btn:disabled { opacity: .5; cursor: not-allowed; }
.opto-photo-btn:focus-visible, .opto-photo-source input:focus-visible + .opto-photo-btn { outline: 2px solid #60a5fa; outline-offset: 2px; }
.opto-photo-camera { position: relative; border-radius: 14px; overflow: hidden; background: #050c16; border: 1px solid #22405f; margin-bottom: 12px; }
.opto-photo-camera[hidden] { display: none; }
.opto-photo-camera video { display: block; width: 100%; max-height: 52vh; object-fit: cover; transform: scaleX(-1); background: #000; }
.opto-photo-camera video.is-rear { transform: none; }
.opto-photo-guide {
  position: absolute; left: 50%; top: 42%; width: 42%; aspect-ratio: 3 / 4; transform: translate(-50%, -50%);
  border: 2px dashed rgba(255, 255, 255, .7); border-radius: 50%; pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, .25);
}
.opto-photo-camera-status { margin: 0; padding: 10px 14px; color: #c3d2e5; font-size: 13px; background: #0d1c2f; }
.opto-photo-camera-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; padding: 0 14px 14px; background: #0d1c2f; }
.employee-photo-preview[hidden] { display: none !important; }
@media (max-width: 560px) { .opto-photo-source { grid-template-columns: 1fr; } .opto-photo-camera-actions .opto-photo-btn { flex: 1; } }
body.opto-ui-v2 .employee-photo-preview:has(img) { background: #0b1a2c !important; }
body.opto-ui-v2 .employee-photo-preview img { object-fit: contain; }

/* ============================================================
   26. Operator production cards: readable status box and details;
       Shift Leader schedule: total weight under the filler field
   ============================================================ */
body.opto-ui-v2 .schedule-card .schedule-meta { color: #dbe7f6 !important; }
body.opto-ui-v2 .schedule-card .schedule-meta div { color: #dbe7f6 !important; }
body.opto-ui-v2 .schedule-card .schedule-meta strong { color: #f1f6fd !important; }
body.opto-ui-v2 .schedule-card .schedule-meta small { color: #8fa6c2 !important; }

body.opto-ui-v2 .card-state { border-width: 1px !important; border-style: solid !important; }
body.opto-ui-v2 .card-state small { font-size: 11px !important; letter-spacing: .08em; opacity: .95; }
body.opto-ui-v2 .card-state strong { font-size: 22px !important; letter-spacing: .04em; }
body.opto-ui-v2 .card-state.delayed { background: rgba(239, 68, 68, .14) !important; border-color: rgba(239, 68, 68, .55) !important; }
body.opto-ui-v2 .schedule-card .card-state.delayed small, body.opto-ui-v2 .card-state.delayed small { color: #fecaca !important; }
body.opto-ui-v2 .schedule-card .card-state.delayed strong, body.opto-ui-v2 .card-state.delayed strong { color: #f87171 !important; }
body.opto-ui-v2 .card-state.upcoming { background: rgba(245, 158, 11, .13) !important; border-color: rgba(245, 158, 11, .5) !important; }
body.opto-ui-v2 .schedule-card .card-state.upcoming small, body.opto-ui-v2 .card-state.upcoming small { color: #fde68a !important; }
body.opto-ui-v2 .schedule-card .card-state.upcoming strong, body.opto-ui-v2 .card-state.upcoming strong { color: #fbbf24 !important; }
body.opto-ui-v2 .card-state.ready { background: rgba(34, 197, 94, .12) !important; border-color: rgba(34, 197, 94, .5) !important; }
body.opto-ui-v2 .schedule-card .card-state.ready small, body.opto-ui-v2 .card-state.ready small { color: #bbf7d0 !important; }
body.opto-ui-v2 .schedule-card .card-state.ready strong, body.opto-ui-v2 .card-state.ready strong { color: #4ade80 !important; }
body.opto-ui-v2 .card-state.active { background: rgba(59, 130, 246, .14) !important; border-color: rgba(59, 130, 246, .55) !important; }
body.opto-ui-v2 .schedule-card .card-state.active small, body.opto-ui-v2 .card-state.active small { color: #bfdbfe !important; }
body.opto-ui-v2 .schedule-card .card-state.active strong, body.opto-ui-v2 .card-state.active strong { color: #60a5fa !important; }
body.opto-ui-v2 .schedule-status.status-delayed { background: rgba(239, 68, 68, .18) !important; color: #fecaca !important; border: 1px solid rgba(239, 68, 68, .5); }
body.opto-ui-v2 .schedule-status.status-upcoming { background: rgba(245, 158, 11, .16) !important; color: #fde68a !important; border: 1px solid rgba(245, 158, 11, .45); }
body.opto-ui-v2 .schedule-status.status-ready { background: rgba(34, 197, 94, .16) !important; color: #bbf7d0 !important; border: 1px solid rgba(34, 197, 94, .45); }
body.opto-ui-v2 .schedule-status.status-active { background: rgba(59, 130, 246, .18) !important; color: #bfdbfe !important; border: 1px solid rgba(59, 130, 246, .45); }

body.opto-ui-v2 .opto-total-hint { color: #c3d2e5 !important; }
body.opto-ui-v2 .opto-req { color: #ef4444; font-weight: 900; margin-left: 2px; }
body.opto-ui-v2 .opto-barrel-note { margin: 4px 0 12px; color: #c3d2e5; font-size: 14px; display: flex; align-items: center; gap: 8px; }
body.opto-ui-v2 .opto-barrel-note strong { color: #f1f6fd; }
