:root {
    /* Color Palette - Premium Dark Mode */
    --bg-main: #0f172a;
    --sidebar-bg: rgba(30, 41, 59, 0.6);
    --card-bg: rgba(30, 41, 59, 0.5);
    --card-hover: rgba(51, 65, 85, 0.6);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-glow: rgba(59, 130, 246, 0.4);
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --border-color: rgba(255, 255, 255, 0.08);
    
    /* Layout & Utilities */
    --glass-blur: blur(16px);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

/* Remove 300ms tap delay on all interactive elements */
a, button, [role="button"], input, select, textarea, label {
    touch-action: manipulation;
}

html {
    height: -webkit-fill-available;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
    min-height: -webkit-fill-available;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: none;
    position: relative;
}

/* Background gradient orb effect */
body::before {
    content: '';
    position: fixed;
    top: -18vw;
    left: -12vw;
    width: 58vw;
    height: 58vw;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.28) 0%, rgba(59, 130, 246, 0.14) 28%, transparent 72%);
    z-index: -1;
    pointer-events: none;
}

body::after {
    content: '';
    position: fixed;
    bottom: -24vw;
    right: -18vw;
    width: 62vw;
    height: 62vw;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(16, 185, 129, 0.18) 0%, rgba(16, 185, 129, 0.08) 24%, transparent 70%);
    z-index: -1;
    pointer-events: none;
}

.app-container {
    display: flex;
    min-height: 100vh;
    min-height: 100dvh;
    min-height: -webkit-fill-available;
    width: 100%;
    max-width: 100%;
}

/* Sidebar Styling */
.sidebar {
    width: 280px;
    min-width: 280px;
    position: sticky;
    top: 0;
    align-self: flex-start;
    height: 100vh;
    height: 100dvh;
    background: var(--sidebar-bg);
    -webkit-backdrop-filter: var(--glass-blur);
    backdrop-filter: var(--glass-blur);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 24px 0;
    transition: var(--transition);
    overflow: hidden;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 24px;
    margin-bottom: 40px;
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--accent), #60a5fa);
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 12px var(--accent-glow);
}

.logo-container h2 {
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: -0.5px;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0 16px;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    text-decoration: none;
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    transition: var(--transition);
    font-weight: 500;
    font-size: 0.95rem;
}

.nav-item:hover {
    background: var(--card-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--accent);
    color: white;
    box-shadow: 0 4px 12px var(--accent-glow);
}

.nav-icon {
    font-size: 1.1rem;
}

