:root {
        --bg-primary: #0f0f14;
        --bg-secondary: #1a1a24;
        --bg-tertiary: #252534;
        --bg-hover: #2a2a3e;
        --text-primary: #e4e4e7;
        --text-secondary: #a1a1aa;
        --text-muted: #71717a;
        --accent: #6366f1;
        --accent-hover: #7c7ff3;
        --success: #22c55e;
        --warning: #f59e0b;
        --danger: #ef4444;
        --border: #2a2a3e;
        --sidebar-width: 260px;

        /* Aliases for tokens referenced inline in admin/client pages.
           Keep these mapped to the canonical tokens above so undefined-var
           fallbacks don't silently drop to inherited/initial values. */
        --primary: var(--accent);
        --text: var(--text-primary);
        --surface: var(--bg-secondary);
        --surface-2: var(--bg-tertiary);
    }

    * {
        margin: 0;
        padding: 0;
        box-sizing: border-box;
    }

    body {
        font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
        background-color: var(--bg-primary);
        color: var(--text-primary);
        line-height: 1.6;
        overflow-x: hidden;
    }

    .app-container {
        display: flex;
        min-height: 100vh;
    }

    /* Sidebar Styles */
    .sidebar {
        width: var(--sidebar-width);
        background: var(--bg-secondary);
        border-right: 1px solid var(--border);
        position: fixed;
        top: 0;
        height: 100vh;
        overflow-y: auto;
        z-index: 1000;
        transition: transform 0.3s ease;
    }

    .sidebar-header {
        height: 64px;
        display: flex;
        align-items: center;
        padding: 0 1.5rem;
        border-bottom: 1px solid var(--border);
        background: var(--bg-secondary);
    }

    .logo {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        font-size: 1.25rem;
        font-weight: 700;
        color: var(--text-primary);
    }

    .logo i {
        color: var(--accent);
        font-size: 1.5rem;
    }

    .nav-menu {
        padding: 1rem 0;
    }

    .nav-item {
        position: relative;
    }

    .nav-link {
        display: flex;
        align-items: center;
        padding: 0.875rem 1.5rem;
        color: var(--text-secondary);
        text-decoration: none;
        transition: all 0.2s ease;
        cursor: pointer;
        border: none;
        background: none;
        width: 100%;
        text-align: left;
        font-size: 0.95rem;
    }

    .nav-link:hover {
        background: var(--bg-hover);
        color: var(--text-primary);
    }

    .nav-link.active {
        background: var(--bg-hover);
        color: var(--accent);
        border-left: 3px solid var(--accent);
    }

    .nav-link i {
        width: 20px;
        margin-right: 0.75rem;
        font-size: 1rem;
    }

    .nav-link .arrow {
        margin-left: auto;
        transition: transform 0.2s ease;
        font-size: 0.8rem;
    }

    .nav-link.expanded .arrow {
        transform: rotate(90deg);
    }

    .submenu {
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
        background: var(--bg-tertiary);
    }

    .submenu.open {
        max-height: 500px;
    }

    .submenu .nav-link {
        padding-left: 3.5rem;
        font-size: 0.875rem;
    }

    /* Main Content */
    .main-content {
        flex: 1;
        margin-left: var(--sidebar-width);
        padding: 2rem;
        padding-top: calc(64px + 2rem);
        min-height: 100vh;
    }

    .content-header {
        margin-bottom: 2rem;
    }

    .page-title {
        font-size: 2rem;
        font-weight: 700;
        margin-bottom: 0.5rem;
        color: var(--text-primary);
    }

    .breadcrumb {
        display: flex;
        gap: 0.5rem;
        color: var(--text-muted);
        font-size: 0.875rem;
    }

    .breadcrumb a {
        color: var(--text-secondary);
        text-decoration: none;
        transition: color 0.2s ease;
    }

    .breadcrumb a:hover {
        color: var(--accent);
    }

    /* Tabs */
    .tabs-container {
        background: var(--bg-secondary);
        border-radius: 0.75rem;
        padding: 1.5rem;
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    }

    .tabs-header {
        display: flex;
        gap: 1rem;
        border-bottom: 1px solid var(--border);
        margin-bottom: 1.5rem;
        align-items: center;
        flex-wrap: wrap;
    }

    .tab-button {
        padding: 0.75rem 1.5rem;
        background: none;
        border: none;
        color: var(--text-secondary);
        cursor: pointer;
        font-size: 0.95rem;
        font-weight: 500;
        position: relative;
        transition: all 0.2s ease;
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }

    .tab-button:hover {
        color: var(--text-primary);
    }

    .tab-button.active {
        color: var(--accent);
    }

    .tab-button.active::after {
        content: '';
        position: absolute;
        bottom: -1px;
        left: 0;
        right: 0;
        height: 2px;
        background: var(--accent);
    }

    .tab-badge {
        background: var(--bg-tertiary);
        padding: 0.125rem 0.5rem;
        border-radius: 0.375rem;
        font-size: 0.75rem;
        font-weight: 600;
    }

    .tab-button.active .tab-badge {
        background: var(--accent);
        color: white;
    }

    .tab-content {
        display: none;
    }

    .tab-content.active {
        display: block;
        animation: fadeIn 0.3s ease;
    }

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

    /* Refresh Button Styles */
    .refresh-button {
        margin-left: auto;
        padding: 0.5rem 1rem;
        background: var(--bg-tertiary);
        color: var(--text-secondary);
        border: 1px solid var(--border);
        border-radius: 0.375rem;
        cursor: pointer;
        font-size: 0.875rem;
        font-weight: 500;
        transition: all 0.2s ease;
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }

    .refresh-button:hover {
        background: var(--bg-hover);
        color: var(--text-primary);
        border-color: var(--accent);
    }

    .refresh-button i {
        transition: transform 0.5s ease;
    }

    .refresh-button.spinning i {
        animation: spin 1s linear infinite;
    }

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

    /* Search Box Styles */
    .search-container {
        position: relative;
        flex: 1;
        max-width: 300px;
        margin-right: 1rem;
    }

    .search-input {
        width: 100%;
        padding: 0.5rem 1rem 0.5rem 2.5rem;
        background: var(--bg-tertiary);
        border: 1px solid var(--border);
        border-radius: 0.375rem;
        color: var(--text-primary);
        font-size: 0.875rem;
        transition: all 0.2s ease;
    }

    .search-input:focus {
        outline: none;
        border-color: var(--accent);
        box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
    }

    .search-icon {
        position: absolute;
        left: 0.75rem;
        top: 50%;
        transform: translateY(-50%);
        color: var(--text-secondary);
        font-size: 0.875rem;
    }

    .clear-search {
        position: absolute;
        right: 0.75rem;
        top: 50%;
        transform: translateY(-50%);
        color: var(--text-secondary);
        cursor: pointer;
        font-size: 0.875rem;
        opacity: 0;
        transition: opacity 0.2s ease;
    }

    .search-input:not(:placeholder-shown) ~ .clear-search {
        opacity: 1;
    }

    .clear-search:hover {
        color: var(--text-primary);
    }

    /* Table Styles */
    .data-table {
        width: 100%;
        border-collapse: collapse;
    }

    .data-table thead {
        background: var(--bg-tertiary);
    }

    .data-table th {
        padding: 1rem;
        text-align: left;
        font-weight: 600;
        color: var(--text-secondary);
        font-size: 0.875rem;
        text-transform: uppercase;
        letter-spacing: 0.025em;
    }

    .data-table tbody tr {
        border-bottom: 1px solid var(--border);
        transition: background 0.2s ease;
    }

    .data-table tbody tr:hover {
        background: var(--bg-hover);
    }

    .data-table td {
        padding: 1rem;
        color: var(--text-primary);
    }

    /* Updated photo thumbnail styles - LARGER SIZE */
    .photo-thumbnail {
        width: 80px;  /* Increased from 50px */
        height: 80px; /* Increased from 50px */
        border-radius: 0.5rem;
        object-fit: cover;
        border: 2px solid var(--border);
        transition: transform 0.2s ease, box-shadow 0.2s ease;
    }

    /* Add a hover effect for thumbnails */
    .photo-thumbnail:hover {
        transform: scale(1.1);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    }

    .client-name {
        font-weight: 600;
        color: var(--text-primary);
    }

    .time-badge {
        display: inline-flex;
        align-items: center;
        gap: 0.25rem;
        padding: 0.25rem 0.75rem;
        background: var(--bg-tertiary);
        border-radius: 0.375rem;
        font-size: 0.875rem;
        color: var(--text-secondary);
    }

    .time-badge i {
        font-size: 0.75rem;
    }

    .email-cell {
        color: var(--text-secondary);
        font-size: 0.875rem;
    }

    .action-button {
        padding: 0.5rem 1rem;
        background: var(--accent);
        color: white;
        border: none;
        border-radius: 0.375rem;
        cursor: pointer;
        font-size: 0.875rem;
        font-weight: 500;
        transition: all 0.2s ease;
        display: inline-flex;
        align-items: center;
        gap: 0.5rem;
    }

    .action-button:hover {
        background: var(--accent-hover);
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
    }

    /* Status Badge */
    .status-badge {
        display: inline-flex;
        align-items: center;
        gap: 0.375rem;
        padding: 0.25rem 0.75rem;
        border-radius: 0.375rem;
        font-size: 0.75rem;
        font-weight: 600;
    }

    .status-badge.waiting {
        background: rgba(245, 158, 11, 0.1);
        color: var(--warning);
    }

    .status-badge.finished {
        background: rgba(34, 197, 94, 0.1);
        color: var(--success);
    }

    .status-badge i {
        font-size: 0.625rem;
    }

    /* NEW: Make all links in tables white */
    .data-table a {
        color: white !important;
    }

    /* NEW: Keep links white even after being visited */
    .data-table a:visited {
        color: white !important;
    }

    /* NEW: Add a subtle hover effect for better UX */
    .data-table a:hover {
        color: var(--accent) !important;
        text-decoration: underline;
    }

    /* No results message */
    .no-results {
        text-align: center;
        padding: 2rem;
        color: var(--text-secondary);
    }

    .no-results i {
        font-size: 2rem;
        margin-bottom: 1rem;
        color: var(--text-muted);
    }

    /* Search indicator */
    .search-indicator {
        display: inline-flex;
        align-items: center;
        gap: 0.5rem;
        margin-left: 1rem;
        padding: 0.25rem 0.75rem;
        background: rgba(99, 102, 241, 0.1);
        border-radius: 0.375rem;
        font-size: 0.875rem;
        color: var(--accent);
    }

    .search-indicator i {
        font-size: 0.75rem;
    }

    /* Mobile Menu Toggle */
    .mobile-menu-toggle {
        display: none;
        position: fixed;
        top: 1rem;
        left: 1rem;
        z-index: 1001;
        background: var(--bg-secondary);
        border: 1px solid var(--border);
        color: var(--text-primary);
        padding: 0.75rem;
        border-radius: 0.5rem;
        cursor: pointer;
    }

    /* Responsive */
    @media (max-width: 768px) {
        .sidebar {
            transform: translateX(-100%);
        }

        .sidebar.open {
            transform: translateX(0);
        }

        .main-content {
            margin-left: 0;
            padding: 1rem;
            padding-top: calc(64px + 1rem);
        }

        .topbar {
            left: 0;
            padding: 0 1rem 0 3.75rem;   /* leave room for the fixed hamburger */
        }

        .user-menu-name { display: none; }

        .mobile-menu-toggle {
            display: block;
        }

        .data-table {
            font-size: 0.875rem;
        }

        .data-table th,
        .data-table td {
            padding: 0.75rem 0.5rem;
        }

        /* Updated mobile thumbnail size */
        .photo-thumbnail {
            width: 60px;  /* Increased from 40px */
            height: 60px; /* Increased from 40px */
        }

        .tabs-header {
            flex-wrap: wrap;
        }

        .refresh-button {
            width: 100%;
            margin-top: 0.5rem;
            margin-left: 0;
        }

        .search-container {
            width: 100%;
            max-width: none;
            margin-right: 0;
            margin-bottom: 0.5rem;
        }
    }

    /* Scrollbar Styles */
    ::-webkit-scrollbar {
        width: 8px;
        height: 8px;
    }

    ::-webkit-scrollbar-track {
        background: var(--bg-primary);
    }

    ::-webkit-scrollbar-thumb {
        background: var(--bg-tertiary);
        border-radius: 4px;
    }

    ::-webkit-scrollbar-thumb:hover {
        background: var(--border);
    }

