:root {
    /* Brand Colors */
    --color-primary: #002366;
    /* Deep Navy Blue */
    --color-secondary: #B22234;
    /* Red */
    --color-accent: #bf953f;
    /* Gold */

    /* Dark Theme Palette */
    --color-bg: #0f172a;
    --color-sidebar: #1e293b;
    --color-surface: rgba(255, 255, 255, 0.05);
    /* Glass effect base */
    --color-surface-hover: rgba(255, 255, 255, 0.1);
    --color-text: #f8fafc;
    --color-text-muted: #cbd5e1;
    /* Increased contrast from #94a3b8 */

    /* Layout */
    --sidebar-width: 260px;
    --header-height: 80px;
    --radius-lg: 12px;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--color-bg);
    background: radial-gradient(circle at top right, #1e3a8a 0%, var(--color-bg) 60%);
    color: var(--color-text);
    min-height: 100vh;
    overflow: hidden;
    /* App-like feel */
}

/* --- UTILITIES --- */
.hidden {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* focus-visible for high contrast accessibility */
:focus-visible {
    outline: 2px solid var(--color-accent) !important;
    outline-offset: 2px !important;
}

/* Admin Visibility System */
.admin-only {
    display: none !important;
}

body.is-admin .admin-only {
    display: inline-flex !important;
}

.glass-panel {
    background: var(--color-surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.input-field {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.6rem 0.8rem;
    border-radius: 6px;
    color: white;
    margin-bottom: 1rem;
    font-size: 0.75rem;
    transition: 0.2s;
}

.input-field:focus {
    outline: none;
    border-color: var(--color-accent);
}

.agreement-scrollable:focus {
    outline: 2px solid var(--color-accent);
    outline-offset: -2px;
}

/* --- BUTTONS --- */
.btn {
    background: var(--color-accent);
    color: #1e293b;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--color-text);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    cursor: pointer;
    transition: 0.2s;
    display: inline-flex;
    align-items: center;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* --- SCREENS --- */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 2rem;
}

/* Agreement Screen Styles */
.agreement-container {
    width: 90%;
    max-width: 800px;
    padding: 2.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    animation: fadeInScale 0.5s ease-out;
}

.agreement-scrollable {
    max-height: 400px;
    overflow-y: auto;
    padding: 1.5rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 0.9rem;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.9);
}

.agreement-scrollable h3 {
    color: var(--color-accent);
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

.agreement-scrollable p {
    margin-bottom: 1rem;
}

.agreement-scrollable strong {
    color: var(--color-text);
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* --- LOGIN SCREEN --- */
.login-container {
    display: flex;
    gap: 4rem;
    align-items: center;
    max-width: 1000px;
    width: 100%;
}

.info-side {
    flex: 1;
    text-align: right;
}

.login-form-side {
    flex: 0 0 400px;
    padding: 2.5rem;
}

.logo-display {
    width: 240px;
    margin-bottom: 2rem;
}

.clock-widget {
    font-size: 4rem;
    font-weight: 200;
    line-height: 1;
}

.date-display {
    font-size: 1.2rem;
    color: var(--color-text-muted);
}

/* --- SIDEBAR LAYOUT --- */
.sidebar {
    width: var(--sidebar-width);
    background: rgba(0, 0, 0, 0.3);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(20px);
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.nav-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-link {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    border-radius: 8px;
    transition: 0.2s;
    text-align: left;
    font-size: 0.95rem;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

.nav-link.active {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-left: 3px solid var(--color-accent);
}

.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.avatar-small {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --- MAIN CONTENT --- */
.main-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.top-header {
    height: var(--header-height);
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(0, 0, 0, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.header-widget {
    background: rgba(255, 255, 255, 0.05);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.content-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
}

/* --- DATA TABLES --- */
.search-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    width: 300px;
}

.search-bar input {
    background: transparent;
    border: none;
    color: white;
    width: 100%;
    outline: none;
}

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

.data-table th {
    text-align: left;
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--color-text-muted);
    font-weight: 500;
    font-size: 0.9rem;
}

.data-table td {
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 0.95rem;
}

.data-table tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

/* --- MODALS --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    width: 100%;
    max-width: 500px;
    padding: 2rem;
    background: #1e293b;
    /* Solid color for readability */
}

#contract-modal .input-field {
    padding: 0.5rem 0.6rem;
    margin-bottom: 0;
    /* Slightly reduced padding too */
}

#contract-modal .modal-content {
    overflow-y: hidden;
    /* explicit remove */
    max-height: 95vh;
    /* Ensure it can grow if needed, or fit screen */
}

#contract-modal .modal-footer {
    margin-top: 0.25rem;
    /* Reduced further */
}

/* --- CLIENT MODAL COMPACT STYLES --- */
#client-modal .input-field {
    margin-bottom: 0;
    padding: 0.5rem 0.6rem;
}

#client-modal .modal-footer {
    margin-top: 0.5rem;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 2rem;
}

.close-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
}

