* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f3f4f6;
    color: #1f2937;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

/* Header */
.header {
    background: white;
    padding: 24px 0;
    margin-bottom: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    font-size: 28px;
    font-weight: 700;
    color: #1f2937;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: #2563eb;
    color: white;
}

.btn-primary:hover {
    background: #1d4ed8;
}

.btn-secondary {
    background: #6b7280;
    color: white;
}

.btn-secondary:hover {
    background: #4b5563;
}

.btn-success {
    background: #16a34a;
    color: white;
    padding: 8px 16px;
    font-size: 13px;
}

.btn-success:hover {
    background: #15803d;
}

.btn-danger {
    background: #dc2626;
    color: white;
    padding: 8px;
}

.btn-danger:hover {
    background: #b91c1c;
}

.icon {
    font-size: 18px;
}

/* Card */
.card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    overflow: hidden;
}

/* Table */
.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background: #f9fafb;
    border-bottom: 2px solid #e5e7eb;
}

th {
    padding: 16px 24px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: #6b7280;
    letter-spacing: 0.05em;
}

td {
    padding: 16px 24px;
    border-bottom: 1px solid #e5e7eb;
}

tbody tr:hover {
    background: #f9fafb;
}

.text-center {
    text-align: center;
}

.empty-state {
    padding: 48px 24px;
    color: #6b7280;
}

.customer-info {
    display: flex;
    flex-direction: column;
}

.customer-name {
    font-weight: 500;
    color: #1f2937;
}

.customer-email {
    font-size: 13px;
    color: #6b7280;
}

.invoice-total {
    font-weight: 600;
    color: #1f2937;
}

/* Actions */
.actions {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.action-btn {
    padding: 8px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 18px;
}

.action-btn.view {
    background: #dbeafe;
    color: #2563eb;
}

.action-btn.view:hover {
    background: #bfdbfe;
}

.action-btn.edit {
    background: #dcfce7;
    color: #16a34a;
}

.action-btn.edit:hover {
    background: #bbf7d0;
}

.action-btn.delete {
    background: #fee2e2;
    color: #dc2626;
}

.action-btn.delete:hover {
    background: #fecaca;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    overflow-y: auto;
    padding: 20px;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1);
}

.modal-large {
    max-width: 1000px;
}

.modal-header {
    padding: 24px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 24px;
    font-weight: 700;
    color: #1f2937;
}

.modal-actions {
    display: flex;
    gap: 12px;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

/* Form */
.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    margin-bottom: 8px;
}

.required {
    color: #dc2626;
}

input, textarea {
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s;
    font-family: inherit;
}

input:focus, textarea:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

h3 {
    font-size: 18px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 16px;
}

/* Items */
.items-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.item-row {
    display: grid;
    grid-template-columns: 5fr 2fr 3fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}

.item-row input {
    width: 100%;
}

.item-row-auto {
    display: grid;
    grid-template-columns: 2fr 1.5fr 1.5fr 1.5fr 1fr 1.5fr 0.5fr;
    gap: 12px;
    margin-bottom: 12px;
    align-items: center;
}

.item-row-auto input,
.item-row-auto select {
    width: 100%;
}

.item-row-auto select {
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s;
    font-family: inherit;
    background: white;
    cursor: pointer;
}

.item-row-auto select:disabled {
    background: #f3f4f6;
    cursor: not-allowed;
}

.item-row-auto select:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Total Box */
.total-box {
    background: #f9fafb;
    padding: 16px;
    border-radius: 8px;
    margin-top: 16px;
}

.total-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 14px;
}

.total-final {
    border-top: 2px solid #d1d5db;
    margin-top: 8px;
    padding-top: 12px;
    font-size: 18px;
    font-weight: 700;
}

.total-final span:last-child {
    color: #2563eb;
}

/* Preview Invoice */
.invoice-preview {
    background: white;
    padding: 32px;
}

.invoice-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid #2563eb;
}

