/* The "Executive Edge" - Refined Bill Generator CSS */
/* REMOVED @import - now handled in HTML head for performance */

:root {
    /* Primary Colors */
    --primary-dark-slate: #2f3640; /* Deep, almost black-blue for primary elements */
    --primary-midnight-blue: #1a202c; /* Even deeper for backgrounds/strong accents */
    --accent-gold: #fcc430; /* A vibrant, rich gold for highlights and calls to action */

    /* Neutrals */
    --background-light-grey: #f0f2f5; /* Soft, very light grey background */
    --card-background: #ffffff; /* Pure white for card elements */
    --border-soft: #e0e6ed; /* Subtle border color */

    /* Text Colors */
    --text-dark: #34495e; /* Dark slate text for main content */
    --text-light: #fefefe; /* Near-white for contrast on dark backgrounds */
    --text-subtle: #8a96a3; /* Lighter grey for secondary info/placeholders */

    /* Shadows */
    --shadow-subtle: 0 4px 8px rgba(0, 0, 0, 0.08);
    --shadow-elevated: 0 8px 16px rgba(0, 0, 0, 0.15);

    /* Feedback Colors */
    --success-green: #2ecc71;
    --danger-red: #e74c3c;
}

/* Global Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Roboto', sans-serif; /* A clean, modern sans-serif for readability */
    background-color: var(--background-light-grey);
    min-height: 100vh;
    color: var(--text-dark);
    line-height: 1.6;
    overflow-x: hidden;
    display: flex;
    flex-direction: column; /* Stacks top-navbar and page-wrapper vertically */
}

/* No particles or distracting patterns */
body::before, .particle {
    content: none;
    display: none;
}

/* Top Navigation - Bold & Authoritative */
.top-navbar {
    background-color: var(--primary-midnight-blue); /* Deepest blue for a strong header */
    border-bottom: 1px solid rgba(255, 255, 255, 0.05); /* Very subtle separator */
    padding: 1.5rem 3rem;
    box-shadow: var(--shadow-elevated);
    z-index: 1000; /* Ensure it's above other content */
    position: sticky;
    top: 0;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
}

.top-navbar h1 {
    font-family: 'Montserrat', sans-serif; /* More impactful font for headings */
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-light); /* White text for strong contrast */
    letter-spacing: 1.5px;
    position: relative;
    padding-bottom: 10px;
    text-transform: uppercase;
}

.top-navbar h1::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80px; /* Modern, clear underline */
    height: 4px;
    background-color: var(--accent-gold); /* Gold accent */
    border-radius: 2px;
}

/* Page Wrapper - Holds Left Nav and Main Content Side-by-Side */
.page-wrapper {
    display: flex;
    flex: 1; /* Allows it to take up remaining height */
    width: 100%; /* Ensure it spans full width */
}

/* Left Navigation - Sleek & Functional */
.left-navbar {
    width: 260px; /* Set a fixed width for the nav */
    background-color: var(--primary-dark-slate); /* Dark slate for sidebar */
    padding-top: 3rem;
    box-shadow: var(--shadow-elevated);
    flex-shrink: 0; /* Prevent it from shrinking */
    position: sticky;
    top: 0; /* Stays at the top */
    height: 100vh; /* Takes full viewport height */
    overflow-y: auto;
    transition: width 0.3s ease-in-out;
    z-index: 999; /* Ensure it's above the main content but below the top nav */
}

.left-navbar ul {
    list-style: none;
    padding: 0;
}

.left-navbar li {
    margin-bottom: 0.8rem; /* More generous spacing */
    transition: background-color 0.2s ease; /* NEW: Add transition here */
}

/* NEW: Subtle hover effect for the list item itself */
.left-navbar li:hover {
    background-color: rgba(255, 255, 255, 0.03); /* Very subtle background on li hover */
}