/* --- TOM SELECT DARK THEME OVERRIDES --- */
.ts-control {
    background: rgba(0, 0, 0, 0.3) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: white !important;
    border-radius: 6px !important;
    padding: 0.6rem 0.8rem !important;
}

.ts-control input {
    color: white !important;
}

.ts-control input::placeholder {
    color: var(--color-text-muted) !important;
}

.ts-dropdown {
    background: #1e293b !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: white !important;
    border-radius: 6px !important;
    margin-top: 4px !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2) !important;
    z-index: 1050 !important;
}

.ts-dropdown .option {
    padding: 0.6rem 0.8rem !important;
    color: white !important;
    transition: background 0.1s;
}

.ts-dropdown .active {
    background: rgba(255, 255, 255, 0.1) !important;
    color: white !important;
}

.ts-dropdown .selected {
    background: var(--color-accent) !important;
    color: #1e293b !important;
}

.ts-dropdown .create:hover,
.ts-dropdown .option:hover,
.ts-dropdown .active:hover {
    background: rgba(255, 255, 255, 0.1) !important;
}

/* --- PRINT STYLES --- */
@media print {

    /* Base color overrides for print */
    body {
        --color-bg: #ffffff;
        --color-sidebar: transparent;
        --color-surface: transparent;
        --color-surface-hover: transparent;
        --color-text: #000000;
        --color-text-muted: #333333;
    }

    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* Hide elements that shouldn't print */
    .sidebar,
    .top-header,
    .tabs,
    .modal-tabs,
    .btn:not(.print-btn),
    .btn-secondary:not(.print-btn),
    .search-bar {
        display: none !important;
    }

    /* Reset layout wrapper sizes to allow multiple pages */
    body,
    html,
    #main-menu-screen,
    .main-body,
    .content-wrapper,
    .view-section {
        height: auto !important;
        min-height: auto !important;
        max-height: none !important;
        overflow: visible !important;
        position: static !important;
        background-color: #ffffff !important;
        background-image: none !important;
    }

    /* Force text colors in print so white text isn't invisible */
    body,
    .main-body,
    .content-wrapper,
    .view-section,
    .glass-panel,
    h1,
    h2,
    h3,
    h4,
    p,
    span,
    div,
    label {
        color: #000000 !important;
    }

    /* Ensure glass panels render nicely but keep their intrinsic display */
    .glass-panel {
        background: #ffffff !important;
        border: 1px solid #ccc !important;
        margin-bottom: 20px !important;
        box-shadow: none !important;
        height: auto !important;
        overflow: visible !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        page-break-inside: auto !important;
    }

    /* Inputs shouldn't be white on white */
    .input-field {
        background: #ffffff !important;
        color: #000000 !important;
        border: 1px solid #999 !important;
    }

    /* Tables */
    .data-table th,
    .data-table td {
        color: #000000 !important;
        border-bottom: 1px solid #ddd !important;
    }

    .print-btn {
        display: none !important;
    }
}