/* Alert Message Styles */
    .alert {
        padding: 1rem;
        margin-bottom: 1.5rem;
        border-radius: 0.375rem;
        display: flex;
        align-items: center;
        gap: 0.75rem;
    }

    .alert-success {
        background: rgba(34, 197, 94, 0.1);
        border: 1px solid var(--success);
        color: var(--success);
    }

    .alert-warning {
        background: rgba(245, 158, 11, 0.1);
        border: 1px solid var(--warning);
        color: var(--warning);
    }

    .alert-danger {
        background: rgba(239, 68, 68, 0.1);
        border: 1px solid var(--danger);
        color: var(--danger);
    }

    @keyframes slideIn {
        from {
            transform: translateX(100%);
            opacity: 0;
        }
        to {
            transform: translateX(0);
            opacity: 1;
        }
    }
    @keyframes slideOut {
        from {
            transform: translateX(0);
            opacity: 1;
        }
        to {
            transform: translateX(100%);
            opacity: 0;
        }
    }

/* Flash messages */
.flash { padding: 1rem; margin-bottom: 1.5rem; border-radius: 0.5rem; display: flex; align-items: center; gap: 0.75rem; }
.flash-success { background: rgba(34,197,94,0.1); border: 1px solid var(--success); color: var(--success); }
.flash-error   { background: rgba(239,68,68,0.1);  border: 1px solid var(--danger);  color: var(--danger);  }
.flash-warning { background: rgba(245,158,11,0.1); border: 1px solid var(--warning); color: var(--warning); }

