:root {
    --primary-color: #0056b3;
    --danger-color: #dc3545;
    --border-color: #ced4da;
    --bg-color: #f8f9fa;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.5;
    color: #333;
    background-color: #f0f2f5;
}

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

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding: 1rem;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.app-author {
    font-size: 0.9rem;
    color: #666;
}

.button-group {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.form-section {
    background-color: white;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.section-title {
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.form-label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 500;
}

.form-input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0,86,179,0.25);
}

.form-input.invalid {
    border-color: var(--danger-color);
}

.details-grid {
    display: grid;
    grid-template-areas: 
        "invoice"
        "supplier"
        "customer";
    gap: 1rem;
    margin-bottom: 1rem;
}

.invoice-details {
    grid-area: invoice;
}

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

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

.button {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    background-color: var(--primary-color);
    color: white;
    min-width: fit-content;
}

.button:hover {
    opacity: 0.9;
}

.button-secondary {
    background-color: #6c757d;
}

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

.button-small {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

.line-item, 
.allowance-charge {
    background-color: white;
    padding: 1rem 2.5rem 1rem 1rem;
    border-radius: 4px;
    margin-bottom: 0.5rem;
    border: 1px solid var(--border-color);
    position: relative;
}

.vat-row,
.identification-row {
    background-color: white;
    padding: 0.25rem;
    border-radius: 4px;
    margin-bottom: 0.25rem;
    border: 1px solid var(--border-color);
    position: relative;
}

.delete-line-item,
.delete-allowance-charge,
.delete-identification {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    width: 20px !important;
    height: 20px !important;
    padding: 0 !important;
    font-size: 12px !important;
    line-height: 1 !important;
    min-width: auto !important;
    flex: 0 0 auto !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.optional-details {
    margin-top: 0.5rem;
    padding: 0.75rem;
    background-color: var(--bg-color);
    border-radius: 4px;
}

.optional-details-content {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.identifications-container {
    width: 100%;
}

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

.identifications-header h4 {
    margin: 0;
    font-size: 0.9rem;
}

.identification-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.identifications-list {
    display: flex;
    flex-direction: column;
    margin-top: 0;
}

.identification-row {
    margin: 0;
    padding: 0.25rem;
}

.identification-content {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 0.25rem;
    align-items: center;
}

.identification-content .scheme-select {
    width: 150px;
    min-width: 150px;
}

.identification-content input[type="text"] {
    flex: 1;
    min-width: 0;
}

.date-input-container {
    display: flex;
    gap: 0.5rem;
}

.calendar-button {
    padding: 0.5rem;
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
}

.totals {
    background-color: white;
    padding: 1.5rem;
    border-radius: 8px;
    margin-top: 1rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

.total-row:last-child {
    border-bottom: none;
}

.total-row-final {
    font-weight: bold;
    font-size: 1.2rem;
    margin-top: 1rem;
    border-top: 2px solid var(--border-color);
}

.editable-total {
    cursor: pointer;
}

/* Updated VAT breakdown layout */
.vat-row .total-row {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.5rem;
    position: relative;
}

.vat-inputs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    width: 100%;
    padding-right: 30px;
}

.vat-inputs > label {
    min-width: 100px;
    text-align: left;
    margin: 0;
}

.vat-inputs > input,
.vat-inputs > select {
    min-width: 150px;
    flex: 1;
    margin: 0;
}

.vat-inputs > input[type="text"] {
    min-width: 100px;
}

.vat-exemption {
    display: flex;
    gap: 1rem;
    width: 100%;
}

.vat-exemption .form-group {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}

.vat-exemption label {
    white-space: nowrap;
    margin: 0;
    min-width: 100px;
}

.vat-exemption .form-input {
    flex: 1;
}

.note-input {
    resize: vertical;
    min-height: 100px;
}

.note-counter {
    text-align: right;
    font-size: 0.8rem;
    color: #666;
    margin-top: 0.25rem;
}

.app-footer {
    text-align: center;
    margin-top: 2rem;
    padding: 1rem;
}

.app-footer a {
    color: var(--primary-color);
    text-decoration: none;
}

.hidden {
    display: none !important;
}

.file-input {
    display: none;
}

@media (max-width: 1200px) {
    .vat-inputs {
        flex-wrap: wrap;
    }
    
    .vat-exemption {
        flex-direction: column;
    }
    
    .vat-exemption .form-group {
        width: 100%;
    }
}

@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .button-group {
        flex-wrap: wrap;
        justify-content: center;
    }

    .vat-inputs {
        gap: 0.5rem;
    }

    .vat-inputs > label {
        min-width: 100px;
        text-align: left;
    }

    .vat-inputs > input,
    .vat-inputs > select {
        width: calc(100% - 110px);
    }

    .vat-exemption {
        flex-direction: column;
        width: 100%;
    }

    .identification-content {
        grid-template-columns: 1fr auto;
    }
    
    .scheme-select {
        grid-column: 1 / -1;
    }
}