.sidebar-footer {
    padding: 0 24px;
    margin-top: auto;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--card-bg);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.avatar {
    width: 36px;
    height: 36px;
    background: var(--accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 0.9rem;
    font-weight: 600;
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.switch-user-btn {
    width: 100%;
    margin-top: 12px;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 10px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    font-weight: 600;
}

.switch-user-btn:hover {
    background: var(--card-hover);
    color: var(--text-primary);
}

/* Main Content */
.main-content {
    flex: 1;
    min-width: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    background:
        linear-gradient(180deg, rgba(37, 99, 235, 0.16) 0%, rgba(15, 23, 42, 0) 220px),
        linear-gradient(180deg, rgba(30, 41, 59, 0.78), rgba(15, 23, 42, 0.94));
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 40px;
    background: transparent;
}

.topbar h1 {
    font-size: 1.75rem;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.topbar-actions {
    display: flex;
    gap: 16px;
    align-items: center;
}

.search-box input {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 10px 16px;
    border-radius: 20px;
    outline: none;
    transition: var(--transition);
    width: 250px;
}

.search-box input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.action-btn {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.action-btn:hover {
    background: var(--card-hover);
}

.view-container {
    flex: 1 1 auto;
    padding: 0 40px 40px 40px;
    /* Custom scrollbar */
    scrollbar-width: thin;
    scrollbar-color: var(--sidebar-bg) transparent;
}

.view-container::-webkit-scrollbar {
    width: 8px;
}
.view-container::-webkit-scrollbar-thumb {
    background-color: var(--sidebar-bg);
    border-radius: 10px;
}

.login-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.82);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 24px;
}

.login-card {
    width: min(560px, 100%);
    background: rgba(15, 23, 42, 0.96);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
    padding: 28px;
}

.login-card h2 {
    font-size: 1.7rem;
    margin-bottom: 10px;
}

.login-card p {
    color: var(--text-secondary);
    margin-bottom: 20px;
    line-height: 1.5;
}

.login-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.auth-step,
.auth-credentials {
    border: 1px solid var(--border-color);
    border-radius: 18px;
    padding: 18px;
    background: rgba(15, 23, 42, 0.45);
    margin-bottom: 16px;
}

.auth-credentials {
    opacity: 0.55;
    pointer-events: none;
}

.auth-credentials.enabled {
    opacity: 1;
    pointer-events: auto;
}

.auth-step.is-complete {
    border-color: rgba(16, 185, 129, 0.4);
}

.auth-step-header {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    margin-bottom: 14px;
}

.auth-step-header p,
.auth-help {
    margin: 4px 0 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.auth-step-index {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(59, 130, 246, 0.18);
    border: 1px solid rgba(59, 130, 246, 0.35);
    color: var(--text-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
}

.auth-ms-btn {
    width: 100%;
    justify-content: center;
    text-align: center;
}

.auth-sso-summary {
    display: none;
    margin-top: 14px;
    padding: 12px 14px;
    border-radius: 12px;
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.28);
}

.auth-sso-summary.visible {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.auth-sso-summary small {
    color: var(--text-secondary);
}

.auth-label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.auth-credentials input,
.auth-credentials select,
.users-form-grid input,
.users-form-grid select,
.users-inline-input {
    width: 100%;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 12px 14px;
    border-radius: var(--radius-md);
    outline: none;
    transition: var(--transition);
}

.auth-credentials input:focus,
.auth-credentials select:focus,
.users-form-grid input:focus,
.users-form-grid select:focus,
.users-inline-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.auth-help {
    border-top: 1px solid var(--border-color);
    padding-top: 14px;
}

.auth-placeholder {
    max-width: 520px;
    margin: 40px auto;
}

.users-page {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.users-directory-card,
.assigned-jobs-card,
.schedule-table-card {
    display: flex;
    flex-direction: column;
}

.users-directory-card {
    min-height: 420px;
}

.users-directory-header,
.assigned-jobs-header,
.schedule-table-header {
    gap: 12px;
    flex-wrap: wrap;
}

.assigned-jobs-titlebar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.responsive-search-input,
.responsive-control {
    width: 100%;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.9rem;
    padding: 8px 12px;
}

select.responsive-control {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
    cursor: pointer;
}

select.responsive-control option {
    background: #1e293b;
    color: #f8fafc;
}

.responsive-search-input {
    max-width: 220px;
}

.assigned-jobs-table,
.schedule-assign-table {
    width: 100%;
    border-collapse: collapse;
}

.assigned-jobs-table {
    min-width: 700px;
}

.schedule-page {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.schedule-filter-bar {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.schedule-filter-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
    align-items: end;
}

.schedule-filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.schedule-filter-group-date,
.schedule-filter-group-timeslot {
    min-width: 0;
}

.schedule-filter-label {
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.schedule-filter-label-inline {
    white-space: nowrap;
}

.schedule-date-trigger {
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 38px;
    min-width: 0;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-secondary,#94a3b8);
}

.schedule-bulk-actions {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}

.schedule-bulk-group {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.schedule-bulk-packer {
    min-width: 140px;
}

.schedule-bulk-btn,
.schedule-assign-visible-btn {
    white-space: nowrap;
    min-height: 38px;
}

.edit-ward-day {
    accent-color: var(--accent);
    width: 14px;
    height: 14px;
    cursor: pointer;
}

/* Ward Card List */
.ward-card-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ward-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 14px 18px;
}

.ward-card-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.76rem;
    color: var(--text-secondary);
    margin-bottom: 5px;
    letter-spacing: 0.01em;
}

.ward-meta-sep {
    opacity: 0.35;
}

.ward-card-title {
    font-size: 0.97rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.ward-card-controls {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.ward-run-group {
    display: flex;
    align-items: center;
    gap: 7px;
    white-space: nowrap;
}

.ward-run-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.ward-run-select {
    min-width: 72px;
    width: 72px;
    padding-inline: 12px 32px;
    font-weight: 600;
}

.ward-days-field {
    position: relative;
    min-width: 260px;
}

.ward-days-field[open] {
    z-index: 5;
}

.ward-days-trigger {
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    min-height: 38px;
    padding: 7px 12px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    cursor: pointer;
}

.ward-days-trigger::-webkit-details-marker {
    display: none;
}

.ward-days-summary {
    color: var(--text-primary);
    font-size: 0.82rem;
    text-align: right;
}

.ward-days-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    min-width: 220px;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: #1b2638;
    box-shadow: 0 18px 38px rgba(0, 0, 0, 0.35);
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 12px;
}

.ward-day-option {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    color: var(--text-primary);
    cursor: pointer;
    user-select: none;
}

.ward-day-option input {
    accent-color: var(--accent);
}

@media (max-width: 640px) {
    .ward-card-controls {
        flex-direction: column;
        align-items: flex-start;
    }
}

.schedule-assign-table {
    min-width: 1100px;
}

.users-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.users-form-actions {
    display: flex;
    align-items: end;
    height: 100%;
}

.users-inline-message {
    margin-top: 14px;
    font-size: 0.92rem;
}

.users-inline-message.success {
    color: var(--success);
}

.users-inline-message.error {
    color: #fca5a5;
}

.users-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 980px;
}

.users-table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}

.users-table th,
.users-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
}

.users-table th {
    position: sticky;
    top: 0;
    background: var(--card-bg);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.login-user-btn {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    text-align: left;
    cursor: pointer;
    transition: var(--transition);
    font-weight: 600;
}

.login-user-btn:hover,
.login-user-btn.active {
    border-color: var(--accent);
    background: rgba(59, 130, 246, 0.18);
    box-shadow: 0 0 0 1px var(--accent-glow);
}

.login-custom {
    display: none;
    margin-bottom: 18px;
}

.login-custom.visible {
    display: block;
}

.login-custom input {
    width: 100%;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 12px 14px;
    border-radius: var(--radius-md);
    outline: none;
    transition: var(--transition);
}

.login-custom input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.login-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.login-error {
    display: none;
    margin-bottom: 14px;
    color: #fca5a5;
    font-size: 0.9rem;
}

.login-error.visible {
    display: block;
}

@media (max-width: 720px) {
    .login-grid {
        grid-template-columns: 1fr;
    }

    .users-form-grid {
        grid-template-columns: 1fr;
    }
}

/* Common UI Components (Cards, Tables) */
.card {
    background: var(--card-bg);
    -webkit-backdrop-filter: var(--glass-blur);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.grid-layout {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-info .stat-value {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.stat-info .stat-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Table styling */
.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

th, td {
    padding: 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

td {
    font-size: 0.95rem;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* Status Badges */
.badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge.success { background: rgba(16, 185, 129, 0.2); color: var(--success); }
.badge.warning { background: rgba(245, 158, 11, 0.2); color: var(--warning); }
.badge.danger { background: rgba(239, 68, 68, 0.2); color: var(--danger); }
.badge.info { background: rgba(59, 130, 246, 0.2); color: var(--accent); }

/* Dashboard */
.dashboard-shell {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.dashboard-kpis {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
}

.dashboard-kpi {
    margin-bottom: 0;
    position: relative;
    overflow: hidden;
}

.dashboard-kpi::before {
    content: '';
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    border-radius: 999px;
}

.dashboard-kpi-info::before { background: var(--accent); }
.dashboard-kpi-warning::before { background: var(--warning); }
.dashboard-kpi-success::before { background: var(--success); }
.dashboard-kpi-danger::before { background: var(--danger); }

.dashboard-kpi-label {
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 10px;
}

.dashboard-kpi-value {
    font-size: 2.1rem;
    font-weight: 700;
    letter-spacing: -0.04em;
}

.dashboard-main-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
    gap: 24px;
}

.dashboard-panel {
    margin-bottom: 0;
}

.dashboard-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 6px;
}

.dashboard-type-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.dashboard-type-card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 18px;
    background: rgba(15, 23, 42, 0.42);
}

.dashboard-type-delivery {
    box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.18);
}

.dashboard-type-topup {
    box-shadow: inset 0 0 0 1px rgba(245, 158, 11, 0.18);
}

.dashboard-type-soil {
    box-shadow: inset 0 0 0 1px rgba(16, 185, 129, 0.18);
}

.dashboard-type-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}

.dashboard-type-head h4,
.dashboard-list-item h4,
.dashboard-activity-item h4 {
    font-size: 1rem;
    font-weight: 600;
}

.dashboard-metric-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
}

.dashboard-metric-row strong {
    color: var(--text-primary);
    font-size: 1rem;
}

.dashboard-list,
.dashboard-activity-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.dashboard-list-item,
.dashboard-activity-item,
.dashboard-loading-card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px 18px;
    background: rgba(15, 23, 42, 0.38);
}

.dashboard-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.dashboard-list-item p,
.dashboard-activity-item p,
.dashboard-empty {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
}

.dashboard-inline-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.dashboard-activity-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.dashboard-activity-time {
    color: var(--text-secondary);
    font-size: 0.82rem;
    white-space: nowrap;
}

/* Analytics */
.analytics-shell {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.analytics-hero,
.analytics-visual-card,
.analytics-panel {
    margin-bottom: 0;
}

.analytics-header {
    align-items: flex-start;
    gap: 16px;
}

.analytics-lookback-note {
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(59, 130, 246, 0.16);
    color: #bfdbfe;
    font-size: 0.82rem;
    font-weight: 600;
}

.analytics-filters {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 16px;
}

.analytics-filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.analytics-filter-group label {
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.analytics-visual-header {
    gap: 16px;
}

.metric-toggle {
    display: inline-flex;
    gap: 8px;
    padding: 6px;
    background: rgba(15, 23, 42, 0.55);
    border: 1px solid var(--border-color);
    border-radius: 999px;
}

.metric-toggle-btn {
    border: none;
    border-radius: 999px;
    background: transparent;
    color: var(--text-secondary);
    padding: 10px 16px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
}

.metric-toggle-btn.active {
    background: rgba(59, 130, 246, 0.2);
    color: var(--text-primary);
    box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.35);
}

.analytics-overlay-toggle {
    align-items: center;
    gap: 14px;
}

.metric-toggle-label {
    color: var(--text-primary);
    font-weight: 700;
    padding: 10px 12px;
}

.analytics-check-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-weight: 600;
    padding: 10px 12px;
    border-radius: 999px;
    cursor: pointer;
}

.analytics-check-toggle input {
    accent-color: var(--success);
}

.chart-container {
    position: relative;
    min-height: 460px;
    padding-top: 12px;
}

.analytics-visual-body {
    display: grid;
    grid-template-columns: minmax(0, 1.95fr) minmax(260px, 320px);
    gap: 20px;
    align-items: stretch;
}

.analytics-visual-main,
.analytics-visual-side {
    min-width: 0;
}

.analytics-visual-main {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.analytics-visual-side {
    display: flex;
    justify-content: flex-end;
    align-self: stretch;
}

.analytics-chart-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    margin-top: 18px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.analytics-chart-summary strong {
    color: var(--text-primary);
}

.analytics-table-card {
    width: min(100%, 360px);
    height: 460px;
    max-height: 460px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: rgba(15, 23, 42, 0.38);
}

.analytics-table-scroll {
    height: 100%;
    max-height: 460px;
    overflow: auto;
}

.analytics-summary-table {
    width: 100%;
    border-collapse: collapse;
}

.analytics-summary-table th,
.analytics-summary-table td {
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.analytics-summary-table th {
    text-transform: none;
    letter-spacing: 0;
    font-size: 0.86rem;
}

.analytics-summary-table tbody tr:first-child td {
    font-weight: 700;
}

.analytics-panel-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
    gap: 24px;
}

.analytics-recommendation-stack {
    display: grid;
    gap: 14px;
}

.recommendation-card,
.trend-anomaly {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: rgba(15, 23, 42, 0.45);
    padding: 18px;
}

.recommendation-card-increase {
    box-shadow: inset 0 0 0 1px rgba(245, 158, 11, 0.15);
}

.recommendation-card-decrease {
    box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.15);
}

.recommendation-card-head,
.analytics-panel-minihead {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.recommendation-card h4,
.trend-anomaly strong {
    font-size: 1rem;
    margin-bottom: 6px;
}

.recommendation-card p,
.trend-anomaly p,
.analytics-empty-state,
.analytics-zero-empty {
    color: var(--text-secondary);
    font-size: 0.92rem;
    line-height: 1.5;
}

.recommendation-delta {
    color: var(--text-secondary);
    font-size: 0.82rem;
}

.recommendation-metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 12px;
    color: var(--text-secondary);
    font-size: 0.84rem;
}

.analytics-trend-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.trend-anomaly-label {
    display: block;
    color: var(--text-secondary);
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 10px;
}

.analytics-zero-card {
    margin-top: 16px;
}

.analytics-zero-list {
    list-style: none;
    display: grid;
    gap: 10px;
    margin: 0;
    padding: 0;
}

.analytics-zero-list li {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
    font-size: 0.88rem;
}

.analytics-zero-list li:first-child {
    border-top: none;
    padding-top: 0;
}

.dashboard-empty {
    border: 1px dashed rgba(255, 255, 255, 0.14);
    border-radius: var(--radius-md);
    padding: 18px;
    text-align: center;
}

/* Loader */
.loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 16px;
    color: var(--text-secondary);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Animations */
.fade-in {
    animation: fadeIn 0.4s ease-out forwards;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Forms */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 20px; }
.form-card { max-width: 1200px; margin: 0 auto; }
.form-group { display: flex; flex-direction: column; gap: 8px; }
.cal-group { grid-column: 1 / -1; }

/* Inline calendar date picker */
.cal-picker { background: var(--card-bg); border: 1px solid var(--border-color); border-radius: var(--radius-sm); padding: 14px 16px; max-width: 300px; user-select: none; }
.cal-waiting { color: var(--text-secondary); text-align: center; padding: 16px 0; font-size: 0.9rem; }
.cal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-title { font-weight: 600; color: var(--text-primary); font-size: 1rem; }
.cal-nav { background: none; border: none; color: var(--text-primary); font-size: 1.5rem; cursor: pointer; padding: 2px 10px; border-radius: var(--radius-sm); line-height: 1; transition: var(--transition); }
.cal-nav:hover:not([disabled]) { background: var(--card-hover); }
.cal-nav[disabled] { opacity: 0.3; cursor: default; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal-dow { text-align: center; font-size: 0.72rem; font-weight: 600; color: var(--text-secondary); padding: 4px 0 6px; }
.cal-cell { text-align: center; font-size: 0.88rem; border-radius: 50%; cursor: default; transition: background 0.15s, color 0.15s; aspect-ratio: 1; display: flex; align-items: center; justify-content: center; }
.cal-empty { background: none; }
.cal-avail { color: var(--text-primary); cursor: pointer; }
.cal-avail:hover { background: var(--accent-glow); }
.cal-unavail { color: var(--text-secondary); text-decoration: line-through; opacity: 0.45; }
.cal-today { box-shadow: inset 0 0 0 1.5px var(--accent); }
.cal-selected { background: var(--accent) !important; color: #fff !important; font-weight: 700; text-decoration: none !important; opacity: 1 !important; }
.form-group label { font-size: 0.85rem; color: var(--text-secondary); font-weight: 500; }
.form-group input, .form-group select { background: var(--card-bg); border: 1px solid var(--border-color); color: var(--text-primary); padding: 10px 14px; border-radius: var(--radius-sm); font-family: inherit; font-size: 0.95rem; transition: var(--transition); }
.form-group input:focus, .form-group select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 2px var(--accent-glow); }
.form-group select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 20px; }
.form-group select option { background: var(--bg-main); color: white; }
.readonly-input { background: rgba(0,0,0,0.3) !important; color: var(--text-secondary) !important; cursor: not-allowed; border-color: transparent !important; }
.mt-4 { margin-top: 24px; auto-overflow: auto; }
.btn { padding: 10px 24px; border-radius: var(--radius-sm); border: none; cursor: pointer; font-weight: 600; transition: var(--transition); font-size: 0.95rem; }
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 4px 12px var(--accent-glow); }
.btn-secondary { background: transparent; border: 1px solid var(--border-color); color: var(--text-primary); }
.btn-secondary:hover { background: rgba(255,255,255,0.05); }
.form-actions { display: flex; justify-content: flex-end; gap: 16px; align-items: center; padding-top: 20px; border-top: 1px solid var(--border-color); }

.assigned-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}

.assigned-filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.assigned-filter-group-compact {
    min-width: 120px;
}

.assigned-filter-control {
    min-height: 38px;
}

.assigned-filter-action {
    display: flex;
    align-items: flex-end;
}

.assigned-filter-action .btn {
    min-height: 38px;
}
/* Input cells in tables */
.input-td input { width: 80px; padding: 8px 10px; text-align: center; background: rgba(255,255,255,0.1); border: 1px solid var(--border-color); color: white; border-radius: var(--radius-sm); font-family: inherit; transition: var(--transition); }
.input-td input:focus { border-color: var(--accent); background: rgba(255,255,255,0.15); outline: none; }
.input-td input[type=number]::-webkit-inner-spin-button,
.input-td input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

#calDate { background:transparent; border:none; padding:0; max-width:none; max-height:none; }
#calDate::backdrop { background:transparent; }
#soilCalDate { background:transparent; border:none; padding:0; max-width:none; max-height:none; }
#soilCalDate::backdrop { background:transparent; }

/* ════════════════════════════════════════════════════════════════
   TABLET RESPONSIVE — 768 px → 1366 px (iPad / Android tablets)
   ════════════════════════════════════════════════════════════════ */

/* ── Hamburger toggle (hidden on desktop) ── */
.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}

/* ── Touch-friendly targets for any pointer:coarse device ≤ 1366px ── */
@media (max-width: 1366px) and (pointer: coarse) {
    .btn {
        min-height: 44px;
        padding: 12px 24px;
        font-size: 1rem;
    }
    /* Android auto-zooms any input with font-size < 16px — force 16px */
    input, select, textarea,
    .form-group input,
    .form-group select,
    .table-filter,
    .search-box input {
        font-size: 16px !important;
        min-height: 44px;
        padding: 12px 14px;
    }
    .nav-item {
        min-height: 48px;
        padding: 14px 16px;
    }
    .input-td input {
        min-height: 40px;
        font-size: 16px !important;
    }
    .switch-user-btn {
        min-height: 44px;
        font-size: 1rem;
    }
    .login-user-btn {
        min-height: 52px;
        padding: 16px;
        font-size: 1rem;
    }
    .action-btn {
        width: 44px;
        height: 44px;
    }
    /* Prevent pull-to-refresh gesture */
    .view-container {
        overscroll-behavior-y: contain;
    }
}

/* ── Collapsed sidebar at ≤ 1080px ── */
@media (max-width: 1080px) {
    .sidebar-toggle { display: block; }

    .sidebar {
        width: 68px;
        padding: 16px 0;
        transition: width 0.25s ease, padding 0.25s ease;
        z-index: 100;
    }
    .sidebar.expanded {
        width: 280px;
        position: absolute;
        top: 0;
        left: 0;
        bottom: 0;
        box-shadow: 4px 0 24px rgba(0,0,0,0.4);
    }

    /* Collapsed state — hide text, center icons */
    .sidebar:not(.expanded) .logo-container {
        justify-content: center;
        padding: 0 8px;
        margin-bottom: 20px;
    }
    .sidebar:not(.expanded) .logo-container h2 { display: none; }
    .sidebar:not(.expanded) .nav-menu { padding: 0 8px; gap: 4px; }
    .sidebar:not(.expanded) .nav-item {
        justify-content: center;
        padding: 12px;
        font-size: 0;       /* hide text */
        gap: 0;
        border-radius: var(--radius-sm);
    }
    .sidebar:not(.expanded) .nav-icon { font-size: 1.35rem; }
    .sidebar:not(.expanded) .sidebar-footer { padding: 0 8px; }
    .sidebar:not(.expanded) .user-details { display: none; }
    .sidebar:not(.expanded) .user-info {
        justify-content: center;
        padding: 8px;
    }
    .sidebar:not(.expanded) .switch-user-btn {
        font-size: 0;
        padding: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .sidebar:not(.expanded) .switch-user-btn::after {
        content: '🔄';
        font-size: 1.1rem;
    }

    /* Main content adjustments */
    .topbar { padding: 16px 24px; }
    .topbar h1 { font-size: 1.35rem; }
    .view-container { padding: 0 24px 24px; }
    .search-box { flex: 1 1 220px; }
    .search-box input { width: 100%; }

    /* Form grids → 2 columns */
    .form-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }

    /* Cards slightly tighter */
    .card { padding: 18px; margin-bottom: 16px; }

    /* Dashboard stat grid → 2 columns */
    .grid-layout {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }

    .dashboard-kpis,
    .dashboard-type-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .dashboard-main-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .analytics-filters,
    .analytics-visual-body,
    .analytics-panel-grid,
    .analytics-trend-grid {
        grid-template-columns: 1fr;
    }

    /* Table cells tighter */
    th, td { padding: 12px 10px; }
    th { font-size: 0.78rem; }
    td { font-size: 0.9rem; }

    .users-directory-card,
    .assigned-jobs-card,
    .schedule-table-card {
        min-height: 0;
    }

    .responsive-search-input {
        max-width: 100%;
    }

    .assigned-jobs-titlebar,
    .schedule-table-header {
        align-items: stretch;
    }

    .schedule-filter-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .schedule-filter-group-date {
        grid-column: 1 / -1;
    }

    .schedule-table-scroll,
    .assigned-table-scroll,
    .users-table-scroll {
        overflow-x: auto;
        overflow-y: visible;
        -webkit-overflow-scrolling: touch;
    }
}

/* ── Portrait tablets / narrow tablets ≤ 820px ── */
@media (max-width: 820px) {
    .app-container {
        display: block;
        width: 100%;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: min(280px, 82vw);
        min-width: 0;
        height: 100vh;
        height: 100dvh;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        z-index: 220;
        box-shadow: none;
    }

    .sidebar.expanded {
        width: min(280px, 82vw);
        transform: translateX(0);
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        box-shadow: 4px 0 24px rgba(0,0,0,0.4);
    }

    .sidebar:not(.expanded) .logo-container,
    .sidebar:not(.expanded) .nav-menu,
    .sidebar:not(.expanded) .sidebar-footer {
        opacity: 0;
        pointer-events: none;
    }

    .main-content {
        width: 100%;
        min-height: 100vh;
        min-height: 100dvh;
    }

    .topbar {
        flex-wrap: wrap;
        gap: 12px;
        padding: 14px 16px;
    }
    .topbar h1 {
        font-size: 1.2rem;
        flex: 1;
        min-width: 0;
    }
    .topbar-actions {
        gap: 10px;
        width: 100%;
        flex-wrap: wrap;
    }
    .search-box {
        flex: 1 1 100%;
        order: 3;
    }
    .search-box input { width: 100%; font-size: 0.88rem; }
    .view-container { padding: 0 16px 16px; }

    /* Form grids → single column on very narrow tablets */
    .form-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .form-card {
        max-width: 100%;
    }

    .form-group input,
    .form-group select,
    .readonly-input,
    .responsive-control,
    .schedule-date-trigger {
        width: 100%;
        min-width: 0;
    }

    /* Dashboard grid → single column */
    .grid-layout {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .dashboard-kpis,
    .dashboard-type-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-list-item,
    .dashboard-activity-top {
        flex-direction: column;
        align-items: flex-start;
    }

    .dashboard-inline-actions {
        width: 100%;
        justify-content: flex-start;
    }

    /* Cards */
    .card { padding: 14px; }

    .assigned-jobs-titlebar,
    .users-directory-header,
    .schedule-table-header {
        flex-direction: column;
        align-items: stretch;
    }

    .assigned-filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .schedule-filter-grid,
    .users-form-grid {
        grid-template-columns: 1fr;
    }

    .schedule-bulk-actions,
    .schedule-bulk-group {
        flex-direction: column;
        align-items: stretch;
    }

    .assigned-filter-group,
    .assigned-filter-group-compact,
    .assigned-filter-action,
    .schedule-filter-group {
        width: 100%;
    }

    .analytics-header,
    .analytics-visual-header,
    .analytics-zero-list li {
        flex-direction: column;
        align-items: flex-start;
    }

    .metric-toggle {
        width: 100%;
    }

    .metric-toggle-btn {
        flex: 1;
    }

    .assigned-filter-action .btn,
    #schBtnAssignAll,
    #schBtnBulkAssign {
        width: 100%;
    }

    /* Login card narrower */
    .login-card { padding: 20px; }
    .login-grid {
        grid-template-columns: 1fr;
    }

    /* Photo grid tighter */
    .form-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
}

/* ── Schedule panel reflow for tablets ── */
@media (max-width: 1080px) {
    #schTableBody td,
    #schTableBody th,
    #assignedTableBody td,
    #assignedTableBody th,
    #schAssignTableBody td,
    #schAssignTableBody th {
        padding: 10px 8px !important;
        font-size: 0.85rem !important;
    }
}

