/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --success: #16a34a;
    --warning: #ca8a04;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-500: #6b7280;
    --gray-700: #374151;
    --gray-900: #111827;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--gray-100);
    color: var(--gray-900);
    line-height: 1.5;
}

/* Navigation */
.navbar {
    background: var(--gray-900);
    color: white;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand a {
    color: white;
    text-decoration: none;
    font-size: 1.25rem;
    font-weight: 600;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
}

.nav-link {
    color: var(--gray-300);
    text-decoration: none;
}

.nav-link:hover {
    color: white;
}

.nav-separator {
    color: var(--gray-500);
}

.nav-logout {
    color: #fca5a5;
}

.nav-logout:hover {
    color: #fef2f2;
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

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

.page-header h1 {
    font-size: 1.75rem;
}

.header-actions {
    display: flex;
    gap: 0.75rem;
}

.header-left {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.back-link {
    color: var(--gray-500);
    text-decoration: none;
    font-size: 0.875rem;
}

.back-link:hover {
    color: var(--primary);
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: background 0.15s;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-300);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: var(--danger-hover);
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Cards */
.job-card {
    background: white;
    border-radius: 0.5rem;
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: box-shadow 0.15s;
}

.job-card:hover {
    box-shadow: var(--shadow-md);
}

.job-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.job-card-header h3 {
    font-size: 1.125rem;
}

.job-card-body p {
    color: var(--gray-500);
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}

.job-card-footer {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--gray-200);
}

.date {
    color: var(--gray-500);
    font-size: 0.75rem;
}

/* Status badges */
.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.status-draft {
    background: var(--gray-200);
    color: var(--gray-700);
}

.status-quoted {
    background: #fef3c7;
    color: #92400e;
}

.status-accepted {
    background: #d1fae5;
    color: #065f46;
}

/* Tables */
.components-table-wrapper,
.items-table-wrapper {
    background: white;
    border-radius: 0.5rem;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.components-table,
.items-table,
.suggestions-table {
    width: 100%;
    border-collapse: collapse;
}

.components-table th,
.components-table td,
.items-table th,
.items-table td,
.suggestions-table th,
.suggestions-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

.components-table th,
.items-table th,
.suggestions-table th {
    background: var(--gray-50);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--gray-500);
}

.components-table td.number,
.items-table td.number {
    text-align: right;
    font-family: monospace;
}

.components-table td.total,
.items-table td.total {
    font-weight: 600;
}

.components-table td.actions,
.items-table td.actions {
    text-align: right;
    white-space: nowrap;
}

.item-code {
    background: var(--gray-100);
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    margin-right: 0.5rem;
    font-family: monospace;
}

.tier-badge {
    background: #dbeafe;
    color: #1e40af;
    padding: 0.125rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.7rem;
    margin-left: 0.5rem;
    font-weight: 500;
}

/* Filters */
.filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.search-box input {
    width: 300px;
    padding: 0.5rem 1rem;
    border: 1px solid var(--gray-300);
    border-radius: 0.375rem;
}

.category-filter select {
    padding: 0.5rem 1rem;
    border: 1px solid var(--gray-300);
    border-radius: 0.375rem;
    background: white;
}

/* Job detail layout */
.job-layout {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 2rem;
}

.job-files-section,
.job-items-section {
    background: white;
    border-radius: 0.5rem;
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

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

.section-header h2 {
    font-size: 1.125rem;
}

/* Files list */
.files-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.file-card {
    padding: 0.75rem;
    background: var(--gray-50);
    border-radius: 0.375rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.file-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.file-icon {
    font-size: 1.25rem;
}

.file-name {
    font-size: 0.875rem;
    word-break: break-all;
}

.file-actions {
    display: flex;
    gap: 0.5rem;
}

.file-upload-btn {
    cursor: pointer;
}

/* Job totals */
.job-totals {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 2px solid var(--gray-200);
}

.total-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    font-size: 0.875rem;
}

.total-row .amount {
    font-family: monospace;
    font-weight: 500;
}

.total-row.grand-total {
    font-size: 1.125rem;
    font-weight: 600;
    border-top: 1px solid var(--gray-200);
    margin-top: 0.5rem;
    padding-top: 1rem;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 0.5rem;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content.modal-large {
    max-width: 800px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--gray-200);
}

.modal-header h2 {
    font-size: 1.25rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--gray-500);
}

.modal-close:hover {
    color: var(--gray-900);
}

/* Forms */
form {
    padding: 1.5rem;
}

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

.form-group label {
    display: block;
    margin-bottom: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: 0.375rem;
    font-size: 0.875rem;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--gray-200);
    margin: 0 -1.5rem -1.5rem;
}

/* Import help */
.import-help {
    background: var(--gray-50);
    padding: 1rem;
    border-radius: 0.375rem;
    margin-bottom: 1rem;
}

.import-help p {
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.import-help ul {
    margin-left: 1.5rem;
    font-size: 0.75rem;
}

.import-help code {
    background: var(--gray-200);
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
}

.import-result {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--gray-200);
}

/* States */
.loading {
    text-align: center;
    color: var(--gray-500);
    padding: 2rem;
}

.empty-state {
    text-align: center;
    color: var(--gray-500);
    padding: 2rem;
}

.error {
    color: var(--danger);
}

.success {
    color: var(--success);
}

/* Responsive */
@media (max-width: 768px) {
    .job-layout {
        grid-template-columns: 1fr;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .filters {
        flex-direction: column;
    }

    .search-box input {
        width: 100%;
    }

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