/* ============================================================
   LiV Dashboard - Modern UI (2026 Stripe-inspired)
   ============================================================ */

/* ---- Design Tokens ---- */
:root {
    /* Primary (Orange - Brand #f69052) */
    --primary-50: #FEF5EF;
    --primary-100: #FDE8D9;
    --primary-200: #FBCDB3;
    --primary-300: #F9B08C;
    --primary-400: #f69052;
    --primary: #f69052;
    --primary-hover: #E5773B;
    --primary-700: #C4612A;

    /* Neutral Scale */
    --gray-25: #FCFCFD;
    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-600: #4B5563;
    --gray-700: #374151;
    --gray-800: #1F2937;
    --gray-900: #111827;
    --gray-950: #030712;

    /* Semantic */
    --success: #059669;
    --success-light: #ECFDF5;
    --success-text: #065F46;
    --warning: #D97706;
    --warning-light: #FFFBEB;
    --warning-text: #92400E;
    --error: #DC2626;
    --error-light: #FEF2F2;
    --error-text: #991B1B;
    --info: #2563EB;
    --info-light: #EFF6FF;
    --info-text: #1E40AF;

    /* Sidebar */
    --sidebar-bg: #000000;
    --sidebar-hover: #1a1a1a;
    --sidebar-active: rgba(246, 144, 82, 0.12);
    --sidebar-text: #94A3B8;
    --sidebar-text-active: #FFFFFF;
    --sidebar-border: rgba(255, 255, 255, 0.06);
    --sidebar-width: fit-content;

    /* Layout */
    --bg: #F9FAFB;
    --card-bg: #FFFFFF;
    --text-main: #111827;
    --text-secondary: #6B7280;
    --text-tertiary: #9CA3AF;
    --border: #E5E7EB;
    --border-light: #F3F4F6;
    --content-max-width: 1200px;

    /* 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-md: 0 4px 8px -2px rgba(0, 0, 0, 0.06), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 12px 24px -4px rgba(0, 0, 0, 0.08), 0 4px 8px -2px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 20px 40px -8px rgba(0, 0, 0, 0.1);

    /* Radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;

    /* Typography */
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --text-xs: 0.75rem;
    --text-sm: 0.8125rem;
    --text-base: 0.875rem;
    --text-md: 0.9375rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 1.875rem;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 200ms ease;
    --transition-slow: 300ms ease;
}

/* ---- Reset & Base ---- */
.skip-link {
    position: absolute; top: -100px; left: 0;
    padding: 0.75rem 1rem; background: var(--primary); color: white;
    font-weight: 500; text-decoration: none; border-radius: 0 0 6px 0;
    z-index: 10000; transition: top 0.2s;
}
.skip-link:focus { top: 0; outline: 2px solid white; outline-offset: 2px; }

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Global: prevent images from overflowing their containers */
img, svg { max-width: 100%; }