/* ── Ensure dialogs/calendars don't clip on tablet ── */
@media (max-width: 1080px) {
    dialog {
        max-width: calc(100vw - 32px) !important;
    }
}

/* ── Schedule panel: make filter controls wrap better ── */
@media (max-width: 1080px) {
    #schSelLocation, #schSelRun, #schSelWard,
    #schSelType, #schSelPacker, #schDateTrigger {
        min-width: 0 !important;
        width: 100%;
    }
    #schSearch,
    #assignedSearch {
        width: 160px !important;
    }
    #schBtnAssign {
        width: 100%;
        min-height: 44px !important;
    }
}
@media (max-width: 820px) {
    #schSearch,
    #assignedSearch {
        width: 100% !important;
    }
}

/* ── Photo search responsive ── */
@media (max-width: 820px) {
    #photoSearch {
        width: 100% !important;
    }
}

/* ── Soil / Delivery form photo buttons: stack on narrow ── */
@media (max-width: 820px) {
    .form-card .form-actions {
        flex-direction: column;
        align-items: stretch;
    }
    .form-card .form-actions .btn {
        width: 100%;
        text-align: center;
    }
}

/* ── Tablet: prevent content overflow ── */
@media (max-width: 1080px) {
    /* Images never exceed their container */
    img {
        max-width: 100%;
        height: auto;
    }

    /* Form card doesn't overflow viewport */
    .form-card {
        max-width: 100%;
    }

    /* Users table: shrink min-width to fit tablet, wrap in scroll */
    .users-table {
        min-width: 700px;
    }

    /* Any table inside a scroll wrapper stays contained */
    .table-scroll,
    .users-table-scroll {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
    }

    /* Prevent any single element blowing past viewport width */
    input, select, textarea {
        max-width: 100%;
    }
}