/* Forms */
.form-group  { margin-bottom: 1.25rem; }
.form-label  { display: block; margin-bottom: 0.4rem; color: var(--text-secondary); font-size: 0.9rem; }
.form-input  { width: 100%; padding: 0.625rem 0.875rem; background: var(--bg-tertiary); border: 1px solid var(--border); border-radius: 0.375rem; color: var(--text-primary); font-size: 0.95rem; }
.form-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(99,102,241,0.2); }
.form-select { width: 100%; padding: 0.625rem 0.875rem; background: var(--bg-tertiary); border: 1px solid var(--border); border-radius: 0.375rem; color: var(--text-primary); font-size: 0.95rem; }
.btn         { display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.625rem 1.25rem; border-radius: 0.375rem; font-size: 0.95rem; font-weight: 500; cursor: pointer; border: none; transition: all 0.2s; text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--bg-tertiary); color: var(--text-secondary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-danger  { background: rgba(239,68,68,0.15); color: var(--danger); border: 1px solid var(--danger); }
.btn-danger:hover { background: rgba(239,68,68,0.25); }
.btn-sm      { padding: 0.375rem 0.75rem; font-size: 0.825rem; }

/* Status badges */
.badge        { display: inline-block; padding: 0.2rem 0.6rem; border-radius: 0.375rem; font-size: 0.75rem; font-weight: 600; }
.badge-active  { background: rgba(34,197,94,0.15);  color: var(--success); }
.badge-pending { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge-admin   { background: rgba(99,102,241,0.15); color: var(--accent);  }

/* Avatar */
.avatar      { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.avatar-icon { width: 36px; height: 36px; border-radius: 50%; background: var(--bg-tertiary); display: inline-flex; align-items: center; justify-content: center; color: var(--text-secondary); }

/* Topbar */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    height: 64px;
    padding: 0 2rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    z-index: 900;
}
.topbar-title { font-size: 1rem; font-weight: 600; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.user-menu { position: relative; flex-shrink: 0; }
.user-menu-trigger {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-primary);
    padding: 0.25rem 0.5rem;
    border-radius: 0.5rem;
    transition: background 0.2s ease;
}
.user-menu-trigger:hover { background: var(--bg-hover); }
.user-menu-name  { font-size: 0.9rem; font-weight: 500; }
.user-menu-caret { font-size: 0.7rem; color: var(--text-muted); transition: transform 0.2s ease; }
.user-menu.open .user-menu-caret { transform: rotate(180deg); }

.user-menu-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 0.5rem);
    min-width: 190px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    padding: 0.4rem;
    display: none;
    z-index: 1000;
}
.user-menu.open .user-menu-dropdown { display: block; }
.user-menu-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.6rem 0.75rem;
    border-radius: 0.4rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
}
.user-menu-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.user-menu-item i { width: 16px; text-align: center; }
.user-menu-sep { border: none; border-top: 1px solid var(--border); margin: 0.4rem 0; }