.left-navbar a {
    display: flex;
    align-items: center;
    color: rgba(255, 255, 255, 0.75); /* Slightly transparent white */
    text-decoration: none;
    padding: 1.1rem 1.8rem;
    font-size: 1rem;
    font-weight: 500;
    transition: background-color 0.2s ease, color 0.2s ease, border-left-color 0.2s ease;
    border-left: 5px solid transparent;
}

.left-navbar a:hover {
    background-color: rgba(255, 255, 255, 0.08);
    color: var(--text-light);
    border-left-color: var(--accent-gold); /* Gold accent on hover */
}

.left-navbar a.active {
    background-color: rgba(255, 255, 255, 0.15);
    color: var(--text-light);
    border-left-color: var(--accent-gold);
    font-weight: 600;
}

/* Main Content Area - Open & Inviting */
.main-content {
   flex-grow: 1; /* Allows main content to take up all remaining space */
    padding: 3.5rem 4rem; /* Ample padding for a spacious feel */
    background-color: var(--background-light-grey);
    display: flex;
    flex-direction: column;
    gap: 3rem; /* Significant spacing between sections */
    animation: fadeInSlideUp 0.8s ease-out forwards;
    position: relative; /* Essential for z-index if any child elements need it */
    z-index: 1; /* Keep main content below the sticky navs */
}

@keyframes fadeInSlideUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Form & Section Cards - Crisp & Defined */
form, .section {
    background-color: var(--card-background); /* White background */
    border: 1px solid var(--border-soft); /* Soft border */
    border-radius: 10px; /* Slightly more rounded corners */
    padding: 3rem; /* Generous padding inside cards */
    box-shadow: var(--shadow-subtle);
    transition: all 0.3s ease-in-out;
}

form:hover, .section:hover {
    transform: translateY(-5px); /* More pronounced lift on hover */
    box-shadow: var(--shadow-elevated);
    border-color: var(--accent-gold); /* Gold border highlight on hover */
}

form h2 {
    font-family: 'Montserrat', sans-serif;
    text-align: center;
    color: var(--primary-dark-slate);
    font-size: 2.3rem;
    margin-bottom: 2.2rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    position: relative;
    padding-bottom: 12px;
}

form h2::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 4px;
    background-color: var(--accent-gold);
    border-radius: 2px;
}

/* NEW: Specific style for the "Latest Invoice No" text */
form h3.latest-invoice-no { /* Targeted specifically using the class */
    font-family: 'Montserrat', sans-serif;
    color: var(--danger-red); /* Keep your current color for emphasis */
    font-size: 1.25rem; /* A bit larger */
    font-weight: 600; /* Bolder */
    text-align: center;
    margin-bottom: 1.5rem; /* Space below it */
    padding: 10px 15px;
    background-color: rgba(231, 76, 60, 0.08); /* Very light red background */
    border-radius: 8px;
    border: 1px solid rgba(231, 76, 60, 0.2);
    display: inline-block; /* To make background fit content */
    margin-left: auto; /* Center it */
    margin-right: auto; /* Center it */
    position: relative; /* For potential future icon/decoration */
    top: -15px; /* Pull it up slightly towards the H2 */
    width: fit-content; /* Ensure it wraps content */
}


.section h3 {
    font-family: 'Montserrat', sans-serif;
    color: var(--primary-dark-slate);
    font-size: 1.8rem; /* Clear section titles */
    margin-bottom: 2rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    letter-spacing: 0.5px;
    padding-left: 0.8rem; /* Space for accent bar */
}

.section h3::before {
    content: '';
    width: 6px; /* Prominent accent bar */
    height: 35px; /* Taller accent bar */
    background-color: var(--accent-gold); /* Gold accent */
    border-radius: 3px;
    margin-right: 1.2rem;
    flex-shrink: 0;
}

/* Input Fields - Clean & Modern */
.input-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem 2.5rem; /* More generous gaps */
    align-items: start;
}

.input-group > div {
    display: flex;
    flex-direction: column;
    position: relative; /* ESSENTIAL for positioning autocomplete suggestions */
}