/* ── Dashboard layout ── */
#dash-root {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding-bottom: 32px;
}

.dash-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}

.dash-kpi-card {
    padding: 20px 22px;
    margin-bottom: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.dash-ops-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
}

.dash-main-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 20px;
    align-items: start;
}

/* Tablet: collapse side-by-side to stacked */
@media (max-width: 1080px) {
    .dash-kpi-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }
    .dash-ops-grid {
        grid-template-columns: 1fr;
    }
    .dash-main-grid {
        grid-template-columns: 1fr;
    }
    #dash-activity {
        max-height: 400px;
        overflow-y: auto;
    }
}

/* Phone / narrow portrait */
@media (max-width: 820px) {
    .dash-kpi-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    .dash-kpi-card {
        padding: 14px 16px;
    }
}

/* ── Timesheet detail dialog ── */
#rosterDetailDialog {
    position: fixed;
    inset: 0;
    margin: auto;
    border: none;
    padding: 0;
    width: min(780px, calc(100vw - 32px));
    max-width: 780px;
    max-height: calc(100vh - 40px);
    overflow: hidden;
    background: var(--card-bg);
    color: var(--text-primary);
    box-shadow: 0 8px 40px rgba(0, 0, 0, .5);
    border-radius: 12px;
}

#rosterDetailDialog::backdrop {
    background:
        radial-gradient(circle at top, rgba(59, 130, 246, 0.16), transparent 38%),
        rgba(2, 6, 23, 0.82);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

