/* Shared dashboard layout */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.dashboard-title h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--foreground);
    margin-bottom: 0.25rem;
}

.dashboard-title p {
    color: var(--muted-foreground);
    font-size: 0.9rem;
}

.search-box {
    position: relative;
    width: 280px;
}

.search-box input {
    width: 100%;
    height: 2.5rem;
    padding: 0.5rem 0.75rem 0.5rem 2.5rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 0.625rem;
    font-size: 0.875rem;
    color: var(--foreground);
    outline: none;
    transition: all 0.2s ease;
}

.search-box input:focus {
    border-color: var(--foreground);
    box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.08);
}

.search-box svg {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--muted-foreground);
    pointer-events: none;
}

.filters,
.filters-bar,
.action-buttons {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: center;
}

.filter-select {
    height: 2.5rem;
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 0.625rem;
    font-size: 0.875rem;
    color: var(--foreground);
    cursor: pointer;
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    background-size: 1rem;
}

.filter-select:focus {
    border-color: var(--foreground);
    box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.08);
}

.date-input {
    height: 2.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 0.625rem;
    font-size: 0.875rem;
    color: var(--foreground);
    outline: none;
}

.date-input:focus {
    border-color: var(--foreground);
    box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.08);
}

.filter-chips {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.filter-chip,
.advanced-filter-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.625rem;
    background: var(--muted);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-size: 0.75rem;
    color: var(--foreground);
}

.filter-chip button,
.advanced-filter-tag button {
    background: none;
    border: none;
    color: var(--muted-foreground);
    cursor: pointer;
    line-height: 1;
    padding: 0;
    font-size: 0.95rem;
}

.filter-chip button:hover,
.advanced-filter-tag button:hover {
    color: var(--error);
}

.advanced-filters {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}

.advanced-filter-builder {
    display: grid;
    grid-template-columns: minmax(160px, 220px) minmax(140px, 180px) minmax(180px, 1fr) auto;
    gap: 0.625rem;
    align-items: center;
}

.advanced-filter-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.column-filters {
    margin-bottom: 1rem;
}

.column-filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 0.625rem;
}

.column-filter-item {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.column-filter-label {
    font-size: 0.72rem;
    color: var(--muted-foreground);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
}

.column-filter-control {
    width: 100%;
}

.column-filter-actions {
    margin-top: 0.6rem;
    display: flex;
    justify-content: flex-end;
}

.table-wrapper {
    background: var(--card);
    border-radius: 1rem;
    border: 1px solid var(--border);
    overflow-x: auto;
    overflow-y: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.table-wrapper .data-table {
    min-width: 980px;
}

.data-table th {
    position: sticky;
    top: 0;
    white-space: nowrap;
}

.data-table td {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}

.data-table td.address-cell,
.data-table td[data-label*="Address"],
.data-table td[data-label*="address"] {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    word-break: break-word;
    max-width: 360px;
    line-height: 1.3;
}

.data-table td[data-label="Actions"] {
    max-width: none;
    overflow: visible;
}

.action-btns {
    display: flex;
    gap: 0.5rem;
}

.action-btn {
    padding: 0.375rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--foreground);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

.action-btn:hover {
    background: var(--muted);
    border-color: #cbd5e1;
}

.action-btn svg {
    width: 14px;
    height: 14px;
}

.action-btn.primary {
    background: var(--foreground);
    color: var(--primary-foreground);
    border: none;
}

.action-btn.primary:hover {
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.15);
}

.status-badge {
    display: inline-flex;
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.025em;
    white-space: nowrap;
}

.status-presented {
    background: #dbeafe;
    color: #2563eb;
}

.status-bidcreated {
    background: #dbeafe;
    color: #1d4ed8;
}

.status-inreviewbycustomer {
    background: #fef3c7;
    color: #b45309;
}

.status-negotiating {
    background: #ede9fe;
    color: #6d28d9;
}

.status-awarded {
    background: #dcfce7;
    color: #16a34a;
}

.status-denied {
    background: #fee2e2;
    color: #b91c1c;
}

.amount-cell {
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', monospace;
    font-weight: 600;
    color: var(--foreground);
}

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
}

.empty-state svg {
    width: 64px;
    height: 64px;
    color: var(--muted-foreground);
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--foreground);
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--muted-foreground);
    font-size: 0.9rem;
}

.kpi-section {
    margin-bottom: 2rem;
}

.kpi-title {
    font-size: 0.8rem;
    color: var(--muted-foreground);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
    margin-bottom: 0.75rem;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.875rem;
}

.kpi-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 0.875rem;
    padding: 1rem 1.1rem;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.kpi-card:hover {
    transform: translateY(-2px);
    border-color: #cbd5e1;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

.kpi-label {
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted-foreground);
    font-weight: 600;
    margin-bottom: 0.35rem;
}

.kpi-value {
    font-size: 1.25rem;
    line-height: 1.2;
    font-weight: 700;
    color: var(--foreground);
}