/* Global touch: suppress the grey tap flash on iOS/Android */
button, a, [role="button"] {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* Reduced-motion: disable animations for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

body {
    font-family: var(--font);
    background-color: var(--bg);
    color: var(--text-main);
    margin: 0; padding: 0;
    display: flex; flex-direction: column;
    min-height: 100vh;
    font-size: var(--text-base);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ---- App Layout ---- */
#app-layout { display: flex; flex-direction: column; min-height: 100vh; width: 100%; }
.app-body { display: flex; flex: 1; min-height: 0; }

/* ---- Sidebar ---- */
.sidebar {
    width: var(--sidebar-width);
    min-width: 180px;
    max-width: 280px;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex; flex-direction: column; flex-shrink: 0;
    position: sticky; top: 0; z-index: 50;
    align-self: stretch;
    border-right: 1px solid var(--sidebar-border);
    transition: width var(--transition-slow);
    overflow: hidden;
}

.sidebar-header {
    padding: 20px 20px 16px;
    display: flex; align-items: center;
}
.sidebar-logo { height: 32px; width: auto; image-rendering: -webkit-optimize-contrast; }
.sidebar-logo-link { text-decoration: none; display: flex; align-items: center; }

.sidebar-nav {
    padding: 8px 12px; flex: 1;
    display: flex; flex-direction: column;
    overflow-y: auto;
}

/* Nav Sections */
.nav-section { padding: 4px 0; }
.nav-section + .nav-section { border-top: 1px solid var(--sidebar-border); margin-top: 4px; padding-top: 8px; }
.nav-section-label {
    display: block; padding: 12px 12px 6px;
    font-size: var(--text-xs); font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.05em;
    color: rgba(148, 163, 184, 0.6);
}

/* Nav Items */
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px; margin: 1px 0;
    color: var(--sidebar-text);
    font-size: var(--text-sm); font-weight: 500;
    background: none; border: none;
    border-left: 3px solid transparent;
    width: 100%; text-align: left;
    cursor: pointer; border-radius: 0;
    transition: all var(--transition-fast);
    text-decoration: none;
    line-height: 1.4;
}
.nav-item:hover {
    background-color: var(--sidebar-hover);
    color: var(--sidebar-text-active);
}
.nav-item.active {
    border-left-color: var(--primary);
    background-color: var(--sidebar-active);
    color: var(--sidebar-text-active);
}
.nav-icon {
    width: 18px; height: 18px; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
}
.nav-icon svg {
    width: 18px; height: 18px;
    stroke: currentColor; fill: none;
    stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round;
}
.nav-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Sidebar Footer */
.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--sidebar-border);
    margin-top: auto;
}
.sidebar-user {
    display: flex; align-items: center; gap: 10px;
}
.sidebar-user-avatar {
    width: 32px; height: 32px; border-radius: var(--radius-full);
    object-fit: cover; flex-shrink: 0;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name {
    display: block; font-size: var(--text-sm); font-weight: 500;
    color: rgba(255,255,255,0.9); white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user-actions {
    display: flex; align-items: center; gap: 4px; margin-top: 8px;
}
.sidebar-signout-btn {
    background: none; border: none; cursor: pointer;
    color: rgba(148, 163, 184, 0.6); padding: 4px;
    border-radius: var(--radius-sm); transition: all var(--transition-fast);
    display: flex; align-items: center; gap: 6px;
    font-size: var(--text-xs); font-family: var(--font);
}
.sidebar-signout-btn:hover { color: rgba(255,255,255,0.8); background: rgba(255,255,255,0.06); }
.sidebar-signout-btn svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.75; }
.version-text {
    display: inline; font-size: 11px; color: rgba(148, 163, 184, 0.4);
}
.sidebar-heart {
    display: inline; font-size: 12px; margin-right: 4px; line-height: 1;
}
.sidebar-version-line {
    margin-top: 8px; line-height: 1.4;
}
.footer-text { display: none; }

/* Mobile Header */
.mobile-header {
    display: none; align-items: center; gap: 12px;
    /* Safe-area inset for iPhone notch/Dynamic Island */
    padding: env(safe-area-inset-top, 0px) 16px 0;
    padding-top: calc(env(safe-area-inset-top, 0px) + 12px);
    padding-bottom: 12px;
    height: 56px;
    min-height: calc(56px + env(safe-area-inset-top, 0px));
    /* Dark header matching sidebar */
    background: var(--sidebar-bg);
    border-bottom: 1px solid var(--sidebar-border);
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    position: sticky; top: 0; z-index: 100;
    transition: box-shadow var(--transition-fast);
}
.mobile-header.is-scrolled {
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
.mobile-logo-link { display: flex; align-items: center; margin-right: auto; }
.mobile-header-logo { height: 28px; width: auto; }
.mobile-alert-btn {
    background: none; border: none;
    /* Minimum 44px touch target per WCAG */
    padding: 10px;
    cursor: pointer; color: var(--sidebar-text); position: relative;
    border-radius: var(--radius-sm); display: flex; align-items: center;
    justify-content: center;
    min-width: 44px; min-height: 44px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.mobile-alert-btn:hover { background: rgba(255,255,255,0.08); color: #fff; }
.mobile-alert-btn svg { width: 20px; height: 20px; stroke: currentColor; fill: none; }
.hamburger-btn {
    background: none; border: none;
    /* Minimum 44px touch target */
    padding: 10px;
    cursor: pointer; color: var(--sidebar-text);
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    min-width: 44px; min-height: 44px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.hamburger-btn:hover { background: rgba(255,255,255,0.08); color: #fff; }
.hamburger-btn svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2; }

/* Mobile header: page title (hidden on desktop, shown on mobile via flex parent) */
.mobile-header-title {
    display: none;
}

/* Mobile header: user avatar */
.mobile-header-avatar {
    display: none;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    object-fit: cover;
    flex-shrink: 0;
    cursor: pointer;
    border: 2px solid rgba(246, 144, 82, 0.3);
}

/* Sidebar close button (X) — only visible on mobile */
.sidebar-close-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--sidebar-text);
    padding: 8px;
    border-radius: var(--radius-sm);
    margin-left: auto;
    -webkit-tap-highlight-color: transparent;
}
.sidebar-close-btn svg { width: 20px; height: 20px; stroke: currentColor; fill: none; }
.sidebar-close-btn:hover { color: white; background: rgba(255,255,255,0.08); }

/* Sidebar Overlay (mobile) */
.sidebar-overlay {
    display: none; position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 199;
    backdrop-filter: blur(2px);
}
.sidebar-overlay.is-visible { display: block; }

/* ---- Main Content ---- */
.main-content { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }

.top-header { display: none; }

.content-container {
    padding: 32px 40px; flex: 1;
    max-width: var(--content-max-width);
    width: 100%; margin: 0 auto;
}

/* Legacy profile menu (hidden, moved to sidebar) */
#auth-container, .profile-menu, .profile-info, .header-right,
.dropdown-content, .dropdown-inner { display: none; }

/* ---- Page Header ---- */
.page-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    padding-bottom: 24px; margin-bottom: 24px;
    border-bottom: 1px solid var(--border-light);
    flex-wrap: wrap; gap: 16px;
}
.page-header-content { flex: 1; min-width: 0; }
.page-title {
    font-size: var(--text-2xl); font-weight: 600;
    color: var(--gray-900); line-height: 1.25; margin: 0;
    letter-spacing: -0.01em;
}
.page-subtitle {
    font-size: var(--text-base); color: var(--text-secondary);
    margin-top: 4px; line-height: 1.5;
}
.page-actions {
    display: flex; align-items: center; gap: 8px;
    flex-shrink: 0; flex-wrap: wrap;
}

/* ---- Views ---- */
.view-section { display: none; }
.view-section.active { display: block; animation: fadeInUp 0.25s ease-out; }
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---- Cards ---- */
.card {
    background: var(--card-bg); border-radius: var(--radius-lg);
    border: 1px solid var(--border); padding: 24px;
    margin-bottom: 24px; box-shadow: var(--shadow-xs);
}
.card-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 20px; padding-bottom: 16px;
    border-bottom: 1px solid var(--border-light);
    flex-wrap: wrap; gap: 12px;
}
.card-header h2 {
    margin: 0; font-size: var(--text-lg); font-weight: 600;
    color: var(--gray-900);
}
.card-header h3 { margin: 0; font-size: var(--text-md); font-weight: 600; }
.header-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---- Buttons ---- */
.btn,
.btn-primary,
.btn-secondary,
.btn-danger,
.btn-clock-out,
.btn-save-roles {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 6px; font-family: var(--font);
    font-weight: 500; font-size: var(--text-base);
    border-radius: var(--radius-md); cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap; border: 1px solid transparent;
    padding: 8px 16px; line-height: 1;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary); color: white;
    border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }

.btn-secondary {
    background: white; color: var(--gray-700);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--gray-50); border-color: var(--gray-300); }
.btn-secondary:active { transform: scale(0.98); }

.btn-ghost {
    background: transparent; color: var(--text-secondary);
    border: none; padding: 6px 12px;
}
.btn-ghost:hover { background: var(--gray-100); color: var(--text-main); }

.btn-danger {
    background: none; border: none;
    color: var(--text-tertiary); cursor: pointer;
    padding: 6px; border-radius: var(--radius-sm);
    transition: all var(--transition-fast); font-size: var(--text-sm);
    display: inline-flex; align-items: center;
}
.btn-danger:hover { background: var(--error-light); color: var(--error); }