/* Auth pages */
.auth-wrapper { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.auth-card    { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 0.75rem; padding: 2.5rem; width: 100%; max-width: 420px; }
.auth-logo    { text-align: center; margin-bottom: 2rem; font-size: 1.5rem; font-weight: 700; color: var(--text-primary); }
.auth-logo i  { color: var(--accent); margin-right: 0.5rem; }
.auth-title   { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.25rem; }
.auth-subtitle { color: var(--text-secondary); margin-bottom: 1.75rem; font-size: 0.9rem; }
.auth-footer  { text-align: center; margin-top: 1.5rem; color: var(--text-secondary); font-size: 0.875rem; }
.auth-footer a { color: var(--accent); text-decoration: none; }

/* Empty state */
.empty-state  { text-align: center; padding: 3rem; color: var(--text-muted); }
.empty-state i { font-size: 3rem; margin-bottom: 1rem; display: block; }

/* Page header actions */
.page-header-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; }

/* Toggle switch */
.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch-slider {
    position: absolute; inset: 0; cursor: pointer;
    background: var(--border); border-radius: 24px;
    transition: background 0.2s;
}
.switch-slider::before {
    content: ""; position: absolute; height: 18px; width: 18px;
    left: 3px; top: 3px; background: #fff; border-radius: 50%;
    transition: transform 0.2s;
}
.switch input:checked + .switch-slider { background: var(--accent); }
.switch input:checked + .switch-slider::before { transform: translateX(18px); }
.switch input:focus-visible + .switch-slider { outline: 2px solid var(--accent-hover); outline-offset: 2px; }
.switch input:disabled + .switch-slider { opacity: 0.5; cursor: default; }

