/* ==========================================================================
   SHEET TOOL CRM — Design System
   Aesthetic: "Midnight Teal" — Professional, distinctive, easy on the eyes
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
    /* ── Color Palette ── */
    --primary: #0d9488;
    --primary-hover: #0f766e;
    --primary-light: #ccfbf1;
    --primary-glow: rgba(13, 148, 136, 0.15);

    --success: #059669;
    --success-light: #d1fae5;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --warning: #d97706;
    --warning-light: #fef3c7;

    --dark: #0f172a;
    --sidebar-bg: #0f172a;
    --sidebar-hover: #1e293b;
    --sidebar-active: #0d9488;

    --bg: #f0f4f8;
    --bg-card: #ffffff;
    --text-main: #334155;
    --text-muted: #64748b;
    --text-heading: #0f172a;

    --border: #e2e8f0;
    --border-light: #f1f5f9;

    /* ── Shadows ── */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 6px 16px -4px rgba(0, 0, 0, 0.1), 0 2px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 12px 28px -6px rgba(0, 0, 0, 0.12), 0 4px 8px -2px rgba(0, 0, 0, 0.06);
    --shadow-primary: 0 4px 14px rgba(13, 148, 136, 0.25);

    /* ── Layout ── */
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --sidebar-width: 260px;
    --topbar-height: 64px;

    /* ── Transitions ── */
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset ── */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg);
    color: var(--text-main);
    margin: 0;
    display: flex;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.6;
}

/* ── Typography ── */
h1, h2, h3, h4, h5, h6 {
    color: var(--text-heading);
    margin-top: 0;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.3;
}

h1 { font-size: 1.5rem; margin-bottom: 0.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.1rem; }

/* ── Selection ── */
::selection {
    background: var(--primary-light);
    color: var(--primary-hover);
}

/* ==========================================================================
   SIDEBAR
   ========================================================================== */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #0f172a 0%, #162032 50%, #1a2740 100%);
    color: white;
    height: 100vh;
    position: fixed;
    padding: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar h2 {
    color: white;
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    margin: 0;
    padding: 24px 24px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Teal accent bar at the top of sidebar */
.sidebar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), #2dd4bf);
}

.sidebar-nav {
    padding: 12px 12px;
    flex: 1;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #94a3b8;
    text-decoration: none;
    padding: 11px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 4px;
    transition: all var(--transition);
    position: relative;
}

.sidebar-nav a:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #e2e8f0;
}

.sidebar-nav a.active {
    background: var(--primary);
    color: white;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(13, 148, 136, 0.3);
}

.sidebar-nav a.active i {
    color: white;
}

.sidebar-nav i {
    font-size: 1.2rem;
    width: 22px;
    text-align: center;
}

.sidebar-spacer {
    flex-grow: 1;
}

/* ==========================================================================
   MAIN CONTENT
   ========================================================================== */
.main-content {
    margin-left: var(--sidebar-width);
    padding: calc(var(--topbar-height) + 28px) 32px 32px 32px;
    width: calc(100% - var(--sidebar-width));
    box-sizing: border-box;
    min-height: 100vh;
}

/* ==========================================================================
   TOPBAR
   ========================================================================== */
.topbar {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    height: var(--topbar-height);
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 0 32px;
    z-index: 50;
    border-bottom: 1px solid var(--border);
}

/* Profile Dropdown */
.profile-dropdown {
    position: relative;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
}

.profile-dropdown:hover {
    background: var(--border-light);
}

.profile-avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary), #2dd4bf);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1rem;
    font-weight: 700;
}

.profile-info {
    display: flex;
    flex-direction: column;
}

.profile-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-heading);
    line-height: 1.3;
}

.profile-role {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: white;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-sm);
    min-width: 160px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: all var(--transition);
    z-index: 100;
    overflow: hidden;
}

.profile-dropdown:hover .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-menu::before {
    content: '';
    position: absolute;
    top: -6px;
    right: 18px;
    width: 10px;
    height: 10px;
    background: white;
    border-top: 1px solid var(--border);
    border-left: 1px solid var(--border);
    transform: rotate(45deg);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    color: var(--text-main);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    transition: all var(--transition);
}

.dropdown-item:hover {
    background: var(--border-light);
    color: var(--primary);
}

.dropdown-item.text-danger {
    color: var(--danger);
}