.company-logo-section {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.company-logo {
    flex-shrink: 0;
}

.logo-img {
    width: 80px !important;
    height: 80px !important;
    object-fit: contain;
    border-radius: 6px;
}

.logo-placeholder {
    width: 50px !important;
    height: 50px !important;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
    overflow: hidden;
}

.logo-placeholder img {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain;
    max-width: 50px !important;
    max-height: 50px !important;
}

.company-full-info {
    flex: 1;
}

.invoice-title h1 {
    font-size: 28px;
    font-weight: 700;
    color: #1f2937;
}

.invoice-number {
    color: #6b7280;
    margin-top: 4px;
}

.company-info {
    text-align: right;
}

.company-info h2 {
    font-size: 16px;
    font-weight: 700;
    color: #1f2937;
}

.company-info p {
    font-size: 11px;
    color: #6b7280;
    margin-top: 2px;
}

.invoice-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

.detail-section h3 {
    font-size: 12px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 8px;
}

.detail-section p {
    font-size: 11px;
    color: #6b7280;
    margin-bottom: 2px;
}

.detail-section .name {
    font-weight: 600;
    color: #1f2937;
    font-size: 12px;
}

.detail-right {
    text-align: right;
}

.invoice-items {
    margin-bottom: 24px;
}

.invoice-items table {
    margin-top: 0;
}

.invoice-items thead {
    background: #f3f4f6;
    border-bottom: 2px solid #d1d5db;
}

.invoice-items th {
    padding: 8px;
    font-size: 11px;
}

.invoice-items td {
    padding: 8px;
    font-size: 11px;
}

.invoice-summary {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 24px;
}

.summary-box {
    width: 280px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 11px;
}

.summary-total {
    border-top: 2px solid #d1d5db;
    margin-top: 6px;
    padding-top: 8px;
    font-size: 14px;
    font-weight: 700;
}

.summary-total span:last-child {
    color: #2563eb;
}

.invoice-notes {
    border-top: 1px solid #e5e7eb;
    padding-top: 16px;
    margin-bottom: 24px;
}

.invoice-notes h3 {
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 6px;
}

.invoice-notes p {
    font-size: 10px;
    color: #6b7280;
}

.bank-info {
    background: #f0f9ff;
    border: 2px solid #2563eb;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 20px;
}

.bank-info h3 {
    font-size: 12px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 8px;
}

.bank-details {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.bank-details p {
    font-size: 10px;
    color: #374151;
    margin: 0;
}

.bank-details strong {
    color: #1f2937;
    display: block;
    margin-bottom: 2px;
}

.invoice-footer {
    text-align: center;
    padding-top: 16px;
    border-top: 1px solid #e5e7eb;
    color: #6b7280;
    font-size: 10px;
}

/* Print Styles */
@media print {
    @page {
        size: A4;
        margin: 10mm;
    }
    
    body {
        background: white;
        margin: 0;
        padding: 0;
    }
    
    /* Sembunyikan semua kecuali invoice */
    body > *:not(#previewModal) {
        display: none !important;
    }
    
    .no-print {
        display: none !important;
    }
    
    .modal {
        position: static;
        background: white;
        padding: 0;
        display: block !important;
        height: auto;
        overflow: visible;
    }
    
    .modal-content {
        box-shadow: none;
        max-height: none;
        max-width: none;
        border-radius: 0;
        overflow: visible;
    }
    
    .modal-header,
    .modal-actions {
        display: none !important;
    }
    
    .modal-body {
        padding: 0;
    }
    
    .invoice-preview {
        padding: 0;
        page-break-after: avoid;
    }
    
    .invoice-header {
        margin-bottom: 16px;
        padding-bottom: 12px;
    }
    
    .logo-placeholder {
        width: 50px;
        height: 50px;
    }
    
    .invoice-details {
        margin-bottom: 16px;
        gap: 16px;
    }
    
    .invoice-items {
        margin-bottom: 16px;
    }
    
    .invoice-items table {
        page-break-inside: avoid;
    }
    
    .invoice-items th,
    .invoice-items td {
        padding: 6px;
        font-size: 10px;
    }
    
    .invoice-summary {
        margin-bottom: 16px;
    }
    
    .bank-info {
        padding: 10px;
        margin-bottom: 12px;
        page-break-inside: avoid;
    }
    
    .invoice-notes {
        margin-bottom: 16px;
        padding-top: 12px;
    }
    
    .invoice-footer {
        padding-top: 12px;
    }
    
    /* Pastikan tidak ada page break di tengah section penting */
    .invoice-header,
    .invoice-details,
    .bank-info,
    .invoice-footer {
        page-break-inside: avoid;
    }
    
    /* Sembunyikan header dan footer browser saat print */
    @page {
        margin-top: 0;
        margin-bottom: 0;
    }
    
    body::before,
    body::after {
        display: none !important;
    }
    
    /* Hapus URL dan tanggal print dari browser */
    html::before,
    html::after {
        display: none !important;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .item-row {
        grid-template-columns: 1fr;
    }
    
    .item-row-auto {
        grid-template-columns: 1fr;
    }
    
    .header .container {
        flex-direction: column;
        gap: 16px;
    }
    
    .invoice-details {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .detail-right {
        text-align: left;
    }
    
    .company-info {
        text-align: left;
    }
    
    .invoice-header {
        flex-direction: column;
        gap: 16px;
    }
    
    .company-logo-section {
        flex-direction: column;
    }
    
    .bank-details {
        grid-template-columns: 1fr;
    }
}