.btn-save-roles { background: #10B981; color: white; border-color: #10B981; }
.btn-save-roles:hover { background: #059669; border-color: #059669; }

.btn-clock-out {
    background: var(--error-light); color: var(--error);
    border: 1px solid rgba(220, 38, 38, 0.2);
    font-weight: 600;
}
.btn-clock-out:hover { background: #FECACA; }

.btn-sm { padding: 5px 10px; font-size: var(--text-sm); }

.btn-icon {
    width: 16px; height: 16px;
    stroke: currentColor; fill: none;
    stroke-width: 2;
}

/* Button loading state */
.btn-loading {
    color: transparent !important;
    position: relative; pointer-events: none;
}
.btn-loading::after {
    content: ''; position: absolute;
    width: 16px; height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
.btn-secondary.btn-loading::after {
    border-color: rgba(0,0,0,0.1);
    border-top-color: var(--gray-700);
}

/* ---- Status Areas ---- */
.status-area { margin-bottom: 16px; }
.status-area .status-msg {
    padding: 10px 14px; border-radius: var(--radius-md);
    font-size: var(--text-base); display: flex; align-items: center; gap: 8px;
}
.status-msg.success { background: var(--success-light); color: var(--success-text); border: 1px solid #A7F3D0; }
.status-msg.error { background: var(--error-light); color: var(--error-text); border: 1px solid #FECACA; }
.status-msg.info { background: var(--info-light); color: var(--info-text); border: 1px solid #BFDBFE; }
.status-msg.loading { background: var(--warning-light); color: var(--warning-text); border: 1px solid #FDE68A; }

/* ---- Item Lists (reminders, memories) ---- */
.item-list { list-style: none; }
.item-list li {
    background: white; border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 14px 16px;
    margin-bottom: 8px;
    display: flex; justify-content: space-between; align-items: flex-start;
    transition: border-color var(--transition-fast);
}
.item-list li:hover { border-color: var(--gray-300); }
.item-text { flex: 1; font-size: var(--text-md); color: var(--text-main); line-height: 1.5; }
.item-meta { font-size: var(--text-xs); color: var(--text-secondary); margin-top: 4px; }

/* Item removal animation */
.item-removing {
    animation: itemRemove 200ms ease forwards;
}
@keyframes itemRemove {
    to { opacity: 0; transform: translateX(20px); height: 0; padding: 0; margin: 0; overflow: hidden; }
}

/* ---- Tables ---- */
/* .data-table-wrapper is an alias for .table-wrapper — use either in HTML.
   Both provide horizontal scroll so tables don't cause page-level overflow. */
.table-wrapper,
.data-table-wrapper {
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border); border-radius: var(--radius-lg);
}
.data-table { width: 100%; border-collapse: collapse; font-size: var(--text-base); }
.data-table th {
    text-align: left; padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary); font-weight: 600;
    font-size: var(--text-xs); text-transform: uppercase;
    letter-spacing: 0.04em;
    background: var(--gray-50);
    position: sticky; top: 0; z-index: 1;
}
.data-table td {
    padding: 10px 16px; border-bottom: 1px solid var(--border-light);
    font-size: var(--text-base); vertical-align: middle;
}
.data-table tbody tr { transition: background-color var(--transition-fast); }
.data-table tbody tr:hover td { background: var(--gray-25); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table td.numeric,
.data-table th.numeric { text-align: right; font-variant-numeric: tabular-nums; }

/* ---- Forms ---- */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-group label,
.form-label {
    font-size: var(--text-sm); font-weight: 500;
    color: var(--gray-700);
}
.form-control,
.form-group input,
.form-group select,
.form-group textarea {
    padding: 9px 13px; border: 1px solid var(--gray-300);
    border-radius: var(--radius-md); font-size: var(--text-base);
    font-family: inherit; background: white; color: var(--text-main);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    line-height: 1.5;
}
.form-group input::placeholder,
.form-control::placeholder { color: var(--text-tertiary); }
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
.form-control:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-100);
}
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; }
.form-actions {
    display: flex; justify-content: flex-end; gap: 8px;
    padding-top: 16px; border-top: 1px solid var(--border-light);
    margin-top: 16px;
}
.form-hint { margin: 4px 0 0 0; font-size: var(--text-xs); color: var(--text-secondary); }

/* ---- Login (PRESERVED - DO NOT MODIFY) ---- */
body.login-mode { background-color: #000; justify-content: center; }
body.login-mode #app-layout { display: none !important; }

#login-prompt {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2rem; margin: auto; width: 100%; min-height: 100vh;
    position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 1000;
}
body:not(.login-mode) #login-prompt { display: none !important; }

.login-message {
    color: #666; font-size: 0.95rem; text-align: center;
    margin-bottom: 0.5rem; max-width: 280px;
}

.login-circle {
    width: 320px; height: 320px; background-color: #000; border-radius: 50%;
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    gap: 1.5rem;
    box-shadow: 0 0 60px rgba(249,115,22,0.3);
    border: 1px solid rgba(255,255,255,0.05);
}
.login-logo { display: block; height: 90px; width: auto; image-rendering: -webkit-optimize-contrast; margin-top: -10px; }
.login-version-text { font-size: 11px; color: rgba(148, 163, 184, 0.3); margin-top: 1rem; }

/* Loading Screen */
#loading-screen {
    position: fixed; inset: 0; z-index: 9999;
    background: #000000;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 1.5rem;
    transition: opacity 0.4s ease;
}
#loading-screen.fade-out { opacity: 0; pointer-events: none; }
.loading-screen-spinner {
    width: 40px; height: 40px;
    border: 3px solid rgba(249, 115, 22, 0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
.loading-screen-text {
    font-size: 0.9rem; color: rgba(148, 163, 184, 0.6);
    font-family: var(--font);
}

#g_id_signin_button { display: flex; justify-content: center; z-index: 10; }

.google-signin-btn {
    display: inline-flex; align-items: center; gap: 0.6rem;
    padding: 0.65rem 1.5rem; background: white; color: #3c4043;
    border: 1px solid #dadce0; border-radius: 20px;
    font-family: 'Inter', -apple-system, sans-serif; font-size: 0.9rem; font-weight: 500;
    cursor: pointer; transition: background 0.2s, box-shadow 0.2s;
    text-decoration: none; z-index: 10;
}
.google-signin-btn:hover {
    background: #f7f8f8; box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.google-signin-btn svg { flex-shrink: 0; }

/* ---- Login: Personalized hint ---- */
.hint-avatar {
    width: 52px; height: 52px; border-radius: 50%;
    border: 2px solid rgba(249,115,22,0.6); object-fit: cover;
}
.hint-name {
    color: #ffffff; font-size: 0.9rem; font-weight: 600; line-height: 1.2;
}
.hint-email {
    color: rgba(255,255,255,0.55); font-size: 0.75rem; line-height: 1.2;
}
.google-signin-btn.personalized {
    background: #1a1a1a; color: #ffffff; border-color: rgba(249,115,22,0.4);
}
.google-signin-btn.personalized:hover {
    background: #252525; box-shadow: 0 1px 3px rgba(249,115,22,0.25);
}
.different-account-link {
    color: rgba(255,255,255,0.45); font-size: 0.75rem;
    text-decoration: underline; cursor: pointer;
}
.different-account-link:hover { color: rgba(255,255,255,0.7); }

/* ---- Toggle ---- */
.toggle-container { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.toggle-label { font-size: var(--text-sm); color: var(--text-secondary); font-weight: 500; }

/* ---- Toggle Switch ---- */
.toggle-switch {
    width: 36px; height: 20px;
    background: var(--gray-300); border-radius: var(--radius-full);
    position: relative; cursor: pointer;
    transition: background var(--transition-fast);
    border: none; padding: 0;
}
.toggle-switch.is-on { background: var(--primary); }
.toggle-switch::after {
    content: ''; position: absolute;
    width: 16px; height: 16px;
    background: white; border-radius: 50%;
    top: 2px; left: 2px;
    transition: transform var(--transition-fast);
    box-shadow: var(--shadow-xs);
}
.toggle-switch.is-on::after { transform: translateX(16px); }

/* ---- Admin Tabs ---- */
.admin-tab-content { }
.tab-bar {
    display: flex; gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
}
.tab-item {
    padding: 10px 20px;
    font-size: var(--text-sm); font-weight: 500;
    color: var(--text-secondary);
    background: none; border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer; transition: all var(--transition-fast);
    margin-bottom: -1px; font-family: var(--font);
}
.tab-item:hover { color: var(--text-main); }
.tab-item.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---- Modal ---- */
.add-account-modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5); z-index: 1000;
    display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(2px);
}
.add-account-modal-content {
    background: white; padding: 28px; border-radius: var(--radius-xl);
    max-width: 500px; width: 90%;
    box-shadow: var(--shadow-xl);
}

/* ---- Role Badges ---- */
.role-badge {
    padding: 2px 10px; border-radius: var(--radius-full);
    font-size: var(--text-xs); font-weight: 500; display: inline-block;
}
.role-admin { background: var(--primary-100); color: var(--primary-700); border: none; }
.role-super-admin { background: linear-gradient(135deg, #7C3AED, #EC4899); color: white; border: none; }
.role-team { background: var(--gray-200); color: var(--gray-700); border: none; }
.role-user { background: var(--gray-100); color: var(--text-secondary); border: none; }

/* ---- Spinner ---- */
.spinner-inline {
    display: none; width: 16px; height: 16px;
    border: 2px solid rgba(0,0,0,0.1); border-top-color: var(--primary);
    border-radius: 50%; animation: spin 0.8s linear infinite;
    margin-left: 8px; vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Custom Dropdown ---- */
.dropdown-wrapper { position: relative; }
.custom-dropdown {
    display: none; position: absolute;
    top: calc(100% + 4px); left: 0; right: 0;
    background: white; border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-height: 280px; overflow-y: auto; z-index: 1000;
}
.dropdown-item {
    padding: 10px 14px; text-decoration: none; display: block;
    color: var(--text-main); font-size: var(--text-base);
    transition: background-color var(--transition-fast);
    border: none; background: none; width: 100%; text-align: left; cursor: pointer;
    border-bottom: 1px solid var(--border-light);
}
.dropdown-item:last-child { border-bottom: none; }
.dropdown-item:hover { background-color: var(--gray-50); }
.dropdown-item-sign-out { color: var(--error); }
.dropdown-divider { height: 1px; background-color: var(--border); margin: 0; }

/* ---- Focus Visible ---- */
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: 2px solid var(--primary); outline-offset: 2px;
}

/* ---- Clock Status Widget ---- */
.clock-status-card { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--card-bg); padding: 20px 24px; margin-bottom: 20px; }
.clock-status-info {
    display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.clock-status-indicator { display: flex; align-items: center; gap: 8px; }
.clock-dot {
    width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0;
}
.clock-dot--in { background: var(--success); box-shadow: 0 0 6px rgba(5,150,105,0.5); }
.clock-dot--out { background: var(--gray-400); }
.clock-dot--break { background: var(--warning); box-shadow: 0 0 6px rgba(217,119,6,0.4); }
.clock-status-text { font-size: var(--text-lg); font-weight: 600; }
.clock-status-since { font-size: var(--text-sm); color: var(--text-secondary); }
.clock-actions {
    display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap;
}

/* ---- Time Clock View ---- */
.tc-clock-hero {
    text-align: center;
    padding: 40px 24px 32px;
    background: linear-gradient(135deg, #000000 0%, #1a1a1a 100%);
    color: white;
    border: none;
}
.tc-hero-content { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.tc-current-time {
    font-size: 3rem; font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
    opacity: 0.95;
}
.tc-status-row {
    display: flex; align-items: center; gap: 10px;
    font-size: var(--text-lg);
}
.tc-dot {
    width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex-shrink: 0;
}
.tc-dot--in { background: #34D399; box-shadow: 0 0 8px rgba(52,211,153,0.6); animation: tcPulse 2s ease-in-out infinite; }
.tc-dot--out { background: var(--gray-400); }
.tc-dot--break { background: #FBBF24; box-shadow: 0 0 8px rgba(251,191,36,0.5); animation: tcPulse 2s ease-in-out infinite; }
@keyframes tcPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.3); }
}
.tc-status-text { font-weight: 600; }
.tc-status-since { font-size: var(--text-sm); opacity: 0.6; }
.tc-hero-actions {
    display: flex; gap: 12px; margin-top: 8px; flex-wrap: wrap; justify-content: center;
}
.tc-btn-clock-in {
    padding: 14px 48px; font-size: var(--text-lg); font-weight: 700;
    background: #34D399; color: #064E3B; border: none;
    border-radius: var(--radius-full); cursor: pointer;
    transition: all var(--transition-fast);
    font-family: var(--font);
    box-shadow: 0 4px 14px rgba(52,211,153,0.4);
}
.tc-btn-clock-in:hover { background: #6EE7B7; transform: translateY(-1px); box-shadow: 0 6px 20px rgba(52,211,153,0.5); }
.tc-btn-clock-in:active { transform: scale(0.97); }
.tc-btn-clock-out {
    padding: 14px 48px; font-size: var(--text-lg); font-weight: 700;
    background: #FCA5A5; color: #7F1D1D; border: none;
    border-radius: var(--radius-full); cursor: pointer;
    transition: all var(--transition-fast);
    font-family: var(--font);
    box-shadow: 0 4px 14px rgba(252,165,165,0.4);
}
.tc-btn-clock-out:hover { background: #FEE2E2; transform: translateY(-1px); }
.tc-btn-clock-out:active { transform: scale(0.97); }
.tc-btn-break {
    padding: 10px 28px; font-size: var(--text-base); font-weight: 600;
    background: rgba(255,255,255,0.15); color: white; border: 1px solid rgba(255,255,255,0.2);
    border-radius: var(--radius-full); cursor: pointer;
    transition: all var(--transition-fast);
    font-family: var(--font);
}
.tc-btn-break:hover { background: rgba(255,255,255,0.25); }

/* Time Clock Summary Grid */
.tc-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px; margin-bottom: 24px;
}
.tc-summary-card {
    background: var(--card-bg); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 24px;
    display: flex; flex-direction: column; gap: 6px;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}
.tc-summary-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.tc-card-label {
    font-size: var(--text-xs); text-transform: uppercase;
    font-weight: 600; color: var(--text-secondary); letter-spacing: 0.05em;
}
.tc-card-value {
    font-size: var(--text-3xl); font-weight: 700;
    color: var(--text-main); letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}
.tc-card-sub { font-size: var(--text-xs); color: var(--text-secondary); }
.tc-card-hours { border-top: 3px solid var(--primary); }
.tc-card-breaks { border-top: 3px solid var(--warning); }
.tc-card-pay { border-top: 3px solid var(--success); }
.tc-card-overtime { border-top: 3px solid var(--error); }

/* Progress bar */
.tc-progress-bar {
    width: 100%; height: 6px; background: var(--gray-200);
    border-radius: var(--radius-full); overflow: hidden; margin-top: 4px;
}
.tc-progress-fill {
    height: 100%; background: var(--primary);
    border-radius: var(--radius-full);
    transition: width 0.5s ease;
}

/* Timesheet timeline */
.tc-timeline { display: flex; flex-direction: column; gap: 6px; }
.tc-timeline-event {
    display: flex; align-items: center; gap: 8px;
    font-size: var(--text-sm);
}
.tc-evt-icon {
    width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.tc-evt-in { background: var(--success); }
.tc-evt-out { background: var(--error); }
.tc-evt-break { background: var(--warning); }
.tc-evt-resume { background: var(--info); }
.tc-evt-other { background: var(--gray-400); }
.tc-evt-time { font-weight: 600; color: var(--text-main); min-width: 80px; }
.tc-evt-type { color: var(--text-secondary); }
.tc-evt-note { color: var(--text-tertiary); font-style: italic; }

/* Hours badge */
.tc-hrs-badge {
    display: inline-block; padding: 3px 10px;
    border-radius: var(--radius-full); font-size: var(--text-sm);
    font-weight: 600; font-variant-numeric: tabular-nums;
}
.tc-hrs-full { background: var(--success-light); color: var(--success-text); }
.tc-hrs-half { background: var(--warning-light); color: var(--warning-text); }
.tc-hrs-short { background: var(--gray-100); color: var(--gray-500); }

@media (max-width: 768px) {
    .tc-current-time { font-size: 2.25rem; }
    .tc-clock-hero { padding: 28px 16px 24px; }
    .tc-btn-clock-in, .tc-btn-clock-out { padding: 12px 36px; font-size: var(--text-base); }
    .tc-summary-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---- Hours Summary Cards ---- */
.hours-summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px; margin-bottom: 20px;
}
.hours-summary-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px; display: flex; flex-direction: column; gap: 4px;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}
.hours-summary-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.hours-summary-card .summary-label {
    font-size: var(--text-xs); text-transform: uppercase;
    font-weight: 600; color: var(--text-secondary); letter-spacing: 0.04em;
}
.hours-summary-card .summary-value {
    font-size: var(--text-2xl); font-weight: 600;
    color: var(--text-main); letter-spacing: -0.01em;
    font-variant-numeric: tabular-nums;
}
.hours-summary-card .summary-sub {
    font-size: var(--text-xs); color: var(--text-secondary);
}

/* ---- Hours Table ---- */
.hours-table tbody tr { cursor: pointer; transition: background-color var(--transition-fast); }
.hours-table tbody tr:hover td { background: var(--primary-50); }

.hours-status-badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 10px; border-radius: var(--radius-full);
    font-size: var(--text-xs); font-weight: 500;
}
.hours-status-badge.status-active { background: var(--success-light); color: var(--success-text); }
.hours-status-badge.status-break { background: var(--warning-light); color: var(--warning-text); }
.hours-status-badge.status-out { background: var(--gray-100); color: var(--gray-500); }

.hours-status-dot {
    width: 7px; height: 7px; border-radius: 50%; display: inline-block;
}
.hours-status-dot.dot-active { background: var(--success); }
.hours-status-dot.dot-break { background: var(--warning); }
.hours-status-dot.dot-out { background: var(--gray-400); }

/* ---- Employee Detail Panel ---- */
.hours-employee-detail {
    margin-top: 24px; border-top: 1px solid var(--border);
    padding-top: 24px;
}
.hours-detail-day {
    display: grid; grid-template-columns: 120px 1fr;
    gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--border-light);
}
.hours-detail-day:last-child { border-bottom: none; }
.hours-detail-date { font-weight: 600; font-size: var(--text-base); color: var(--text-main); }
.hours-detail-events { display: flex; flex-direction: column; gap: 4px; }
.hours-detail-event {
    font-size: var(--text-sm); color: var(--text-secondary);
    display: flex; align-items: center; gap: 8px;
}
.hours-detail-event .event-time { font-weight: 500; color: var(--text-main); }

.hours-detail-weekly { margin-bottom: 24px; }
.hours-detail-weekly table { margin-top: 8px; }

/* ---- Toast System ---- */
.toast-container {
    position: fixed; top: 24px; right: 24px;
    display: flex; flex-direction: column; gap: 10px;
    z-index: 10000; pointer-events: none;
}
.toast {
    padding: 14px 18px; border-radius: var(--radius-lg);
    background: white; border: 1px solid var(--border);
    box-shadow: var(--shadow-lg); font-size: var(--text-base);
    max-width: 400px; min-width: 300px;
    pointer-events: auto;
    animation: toastIn 0.3s ease-out;
    display: flex; align-items: flex-start; gap: 10px;
}
.toast.toast-exit { animation: toastOut 0.2s ease forwards; }
.toast-success { border-left: 3px solid var(--success); }
.toast-error { border-left: 3px solid var(--error); }
.toast-info { border-left: 3px solid var(--info); }
.toast-body { flex: 1; line-height: 1.5; }
.toast-close {
    background: none; border: none; cursor: pointer;
    color: var(--text-tertiary); padding: 2px; font-size: 18px;
    line-height: 1; transition: color var(--transition-fast);
}
.toast-close:hover { color: var(--text-main); }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(100%); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(100%); }
}

/* ---- Loading Skeleton ---- */
.skeleton {
    background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-200) 50%, var(--gray-100) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
}
.skeleton-text { height: 14px; width: 80%; margin-bottom: 8px; }
.skeleton-text-short { height: 14px; width: 50%; margin-bottom: 8px; }
.skeleton-heading { height: 20px; width: 40%; margin-bottom: 12px; }
.skeleton-card { height: 64px; margin-bottom: 8px; border-radius: var(--radius-lg); }
@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ---- Empty State ---- */
.empty-state {
    text-align: center; padding: 48px 24px; color: var(--text-secondary);
}
.empty-state-icon { margin-bottom: 12px; color: var(--text-tertiary); }
.empty-state-text { font-size: var(--text-md); line-height: 1.5; }

/* ---- "Coming soon" badge in sidebar ---- */
.nav-coming-soon {
    display: block;
    font-size: 0.6rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--primary);
    background: rgba(246, 144, 82, 0.12);
    padding: 1px 6px;
    border-radius: var(--radius-sm);
    margin: 2px 0 4px 12px;
    white-space: nowrap;
    width: fit-content;
}

/* Prevent sidebar nav labels from wrapping (supports dynamic width) */
.nav-label { white-space: nowrap; }

/* ---- Home View ---- */
.home-greeting {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding-bottom: 40px;
    margin-bottom: 8px;
}

.home-avatar {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-full);
    object-fit: cover;
    border: 2px solid var(--primary-200);
    margin-bottom: 20px;
    flex-shrink: 0;
}

.home-greeting-headline {
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1.15;
    letter-spacing: -0.02em;
    margin: 0 0 10px 0;
}

.home-greeting-sub {
    font-size: var(--text-lg);
    font-weight: 400;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.5;
}

.home-tools-label {
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
    margin: 0 0 14px 0;
}

.home-tools-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 14px;
}

.home-skeleton {
    min-height: 100px;
    border-radius: var(--radius-xl);
    border: none;
}

.home-tool-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 100px;
    padding: 18px 12px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xs);
    cursor: pointer;
    font-family: var(--font);
    transition: all var(--transition-base);
    text-align: center;
}