.dropdown-item.text-danger:hover {
    background: var(--danger-light);
}

/* ==========================================================================
   CARDS
   ========================================================================== */
.card {
    background: var(--bg-card);
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
    border: 1px solid var(--border);
    transition: box-shadow var(--transition), transform var(--transition);
    animation: cardFadeIn 0.4s ease both;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

@keyframes cardFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Staggered card animations */
.card:nth-child(1) { animation-delay: 0s; }
.card:nth-child(2) { animation-delay: 0.06s; }
.card:nth-child(3) { animation-delay: 0.12s; }
.card:nth-child(4) { animation-delay: 0.18s; }
.card:nth-child(5) { animation-delay: 0.24s; }

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.card-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
}

/* ==========================================================================
   FORMS & INPUTS
   ========================================================================== */
.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 0.9rem;
    font-weight: 500;
    box-sizing: border-box;
    transition: all var(--transition);
    color: var(--text-main);
    background: white;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-control::placeholder {
    color: #94a3b8;
}

label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* ==========================================================================
   BUTTONS
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.88rem;
    transition: all var(--transition);
    font-family: 'Plus Jakarta Sans', sans-serif;
    text-decoration: none;
    position: relative;
    overflow: hidden;
    letter-spacing: 0.01em;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: var(--shadow-primary);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #047857;
    box-shadow: 0 4px 14px rgba(5, 150, 105, 0.25);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #b91c1c;
    box-shadow: 0 4px 14px rgba(220, 38, 38, 0.25);
}

.btn-secondary {
    background: white;
    border: 1.5px solid var(--border);
    color: var(--text-main);
}

.btn-secondary:hover {
    background: var(--border-light);
    border-color: #cbd5e1;
}

.btn-warning {
    background: var(--warning);
    color: white;
}

.btn-warning:hover {
    background: #b45309;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.8rem;
}

.btn-block {
    width: 100%;
    padding: 13px;
    font-size: 0.95rem;
    font-weight: 700;
}

/* Outline variant — for pagination, secondary actions */
.btn-outline {
    background: white;
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 5px 12px;
    font-size: 0.78rem;
}

.btn-outline:hover {
    background: var(--border-light);
    border-color: #cbd5e1;
}

.btn-outline.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.btn-outline:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text-main);
    border: 1px solid var(--border);
    transition: all var(--transition);
    cursor: pointer;
    font-size: 1.05rem;
}

.btn-icon:hover {
    background: var(--primary-light);
    color: var(--primary);
    border-color: var(--primary);
    transform: scale(1.08);
}

.btn-icon.danger {
    color: var(--text-main);
}

.btn-icon.danger:hover {
    background: var(--danger-light);
    color: var(--danger);
    border-color: var(--danger);
}

/* Loading spinner inside buttons */
.btn.loading {
    pointer-events: none;
    opacity: 0.75;
}

.btn.loading::after {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: btnSpin 0.6s linear infinite;
    margin-left: 6px;
}

@keyframes btnSpin {
    to { transform: rotate(360deg); }
}

/* ==========================================================================
   TABS
   ========================================================================== */
.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid var(--border);
    margin-bottom: 24px;
}