/* ── Movement Log detail dialog ── */
#mov-detail-dialog {
    position: fixed;
    inset: 0;
    margin: auto;
    border: none;
    padding: 0;
    width: min(780px, calc(100vw - 32px));
    max-width: 780px;
    max-height: calc(100vh - 40px);
    overflow: visible;
    background: transparent;
}

#mov-detail-dialog::backdrop {
    background:
        radial-gradient(circle at top, rgba(59, 130, 246, 0.16), transparent 38%),
        rgba(2, 6, 23, 0.8);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

.mov-modal-shell {
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 24px;
    background:
        linear-gradient(180deg, rgba(15, 23, 42, 0.98), rgba(15, 23, 42, 0.94));
    box-shadow:
        0 28px 90px rgba(2, 6, 23, 0.68),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.mov-dialog-scroll {
    overflow-y: auto;
    max-height: calc(100vh - 40px);
}

.mov-dialog-topline {
    padding: 18px 28px 0;
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #93c5fd;
}

.mov-dialog-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 28px 22px;
}

.mov-dialog-title-block h2 {
    margin: 0;
    font-size: 1.65rem;
    line-height: 1.1;
    letter-spacing: -0.03em;
    color: var(--text-primary);
}

.mov-dialog-title-block p {
    margin-top: 8px;
    max-width: 460px;
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.5;
}