.home-tool-card:hover {
    border-color: var(--primary-300);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.home-tool-card:active {
    transform: scale(0.97);
    box-shadow: var(--shadow-xs);
}

.home-tool-icon {
    width: 36px;
    height: 36px;
    background: var(--primary-50);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background var(--transition-base);
}

.home-tool-card:hover .home-tool-icon {
    background: var(--primary-100);
}

.home-tool-icon svg {
    width: 18px;
    height: 18px;
    stroke: var(--primary);
    fill: none;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.home-tool-label {
    font-size: var(--text-xs);
    font-weight: 500;
    color: var(--text-main);
    text-align: center;
    line-height: 1.35;
    word-break: break-word;
}

/* ---- Home Clock Status ---- */
.home-clock-status {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 14px 20px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-xs);
}

.home-clock-inner {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.home-clock-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

/* ---- Header Profile Avatar + Dropdown ---- */
.header-profile {
    position: relative;
    display: flex;
    align-items: center;
}

.header-avatar-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    padding: 2px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.header-avatar-btn:hover {
    border-color: var(--gray-300);
    box-shadow: 0 0 0 3px var(--primary-100);
}

.header-avatar-btn[aria-expanded="true"] {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-100);
}

.header-avatar {
    width: 30px;
    height: 30px;
    border-radius: var(--radius-full);
    object-fit: cover;
    display: block;
    vertical-align: middle;
}

.header-profile-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 220px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    overflow: hidden;
    transform-origin: top right;
    animation: headerDropdownIn var(--transition-fast) ease forwards;
}