.tab {
    padding: 10px 18px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all var(--transition);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.tab:hover {
    color: var(--primary);
    background: var(--primary-glow);
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: var(--primary-glow);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   MODALS
   ========================================================================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.modal-content {
    background: white;
    padding: 32px;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    animation: modalSlideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalSlideUp {
    from { opacity: 0; transform: scale(0.92) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

/* ==========================================================================
   TABLES
   ========================================================================== */
.table-responsive {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    padding: 12px 16px;
    background: var(--border-light);
    border-bottom: 2px solid var(--border);
    color: var(--text-muted);
    font-size: 0.72rem;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.06em;
}

td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 0.88rem;
    vertical-align: middle;
}

tbody tr {
    transition: background var(--transition);
}

tbody tr:hover {
    background-color: var(--border-light);
}

/* Active row highlight — for the row currently being edited */
tbody tr:focus-within {
    background-color: var(--primary-glow);
    outline: none;
}

/* ==========================================================================
   BADGES
   ========================================================================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 9999px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.badge-pending {
    background: var(--warning-light);
    color: var(--warning);
}

.badge-done {
    background: var(--success-light);
    color: var(--success);
}

.badge-error {
    background: var(--danger-light);
    color: var(--danger);
}

.badge-default {
    background: var(--border-light);
    color: #475569;
}

/* ==========================================================================
   STAT CARDS
   ========================================================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stats-grid.cols-5 {
    grid-template-columns: repeat(5, 1fr);
}

@media (max-width: 1100px) {
    .stats-grid.cols-5 {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .stats-grid.cols-5 {
        grid-template-columns: 1fr;
    }
}

.stat-card {
    background: white;
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Colored top accent for stat cards — uses --stat-accent custom property if set */
.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--stat-accent, var(--primary));
}

.stat-card.success { --stat-accent: var(--success); }
.stat-card.danger { --stat-accent: var(--danger); }
.stat-card.warning { --stat-accent: var(--warning); }

.stat-title {
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-heading);
    letter-spacing: -0.03em;
}

/* ==========================================================================
   DASHBOARD HEADER
   ========================================================================== */
.dashboard-header {
    background: white;
    padding: 20px 28px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border: 1px solid var(--border);
    animation: cardFadeIn 0.3s ease both;
}

/* ==========================================================================
   WORKER DATA PAGE — IP Input
   ========================================================================== */
.ip-input {
    width: 100%;
    min-width: 140px;
    padding: 9px 12px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    box-sizing: border-box;
    font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-heading);
    transition: all var(--transition);
    letter-spacing: 0.02em;
}

.ip-input:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px var(--primary-glow);
    background: #f0fdfa;
}

.ip-input::placeholder {
    color: #cbd5e1;
    font-weight: 400;
}

/* ==========================================================================
   WORKER ASSIGNMENT GRID
   ========================================================================== */
.worker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    padding: 10px 0;
}

.worker-assign-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 15px;
    background: var(--border-light);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition);
    user-select: none;
}

.worker-assign-card:hover {
    border-color: var(--primary);
    background: var(--primary-glow);
}

.worker-assign-card:has(input:checked) {
    background: var(--primary-light);
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary);
}

.worker-assign-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.worker-avatar {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary), #2dd4bf);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
}

.worker-name {
    font-weight: 600;
    color: var(--text-heading);
    font-size: 0.92rem;
}

.custom-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary);
}

/* ==========================================================================
   SUBMIT BUTTON (worker data page)
   ========================================================================== */
.submit-btn {
    background: var(--success);
    color: white;
    border: none;
    padding: 14px 40px;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 0.95rem;
    font-family: 'Plus Jakarta Sans', sans-serif;
    cursor: pointer;
    transition: all var(--transition);
    display: block;
    margin: 24px auto 0;
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(5, 150, 105, 0.3);
    background: #047857;
}

.submit-btn:active {
    transform: translateY(0);
}

/* ==========================================================================
   TOGGLE SWITCH
   ========================================================================== */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    margin: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #cbd5e1;
    transition: var(--transition-slow);
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: var(--transition-slow);
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

input:checked + .slider {
    background-color: var(--danger);
}

input:focus + .slider {
    box-shadow: 0 0 1px var(--danger);
}

input:checked + .slider:before {
    transform: translateX(20px);
}

/* ==========================================================================
   TOAST NOTIFICATIONS
   ========================================================================== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 600;
    font-family: 'Plus Jakarta Sans', sans-serif;
    color: white;
    box-shadow: var(--shadow-lg);
    animation: toastSlideIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    cursor: pointer;
    max-width: 360px;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }
.toast.info { background: var(--primary); }

.toast.leaving {
    animation: toastSlideOut 0.25s ease forwards;
}

@keyframes toastSlideIn {
    from { opacity: 0; transform: translateX(100px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes toastSlideOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(100px); }
}

/* ==========================================================================
   SKELETON LOADING
   ========================================================================== */
