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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.6;
    background: linear-gradient(135deg, #f8fafc 0%, #ffffff 50%, #f1f5f9 100%);
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Header */
.header {
    background: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border-bottom: 1px solid #e2e8f0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 0;
}

.logo-container {
    width: 3.5rem;
    height: 3.5rem;
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.logo-placeholder span {
    font-size: 1.5rem;
    color: white;
}

.header-text h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 0.25rem;
}

.header-text p {
    font-size: 0.875rem;
    color: #64748b;
}

.nav {
    margin-left: auto;
    display: flex;
    gap: 0.5rem;
}

.nav-link {
    padding: 0.5rem 1rem;
    text-decoration: none;
    color: #64748b;
    font-weight: 500;
    border-radius: 0.5rem;
    transition: all 0.2s;
}

.nav-link:hover {
    background: #f1f5f9;
    color: #3b82f6;
}

.nav-link.active {
    background: #3b82f6;
    color: white;
}

/* Main Content */
.main {
    padding: 2rem 0;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.content-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
    align-items: start;
}

@media (min-width: 1200px) {
    .content-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* Form Styles */
.form-section {
    background: white;
    border-radius: 1rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
    padding: 2rem;
}

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

.form-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 0.5rem;
}

.form-header p {
    color: #64748b;
}

.form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.form-section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 2rem 0 1rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #f1f5f9;
}

.form-section-title h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: #1e293b;
}

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

@media (min-width: 768px) {
    .form-row {
        grid-template-columns: 1fr 1fr;
    }
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    font-size: 1rem;
    transition: all 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Buttons */
.btn-primary {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: white;
    font-weight: 600;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
    transform: translateY(-1px);
}

.btn-secondary {
    background: #f8fafc;
    color: #475569;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-secondary:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.btn-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    font-weight: 600;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-success:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4);
    transform: translateY(-1px);
}

.btn-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    font-weight: 600;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.btn-warning:hover {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
    box-shadow: 0 6px 16px rgba(245, 158, 11, 0.4);
    transform: translateY(-1px);
}

/* Inventory List */
.inventory-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.inventory-item {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    padding: 1rem;
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    gap: 1rem;
    align-items: center;
}

.inventory-item-info h4 {
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 0.25rem;
}

.inventory-item-info p {
    font-size: 0.875rem;
    color: #64748b;
}

.inventory-item-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.quantity-btn {
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 0.25rem;
    width: 2rem;
    height: 2rem;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s;
}

.quantity-btn:hover {
    background: #2563eb;
}

.quantity {
    font-weight: 600;
    min-width: 2rem;
    text-align: center;
}

.inventory-item-price {
    font-weight: 600;
    color: #059669;
}

.inventory-item-remove {
    background: #fee2e2;
    color: #dc2626;
    border: none;
    border-radius: 0.25rem;
    padding: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

.inventory-item-remove:hover {
    background: #fecaca;
}

/* Preview Section */
.preview-section {
    background: white;
    border-radius: 1rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
    padding: 2rem;
    position: sticky;
    top: 6rem;
}

.preview-section h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 1.5rem;
}

.contract-preview {
    background: #f8fafc;
    border: 2px dashed #cbd5e1;
    border-radius: 0.5rem;
    padding: 2rem;
    min-height: 400px;
}

.preview-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #94a3b8;
    text-align: center;
}

.placeholder-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

/* Inventory Management */
.inventory-management {
    background: white;
    border-radius: 1rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
    padding: 2rem;
}

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

.inventory-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e293b;
}

.inventory-filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
}

.search-box {
    position: relative;
    flex: 1;
}

.search-box input {
    width: 100%;
    padding: 0.75rem 2.5rem 0.75rem 1rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    font-size: 1rem;
}

.search-icon {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
}

.inventory-filters select {
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    font-size: 1rem;
    min-width: 200px;
}

.inventory-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.inventory-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    padding: 1.5rem;
    transition: all 0.2s;
}

.inventory-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.inventory-card h4 {
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 0.5rem;
}

.inventory-card .category {
    display: inline-block;
    background: #dbeafe;
    color: #1e40af;
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    margin-bottom: 0.5rem;
}

.inventory-card .price {
    font-size: 1.125rem;
    font-weight: 700;
    color: #059669;
    margin-bottom: 0.5rem;
}

.inventory-card .description {
    font-size: 0.875rem;
    color: #64748b;
    margin-bottom: 1rem;
}

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

.btn-small {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    border-radius: 0.375rem;
}

/* Inventory Selector */
.inventory-selector-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
    max-height: 400px;
    overflow-y: auto;
    margin: 1rem 0;
}

.inventory-selector-item {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    padding: 1rem;
    transition: all 0.2s;
    cursor: pointer;
}

.inventory-selector-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.inventory-selector-item h4 {
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 0.5rem;
}

.inventory-selector-item .category {
    display: inline-block;
    background: #dbeafe;
    color: #1e40af;
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    margin-bottom: 0.5rem;
}

.inventory-selector-item .price {
    font-size: 1rem;
    font-weight: 700;
    color: #059669;
    margin-bottom: 0.5rem;
}

.inventory-selector-item .description {
    font-size: 0.875rem;
    color: #64748b;
    margin-bottom: 1rem;
}

/* History Section */
.history-section {
    background: white;
    border-radius: 1rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
    padding: 2rem;
}

.history-section h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 2rem;
}