.header-profile-dropdown[hidden] { display: none; }

@keyframes headerDropdownIn {
    from { opacity: 0; transform: scale(0.95) translateY(-4px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.header-profile-identity {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 16px 14px;
}

.header-dropdown-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid var(--border);
}

.header-profile-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.header-profile-name {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-profile-email {
    font-size: var(--text-xs);
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-profile-dropdown .dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-profile-dropdown .dropdown-item svg {
    width: 15px;
    height: 15px;
    stroke: currentColor;
    fill: none;
    flex-shrink: 0;
}

/* ---- Super Admin Preview Mode Bar ---- */
#preview-mode-bar {
    position: relative;
    z-index: 9000;
    background: #1e3a5f;
    border-bottom: 2px solid #3b82f6;
    box-shadow: 0 2px 12px rgba(59, 130, 246, 0.25);
    transition: transform var(--transition-base);
    flex-shrink: 0;
}

#preview-mode-bar.preview-active {
    background: #7c2d12;
    border-bottom-color: #f97316;
    box-shadow: 0 2px 12px rgba(249, 115, 22, 0.3);
}

.preview-bar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 24px;
    margin: 0 auto;
    gap: 16px;
    min-height: 44px;
}

.preview-bar-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.preview-bar-icon { color: #93c5fd; display: flex; align-items: center; }
#preview-mode-bar.preview-active .preview-bar-icon { color: #fdba74; }

.preview-bar-label {
    font-size: var(--text-sm);
    font-weight: 600;
    color: #93c5fd;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    white-space: nowrap;
}

#preview-mode-bar.preview-active .preview-bar-label { color: #fdba74; }

.preview-bar-center {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    justify-content: center;
}

.preview-bar-select-label {
    font-size: var(--text-sm);
    color: rgba(255, 255, 255, 0.7);
    white-space: nowrap;
}

.preview-bar-select {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-md);
    color: #ffffff;
    font-size: var(--text-sm);
    font-family: var(--font);
    padding: 4px 28px 4px 10px;
    cursor: pointer;
    outline: none;
    -webkit-appearance: none;
    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='rgba(255,255,255,0.6)' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    transition: border-color var(--transition-fast), background-color var(--transition-fast);
}

.preview-bar-select:hover {
    border-color: rgba(255, 255, 255, 0.4);
    background-color: rgba(255, 255, 255, 0.15);
}

.preview-bar-select:focus {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

.preview-bar-select option { background: #1e293b; color: #ffffff; }

.preview-bar-right { display: flex; align-items: center; flex-shrink: 0; }

.preview-exit-btn {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-md);
    color: #ffffff;
    font-size: var(--text-sm);
    font-family: var(--font);
    font-weight: 500;
    padding: 5px 14px;
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast);
    white-space: nowrap;
}

.preview-exit-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
}