.kpi-subtext {
    margin-top: 0.3rem;
    font-size: 0.75rem;
    color: var(--muted-foreground);
}

/* Shared bid/detail/history modal */
#bidModal .modal,
#historyModal .modal {
    background: var(--card);
    border-radius: 1rem;
    width: 90%;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
}

#bidModal .modal {
    max-width: 1100px;
}

#historyModal .modal {
    max-width: 600px;
}

#modalContent {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
}

.modal-body {
    display: flex;
    width: 100%;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.modal-main {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1.5rem;
}

.modal-sidebar {
    width: 380px;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
    background: var(--muted);
    border-radius: 0 1rem 1rem 0;
    border: 1px solid var(--border);
    position: relative;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
}

.modal-sidebar-header {
    padding: 1.25rem 1.5rem;
    background: linear-gradient(135deg, var(--foreground) 0%, rgba(15, 23, 42, 0.85) 100%);
    flex-shrink: 0;
}

.sidebar-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary-foreground);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}

.sidebar-title svg {
    width: 18px;
    height: 18px;
    color: var(--primary-foreground);
    opacity: 0.9;
}

.sidebar-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem;
}

.sidebar-content::-webkit-scrollbar {
    width: 6px;
}

.sidebar-content::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-content::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.sidebar-content::-webkit-scrollbar-thumb:hover {
    background: #cbd5e1;
}

.modal-main::-webkit-scrollbar {
    width: 8px;
}

.modal-main::-webkit-scrollbar-track {
    background: var(--muted);
    border-radius: 4px;
}

.modal-main::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.modal-main::-webkit-scrollbar-thumb:hover {
    background: #cbd5e1;
}

#bidModal .modal-header,
#historyModal .modal-header,
#editBidModal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0;
}

#bidModal .modal-title,
#historyModal .modal-title,
#editBidModal .modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--foreground);
}

#bidModal .modal-close,
#historyModal .modal-close,
#editBidModal .modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--muted-foreground);
    cursor: pointer;
    padding: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    transition: all 0.2s ease;
}

#bidModal .modal-close:hover,
#historyModal .modal-close:hover,
#editBidModal .modal-close:hover {
    background: var(--muted);
    color: var(--foreground);
}

.history-timeline {
    padding: 0;
}

.history-item {
    position: relative;
    padding: 1rem 1rem 1rem 2.75rem;
    margin-bottom: 0.75rem;
    background: var(--card);
    border-radius: 0.75rem;
    border: 1px solid var(--border);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    animation: fadeInHistory 0.3s ease-out;
}

.history-item:hover {
    border-color: #cbd5e1;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    transform: translateY(-1px);
}

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

.history-item::before {
    content: '';
    position: absolute;
    left: 1rem;
    top: 1.25rem;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--foreground);
    border: 2.5px solid var(--card);
    box-shadow: 0 0 0 2px var(--border);
    z-index: 1;
}

.history-item.admin-change::before {
    background: linear-gradient(135deg, #8b5cf6, #a855f7);
    box-shadow: 0 0 0 2px var(--card), 0 0 0 4px rgba(139, 92, 246, 0.2);
}

.history-item.estimator-change::before {
    background: linear-gradient(135deg, #10b981, #34d399);
    box-shadow: 0 0 0 2px var(--card), 0 0 0 4px rgba(16, 185, 129, 0.2);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
    gap: 0.375rem;
}

.history-user {
    font-weight: 600;
    color: var(--foreground);
    font-size: 0.8rem;
    letter-spacing: 0.01em;
}

.history-role {
    font-size: 0.65rem;
    padding: 0.2rem 0.5rem;
    border-radius: 9999px;
    margin-left: 0.375rem;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.05em;
}

.history-role.admin {
    background: linear-gradient(135deg, #f3e8ff, #e9d5ff);
    color: #9333ea;
    border: 1px solid rgba(147, 51, 234, 0.1);
}

.history-role.estimator {
    background: linear-gradient(135deg, #dcfce7, #d1fae5);
    color: #16a34a;
    border: 1px solid rgba(22, 163, 74, 0.1);
}

.history-date {
    font-size: 0.7rem;
    color: var(--muted-foreground);
    font-weight: 500;
}

.history-field {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted-foreground);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.5rem;
}

.history-change {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    flex-wrap: wrap;
    padding: 0.625rem;
    background: var(--muted);
    border-radius: 0.5rem;
    border: 1px solid var(--border);
}

.history-old {
    color: var(--error);
    text-decoration: line-through;
    opacity: 0.8;
    font-weight: 400;
}

.history-new {
    color: var(--success);
    font-weight: 600;
}

.history-arrow {
    color: var(--muted-foreground);
    font-weight: 500;
}

.edit-bid-button {
    display: inline-flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.75rem 1.5rem;
    background: var(--foreground);
    color: var(--primary-foreground);
    border: none;
    border-radius: 0.75rem;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.12);
}

.edit-bid-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.2);
    background: var(--foreground);
}