.mov-dialog-close {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border-radius: 50%;
    border: 1px solid rgba(148, 163, 184, 0.2);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.mov-dialog-close:hover {
    background: rgba(59, 130, 246, 0.16);
    border-color: rgba(96, 165, 250, 0.34);
    color: var(--text-primary);
    transform: translateY(-1px);
}

.mov-dialog-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    padding: 0 28px 24px;
}

.mov-summary-card {
    padding: 16px 18px;
    border-radius: 18px;
    background: rgba(30, 41, 59, 0.62);
    border: 1px solid rgba(148, 163, 184, 0.14);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.mov-summary-label {
    display: block;
    margin-bottom: 10px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.mov-summary-value {
    display: block;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.mov-dialog-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    padding: 24px 28px;
    background: rgba(15, 23, 42, 0.52);
    border-top: 1px solid rgba(148, 163, 184, 0.12);
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

.mov-meta-item {
    padding: 14px 16px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(148, 163, 184, 0.12);
}

.mov-meta-item label {
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.mov-meta-item span {
    font-size: 0.96rem;
    color: var(--text-primary);
    line-height: 1.4;
    word-break: break-word;
}

.mov-dialog-items-heading {
    padding: 20px 28px 10px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
}

.mov-items-table-wrap {
    padding: 0 28px 28px;
    overflow-x: auto;
}

.mov-proof-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 0 28px 24px;
}

.mov-photo-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid rgba(96, 165, 250, 0.24);
    background: rgba(30, 41, 59, 0.58);
    color: #bfdbfe;
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.mov-photo-link:hover {
    background: rgba(59, 130, 246, 0.16);
    border-color: rgba(96, 165, 250, 0.42);
    color: #eff6ff;
    transform: translateY(-1px);
}

.mov-proof-empty {
    width: 100%;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px dashed rgba(148, 163, 184, 0.22);
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.02);
}

.mov-proof-loading {
    width: 100%;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px dashed rgba(96, 165, 250, 0.22);
    color: #bfdbfe;
    background: rgba(59, 130, 246, 0.05);
}

.mov-photo-viewer[hidden] {
    display: none;
}

.mov-photo-viewer {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.mov-photo-viewer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(2, 6, 23, 0.84);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
}

.mov-photo-viewer-card {
    position: relative;
    z-index: 1;
    width: min(820px, calc(100vw - 48px));
    max-height: calc(100vh - 80px);
    border-radius: 22px;
    overflow: hidden;
    border: 1px solid rgba(148, 163, 184, 0.18);
    background: rgba(15, 23, 42, 0.98);
    box-shadow: 0 24px 80px rgba(2, 6, 23, 0.6);
}

.mov-photo-viewer-card img {
    display: block;
    width: 100%;
    height: auto;
    max-height: calc(100vh - 80px);
    object-fit: contain;
    background: #020617;
}

.mov-photo-viewer-close {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 2;
    width: 42px;
    height: 42px;
    border: 1px solid rgba(148, 163, 184, 0.24);
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.7);
    color: #f8fafc;
    font-size: 1.15rem;
    cursor: pointer;
}

.mov-items-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    min-width: 560px;
    overflow: hidden;
    border-radius: 18px;
    border: 1px solid rgba(148, 163, 184, 0.12);
    background: rgba(15, 23, 42, 0.6);
}