/* preview bar is now at top via relative positioning — no extra padding needed */

/* ---- Responsive ---- */

/* =============================================================
   TABLET  —  max-width: 1024px
   Sidebar collapses to icon-only rail (72px). Layout remains
   side-by-side; content gets tighter padding.
   ============================================================= */
@media (max-width: 1024px) {
    .sidebar { width: 72px; }
    .sidebar .nav-label,
    .sidebar .nav-section-label,
    .sidebar-user-info,
    .sidebar-user-actions,
    .version-text { display: none; }
    .sidebar-header { justify-content: center; padding: 16px 8px; }
    .sidebar-logo { height: 24px; }
    .sidebar-nav { padding: 8px; }
    .nav-item { justify-content: center; padding: 10px; border-left: none; }
    .nav-item.active { border-left: none; background: var(--sidebar-active); border-radius: var(--radius-md); }
    .nav-icon { width: 20px; height: 20px; }
    .sidebar-footer { padding: 12px 8px; display: flex; justify-content: center; }
    .sidebar-user-avatar { width: 28px; height: 28px; }
    .content-container { padding: 24px; }

    /* Two-column stat grids on tablet */
    .stat-grid,
    .hours-summary-cards { grid-template-columns: repeat(2, 1fr); }

    /* Home view: 4-col on tablet */
    .home-tools-grid { grid-template-columns: repeat(4, 1fr); }
    .home-greeting-headline { font-size: 1.875rem; }
    .home-clock-actions { margin-left: 0; }
}

/* =============================================================
   MOBILE  —  max-width: 768px
   Sidebar becomes a fixed slide-out drawer. Mobile header
   becomes visible. Layout is single-column.
   ============================================================= */
