:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --background-color: #f8fafc;
    --card-background: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --success-color: #10b981;
    --error-color: #ef4444;
    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--background-color);
    color: var(--text-primary);
    line-height: 1.5;
    padding: 2rem;
}

.container {
    max-width: 1300px;
    margin: 0 auto;
    background-color: var(--card-background);
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

header {
    margin-bottom: 2rem;
    text-align: center;
}

h1 {
    font-size: 1.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-secondary);
}

.controls {
    display: flex;
    justify-content: center;
    margin-bottom: 2rem;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Loading State */
.btn-loading {
    position: relative;
    pointer-events: none;
    color: transparent !important;
}

.btn-loading::after {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    top: 50%;
    left: 50%;
    margin: -9px 0 0 -9px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.6s linear infinite;
}

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

.table-container {
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
}

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

th,
td {
    padding: 1rem;
    text-align: left;
    border: 1px solid var(--border-color);
    /* Full grid borders */
}

th {
    background-color: #e2e8f0;
    /* Slightly darker header */
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Zebra Striping */
tbody tr:nth-child(even) {
    background-color: #f8fafc;
}

/* Hover Effect */
tbody tr:hover {
    background-color: #dbeafe;
    /* Distinct light blue hover */
    transition: background-color 0.15s ease;
}

.placeholder-row {
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
}

.placeholder-row td {
    text-align: center;
    padding: 3rem;
}

.status-message {
    margin-top: 1.5rem;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    text-align: center;
    font-size: 0.9375rem;
    font-weight: 500;
    min-height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
    transform: translateY(10px);
}

.status-message.active {
    opacity: 1;
    transform: translateY(0);
}

.status-error {
    background-color: #fef2f2;
    color: var(--error-color);
    border: 1px solid #fee2e2;
}

.status-success {
    background-color: #f0fdf4;
    color: var(--success-color);
    border: 1px solid #dcfce7;
}

.status-normal {
    background-color: #f0f9ff;
    color: var(--primary-color);
    border: 1px solid #e0f2fe;
}

/* Secondary Button */
.btn-secondary {
    background-color: transparent;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
    background: #fff;
}

.btn-secondary:hover {
    background-color: #eff6ff;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease-out;
}

.modal-content {
    background: white;
    width: 90%;
    max-width: 600px;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    max-height: 80vh;
    animation: slideUp 0.3s ease-out;
}

.modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
}

.close-modal {
    font-size: 1.5rem;
    cursor: pointer;
    color: #999;
}

.close-modal:hover {
    color: #333;
}

.modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.search-input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
    margin-bottom: 10px;
}

.search-results {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto;
    max-height: 300px;
    border: 1px solid #eee;
    border-radius: 6px;
}

.search-results li {
    padding: 10px 15px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background 0.1s;
}

.search-results li:hover {
    background-color: #f0f9ff;
    color: var(--primary-color);
}

.search-results li:last-child {
    border-bottom: none;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Manual Row Styling */
.manual-row td {
    color: #d97706;
    /* Orange */
    font-weight: 500;
}

/* Delete Button */
.delete-btn {
    background: none;
    border: none;
    color: #ef4444;
    /* Red */
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    padding: 0 5px;
    line-height: 1;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.delete-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}


/* --- SIDEBAR MENU --- */
.menu-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    background: var(--primary-color);
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s;
}

.menu-btn:hover {
    transform: scale(1.05);
}

.menu-btn span {
    display: block;
    width: 24px;
    height: 3px;
    background: white;
    margin: 2px 0;
    border-radius: 2px;
}