.edit-bid-button:active {
    transform: translateY(0);
}

.edit-bid-button svg {
    width: 18px;
    height: 18px;
}

/* Shared workflow forms (status / follow-up / phase edit) */
.workflow-form {
    padding: 1.25rem 1.5rem 1.5rem;
}

.workflow-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.9rem;
}

.workflow-group.full {
    grid-column: 1 / -1;
}

.workflow-group label {
    display: block;
    font-size: 0.82rem;
    color: var(--muted-foreground);
    margin-bottom: 0.35rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}

.workflow-group input,
.workflow-group select,
.workflow-group textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 0.6rem;
    padding: 0.55rem 0.7rem;
    font-size: 0.88rem;
    background: var(--card);
    color: var(--foreground);
}

.workflow-group input[readonly] {
    background: var(--muted);
}

.workflow-group textarea {
    min-height: 86px;
    resize: vertical;
}

.workflow-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
    margin-top: 1rem;
}

.workflow-switch {
    display: inline-flex;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.workflow-switch .btn.active {
    background: var(--foreground);
    color: var(--primary-foreground);
}

.workflow-file-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-top: 0.6rem;
}

.file-item,
.workflow-file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    background: var(--card);
    font-size: 0.85rem;
    gap: 0.5rem;
}

.file-item span,
.workflow-file-item span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.upload-zone {
    border: 2px dashed var(--border);
    border-radius: 0.75rem;
    padding: 1.25rem;
    text-align: center;
    background: var(--muted);
    cursor: pointer;
    transition: all 0.2s ease;
}

.upload-zone.drag {
    border-color: var(--foreground);
    background: var(--border);
}

.action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

/* Shared edit bid modal layout */
.edit-form {
    padding: 1.5rem;
    max-height: calc(90vh - 180px);
    overflow-y: auto;
}

.edit-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.edit-form-group {
    margin-bottom: 1rem;
}

.edit-form-group.full-width {
    grid-column: 1 / -1;
}

.edit-form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--foreground);
    margin-bottom: 0.5rem;
}

.edit-form-input {
    width: 100%;
    height: 2.5rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-size: 0.875rem;
    outline: none;
    transition: all 0.2s ease;
}

.edit-form-input:focus {
    border-color: var(--foreground);
    box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.08);
}

.edit-form-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    background: var(--card);
    flex-shrink: 0;
}

#editBidModal {
    align-items: flex-start;
    padding: 1rem;
}

#editBidModal .modal {
    width: 100%;
    max-width: 900px !important;
    max-height: calc(100vh - 2rem);
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    margin: 0 auto;
}

#editBidContent {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
}

#editBidForm {
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
}

#editBidModal .edit-form {
    flex: 1;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    padding: 1.5rem;
}

#editBidModal .edit-form-actions {
    border-top: 1px solid var(--border);
    background: var(--card);
    padding: 1rem 1.5rem calc(1rem + env(safe-area-inset-bottom, 0px));
    position: sticky;
    bottom: 0;
    z-index: 2;
}

#historyModal .modal {
    overflow: visible;
}

@media (max-width: 768px) {
    .table-wrapper {
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        overflow: visible !important;
    }

    .table-wrapper .data-table {
        min-width: 0 !important;
        width: 100% !important;
    }

    .dashboard-header {
        flex-direction: column;
        align-items: stretch;
    }

    .search-box {
        width: 100%;
    }

    .filters,
    .filters-bar,
    .action-buttons {
        width: 100%;
    }

    .action-btn {
        justify-content: center;
    }

    .advanced-filter-builder {
        grid-template-columns: 1fr;
    }

    .filter-select {
        width: 100%;
    }

    .kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .data-table td {
        max-width: none !important;
        white-space: normal !important;
        overflow: visible !important;
        text-overflow: clip !important;
    }

    .data-table td.address-cell,
    .data-table td[data-label*="Address"],
    .data-table td[data-label*="address"] {
        align-items: flex-start;
    }
}

@media (max-width: 640px) {
    .modal-body {
        flex-direction: column;
    }

    .modal-main {
        border-right: none;
        border-bottom: 1px solid var(--border);
        max-height: 50vh;
    }

    .modal-sidebar {
        width: 100%;
        max-height: 40vh;
        border-radius: 0 0 1rem 1rem;
    }

    .edit-form-grid {
        grid-template-columns: 1fr;
    }

    .workflow-grid {
        grid-template-columns: 1fr;
    }

    #editBidModal {
        padding: 0.5rem;
    }

    #editBidModal .modal {
        max-height: calc(100vh - 1rem);
    }

    #editBidModal .edit-form-actions {
        padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
        flex-wrap: wrap;
        justify-content: stretch;
    }

    #editBidModal .edit-form-actions .btn {
        flex: 1 1 calc(50% - 0.375rem);
    }
}

@media (max-width: 480px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }
}