@media (max-width: 768px) {

    /* --- Sidebar: fixed drawer --- */
    .sidebar {
        position: fixed; left: 0; top: 0; bottom: 0;
        width: 280px; transform: translateX(-100%);
        transition: transform var(--transition-slow);
        z-index: 200;
        /* Respect iPhone safe area at the bottom */
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }
    .sidebar.is-open { transform: translateX(0); }
    .preview-mode-open .sidebar.is-open {
        top: 44px;
        height: calc(100% - 44px);
    }

    /* Restore full sidebar labels when drawer is open */
    .sidebar .nav-label,
    .sidebar .nav-section-label,
    .sidebar-user-info,
    .sidebar-user-actions,
    .version-text { display: revert; }
    .sidebar-header { justify-content: flex-start; padding: 20px; }
    .sidebar-logo { height: 32px; }
    .sidebar-nav { padding: 8px 12px; }
    .nav-item {
        justify-content: flex-start; padding: 10px 12px;
        border-left: 3px solid transparent; border-radius: 0;
        /* Comfortable touch target */
        min-height: 44px;
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }
    .nav-item.active { border-left-color: var(--primary); border-radius: 0; }
    .sidebar-footer { display: block; padding: 16px 20px; }

    /* --- Mobile header: visible --- */
    .mobile-header { display: flex; }
    .mobile-header-avatar { display: block; }

    /* --- Sidebar close button: visible --- */
    .sidebar-close-btn { display: flex; align-items: center; }

    /* --- App body: switch to vertical stacking on mobile --- */
    .app-body { flex-direction: column; }

    /* --- Main content area --- */
    .main-content { min-height: calc(100vh - 56px); }
    .content-container { padding: 16px 12px; }

    /* Hide the desktop notification-bell row — it's on the mobile header */
    .content-header { display: none; }

    /* --- Page header --- */
    .page-header { flex-direction: column; gap: 12px; }
    .page-actions { width: 100%; flex-wrap: wrap; }
    /* Slightly reduce title sizes on mobile */
    .page-title { font-size: var(--text-xl); }
    .page-subtitle { font-size: var(--text-sm); }

    /* --- Cards --- */
    .card { padding: 16px; margin-bottom: 16px; }
    .card-header { margin-bottom: 16px; padding-bottom: 12px; }

    /* --- Typography headings --- */
    .card-header h2 { font-size: var(--text-md); }

    /* --- Stat / summary grids: 2-col on mobile, 1-col on tiny --- */
    .stat-grid,
    .hours-summary-cards { grid-template-columns: repeat(2, 1fr); gap: 10px; }

    /* --- Forms --- */
    .form-grid { grid-template-columns: 1fr; }
    .form-actions {
        flex-direction: column-reverse; align-items: stretch;
    }
    .form-actions .btn,
    .form-actions .btn-primary,
    .form-actions .btn-secondary {
        width: 100%; justify-content: center;
    }
    /* Prevent iOS auto-zoom on input focus (requires 16px minimum) */
    .form-control,
    .form-group input,
    .form-group select,
    .form-group textarea,
    select, input, textarea { font-size: 16px; }

    /* --- Buttons: minimum touch target height --- */
    .btn,
    .btn-primary,
    .btn-secondary,
    .btn-clock-out,
    .btn-save-roles {
        min-height: 44px;
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }
    .btn-sm { min-height: 36px; }

    /* --- Tables: horizontal scroll wrapper ---
       Wrap any .data-table in .data-table-wrapper in the HTML,
       or the .table-wrapper class already handles this.
       This rule ensures all direct data-table wrappers scroll. */
    .table-wrapper,
    .data-table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: var(--radius-lg);
        /* Reserve space for scrollbar so it doesn't overlap content */
        padding-bottom: 2px;
    }
    .data-table {
        /* Prevent columns from crushing on mobile */
        min-width: 500px;
    }

    /* --- Tab bar: horizontal scroll, no wrap --- */
    .tab-bar {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
        /* Hide the scrollbar visually but keep scroll behaviour */
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    .tab-bar::-webkit-scrollbar { display: none; }
    .tab-item { white-space: nowrap; flex-shrink: 0; }

    /* --- Toast: top-center on mobile instead of top-right --- */
    .toast-container {
        top: calc(56px + 12px); /* below mobile header */
        right: 16px;
        left: 16px;
        align-items: stretch;
        /* On iOS, respect notch */
        top: calc(env(safe-area-inset-top, 56px) + 68px);
    }
    .toast {
        max-width: none;
        min-width: unset;
        width: 100%;
    }
    /* Keep toast entrance/exit from the top on mobile */
    @keyframes toastIn {
        from { opacity: 0; transform: translateY(-12px); }
        to   { opacity: 1; transform: translateY(0); }
    }
    @keyframes toastOut {
        from { opacity: 1; transform: translateY(0); }
        to   { opacity: 0; transform: translateY(-12px); }
    }

    /* --- Alert cards --- */
    .alert-card { width: 100%; }
    .alert-card .alert-header { flex-wrap: wrap; gap: 6px; }

    /* --- Modal content --- */
    .add-account-modal-content {
        width: calc(100% - 32px);
        max-height: 80vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 20px;
        /* Slide up from bottom on mobile */
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
        position: fixed; bottom: 0; left: 0; right: 0;
        max-width: none;
        padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    }
    .add-account-modal-overlay { align-items: flex-end; }

    /* --- Clock status card: stack vertically --- */
    .clock-status-card { padding: 16px; }
    .clock-status-info {
        flex-direction: column; align-items: flex-start; gap: 8px; padding: 0;
    }
    .clock-actions { flex-direction: column; gap: 8px; }
    .clock-actions .btn,
    .clock-actions .btn-primary,
    .clock-actions .btn-secondary,
    .clock-actions .btn-clock-out { width: 100%; justify-content: center; }

    /* --- Login screen: fits smaller screens --- */
    .login-circle { width: 280px; height: 280px; }
    .login-logo { height: 72px; }
    .hint-avatar { width: 44px; height: 44px; }

    /* --- Item lists: full-bleed padding reduction --- */
    .item-list li { padding: 12px 14px; }

    /* --- Home view: 3-col on mobile --- */
    .home-greeting { padding-bottom: 28px; }
    .home-greeting-headline { font-size: 1.5rem; }
    .home-greeting-sub { font-size: var(--text-base); }
    .home-tools-grid { grid-template-columns: repeat(3, 1fr); gap: 10px; }
    .home-tool-card { min-height: 90px; padding: 14px 8px; }
    .home-tool-icon { width: 32px; height: 32px; }
    .home-tool-icon svg { width: 16px; height: 16px; }
    .home-clock-inner { flex-direction: column; align-items: flex-start; gap: 10px; }
    .home-clock-actions { margin-left: 0; width: 100%; }
    .home-clock-actions button { flex: 1; }

    /* --- Preview bar: compact on mobile --- */
    .preview-bar-inner { padding: 6px 12px; gap: 8px; }
    .preview-bar-label { display: none; }
    .preview-bar-icon { display: none; }
    .preview-bar-select-label { font-size: var(--text-xs); }
    .preview-exit-btn { font-size: var(--text-xs); padding: 4px 10px; }

    /* --- Coming soon badge visible on mobile --- */
    .nav-coming-soon { display: block; }

    /* --- Mobile profile dropdown positioning --- */
    .header-profile-dropdown.mobile-dropdown-active {
        position: fixed;
        top: 64px;
        right: 12px;
        z-index: 300;
    }
}

/* =============================================================
   SMALL PHONES  —  max-width: 480px
   Tighten spacing further; collapse to single column.
   ============================================================= */