/* Sidebar Container */
.side-menu {
    position: fixed;
    top: 0;
    right: -75%;
    /* Hidden initially */
    width: 75%;
    /* Requested 3/4 screen */
    height: 100vh;
    background: white;
    box-shadow: -5px 0 15px rgba(0, 0, 0, 0.1);
    z-index: 2001;
    /* Above button? No, button is 2000. Wait button should be outside or inside? */
    /* Let's put z-index higher */
    transition: right 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.side-menu.open {
    right: 0;
}

.side-menu-header {
    padding: 20px;
    background: var(--background-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.side-menu-header h2 {
    margin: 0;
    font-size: 1.25rem;
}

.close-menu-btn {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: var(--text-secondary);
    line-height: 1;
}

.side-menu-content {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
}

/* PILL SWITCH */
.view-toggle-container {
    display: flex;
    justify-content: center;
    margin-bottom: 2rem;
}

.pill-switch {
    position: relative;
    display: flex;
    background: #e2e8f0;
    border-radius: 30px;
    padding: 4px;
    width: 200px;
    height: 44px;
}

.pill-switch input {
    display: none;
}

.pill-switch label {
    flex: 1;
    text-align: center;
    cursor: pointer;
    z-index: 2;
    font-weight: 500;
    line-height: 36px;
    color: var(--text-secondary);
    transition: color 0.3s;
}

.pill-switch input:checked+label {
    color: var(--primary-color);
}

.pill-slider {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 50%;
    /* Approx half minus padding */
    width: calc(50% - 4px);
    height: 36px;
    background: white;
    border-radius: 26px;
    transition: transform 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 1;
}

/* Move slider logic based on checked input is tricky with CSS only if inputs are separate siblings.
   We can use general sibling selector.
*/
#viewAll:checked~.pill-slider {
    transform: translateX(0);
}

#viewDeal:checked~.pill-slider {
    transform: translateX(100%);
    /* We need to adjust for padding */
    transform: translateX(calc(100% + 4px));
    /* Wait, 100% of slider width (96px). Container width 200px. Padding 4px.
       Slider width ~ 96px.
       Left 4px.
       Target Left should be 200 - 4 - 96 = 100px.
       So transform X is roughly 100%.
       Actually 'calc(100% + 4px)' might be needed depending on box model.
       Let's simplify.
    */
    transform: translateX(96px);
}


/* All Deals List Styling */
.deals-list-container {
    margin-top: 1rem;
    overflow-x: auto;
}

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

.deals-table th,
.deals-table td {
    padding: 12px;
    border-bottom: 1px solid #eee;
}

.deals-table tr:hover {
    background-color: #f8fafc;
    cursor: pointer;
}

/* Custom Checkbox */
.big-checkbox {
    width: 20px;
    height: 20px;
    accent-color: #10b981;
    cursor: pointer;
}

.list-input {
    border: 1px solid #cbd5e1;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.9em;
    color: #334155;
    background: #fff;
}


/* --- DASHBOARD MODE OVERRIDES --- */
body.dashboard-mode {
    padding: 0;
    background-color: white;
}

/* Force expanded View in Dashboard Mode */
body.dashboard-mode .side-menu {
    position: static !important;
    width: 100% !important;
    right: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    height: auto !important;
    display: block !important;
    transform: none !important;
}

body.dashboard-mode .side-menu-content {
    padding: 20px;
    height: auto;
    overflow: visible;
}

body.dashboard-mode .side-menu-header,
body.dashboard-mode .menu-btn,
body.dashboard-mode .view-toggle-container,
body.dashboard-mode #singleDealView {
    display: none !important;
}

body.dashboard-mode .deals-list-container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    padding: 20px;
}

/* --- pending banner --- */
.pending-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin: 12px 0 18px;
    padding: 12px 16px;
    background: #fef9c3;
    border: 1px solid #fde047;
    border-radius: 8px;
    color: #713f12;
}
.pending-banner-text strong { margin-right: 6px; }
.pending-banner-actions { display: flex; gap: 8px; }
.link-btn {
    background: none;
    border: none;
    color: #2563eb;
    cursor: pointer;
    text-decoration: underline;
    padding: 0 6px;
    font: inherit;
}
.pending-details {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 14px;
}
.pending-block + .pending-block { border-top: 1px solid #fde68a; margin-top: 8px; padding-top: 8px; }
.pending-block-meta { color: #92400e; font-size: 0.85em; margin-bottom: 4px; }
.pending-block ul { margin: 0; padding-left: 18px; }

/* --- client-info layout --- */
.client-info {
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}
.client-info-grid {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 30px;
    align-items: start;
}
.client-info-grid p { margin-bottom: 6px; }
.urgent-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    cursor: pointer;
    font-weight: bold;
    color: #d32f2f;
    text-transform: uppercase;
}
.ops-fields { display: flex; flex-direction: column; gap: 8px; }
.field-row {
    display: flex;
    align-items: center;
    gap: 10px;
}
.field-row strong { white-space: nowrap; min-width: 140px; }
.field-row .list-input { flex: 1; padding: 6px; }
.paid-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: bold;
    padding-top: 6px;
    border-top: 1px solid #eee;
}
.big-checkbox { width: 18px; height: 18px; }