label {
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 0.8rem; /* More space for label */
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

input[type="text"],
input[type="number"],
input[type="date"],
select,
textarea {
    padding: 14px 16px; /* Larger padding for easier interaction */
    border: 1px solid var(--border-soft);
    border-radius: 8px; /* Softer rounded corners */
    font-size: 1rem;
    background-color: var(--background-light-grey); /* Input background matches page */
    color: var(--text-dark);
    transition: all 0.25s ease-in-out;
    box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.05); /* Subtle inner shadow */
    font-weight: 400;
    line-height: 1.5;
    width: 100%; /* Ensure inputs take full available width in their grid cell */
}

/* NEW: Specific style for the Invoice Number input */
#id_invoice_no {
    background-color: var(--card-background); /* White background to match the card */
    font-weight: 500; /* Slightly bolder */
    letter-spacing: 0.5px;
    text-transform: uppercase;
    padding: 14px 20px;
    font-size: 1.1rem;
    color: var(--primary-dark-slate);
}


input[type="text"]::placeholder,
input[type="number"]::placeholder,
textarea::placeholder {
    color: var(--text-subtle);
    font-style: italic; /* Subtle italic for placeholders */
    font-weight: 300;
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent-gold); /* Gold focus glow */
    box-shadow: 0 0 0 4px rgba(252, 196, 48, 0.3), inset 0 1px 4px rgba(0, 0, 0, 0.05);
    background-color: var(--card-background); /* White background on focus */
}

textarea {
    resize: vertical;
    min-height: 120px;
}

select {
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a96a3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-position: right 15px center;
    background-repeat: no-repeat;
    background-size: 20px;
    padding-right: 45px;
    appearance: none;
    background-color: var(--card-background); /* White for select by default */
}

/* --- Autocomplete Suggestions Styles --- */
/* Container for suggestions */
.autocomplete-suggestions {
    position: absolute; /* Position relative to the parent with position: relative; */
    background-color: var(--card-background); /* White background */
    border: 1px solid var(--border-soft); /* Soft border */
    border-radius: 8px; /* Consistent rounded corners */
    z-index: 1001; /* Higher than top nav, left nav, and any other content */
    max-height: 200px; /* Slightly less height */
    overflow-y: auto;
    width: 100%; /* Match the input field width */
    box-shadow: var(--shadow-subtle); /* Consistent shadow */
    margin-top: 5px; /* Small gap below the input */
    padding: 0; /* Remove internal padding, items will have their own */
    font-family: 'Roboto', sans-serif; /* Use your theme font */
    font-size: 0.95rem; /* Slightly smaller font size */

    /* NEW: Use opacity and pointer-events for smoother transitions */
    opacity: 0;
    pointer-events: none; /* Prevents interaction when hidden */
    transition: opacity 0.2s ease-in-out, transform 0.2s ease-in-out; /* Smooth transition */
    transform: translateY(-5px); /* Start slightly above */
}

/* NEW: Class to be added by JavaScript when suggestions are available */
.autocomplete-suggestions.is-visible {
    opacity: 1;
    pointer-events: auto; /* Allow interaction when visible */
    transform: translateY(0); /* Slide into place */
}


/* Each suggestion item */
.autocomplete-item {
    padding: 10px 15px; /* Consistent padding */
    cursor: pointer;
    transition: background-color 0.2s ease-in-out;
    color: var(--text-dark); /* Dark text color */
    border-bottom: 1px solid var(--border-soft); /* Subtle divider line */
}

/* Remove bottom border from the last item */
.autocomplete-item:last-child {
    border-bottom: none;
}

/* Hover effect */
.autocomplete-item:hover {
    background-color: rgba(252, 196, 48, 0.1); /* Subtle gold tint on hover */
    color: var(--primary-dark-slate); /* Darker text on hover */
}

/* Fade-in animation for suggestions */
/* No change needed as the .is-visible class will drive the transition */

/* --- End Autocomplete Suggestions Styles --- */

/* Divider - Minimalist & Horizontal */
.divider {
    height: 1px;
    background-color: var(--border-soft);
    margin: 3.5rem 0; /* Consistent vertical spacing */
    border-radius: 0;
    box-shadow: none;
}