.history-filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
}

.history-filters input,
.history-filters select {
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    font-size: 1rem;
}

.history-filters input {
    flex: 1;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.history-item {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    padding: 1.5rem;
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 1rem;
    align-items: center;
}

.history-item-info h4 {
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 0.25rem;
}

.history-item-info p {
    font-size: 0.875rem;
    color: #64748b;
}

.history-item-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

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

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

.status-completed {
    background: #dbeafe;
    color: #1e40af;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 1rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-large {
    max-width: 900px;
}

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

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1e293b;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #64748b;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 0.25rem;
    transition: all 0.2s;
}

.modal-close:hover {
    background: #f1f5f9;
    color: #1e293b;
}

.modal-form {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

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

/* Beautiful Modal Styles */
.beautiful-modal {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 1.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
    overflow: hidden;
    max-width: 450px;
}

.beautiful-modal .modal-header {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
}

.beautiful-modal .modal-content-inner {
    background: white;
    padding: 2rem;
}

.beautiful-modal .modal-icon {
    width: 4rem;
    height: 4rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    font-size: 1.5rem;
    color: white;
    box-shadow: 0 10px 25px -5px rgba(102, 126, 234, 0.4);
}

.beautiful-modal h3 {
    text-align: center;
    color: #1e293b;
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.beautiful-modal p {
    text-align: center;
    color: #64748b;
    margin-bottom: 2rem;
    line-height: 1.6;
}

.beautiful-modal .modal-actions {
    justify-content: center;
    gap: 1rem;
}

.beautiful-modal .btn-option {
    min-width: 120px;
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    font-weight: 600;
    transition: all 0.3s;
    border: none;
    cursor: pointer;
}

.beautiful-modal .btn-option.primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.beautiful-modal .btn-option.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.6);
}

.beautiful-modal .btn-option.secondary {
    background: #f8fafc;
    color: #475569;
    border: 1px solid #e2e8f0;
}

.beautiful-modal .btn-option.secondary:hover {
    background: #f1f5f9;
    transform: translateY(-1px);
}

/* Status Change Modal */
.status-modal .status-option {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 0.75rem;
    margin-bottom: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.status-modal .status-option:hover {
    border-color: #3b82f6;
    background: #f8fafc;
}

.status-modal .status-option.selected {
    border-color: #3b82f6;
    background: #dbeafe;
}

.status-modal .status-icon {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: white;
}

.status-modal .status-draft .status-icon {
    background: #f59e0b;
}

.status-modal .status-signed .status-icon {
    background: #10b981;
}

.status-modal .status-completed .status-icon {
    background: #3b82f6;
}

.status-modal .status-info h4 {
    margin: 0;
    color: #1e293b;
    font-weight: 600;
}

.status-modal .status-info p {
    margin: 0;
    color: #64748b;
    font-size: 0.875rem;
}

/* Email Modal */
.email-modal .email-preview {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    padding: 1rem;
    margin: 1rem 0;
}

.email-modal .email-preview h4 {
    color: #1e293b;
    margin-bottom: 0.5rem;
}

.email-modal .email-preview p {
    color: #64748b;
    font-size: 0.875rem;
    margin: 0;
}

.email-modal .checkbox-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: #f8fafc;
    border-radius: 0.5rem;
    margin: 1rem 0;
}

.email-modal .checkbox-container input[type="checkbox"] {
    width: 1.25rem;
    height: 1.25rem;
    accent-color: #3b82f6;
}

.email-modal .checkbox-container label {
    color: #1e293b;
    font-weight: 500;
    cursor: pointer;
}

/* Signing Modal */
.signing-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    padding: 1.5rem;
}

.contract-display {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    padding: 1.5rem;
    max-height: 500px;
    overflow-y: auto;
    font-size: 0.875rem;
    line-height: 1.6;
}

.signature-section h4 {
    font-size: 1.125rem;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 0.5rem;
}

.signature-section p {
    color: #64748b;
    margin-bottom: 1rem;
}

.signature-pad-container {
    border: 2px solid #e2e8f0;
    border-radius: 0.5rem;
    padding: 1rem;
    background: white;
}

#signaturePad {
    border: 1px dashed #cbd5e1;
    border-radius: 0.25rem;
    cursor: crosshair;
    width: 100%;
    height: 200px;
}

.signature-controls {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
    justify-content: space-between;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed !important;
    inset: 0 !important;
    background: rgba(0, 0, 0, 0.5) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 2000 !important;
    visibility: visible !important;
}

.loading-overlay.hidden {
    display: none !important;
    visibility: hidden !important;
}

.loading-content {
    background: white;
    padding: 2rem;
    border-radius: 1rem;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.spinner {
    width: 2rem;
    height: 2rem;
    border: 3px solid #e5e7eb;
    border-top: 3px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 0 1rem;
    }
    
    .header-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .nav {
        margin-left: 0;
        width: 100%;
    }
    
    .form-section,
    .preview-section,
    .inventory-management,
    .history-section {
        padding: 1.5rem;
    }
    
    .content-grid {
        gap: 1.5rem;
    }
    
    .inventory-filters {
        flex-direction: column;
    }
    
    .history-filters {
        flex-direction: column;
    }
    
    .signing-content {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        margin: 1rem;
        max-width: none;
    }
    
    .inventory-item {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    
    .history-item {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    
    .history-item-actions {
        justify-content: flex-start;
    }
}

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