:root {
    --bg-color: #f3f4f6;
    --surface-color: #ffffff;
    --text-primary: #111827;
    --text-secondary: #4b5563;
    --border-color: #e5e7eb;
    --primary-color: #138708;
    --primary-hover: #107207;
    --secondary-color: #FF9935;
    --secondary-hover: #E68A30;
    --error-color: #ef4444;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --radius-md: 8px;
    --radius-lg: 12px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.5;
}

/* Layout */
.app-container {
    display: flex;
    flex-wrap: wrap;
    height: 100vh;
    overflow-y: auto;
}

.form-pane {
    flex: 1 1 35vw;
    min-width: 320px;
    background-color: var(--surface-color);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 2rem;
    box-shadow: var(--shadow-md);
    z-index: 10;
}

.preview-pane {
    flex: 1 1 55vw;
    background-color: #e2e8f0;
    overflow: auto;
    padding: 2rem;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.actions {
    display: flex;
    gap: 0.5rem;
}

/* Buttons */
button {
    cursor: pointer;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}
.btn-primary:hover { background-color: var(--primary-hover); }

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
}
.btn-secondary:hover { background-color: var(--secondary-hover); }

/* Forms */
.form-section {
    margin-bottom: 2rem;
    background: #fafafa;
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.form-section h2 {
    font-size: 1.125rem;
    margin-bottom: 1rem;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.input-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-group { display: flex; flex-direction: column; }
.form-group.full-width { grid-column: span 2; }

label {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--text-secondary);
}

input, select, textarea {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.875rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* Table */
.table-responsive {
    overflow-x: auto;
}
.items-entry-table {
    width: 100%;
    min-width: 280px;
    border-collapse: collapse;
}
.items-entry-table th {
    text-align: left;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    padding: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}
.items-entry-table td {
    padding: 0.5rem;
}
.items-entry-table input, .items-entry-table select {
    width: 100%;
}
.btn-remove {
    background: var(--error-color);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-md);
    font-size: 0.75rem;
}

/* Hide spin buttons for GST input since it uses a datalist */
.item-gst::-webkit-outer-spin-button,
.item-gst::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.item-gst {
    -moz-appearance: textfield;
    appearance: textfield;
}

.mt-2 { margin-top: 1rem; }
.whitespace-pre { white-space: pre-wrap; }

/* Totals */
.totals-summary p { margin: 0.25rem 0; color: var(--text-secondary); }
.totals-summary h3 { margin-top: 0.5rem; color: var(--text-primary); font-size: 1.25rem; }

/* Utility */
.error-msg {
    color: var(--error-color);
    font-size: 0.75rem;
    margin-top: 0.25rem;
}
input:invalid:not(:focus):not(:placeholder-shown) {
    border-color: var(--error-color);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center; justify-content: center;
    z-index: 100;
}
.modal-content {
    background: var(--surface-color);
    padding: 2rem;
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-md);
}
.modal-content h2 { margin-bottom: 1.5rem; color: var(--text-primary); }

/* Responsive Design */
@media (max-width: 992px) {
    .form-pane {
        flex: 1 1 100vw;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    .preview-pane {
        flex: 1 1 100vw;
        min-height: 100vh;
        overflow-x: auto;
        justify-content: flex-start;
    }
}

@media (max-width: 1200px) {
    .input-grid {
        grid-template-columns: 1fr;
    }
    .form-group.full-width {
        grid-column: span 1;
    }
}


/* Global Navigation */
.global-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--primary-color);
    color: white;
    padding: 15px 30px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.global-nav .nav-brand {
    font-size: 22px;
    font-weight: bold;
    letter-spacing: 0.5px;
}

.global-nav .nav-links a.nav-btn {
    color: var(--primary-color);
    background-color: white;
    text-decoration: none;
    margin-left: 20px;
    font-size: 15px;
    font-weight: 600;
    transition: all 0.2s ease-in-out;
    padding: 8px 16px;
    border-radius: 20px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.global-nav .nav-links a.nav-btn:hover {
    background-color: #f0f0f0;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

/* Enhanced Buttons */
button {
    cursor: pointer;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    white-space: nowrap;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}
.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}
.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
}
.btn-secondary:hover {
    background-color: var(--secondary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}
.btn-secondary:active {
    transform: translateY(0);
}


/* Mandatory Field Indicators */
.form-group:has(input[required]) label::after,
.form-group:has(select[required]) label::after,
.form-group:has(textarea[required]) label::after {
    content: " *";
    color: #e74c3c;
}