.mov-items-table th {
    padding: 12px 14px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
    background: rgba(30, 41, 59, 0.72);
    white-space: nowrap;
}

.mov-items-table th:not(:first-child) { text-align: right; }

.mov-items-table td {
    padding: 12px 14px;
    font-size: 0.9rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
    color: var(--text-primary);
}

.mov-items-table td:not(:first-child) {
    text-align: right;
    color: #cbd5e1;
    font-variant-numeric: tabular-nums;
}

.mov-items-table tbody tr:last-child td { border-bottom: none; }

.mov-items-table tbody tr:hover {
    background: rgba(59, 130, 246, 0.08);
}

@media (max-width: 820px) {
    #mov-detail-dialog {
        width: min(100vw - 20px, 780px);
        max-height: calc(100vh - 20px);
    }

    .mov-dialog-header,
    .mov-dialog-summary,
    .mov-dialog-meta,
    .mov-proof-wrap,
    .mov-items-table-wrap,
    .mov-dialog-items-heading,
    .mov-dialog-topline {
        padding-left: 18px;
        padding-right: 18px;
    }

    .mov-dialog-header {
        padding-top: 10px;
        padding-bottom: 18px;
    }

    .mov-dialog-summary,
    .mov-dialog-meta {
        grid-template-columns: 1fr;
    }
}