.skeleton {
    background: linear-gradient(90deg, var(--border-light) 25%, #e2e8f0 50%, var(--border-light) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ==========================================================================
   EMPTY STATES
   ========================================================================== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 3rem;
    color: #cbd5e1;
    margin-bottom: 16px;
    display: block;
}

.empty-state h3 {
    color: var(--text-heading);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 0.9rem;
    max-width: 360px;
    margin: 0 auto;
    line-height: 1.6;
}

/* ==========================================================================
   FOCUS-VISIBLE (Keyboard Accessibility)
   ========================================================================== */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* ==========================================================================
   UTILITY CLASSES
   ========================================================================== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-primary { color: var(--primary) !important; }
.text-muted { color: var(--text-muted) !important; }

.bg-success-light { background: var(--success-light) !important; }
.bg-danger-light { background: var(--danger-light) !important; }
.bg-warning-light { background: var(--warning-light) !important; }

/* ==========================================================================
   SCROLLBAR
   ========================================================================== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ── Report cards (dashboard) ── */
.report-card {
    padding: 0;
    overflow: hidden;
}

/* ==========================================================================
   TABLET RESPONSIVENESS (≤1024px)
   ========================================================================== */
@media (max-width: 1024px) {
    /* Podium cards shrink gracefully */
    .podium-container {
        gap: 12px;
    }

    .podium-card {
        width: 160px;
        padding: 24px 14px 16px;
    }

    .podium-score {
        font-size: 2.2rem;
    }

    /* Report grids stack on tablets */
    .reports-grid {
        grid-template-columns: 1fr !important;
    }
}

/* ==========================================================================
   MOBILE RESPONSIVENESS (≤768px)
   ========================================================================== */
@media (max-width: 768px) {
    /* ── Prevent horizontal overflow on mobile ── */
    html, body {
        overflow-x: hidden;
        max-width: 100vw;
    }

    /* ── Sidebar: off-canvas drawer ── */
    .sidebar {
        transform: translateX(-100%);
        z-index: 1000;
        transition: transform var(--transition-slow);
        box-shadow: var(--shadow-lg);
        position: fixed;
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    body.sidebar-open::after {
        content: '';
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 0;
        background: rgba(15, 23, 42, 0.5);
        z-index: 999;
        backdrop-filter: blur(3px);
        -webkit-backdrop-filter: blur(3px);
    }

    /* ── Main layout ── */
    .main-content {
        margin-left: 0;
        width: 100%;
        max-width: 100vw;
        padding: calc(var(--topbar-height) + 16px) 12px 24px 12px;
        overflow-x: hidden;
        min-width: 0;
    }

    .topbar {
        left: 0;
        padding: 0 12px;
        justify-content: space-between;
    }

    .mobile-menu-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
        background: transparent;
        border: none;
        color: var(--text-heading);
        font-size: 1.4rem;
        cursor: pointer;
        padding: 8px;
        border-radius: var(--radius-sm);
        transition: background var(--transition);
    }

    .mobile-menu-toggle:hover {
        background: var(--border-light);
    }

    /* ── Dashboard header: stack vertically ── */
    .dashboard-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 12px;
        padding: 16px;
    }

    .dashboard-header form {
        width: 100%;
    }

    .dashboard-header select.form-control {
        width: 100% !important;
        min-width: unset !important;
    }

    /* ── Stats & grids: single column ── */
    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 12px;
    }

    /* ── Reports grid (inline-styled 2-col → 1-col) ── */
    .reports-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    /* ── Cards: prevent overflow on mobile ── */
    .card,
    .reports-grid .card {
        max-width: 100%;
        overflow-x: auto;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    /* ── Report cards: allow visible overflow on mobile ── */
    .report-card {
        overflow: visible;
    }

    /* ── Stat card: smaller on mobile ── */
    .stat-card {
        padding: 16px;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    /* ── Card internal flex layouts: stack vertically ── */
    .card-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 10px;
    }

    .card-header > div {
        width: 100%;
    }

    .card-header > div[style*="display:flex"],
    .card-header > div[style*="display: flex"] {
        flex-wrap: wrap;
    }

    /* ── Toolbars & button groups: wrap ── */
    .card > div[style*="justify-content: space-between"],
    .card > div[style*="justify-content:space-between"] {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 10px !important;
    }

    .card > div[style*="display:flex"] > div[style*="display:flex"],
    .card > div[style*="display: flex"] > div[style*="display:flex"] {
        flex-wrap: wrap;
    }

    /* ── Filter forms: stack all inputs ── */
    #filterForm,
    form[style*="display: flex"][style*="gap"] {
        flex-direction: column !important;
        align-items: stretch !important;
    }

    #filterForm > div,
    form[style*="display: flex"][style*="gap"] > div {
        flex: 1 1 100% !important;
        width: 100% !important;
    }

    #filterForm .form-control,
    form[style*="display: flex"][style*="gap"] .form-control {
        width: 100% !important;
        min-width: unset !important;
    }

    /* ── Tabs: scrollable row on mobile ── */
    .tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
    }

    .tab {
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* ── Tables: horizontal scroll ── */
    .table-responsive,
    [style*="overflow-x: auto"],
    [style*="overflow-x:auto"] {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Force data tables (in scroll wrappers) to scroll horizontally */
    .table-responsive table,
    .tab-content table,
    [style*="overflow-x: auto"] table,
    [style*="overflow-x:auto"] table {
        min-width: 600px;
    }

    th, td {
        padding: 10px 12px;
        font-size: 0.82rem;
    }

    /* ── Modal: full-width on mobile ── */
    .modal-content {
        margin: 16px;
        max-width: calc(100vw - 32px);
        padding: 24px 20px;
        max-height: 90vh;
        overflow-y: auto;
    }

    /* ── Podium: stack vertically on mobile ── */
    .podium-container {
        flex-direction: column;
        align-items: center;
        gap: 30px;
        margin: 20px 0 30px;
    }

    .podium-card {
        width: 100%;
        max-width: 280px;
    }

    .podium-1 {
        transform: scale(1.05);
        order: -1;
    }

    .podium-1:hover {
        transform: scale(1.05) translateY(-5px);
    }

    .podium-score {
        font-size: 2.5rem;
    }

    /* ── Bulk actions toolbar: wrap ── */
    #bulkActions {
        flex-wrap: wrap !important;
        gap: 8px !important;
    }

    #bulkActions .btn {
        flex: 1 1 auto;
        min-width: 0;
        font-size: 0.78rem;
        padding: 6px 10px;
    }

    /* ── Pagination: stack on mobile ── */
    [style*="justify-content:space-between"][style*="margin-top"],
    [style*="justify-content: space-between"][style*="margin-top"] {
        flex-direction: column !important;
        gap: 10px !important;
        align-items: stretch !important;
    }

    /* ── Toast notifications: full width ── */
    .toast-container {
        left: 12px;
        right: 12px;
    }

    .toast {
        max-width: 100%;
    }

    /* ── Typography: slightly smaller on mobile ── */
    h1 {
        font-size: 1.25rem;
    }

    /* ── Worker data page: allow IP input to shrink ── */
    .ip-input {
        min-width: 110px;
        font-size: 0.85rem;
        padding: 7px 10px;
    }

    /* ── Profile dropdown: hide name on small screens ── */
    .profile-info .profile-name {
        max-width: 80px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* ── View toggle buttons: wrap ── */
    .view-toggle-btn {
        font-size: 0.78rem;
        padding: 0.35rem 0.8rem;
    }

    /* ── Login tab buttons: smaller ── */
    .login-tab-btn {
        padding: 0.4rem 1rem;
        font-size: 0.8rem;
    }
}