/* Table - Clean & Professional */
.table-container { /* This wraps your #items-table */
    overflow-x: auto;
    margin-top: 2rem;
    border-radius: 10px;
    background-color: var(--card-background); /* Applies white background to the container */
    border: 1px solid var(--border-soft);
    box-shadow: var(--shadow-subtle);
}

#items-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

#items-table thead {
    background-color: var(--primary-dark-slate);
    color: var(--text-light);
}

#items-table th {
    padding: 1.2rem 1.5rem;
    text-align: left;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.88rem;
}

#items-table td {
    padding: 1.2rem 1.5rem;
    border-bottom: 1px solid var(--border-soft);
    color: var(--text-dark);
    transition: background-color 0.15s ease;
    font-weight: 400;
}

#items-table tbody tr:hover {
    background-color: rgba(252, 196, 48, 0.05); /* Subtle gold hover for rows */
}

#items-table tbody tr:nth-child(even) {
    background-color: var(--background-light-grey); /* Subtle striping */
}

#items-table input,
#items-table select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-soft);
    border-radius: 6px;
    font-size: 0.9rem;
    background-color: var(--card-background); /* Ensured white background */
    color: var(--text-dark);
    font-weight: 400;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.03);
}

/* MODIFIED: More prominent focus state for table inputs/selects */
#items-table input:focus,
#items-table select:focus {
    outline: none;
    border-color: var(--accent-gold);
    box-shadow: 0 0 0 3px rgba(252, 196, 48, 0.3), inset 0 1px 2px rgba(0, 0, 0, 0.03);
    background-color: var(--card-background); /* Ensure background is white on focus */
}


/* Buttons - Strong & Defined */
.add-row-btn,
button[type="submit"] {
    background-color: var(--accent-gold); /* Gold for add */
    color: var(--primary-dark-slate); /* Dark text on gold for strong contrast */
    border: none;
    padding: 13px 30px;
    font-size: 1rem;
    font-weight: 700; /* Bolder text for impact */
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.25s ease;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    box-shadow: var(--shadow-subtle);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 2rem; /* Space from table */
}

.add-row-btn:hover,
button[type="submit"]:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-elevated);
    filter: brightness(1.08); /* More noticeable brightness */
}

button[type="submit"] {
    background-color: var(--primary-midnight-blue); /* Deepest blue for submit */
    color: var(--text-light); /* White text on dark background */
    margin: 4rem auto 0; /* Centered with more space */
    padding: 16px 45px;
    font-size: 1.15rem;
    box-shadow: 0 10px 25px rgba(26, 32, 44, 0.3);
}

button[type="submit"]:hover {
    box-shadow: 0 12px 30px rgba(26, 32, 44, 0.4);
}

/* Remove Button - Clear Negative Action */
.remove-row-btn {
    background-color: var(--danger-red);
    color: var(--text-light);
    border: none;
    padding: 8px 15px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.2px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.remove-row-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    filter: brightness(1.05);
}

/* --- Invoice List Table Styles --- */

/* Base table style for both main and nested tables */
.invoice-table,
.invoice-item-table {
    width: 100%;
    border-collapse: collapse; /* Ensure cells share borders */
    font-size: 0.95rem; /* Consistent with other table font sizes */
    margin-bottom: 2rem; /* Space below tables */
    border: 1px solid var(--border-soft); /* Soft border for the whole table */
    border-radius: 10px; /* Rounded corners for the table */
    overflow: hidden; /* Ensures rounded corners clip content */
    box-shadow: var(--shadow-subtle); /* Consistent shadow */
}

/* Header styles for both main and nested tables */
.invoice-table thead,
.invoice-item-table thead {
    background-color: var(--primary-dark-slate); /* Dark header background */
    color: var(--text-light); /* Light text for headers */
}