/* ---- Soil Pickup Time Slot Selector ---- */
.sch-timeslot-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 4px;
}

.sch-timeslot-btn {
    padding: 8px 14px;
    border-radius: 8px;
    border: 2px solid var(--border-color);
    background: var(--input-bg, #1e293b);
    color: var(--text-primary);
    font-size: .88rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
    white-space: nowrap;
}

.sch-timeslot-btn:hover {
    border-color: var(--primary, var(--accent));
    background: rgba(99, 102, 241, 0.12);
}

.sch-timeslot-btn.active {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
}

@media (max-width: 820px) {
    .sch-timeslot-group {
        flex-direction: column;
    }
    .sch-timeslot-btn {
        width: 100%;
        text-align: center;
        min-height: 44px;
    }
}

/* ── Landing / Entry Page ─────────────────────────────────────────── */

.entry-page {
    min-height: 100vh;
    margin: 0;
    background:
        radial-gradient(circle at top left, rgba(56, 189, 248, 0.22), transparent 30%),
        linear-gradient(180deg, #0f172a 0%, #111827 100%);
    color: #e5eefc;
    font-family: 'Inter', sans-serif;
}

.entry-shell {
    max-width: 720px;
    margin: 0 auto;
    padding: 4rem 1.5rem;
}

.entry-hero {
    text-align: center;
    margin-bottom: 3rem;
}

.entry-kicker {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #94a3b8;
    margin-bottom: 0.5rem;
}

.entry-hero h1 {
    font-size: 2rem;
    font-weight: 700;
    margin: 0 0 0.75rem;
}

.entry-copy {
    color: #94a3b8;
    font-size: 1rem;
    line-height: 1.5;
}

.entry-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.entry-card {
    display: block;
    padding: 2rem 1.5rem;
    background: rgba(30, 41, 59, 0.7);
    border: 1px solid rgba(148, 163, 184, 0.15);
    border-radius: 1rem;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.2s, transform 0.2s;
}

.entry-card:hover {
    border-color: rgba(56, 189, 248, 0.5);
    transform: translateY(-2px);
}

.entry-card h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0 0 0.5rem;
}

.entry-card p {
    font-size: 0.9rem;
    color: #94a3b8;
    margin: 0;
    line-height: 1.4;
}

@media (max-width: 540px) {
    .entry-grid {
        grid-template-columns: 1fr;
    }
}

/* ── Roster Weekly Grid ─────────────────────────────────────────────── */

.roster-grid-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.roster-grid-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: .88rem;
    min-width: 700px;
}

.roster-grid-table th,
.roster-grid-table td {
    padding: 10px 8px;
    border-bottom: 1px solid rgba(255, 255, 255, .12);
    border-right: 1px solid rgba(255, 255, 255, .06);
    white-space: nowrap;
    color: var(--text-primary);
}

.roster-grid-table th:last-child,
.roster-grid-table td:last-child {
    border-right: none;
}

.roster-grid-table thead th {
    position: sticky;
    top: 0;
    background: #1e293b;
    z-index: 2;
    font-size: .8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #cbd5e1;
    padding: 12px 8px;
    border-bottom: 2px solid rgba(99, 102, 241, .4);
}

.roster-staff-col {
    position: sticky;
    left: 0;
    background: #1e293b;
    z-index: 3;
    font-weight: 600;
    min-width: 120px;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #e2e8f0;
}

tbody .roster-staff-col {
    background: rgba(30, 41, 59, .95);
}

thead .roster-staff-col {
    z-index: 4;
}

.roster-weekend-col {
    background: rgba(99, 102, 241, .06);
}

tbody tr:hover td {
    background: rgba(255, 255, 255, .04);
}

tbody tr:hover .roster-staff-col {
    background: rgba(30, 41, 59, .98);
}

.roster-cell {
    transition: background .15s;
    cursor: pointer;
    text-align: center;
}

.roster-cell:hover {
    background: rgba(99, 102, 241, .15) !important;
}

.roster-cell-off {
    color: #334155;
}

.roster-add-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1.5px dashed #334155;
    font-size: 1.1rem;
    font-weight: 300;
    color: #475569;
    transition: all .2s;
}

.roster-cell-off:hover {
    background: rgba(99, 102, 241, .1) !important;
}

.roster-cell-off:hover .roster-add-icon {
    border-color: #6366f1;
    color: #818cf8;
    background: rgba(99, 102, 241, .12);
}

/* Roster shift edit/create dialog */
dialog.roster-shift-dialog {
    border: none;
    border-radius: 14px;
    padding: 28px;
    min-width: 380px;
    max-width: 440px;
    background: #1e293b;
    color: #f8fafc;
    box-shadow: 0 12px 48px rgba(0, 0, 0, .5);
    /* Force center — override UA default positioning */
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    margin: 0;
}

dialog.roster-shift-dialog::backdrop {
    background: rgba(0, 0, 0, .6);
    backdrop-filter: blur(4px);
}

@media (max-width: 640px) {
    .roster-grid-table {
        font-size: .78rem;
    }
    .roster-grid-table th,
    .roster-grid-table td {
        padding: 7px 4px;
    }
    .roster-staff-col {
        min-width: 90px;
    }
}