/* ==========================================================================
   SMALL MOBILE (≤480px)
   ========================================================================== */
@media (max-width: 480px) {
    .main-content {
        padding: calc(var(--topbar-height) + 12px) 8px 20px 8px;
    }

    .card {
        padding: 16px;
        border-radius: var(--radius-sm);
    }

    .stat-card {
        padding: 14px;
    }

    .stat-value {
        font-size: 1.3rem;
    }

    .stat-title {
        font-size: 0.7rem;
    }

    .btn {
        font-size: 0.82rem;
        padding: 8px 14px;
    }

    .btn-sm {
        font-size: 0.75rem;
        padding: 5px 10px;
    }

    .profile-info {
        display: none;
    }
}

/* ==========================================================================
   CONFIRM DIALOG (replaces native confirm())
   ========================================================================== */
.confirm-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.5);
    z-index: 10001;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    animation: fadeIn 0.2s ease;
}

.confirm-dialog {
    background: white;
    border-radius: var(--radius-lg);
    padding: 28px 32px;
    max-width: 440px;
    width: 90%;
    box-shadow: var(--shadow-lg);
    animation: modalSlideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.confirm-dialog h3 {
    margin: 0 0 12px;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.confirm-dialog p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0 0 24px;
    line-height: 1.6;
}

.confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ==========================================================================
   UTILITY CLASSES (replace common inline styles)
   ========================================================================== */
.page-title {
    margin: 0;
    font-size: 1.5rem;
}

.breadcrumb-text {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.toolbar {
    margin-bottom: 20px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.form-group {
    margin-bottom: 15px;
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.nowrap {
    white-space: nowrap;
}

.col-checkbox {
    width: 40px;
}

.font-mono {
    font-family: monospace;
    font-size: 0.85rem;
    color: #4b5563;
}

.status-dot {
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.82rem;
}

.status-dot.active {
    color: var(--success);
}

.status-dot.inactive {
    color: var(--danger);
}

.ip-count-badge {
    background: #fee2e2;
    color: #dc2626;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: bold;
}

/* ==========================================================================
   SIDEBAR SECTION LABELS (#9 — visual grouping)
   ========================================================================== */
.sidebar-section-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(148, 163, 184, 0.5);
    padding: 16px 16px 6px;
    margin-top: 4px;
}

.sidebar-section-label:first-child {
    margin-top: 0;
    padding-top: 8px;
}

/* ==========================================================================
   SIDEBAR ACTIVE INDICATOR (#12 — sliding animation)
   ========================================================================== */
.sidebar-nav a.active {
    position: relative;
}

.sidebar-nav a.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 4px;
    bottom: 4px;
    width: 3px;
    background: white;
    border-radius: 0 3px 3px 0;
    animation: slideIndicator 0.3s ease;
}

@keyframes slideIndicator {
    from { transform: scaleY(0); }
    to { transform: scaleY(1); }
}

/* ==========================================================================
   TABLE ROW HOVER ACTIONS (#13 — subtle lift on row hover)
   ========================================================================== */
@media (min-width: 769px) {
    td .btn-icon {
        opacity: 0.75;
        transition: opacity var(--transition), background var(--transition), color var(--transition), transform var(--transition);
    }

    tr:hover td .btn-icon {
        opacity: 1;
    }
}

/* ==========================================================================
   STAT CARD VALUE ANIMATION (#11 — count-up entrance)
   ========================================================================== */
.stat-value {
    animation: statValueIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes statValueIn {
    from { opacity: 0; transform: translateY(8px) scale(0.9); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Staggered stat card delays */
.stat-card:nth-child(1) .stat-value { animation-delay: 0.1s; }
.stat-card:nth-child(2) .stat-value { animation-delay: 0.2s; }
.stat-card:nth-child(3) .stat-value { animation-delay: 0.3s; }
.stat-card:nth-child(4) .stat-value { animation-delay: 0.4s; }
.stat-card:nth-child(5) .stat-value { animation-delay: 0.5s; }

/* ==========================================================================
   PRINT STYLESHEET (#20)
   ========================================================================== */
@media print {
    .sidebar,
    .topbar,
    .mobile-menu-toggle,
    .toast-container,
    .confirm-overlay,
    .btn,
    .tabs,
    .dashboard-header form,
    .profile-dropdown {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }

    body {
        background: white;
        color: black;
        font-size: 12pt;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ddd;
        break-inside: avoid;
    }

    .stat-card {
        box-shadow: none;
        border: 1px solid #ddd;
    }

    .stat-value {
        animation: none;
    }

    table {
        font-size: 10pt;
    }

    a {
        color: inherit;
        text-decoration: none;
    }
}

/* ==========================================================================
   :has() FALLBACK (Firefox <121 support)
   ========================================================================== */
.worker-assign-card.is-checked {
    background: var(--primary-light);
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary);
}

/* ==========================================================================
   TABLET BREAKPOINT (769px – 1024px)
   ========================================================================== */
@media (min-width: 769px) and (max-width: 1024px) {
    .main-content {
        padding: calc(var(--topbar-height) + 24px) 20px 28px 20px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .dashboard-header {
        padding: 18px 22px;
        flex-wrap: wrap;
        gap: 12px;
    }

    .card {
        padding: 20px;
    }

    .modal-content {
        max-width: 440px;
        padding: 28px;
    }

    .worker-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }

    .toolbar {
        gap: 8px;
    }

    .btn {
        padding: 8px 16px;
        font-size: 0.85rem;
    }

    th, td {
        padding: 10px 14px;
        font-size: 0.85rem;
    }

    .confirm-dialog {
        max-width: 400px;
        padding: 24px;
    }
}