.invoice-table th,
.invoice-item-table th {
    padding: 1.2rem 1.5rem; /* Consistent padding */
    text-align: left; /* Align text to the left */
    font-weight: 600; /* Bolder header text */
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.88rem;
}

/* Body cell styles for both main and nested tables */
.invoice-table td,
.invoice-item-table td {
    padding: 1.2rem 1.5rem;
    border-bottom: 1px solid var(--border-soft);
    color: var(--text-dark);
    transition: background-color 0.15s ease;
    font-weight: 400;
}

/* Remove bottom border from the last row of the body */
.invoice-table tbody tr:last-child td,
.invoice-item-table tbody tr:last-child td {
    border-bottom: none;
}


/* Hover effect for rows */
.invoice-table tbody tr:hover,
.invoice-item-table tbody tr:hover {
    background-color: rgba(252, 196, 48, 0.05); /* Subtle gold hover for rows */
}

/* Striping for table rows (even rows lighter) */
.invoice-table tbody tr:nth-child(even),
.invoice-item-table tbody tr:nth-child(even) {
    background-color: var(--background-light-grey); /* Subtle striping */
}

/* Specific styling for the nested invoice item table */
.invoice-item-table {
    width: calc(100% - 3rem); /* Adjust width to fit within parent td padding */
    margin: 1.5rem auto 0; /* Center it and give top margin */
    box-shadow: none; /* Remove extra shadow for nested table */
    border: 1px dashed var(--border-soft); /* Make nested table border dashed */
}

.invoice-item-table th,
.invoice-item-table td {
    padding: 0.8rem 1rem; /* Slightly less padding for nested table cells */
    font-size: 0.85rem; /* Smaller font for nested table */
    text-align: center; /* Center align for numeric/item data */
}

/* Override text-align for Item Name in nested table */
.invoice-item-table th:first-child,
.invoice-item-table td:first-child {
    text-align: left;
}


/* Styles for the "Total" row in the nested item table's footer */
.invoice-item-table tfoot td {
    text-align: right !important; /* Ensure right alignment for totals */
    background-color: #e6ffe6; /* Light green for totals background (still using for contrast, could be adjusted) */
    font-weight: 700; /* Bold total values */
    border-top: 2px solid var(--success-green); /* Stronger top border for totals */
    color: var(--primary-dark-slate); /* Darker text for totals */
}

.invoice-item-table tfoot td:first-child {
    text-align: center !important; /* Center the "Total" label */
    background-color: #d4f7d4; /* Slightly different shade for the Total label cell (still using for contrast) */
}

/* Invoice List Page specific styles */
/* --- REFINED "All Invoices" HEADING --- */
.main-content h2.invoice-list-title {
    font-family: 'Montserrat', sans-serif; /* Consistent font */
    text-align: center;
    color: var(--primary-dark-slate); /* Matches other main headings */
    font-size: 2.3rem; /* Matches other form h2 */
    margin-bottom: 2.2rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    position: relative;
    padding-bottom: 12px;
}

.main-content h2.invoice-list-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 4px;
    background-color: var(--accent-gold); /* Gold accent for underline */
    border-radius: 2px;
}


/* --- REFINED SEARCH BAR AND BUTTONS --- */
.search-controls {
    margin-bottom: 1.5rem;
    display: flex;
    gap: 1rem;
    align-items: center;
    justify-content: flex-end; /* Align to the right */
    flex-wrap: wrap; /* Allow wrapping on smaller screens */
    padding: 1.5rem; /* Give some padding, perhaps like a card, but lighter */
    background-color: var(--card-background); /* White background for the search bar section */
    border: 1px solid var(--border-soft);
    border-radius: 10px;
    box-shadow: var(--shadow-subtle);
}

.search-controls label {
    margin-bottom: 0;
    font-weight: 600; /* Bolder label */
    color: var(--text-dark);
    flex-shrink: 0;
    text-transform: uppercase; /* Uppercase label */
    letter-spacing: 0.5px;
}