@media (max-width: 480px) {

    /* Even tighter content padding */
    .content-container { padding: 12px 8px; }

    /* Single column for all grid-based card sets */
    .stat-grid,
    .hours-summary-cards,
    .tc-summary-grid { grid-template-columns: 1fr; gap: 8px; }

    /* Reduce card padding to maximise content space */
    .card { padding: 14px 12px; }

    /* Page title slightly smaller */
    .page-title { font-size: var(--text-lg); }
    .card-header h2 { font-size: var(--text-base); }

    /* Spend chart takes less vertical space */
    .spend-chart { height: 80px; }

    /* Time clock hero: compress */
    .tc-clock-hero { padding: 24px 12px 20px; }
    .tc-current-time { font-size: 2rem; }
    .tc-btn-clock-in,
    .tc-btn-clock-out { padding: 12px 28px; font-size: var(--text-base); width: 100%; }
    .tc-hero-actions { flex-direction: column; align-items: center; gap: 8px; }
    .tc-btn-break { width: 100%; text-align: center; }

    /* Login circle shrinks further */
    .login-circle { width: 240px; height: 240px; }
    .login-logo { height: 56px; }

    /* Tabs even more compact */
    .tab-item { padding: 8px 14px; font-size: var(--text-xs); }

    /* Home view: 2-col on small phones */
    .home-tools-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .home-tool-card { min-height: 84px; padding: 12px 8px; }
    .home-greeting-headline { font-size: 1.25rem; }
}

/* ---- Scrollbar (subtle) ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ---- Tool Test Results ---- */
.tool-test-result { margin-top: 0.5rem; text-align: left; }
.tool-test-loading { font-size: 0.75rem; color: var(--gray-500); }
.tool-test-summary { font-size: 0.75rem; font-weight: 600; padding: 2px 8px; border-radius: 4px; display: inline-block; margin-bottom: 0.25rem; }
.tool-test-pass { color: #15803d; background: #f0fdf4; }
.tool-test-error { color: #b91c1c; background: #fef2f2; }
.tool-test-warning { color: #a16207; background: #fefce8; }
.tool-test-checks { list-style: none; padding: 0; margin: 0.25rem 0 0; font-size: 0.7rem; }
.tool-test-checks li { padding: 1px 0; color: var(--gray-600); }
.tool-check-icon { font-weight: 700; }
.tool-check-pass .tool-check-icon { color: #15803d; }
.tool-check-error .tool-check-icon { color: #b91c1c; }
.tool-check-warning .tool-check-icon { color: #a16207; }

/* Content Header (notification bell area) */
.content-header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 8px 24px;
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg);
}
.content-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}
.notification-bell {
    position: relative;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 7px;
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.notification-bell:hover {
    background: var(--gray-100);
    color: var(--text-main);
    border-color: var(--gray-300);
}
.notification-bell svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
}
.notification-bell.has-alerts svg {
    animation: bellShake 0.6s ease-in-out;
}
.notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #DC2626;
    color: #fff;
    font-size: 0.6rem;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    line-height: 16px;
    text-align: center;
    border-radius: 8px;
    padding: 0 4px;
}
@keyframes bellShake {
    0%, 100% { transform: rotate(0deg); }
    15% { transform: rotate(14deg); }
    30% { transform: rotate(-14deg); }
    45% { transform: rotate(10deg); }
    60% { transform: rotate(-6deg); }
    75% { transform: rotate(2deg); }
}

/* Category badges on alert cards */
.category-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 4px;
    margin-left: 0.5rem;
    text-transform: capitalize;
}
.category-badge.cat-ad_monitoring { background: #EFF6FF; color: #1D4ED8; }
.category-badge.cat-email_urgency { background: #FEF3C7; color: #92400E; }
.category-badge.cat-hours_tracking { background: #F0FDF4; color: #15803D; }
.category-badge.cat-integration_failure { background: #FEF2F2; color: #991B1B; }
.category-badge.cat-system { background: #F3F4F6; color: #374151; }

/* Alert Center & Ad Monitoring Enhancements */
.alert-badge {
    display: inline-block;
    background: #DC2626;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 10px;
    margin-left: 6px;
    min-width: 16px;
    text-align: center;
    line-height: 1.4;
}

.alert-card {
    padding: 1rem;
    margin-bottom: 0.75rem;
    border-radius: 8px;
    border-left: 4px solid var(--border);
    background: var(--card-bg);
    transition: background 0.15s;
}
.alert-card:hover {
    background: var(--hover-bg, rgba(255,255,255,0.03));
}
.alert-card.severity-critical {
    border-left-color: #DC2626;
}
.alert-card.severity-warning {
    border-left-color: #F59E0B;
}
.alert-card.severity-info {
    border-left-color: #3B82F6;
}
.alert-card .alert-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}
.alert-card .alert-type {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 8px;
    border-radius: 4px;
    background: rgba(255,255,255,0.06);
}
.alert-card .alert-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
}
.alert-card .alert-message {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}
.alert-card .alert-account {
    font-size: 0.8rem;
    color: var(--text-secondary);
}
.alert-card .alert-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}
.alert-card.is-read {
    opacity: 0.7;
}

.connection-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #6B7280;
    vertical-align: middle;
}
.connection-dot.connected {
    background: #10B981;
}
.connection-dot.disconnected {
    background: #DC2626;
}
.connection-dot.unknown {
    background: #6B7280;
}

.payment-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    vertical-align: middle;
    margin-left: 6px;
}
.payment-badge.payment-healthy {
    background: rgba(16,185,129,0.15);
    color: #10B981;
}
.payment-badge.payment-declined {
    background: rgba(220,38,38,0.15);
    color: #DC2626;
}
.payment-badge.payment-warning {
    background: rgba(245,158,11,0.15);
    color: #F59E0B;
}

.ad-account-card {
    padding: 1rem;
    margin-bottom: 0.75rem;
    border-radius: 8px;
    background: var(--card-bg);
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    border: 1px solid var(--border);
}
.ad-account-card:hover {
    background: var(--hover-bg, rgba(255,255,255,0.03));
    transform: translateY(-1px);
}

.spend-chart {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 120px;
    padding: 0.5rem 0;
}
.spend-bar {
    flex: 1;
    background: #3B82F6;
    border-radius: 2px 2px 0 0;
    min-height: 2px;
    transition: height 0.3s;
    position: relative;
}
.spend-bar:hover {
    background: #60A5FA;
}
.spend-bar-label {
    position: absolute;
    bottom: -18px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.55rem;
    color: var(--text-secondary);
    white-space: nowrap;
}
.spend-total {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}
.spend-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.account-tab-content {
    padding: 1rem 0;
}

.severity-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}
.severity-badge.critical {
    background: rgba(220,38,38,0.15);
    color: #DC2626;
}
.severity-badge.warning {
    background: rgba(245,158,11,0.15);
    color: #F59E0B;
}
.severity-badge.info {
    background: rgba(59,130,246,0.15);
    color: #3B82F6;
}

/* Content header mobile override — must be after .content-header definition */
@media (max-width: 768px) {
    .content-header { display: none !important; }
}