/* Rich action tooltips (multi-sentence, right-anchored for actions columns) */
.has-tip { position: relative; }
.has-tip::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 10px);
    right: 0;
    width: max-content;
    max-width: 260px;
    white-space: normal;
    text-align: left;
    line-height: 1.45;
    padding: 0.6rem 0.7rem;
    font-size: 0.78rem;
    font-weight: 400;
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transform: translateY(4px);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s ease;
    pointer-events: none;
    z-index: 100;
}
.has-tip::before {
    content: "";
    position: absolute;
    bottom: calc(100% + 5px);
    right: 12px;
    border: 6px solid transparent;
    border-top-color: var(--bg-tertiary);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, visibility 0.15s ease;
    pointer-events: none;
    z-index: 101;
}
.has-tip:hover::after,
.has-tip:focus-visible::after { opacity: 1; visibility: visible; transform: translateY(0); }
.has-tip:hover::before,
.has-tip:focus-visible::before { opacity: 1; visibility: visible; }

.quota-banner {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem 1rem;
    margin: 0 0 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
}
.quota-banner a { margin-left: auto; font-weight: 600; text-decoration: none; white-space: nowrap; }
.quota-banner--warn { background: #fff4e0; color: #8a5a00; border: 1px solid #f0c97a; }
.quota-banner--warn a { color: #8a5a00; }
.quota-banner--full { background: #fdecea; color: #a12622; border: 1px solid #f0a8a3; }
.quota-banner--full a { color: #a12622; }