.search-controls input[type="text"] {
    width: 300px;
    max-width: 100%;
    padding: 12px 15px; /* Slightly more padding */
    font-size: 1rem;
    border: 1px solid var(--border-soft); /* Soft border */
    border-radius: 8px;
    background-color: var(--background-light-grey); /* Light grey background */
    color: var(--text-dark);
    transition: all 0.25s ease-in-out;
    box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.05); /* Subtle inner shadow */
    cursor: text;
    flex-grow: 1; /* Allow input to grow */
}

.search-controls input[type="text"]:focus {
    outline: none;
    border-color: var(--accent-gold); /* Gold focus glow */
    box-shadow: 0 0 0 4px rgba(252, 196, 48, 0.3), inset 0 1px 4px rgba(0, 0, 0, 0.05);
    background-color: var(--card-background); /* White background on focus */
}

.search-controls button {
    display: inline-block;
    padding: 12px 25px; /* Adjusted padding for better click area */
    font-size: 1rem; /* Slightly larger font */
    color: var(--text-light); /* White text */
    background-color: var(--primary-dark-slate); /* Dark slate for search buttons */
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 700; /* Bolder text */
    transition: all 0.25s ease;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    box-shadow: var(--shadow-subtle);
    flex-shrink: 0;
}

.search-controls button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-elevated);
    background-color: var(--primary-midnight-blue); /* Even darker on hover */
}


/* Pagination styles */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 3rem;
    gap: 10px;
}

.pagination a {
    text-decoration: none;
    color: var(--primary-dark-slate);
    padding: 10px 15px;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    transition: all 0.3s ease;
    background-color: var(--card-background);
    font-weight: 500;
}

.pagination a:hover {
    background-color: var(--accent-gold);
    color: var(--primary-dark-slate);
    border-color: var(--accent-gold);
    transform: translateY(-2px);
    box-shadow: var(--shadow-subtle);
}

.pagination a.active {
    background-color: var(--primary-dark-slate);
    color: var(--text-light);
    border-color: var(--primary-dark-slate);
    cursor: default;
    box-shadow: var(--shadow-subtle);
}

.pagination a.active:hover {
    transform: none;
    filter: brightness(1.05);
}

/* Action Icons (for view/edit) */
.action-icons a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    transition: all 0.2s ease;
    text-decoration: none;
    margin: 0 0.2rem;
    box-shadow: var(--shadow-subtle);
}

.action-icons a svg {
    width: 20px;
    height: 20px;
}

.action-icons a.view-icon {
    background-color: var(--primary-dark-slate);
    color: var(--text-light);
}

.action-icons a.view-icon:hover {
    background-color: var(--primary-midnight-blue);
    transform: scale(1.1);
    box-shadow: var(--shadow-elevated);
}

.action-icons a.edit-icon {
    background-color: var(--accent-gold);
    color: var(--primary-dark-slate);
}

.action-icons a.edit-icon:hover {
    background-color: #e6b22c; /* Slightly darker gold */
    transform: scale(1.1);
    box-shadow: var(--shadow-elevated);
}

/* Responsive Design */
@media (max-width: 1200px) {
    .main-content {
        padding: 3rem;
    }
}

@media (max-width: 1024px) {
    .page-wrapper {
        flex-direction: column; /* Stacks nav and content vertically on smaller screens */
    }

    .left-navbar {
        position: static; /* No longer sticky on smaller screens */
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        padding-top: 0;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        box-shadow: var(--shadow-subtle);
        z-index: auto; /* Reset z-index when not sticky */
    }

    .left-navbar ul {
        display: flex;
        justify-content: flex-start; /* Align left for mobile */
        flex-wrap: nowrap;
        padding: 0.8rem 1.5rem;
    }

    .left-navbar li {
        margin: 0 1rem;
        flex-shrink: 0;
    }

    .left-navbar a {
        padding: 0.9rem 1.2rem;
        border-left: none;
        border-bottom: 4px solid transparent;
        font-size: 0.95rem;
    }

    .left-navbar a:hover,
    .left-navbar a.active {
        background-color: transparent;
        border-bottom-color: var(--accent-gold);
        color: var(--text-light);
    }

    .main-content {
        max-width: 100%; /* Important: allow it to take full width */
        padding: 2.5rem;
        gap: 2.5rem;
    }

    form, .section {
        padding: 2.5rem;
    }

    form h2 {
        font-size: 2rem;
        margin-bottom: 2rem;
    }

    .section h3 {
        font-size: 1.6rem;
        margin-bottom: 1.8rem;
    }

    .search-controls {
        justify-content: center; /* Center search controls on smaller screens */
        gap: 0.8rem;
        padding: 1rem; /* Reduced padding for smaller screens */
    }

    .search-controls input[type="text"] {
        width: 100%; /* Full width for input */
    }
}

@media (max-width: 768px) {
    .top-navbar h1 {
        font-size: 2rem;
        letter-spacing: 1px;
    }
    .top-navbar h1::after {
        width: 50px;
        height: 3px;
    }

    form, .section {
        padding: 2rem;
    }

    form h2 {
        font-size: 1.8rem;
        margin-bottom: 1.5rem;
    }

    /* NEW: Adjust "Latest Invoice No" for smaller screens */
    form h3.latest-invoice-no {
        font-size: 1.1rem;
        padding: 8px 12px;
        margin-bottom: 1rem;
        top: -10px;
    }

    .section h3 {
        font-size: 1.4rem;
        margin-bottom: 1.5rem;
        padding-left: 0.5rem;
    }
    .section h3::before {
        width: 5px;
        height: 30px;
        margin-right: 1rem;
    }

    .input-group {
        grid-template-columns: 1fr;
        gap: 1.8rem;
    }

    label {
        font-size: 0.9rem;
    }

    input[type="text"],
    input[type="number"],
    input[type="date"],
    select,
    textarea {
        padding: 12px 14px;
        font-size: 0.95rem;
    }

    #items-table th,
    #items-table td {
        padding: 1rem 1.2rem;
        font-size: 0.9rem;
    }

    #items-table input,
    #items-table select {
        padding: 8px 10px;
        font-size: 0.85rem;
    }

    .add-row-btn,
    button[type="submit"] {
        padding: 11px 25px;
        font-size: 0.95rem;
    }

    button[type="submit"] {
        padding: 14px 35px;
        font-size: 1.05rem;
        margin-top: 3rem;
    }

    .remove-row-btn {
        padding: 7px 14px;
        font-size: 0.78rem;
    }

    .search-controls {
        flex-direction: column; /* Stack search input and buttons vertically */
        align-items: stretch; /* Stretch items to full width */
    }

    .search-controls input[type="text"],
    .search-controls button {
        width: 100%;
        margin-top: 0.5rem; /* Small gap between stacked items */
    }

    .search-controls label {
        align-self: flex-start; /* Align label to the left */
        margin-bottom: 0.5rem;
    }
}

/* Scroll Bar - Refined Dark */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--background-light-grey);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb {
    background-color: var(--text-subtle); /* Muted scrollbar thumb */
    border-radius: 5px;
    border: 2px solid var(--background-light-grey); /* Adds slight padding */
    transition: background-color 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
    background-color: var(--primary-dark-slate); /* Dark slate on hover */
}

/* Specific styling for the Grand Total input */
#grand_total {
    background-color: var(--card-background); /* White background for total */
    border: 2px solid var(--accent-gold); /* Prominent gold border */
    color: var(--primary-dark-slate); /* Strong text color */
    font-size: 1.5rem; /* Larger font for emphasis */
    font-weight: 700; /* Bold */
    text-align: right; /* Align numbers to the right */
    padding: 15px 20px; /* Generous padding */
    box-shadow: var(--shadow-elevated); /* More pronounced shadow */
    width: fit-content; /* Adjust width to content */
    margin-left: auto; /* Push to the right */
    margin-right: 0;
    display: block; /* Ensure it takes its own line */
    margin-top: 2rem; /* Space from previous section */
    margin-bottom: 2rem; /* Space before next section */
}