* {
    padding: 0;
    margin: 0;
    box-sizing: border-box;
    max-width: 100%;
}

/* Variables */
:root {
    --Primary-background-colour: #eaeaea;
    --card-selection: #FFFFFF;
    --text-colour: #212529;
    --muted-text-colour: #6C757D;
    --text-hover: #bdbdbd;
    --primary-button: #007BFF;
    --primary-hover: #0056B3;
    --download-button: #0a9d2d;
    --download-hover: #28a745;
    --accent-colour: #20C997;
    /* For upgrade prompts or subtle alerts */
    --accent-hover: #138F75;
    --border-lines: #E0E0E0;
    /* to seperate the content */
    --row-odd: #ffffff;
    --row-even: #e3e3e3;

    --dp-bg: #ffffff;
    --dp-text: #2a2e37;
    --dp-muted: #8a909a;
    --dp-border: #e6e8ee;
    --dp-shadow: 0 10px 30px rgba(0, 0, 0, .12);
    --dp-accent: #1da1f2;
    --dp-accent-hover: #168cd3;
    --dp-today-ring: #1da1f2;


}

html[data-theme="dark"] {
    --Primary-background-colour: #1a1a1d;
    --card-selection: #303030;
    --text-colour: #E4E4E7;
    --muted-text-colour: #B0B0BC;
    --border-lines: #424242;
    --primary-button: #4CAFEB;
    --primary-hover: #7CCBFF;
    --download-button: #0a9d2d;
    --download-hover: #28a745;
    --accent-colour: #66D1B8;
    --accent-hover: #4FB79E;
    --row-odd: #303030;
    /* darker stripe */
    --row-even: #424242;
    /* lighter stripe */

    --dp-bg: #0f172a;
    --dp-text: #e5e7eb;
    --dp-muted: #94a3b8;
    --dp-border: #1f2937;
    --dp-shadow: 0 12px 36px rgba(0, 0, 0, .45);
    --dp-accent: #2563eb;
    --dp-accent-hover: #1e40af;
    --dp-today-ring: #60a5fa;
}

body {
    background: var(--Primary-background-colour);
    color: var(--text-colour);
}

.invoice-template {
    background: var(--card-selection);
}

.invoice-template input {
    background: var(--card-selection);
    color: var(--text-colour);
    border: 1px solid var(--text-colour);
}

body input {
    background: var(--card-selection);
    color: var(--text-colour);
    border: 1px solid var(--text-colour)
}


textarea {
    background: var(--card-selection);
    color: var(--text-colour);
    border: 1px solid var(--text-colour)
}

.dropdownBox {
    background-color: var(--card-selection);
    color: var(--text-colour);
    border: 1px solid var(--text-colour)
}


html,
body {
    overflow-x: hidden;
    max-width: 100vw;
}

#item-rate::-webkit-outer-spin-button,
#item-rate::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Firefox */
input#item-rate {
    -moz-appearance: textfield;
    appearance: textfield;
}

/* Ensure spin buttons are visible for tax-rate input */
.tax-rate::-webkit-inner-spin-button,
.tax-rate::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.item-rate::-webkit-inner-spin-button,
.item-rate::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Stops calendar symbol from showing on inputs */
input[type="date"]::-webkit-inner-spin-button,
input[type="date"]::-webkit-calendar-picker-indicator {
    display: none;
    -webkit-appearance: none;
}

/* Ensure spin buttons are visible for tax-rate input */
.item-quantity::-webkit-inner-spin-button,
.item-quantity::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}




textarea {
    resize: vertical;
}

body {
    background-color: var(--Primary-background-colour);
    font-family: Helvetica, Arial, sans-serif;
}

h1,
h2,
h3 {
    font-family: "Montserrat", "Roboto", sans-serif;
    font-weight: 600;
}

.height {
    min-height: 100vh;
    min-height: 100dvh;
}

/* Invoice adSpace Stuff */

.invoice-adSpace {
    width: 12%;
}

/* navbar details */

nav {
    display: flex;
    flex-direction: column;
    background-color: var(--card-selection);
    border-bottom: 1px solid var(--border-lines);
    padding-left: 20px;
    padding-right: 20px;
}

nav li {
    display: flex;
    align-items: center;
}

nav ul {
    list-style: none;
    display: flex;
    gap: 20px;
}

nav .alwaysVisible {
    margin-right: auto;
}

nav a {
    display: flex;
    text-decoration: none;
    color: var(--text-colour);
    transition: background-color 150ms ease;
}

nav a:hover {
    color: var(--primary-hover);
}

#open-sidebar-button {
    display: none;
    background: none;
    border: none;
    padding: 1em;
    margin-left: auto;
    cursor: pointer;
}

#close-sidebar-button {
    display: none;
    background: none;
    border: none;
    padding: 1em;
    cursor: pointer;
}

.icon {
    width: 32px;
    height: 32px;
}

.hidden {
    display: none;
}

#toggle-menu-button {
    display: none;
    /* default = hidden on desktop */
    background: none;
    border: none;
    cursor: pointer;
    padding: 1em;
    align-items: center;
}


.mobile-only {
    display: none;
}

/* Hide the label everywhere by default */
.mode-label {
    display: none;
}

@media screen and (max-width: 900px) {
    nav {
        position: relative;
        padding-right: 0;
    }

    nav ul {
        flex-direction: column;
        align-items: flex-start;
        padding-left: 1em;
    }

    nav ul li {
        display: none;
    }

    nav.show .mode-label {
        display: inline-block;
    }

    nav ul li.alwaysVisible {
        display: flex;
        justify-content: space-between;
        width: 100%;
    }

    nav.show ul li {
        display: flex;
        width: 100%;
        padding: 0.5em 0;
    }

    #toggle-menu-button {
        display: flex;
        /* visible only on small screens */
    }

    #open-sidebar-button,
    #close-sidebar-button {
        background: none;
        border: none;
        padding: 1em;
        cursor: pointer;
        display: block;
    }

    #open-sidebar-button {
        margin-left: auto;
    }

    #close-sidebar-button {
        margin-left: auto;
    }

    /* Menu closed: hide the whole toggle row and its label */
    #navbar .themeToggle-li {
        display: none !important;
    }

    #navbar .mode-label {
        display: none !important;
    }

    /* Menu OPEN (nav gets .show): reveal toggle and label inside the dropdown */
    #navbar.show .themeToggle-li {
        display: flex !important;
        align-items: center;
        gap: .6rem;
    }

    #navbar.show .mode-label {
        display: inline-block !important;

    }
}

/* Checkbox */

.item-checkbox {
    display: flex;
    justify-content: center;
    align-items: center;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* The clickable “button” */
.theme-toggle {
    inline-size: 44px;
    block-size: 44px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    background: var(--card-selection);
    cursor: pointer;
    user-select: none;
}

.theme-toggle:active {
    transform: scale(.96);
}

/* Icons */
.theme-toggle .icon {
    width: 22px;
    height: 22px;
    stroke: var(--text-colour);
    fill: none;
    stroke-width: 1.6;
    position: absolute;
    opacity: 0;
    transform: scale(.7) rotate(-10deg);
    transition: opacity .18s ease, transform .18s ease, stroke .2s ease, fill .2s ease;
}

.theme-toggle .sun circle {
    fill: currentColor;
    opacity: .7;
}

.theme-toggle .moon {
    fill: currentColor;
    stroke: none;
}

/* Icons hidden by default */
.theme-toggle .icon {
    opacity: 0;
    transform: scale(.7) rotate(-10deg);
    transition: opacity .18s ease, transform .18s ease, stroke .2s ease, fill .2s ease;
}

/* Show the correct icon based on the current theme */
html[data-theme="light"] .theme-toggle .sun {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

html[data-theme="dark"] .theme-toggle .moon {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

/* Focus ring for keyboard users */
#colour-toggle:focus-visible+.theme-toggle {
    outline: 2px solid var(--primary-hover);
    outline-offset: 2px;
}

/* Feed currentColor to the icons */
.theme-toggle {
    color: var(--text-colour);
}

/* In dark mode, make the moon white (and sun strokes lighten too) */
.dark-mode .theme-toggle {
    color: #fff;
}

/* Main invoice builder css */

main {
    display: block;
    overflow: auto;

}


.invoice-container {
    max-width: clamp(1000px, 100vw, 1440px);
    margin-inline: auto;
    padding: 2rem clamp(1rem, 3vw, 2rem);
    display: flex;
    gap: clamp(1rem, 2vw, 2rem);
    justify-content: center;
    /* no empty right strip */
    align-items: flex-start;

}


.invoice-template {
    flex: 1 1 auto;
    width: auto;
    max-width: none;
    /* remove the old 900px cap */
    background: var(--card-selection);
    display: flex;
    flex-direction: column;
    /* feels “about the same size” at 100% and scales at 75% */
    inline-size: clamp(720px, 64vw, 980px);
}

.invoice-header {
    margin: 2rem 2rem 0rem 2rem;
}

.invoiceBox {
    height: 60px;
    width: 50%;
    font-size: xx-large;
    font-weight: 520;
}

.logo-upload-box {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 240px;
    height: 140px;
    background-color: var(--border-lines);
    border: 2px dashed #bbb;
    border-radius: 8px;
    color: #555;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease;
}

.logo-upload-box:hover {
    background-color: #d3d3d3;
}

.logo-upload-box span {
    pointer-events: none;
}

.addLogo {
    width: 100%;
    height: 100%;
    object-fit: fill;
}

.header-top {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 1rem;
    margin-bottom: 20px;
}

.header-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}


.from-details {
    display: grid;
    gap: 10px;
    margin-bottom: 20px;

}

.from-details input {
    width: 100%;
    height: 40px;
    padding-left: 5px;
}

.billToHeader {
    margin-bottom: 10px;
    height: 28px;
}

.detailsHeader {
    margin-bottom: 10px;
    height: 28px;
}

.custom-line {
    height: 1px;
    background-color: var(--muted-text-colour);
    width: 100%;
    margin: 1rem 0;
}

.invoice-sendTo {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-top: 1rem;
    margin-left: 2rem;
    margin-right: 2rem;
}



/* Mobile: stack Bill To then Details, inputs fill the row */
@media (max-width: 820px) {
    .invoice-sendTo {
        grid-template-columns: 1fr;
        /* Details goes underneath */
        gap: 1.25rem;
    }

    /* Use the same label column width for BOTH sections on mobile */
    .invoice-billTo,
    .invoice-meta {
        --label-w: clamp(7rem, 34vw, 9rem);
        /* left label gutter */
        gap: 10px;
    }

    /* Each row = [label | input expands] */
    .invoice-billTo .billToDiv,
    .invoice-meta .invoiceMetaDiv {
        display: grid;
        grid-template-columns: var(--label-w) minmax(0, 1fr);
        align-items: center;
        column-gap: 12px;
    }

    /* Ensure controls actually stretch */
    .invoice-billTo input,
    .invoice-meta input {
        width: 100%;
    }

    /* Slightly tighter headings on mobile */
    .billToHeader,
    .detailsHeader {
        margin-bottom: .35rem;
    }
}


.invoice-meta input {
    width: 100%;
}

.invoice-billTo {
    display: grid;
    gap: 10px;

}

.invoice-billTo label {
    font-size: 14px;
}

.invoice-billTo input {
    width: 100%;
    height: 40px;
    padding-left: 5px;

}

.billToDiv {
    display: flex;
    gap: 10px;
}


.invoice-meta {
    display: grid;
    gap: 10px;
    height: 100%;
}

.invoice-meta label {
    font-size: 14px;
}

.invoice-meta input {
    width: 100%;
    height: 40px;
    padding-left: 5px;

}

.invoiceMetaDiv {
    display: flex;
    gap: 10px;
}


/* Pull the rows left so they line up under the section titles */
.invoice-billTo {
    --label-w: 3.5rem;
    /* was 10.5rem; shrink if you want it even closer */
}

.invoice-meta {
    --label-w: 6.8rem
}

/* keep both columns on the same grid, but with a slimmer label column */
.invoice-billTo .billToDiv,
.invoice-meta .invoiceMetaDiv {
    display: grid;
    grid-template-columns: var(--label-w) minmax(0, 1fr);
    column-gap: 12px;
    align-items: center;
}

/* LEFT-align label text (this is the big fix) */
.invoice-billTo label,
.invoice-meta label {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    /* was flex-end */
    white-space: nowrap;
    padding-right: 12px;
}


.invoice-items {
    margin-top: 2rem;
    margin-left: 2rem;
    margin-right: 2rem;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
}

/* Compact the black header bar */
.item-header {
    background: #272727;
    color: #fff;
    height: 38px;
    /* ← control the bar height (try 32–44px) */
    padding: 0 12px;
    /* no vertical padding */
    display: grid;
    grid-template-columns: 2rem 4rem minmax(250px, 0.9fr) 6rem 6rem 6rem;
    align-items: center;
    /* keep labels vertically centered */
}

/* Table header – smaller, uppercase, tighter */
.item-header {
    font-size: 14px;
    /* ~13–14px */
    line-height: 1.2;
    text-transform: uppercase;
    letter-spacing: .02em;
    padding: 6px 0;
}

.item-header>div {
    margin: 0;
    padding: 0;
    line-height: 1;
    /* avoid extra line height */
    font-size: 0.85rem;
    /* optional: small, neat labels */
    font-weight: 600;
}

/* Keep input text normal-sized */
.item-inputs input,
.item-inputs textarea {
    font-size: 0.95rem;
}

.item-header,
.item-inputs {
    display: grid;
    grid-template-columns: 2rem 4rem minmax(250px, 0.9fr) 6rem 6rem 6rem;
    gap: 5px;
    justify-content: center;
    align-items: center;
    text-align: center;

}

.item-inputs {
    width: 100%;
    margin-top: 5px;
}

.item-inputs input {
    width: 100%;
    height: 40px;
    padding-left: 5px;
}


.item-details {
    width: 71%;
    align-items: center;
    justify-content: center;
    margin-left: 127px;
}

.item-details {
    padding-left: 5px;
    padding-top: 5px;
}

.item-description {
    width: 100%;
}

.item-details {
    grid-column: 1 / -1;
    /* Span entire row */
    margin-top: 0.5rem;
}

.item-header>div:nth-child(2),
.item-inputs input[type="checkbox"] {
    width: 1rem;
    /* Or any consistent width */
    justify-self: center;
}


/* Hide the disabled delete button on the first item */
.delete-button[disabled] {
    visibility: hidden;
    pointer-events: none;
}

/* Odd even rows for items and details wrapper */

.newItemDiv {
    padding: .25rem 0 .75rem;
    transition: background-color 120ms ease;
}

.newItemDiv.strip-odd {
    background: var(--row-odd);
}

.newItemDiv.strip-even {
    background: var(--row-even);
}


/* Focus ring for keyboard users */
#colour-toggle:focus-visible+.theme-toggle {
    outline: 2px solid var(--primary-hover);
    outline-offset: 2px;
}


.newItem {
    margin-top: 10px;
    margin-right: 5px;
}

.newItem-Button {
    float: right;
    background-color: var(--download-button);
    color: white;
    border: none;
    height: 30px;
    width: 70px;
    border-radius: 10px;
}

.newItem-Button:hover {
    background-color: var(--download-hover);
}

.delete-button {
    border: none;
    background-color: transparent;
    color: inherit;
    cursor: pointer;
}



.trashIcon {
    color: crimson;
}

.item-inputs label {
    display: none;
}

.newItemLine {
    margin-top: 5px;
    border: grey 0.5px dashed;
}

.mobile-custom-line {
    display: none;
    height: 1px;
    background-color: var(--muted-text-colour);
    width: 100%;
    margin: 2rem 0;
}

.terms {
    margin: 0rem 2rem 2rem 2rem;
}

.termsBox {
    resize: vertical;
    width: 100%;
    height: 3rem;
    padding-left: 5px;
    padding-top: 5px;
}

.invoice-currency {
    margin-right: 5px
}

@media (max-width: 1035px) {
    .invoice-adSpace {
        display: none;
    }

    .invoice-container {
        flex-direction: column;
    }

    .invoice-template {
        width: 100%;
    }
}



/* Stack on smaller screens */
@media (max-width: 768px) {
    .invoice-container {
        flex-direction: column;
    }

    .mobile-custom-line {
        display: block;
        height: 1px;
        background-color: var(--muted-text-colour);
        width: 100%;
        margin: 1rem 0;
    }

    .invoice-template {
        width: 100%;
    }

    .item-checkbox {
        text-align: left;
        align-self: flex-start;
    }

    .newAmount {
        text-align: right;

    }

    .invoice-adSpace {
        display: none;
    }

    .header-top,
    .header-details {
        grid-template-columns: 1fr;
    }

    .item-header {
        display: none;
        /* hide headers on mobile*/

    }

    .item-inputs {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
        padding: 1rem;
        width: 100%;
        text-align: left;
    }

    .invoice-items {
        grid-template-rows: none;
    }

    .item-inputs>* {
        width: 100%;
    }

    .delete-button[disabled] {
        visibility: hidden;
        pointer-events: none;
        height: 0;
        width: 0;
        padding: 0;
        margin: 0;
        border: none;
    }

    .item-inputs label {
        font-size: 0.85rem;
        font-weight: bold;
        display: block;
        color: var(--muted-text-colour);
    }


    label[for="item-amount"] {
        text-align: right;
        width: 100%;
    }

    #item-amount {
        text-align: right;
        font-weight: bold;
    }

    #item-checkbox {
        align-self: flex-start;
        margin-top: -0.5rem;
    }

    .item-inputs label[for="item-checkbox"] {
        order: -1;
        /* Moves label just before checkbox visually */
    }

    .item-inputs {
        margin-top: 0px;
    }

    .delete-button {
        align-self: flex-start;
        float: left;
        width: 5%;
    }

    .item-amount {
        text-align: right;
        font-weight: bold;
    }

    .item-details {
        margin: 0 0 0 0;
        width: 100%;
    }

    .newItem-Button {
        margin-top: 1rem;
        margin-left: 0;
    }

}

/* Invoice subtotal section */

.subtotalContianer {
    margin-right: 2rem;
    margin-left: 2rem;
}

.invoice-subtotal {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr;
    float: right;
    justify-content: right;
    margin-right: 20px;

}

.subtotalText {
    display: grid;
    gap: 10px;
}

.subtotalTextAmount {
    float: right;
    text-align: end;
    display: grid;
    gap: 10px;
}


/* notes section of template */

.notes {
    margin-top: 2rem;
    margin-left: 2rem;
    margin-right: 2rem;
}

.additional-notes {
    height: 3rem;
    width: 100%;
    padding-left: 5px;
    padding-top: 5px;
}



/* Invoice Sidebar */

.downloadButton {
    background-color: var(--download-button);
    color: white;
    border: none;
    font-size: larger;
    height: 50px;
    width: 100%;
    cursor: pointer;
    font-family: sans-serif;
    border-radius: 10px;
}

.downloadButton:hover {
    background-color: var(--download-hover);
}

.invoice-sidebar {
    min-width: 20%;
}

.sidebar-line {
    height: 1px;
    background-color: var(--muted-text-colour);
    width: 100%;
    margin-left: 0rem;
    margin-right: 0rem;
    margin-bottom: 0.5rem;
}

.custom-percent-input {
    position: relative;
    width: 6.2rem;
    height: 2rem;
}

.custom-percent-input input {
    width: 100%;
    padding-right: 1.8rem;
    padding-left: 0.4rem;
    height: 100%;
    box-sizing: border-box;
    font-size: 0.9rem;
}

.custom-spinner {
    position: absolute;
    right: 0.1rem;
    top: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.custom-spinner button {
    background: transparent;
    border: none;
    font-size: 0.65rem;
    line-height: 1;
    padding: 0;
    width: 1.4rem;
    cursor: pointer;
    color: var(--muted-text-colour);
    height: 50%;
}

.sidebar-download {
    margin-bottom: 2rem;
}

.taxType {
    background: var(--card-selection);
    color: var(--text-colour);
    border: 1px solid var(--text-colour);
    height: 30px;
    font-size: 14px;
    margin-bottom: 20px;
    width: 100px;
}

/* Date Format */

.dateFormatSelect {
    background: var(--card-selection);
    color: var(--text-colour);
    border: 1px solid var(--text-colour);
    height: 30px;
    font-size: 13px;
    width: 110px;
}


.tax-box {
    margin-bottom: 20px;
}

.dateFormat {
    margin-bottom: 20px;
}

/* currency dropdown */

.options {
    border: 1px solid var(--border-lines);
    width: 100%;
    height: 3rem;
    background-color: var(--card-selection)
}

.option {
    height: 100%;
    width: 100%;
    display: grid;
    grid-template-columns: 0.5fr 1fr 0.2fr;
    cursor: pointer;
    align-items: center;
}

.dropdownArrow {
    display: flex;
    justify-content: center;
    align-items: center;
}


/* Dropdown customisation */
.currency-option {
    display: flex;
    align-items: center;
    padding: 5px;
    gap: 8px;
    cursor: pointer;
}

.flag-img {
    width: 24px;
    height: 16px;
    object-fit: contain;
}

/* Make the dropdown match the full width */
#dropdownCurrencies {
    width: 100%;
    /* Match the parent container width */
    max-height: 300px;
    overflow-y: auto;
    background-color: white;
    border: 1px solid #ccc;
    z-index: 999;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

/* Wrap the entire currency control in a relatively positioned container */
.currency-wrapper {
    position: relative;
    width: 100%;
}

/* Style for each currency option */
.dropdownBox {
    border: 3px grey solid;
    background-color: transparent;
    width: 250px;
    height: 80px;
    display: grid;
    grid-template-columns: 2fr 0.2fr;
    justify-content: center;
    align-items: center;
}

.dropdownOption {
    border: 3px grey solid;
    background-color: transparent;
    width: 250px;
    height: 300px;
    border-top: 0px;
    overflow-y: scroll;
}

.dropdownChoice {
    display: grid;
    grid-template-columns: 0.7fr 0.9fr;
    justify-content: center;
    align-items: center;
    gap: 10px;
    font-size: large;
    padding-top: 5px;
    padding-bottom: 5px;
    padding-left: 5px;
}

.choiceRight {
    display: flex;
    gap: 20px;
    align-items: center;
    margin-left: 10px;
}

.flag {
    width: 100px;
    height: 60px;
    /* pick a consistent height */
    object-fit: contain;
    /* crop/scale nicely without distortion */
}

.dropdownArrow {
    font-size: 35px;
}


@media (max-width: 1200px) {
    .invoice-adSpace {
        display: none;
    }

    .invoice-sidebar {
        width: 100%;
    }

}

@media (max-width: 1036px) {
    .invoice-container {
        padding-right: 0;
    }
}

@media (max-width: 1035px) {

    .invoice-sidebar {
        width: 100%;
        margin-right: 2rem;
        overflow: hidden;
    }

    .invoice-container {
        padding-right: 2rem;
    }

}

@media (max-width: 768px) {
    .invoice-sidebar {
        margin-right: 2rem;
    }

    .sidebar-line {
        width: 100%
    }

    .invoice-container {
        padding-right: 2rem;
    }
}


/* Image preview */

/* Keep the upload box a predictable size on screen */
.logo-upload-box {
    width: 240px;
    height: 140px;
    overflow: hidden;
    /* never let content spill */
}

/* When an image is present, contain it inside the box without distortion */
#imagePreview {
    display: block;
    max-width: 100%;
    max-height: 100%;
    height: 100%;
    object-fit: contain;
    /* <— was fill, which can look stretched */
}


/* pdf download */

/* Force a new page exactly where we inject the marker */
.html2pdf__page-break {
    display: block !important;
    height: 0 !important;
    margin: 0 !important;
    border: 0 !important;
    page-break-before: always !important;
    break-before: page !important;
    width: 100% !important;
}

/* A4 page for print/PDF */
@page {
    size: A4;
    margin: 12mm;
}

/* What to hide/look like during export (we toggle .exporting on <body>) */
.exporting #invoice-sidebar,
.exporting .newItem,
/* New Item button row */
.exporting .dropdownOption,
/* currency popup if open */
.exporting .logo-upload-box,
.exporting .mobile-custom-line {
    display: none !important;
}

.export-rate {
    justify-self: start;
    text-align: left !important;
}

.exporting .subtotalContianer {
    clear: both !important;
    display: block !important;
}

/* Also make the “bottom blocks” unbreakable and block-level */
.exporting .subtotalContianer,
.exporting .notes,
.exporting .terms {
    break-inside: avoid !important;
    page-break-inside: avoid !important;
    display: block !important;
    width: 100% !important;
}

/* Keep delete column but hide the icon */
.exporting .delete-button {
    visibility: hidden !important;
    /* (not display:none) keeps grid layout */
}

/* tighter header during export */
.exporting .invoice-header {
    margin-top: 6mm !important;
}

/* Make placeholders invisible everywhere... */
.exporting input::placeholder,
.exporting textarea::placeholder {
    color: transparent !important;
}

/* Keep the totals with the table; only move to next page if needed */
.exporting .invoice-items {
    page-break-after: avoid !important;
}

.exporting .subtotalContianer {
    page-break-before: auto !important;
    break-inside: avoid !important;
    page-break-inside: avoid !important;
    float: none !important;
    /* already present, but safe to repeat */
    clear: none !important;
    /* ensure no unexpected clearance */
}

/* Ensure the items area doesn’t become a grid during export */
.exporting .invoice-items {
    display: block !important;
    margin-bottom: 6mm !important;
    /* a small, consistent gap */
}

/* ...except for the very top title input */
.exporting .invoiceBox::placeholder {
    color: inherit !important;
}

.exporting .balanceDue-amount,
.exporting .balanceDueText {
    margin-top: 5px;
    background-color: rgb(236, 236, 236);
    height: 20px;
    font-weight: bold;
    font-size: large;
}

.exporting .rateDiv {
    text-align: left;
}

/* PDF/export: still cap the logo to sane physical size on A4 */
.exporting .logo-upload-box.show-logo {
    display: inline-block !important;
    border: 0 !important;
    background: transparent !important;
    /* keep a predictable box even in export */
    width: auto;
    height: auto;
}

.exporting .logo-upload-box.show-logo img {
    display: block !important;
    max-width: 60mm;
    /* tweak to taste */
    max-height: 28mm;
    /* tweak to taste */
    width: auto;
    height: auto;
    object-fit: contain;
}

/* Remove input chrome so PDFs look typeset */
.exporting input,
.exporting textarea,
.exporting select {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    background: transparent !important;
    -webkit-appearance: none;
    appearance: none;
}

/* Tighter layout for export */
.exporting .invoice-template {
    width: 100% !important;
}

.exporting .invoice-header,
.exporting .invoice-sendTo,
.exporting .invoice-items,
.exporting .subtotalContianer,
.exporting .notes,
.exporting .terms {
    margin-left: 0 !important;
    margin-right: 0 !important;
}

/* Generic helper you can reuse anywhere that must not split */
.no-split {
    break-inside: avoid;
    page-break-inside: avoid;
}

/* Keep important invoice blocks together when exporting */
.exporting .invoice-header,
.exporting .invoice-sendTo,
.exporting .item-row,
.exporting .newItemDiv,
.exporting .subtotalContianer,
.exporting .notes,
.exporting .terms {
    break-inside: avoid;
    page-break-inside: avoid;
}

/* Also keep each details+divider pair with its row */
.exporting .item-details,
.exporting .newItemLine {
    break-inside: avoid;
    page-break-inside: avoid;
}

.exporting .invoice-container {
    padding-left: 0 !important;
    padding-right: 0 !important;
    gap: 0 !important;
}

/* Utility class we’ll toggle from JS when something is empty */
.exporting .hide-on-export {
    display: none !important;
}

/* hide editor chrome during export */
.exporting #invoice-sidebar,
.exporting .newItem,
.exporting .dropdownOption,
.exporting .mobile-custom-line {
    display: none !important;
}

/* remove input chrome & placeholders for clean PDF */
.exporting input,
.exporting textarea,
.exporting select {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    background: transparent !important;
    -webkit-appearance: none;
    appearance: none;
}

.logo-upload-box {
    width: 240px;
    height: 140px;
    overflow: hidden;
}

#imagePreview {
    display: block;
    max-width: 100%;
    max-height: 100%;
    height: 100%;
    object-fit: contain;
}

/* Export caps (still useful, but pixels above are the enforcement) */
.exporting .logo-upload-box.show-logo img {
    display: block !important;
    width: auto;
    height: auto;
    object-fit: contain;
}

.exporting input::placeholder,
.exporting textarea::placeholder {
    color: transparent !important;
}

.exporting .invoiceBox::placeholder {
    color: inherit !important;
}

/* keep top “Invoice” placeholder */

/* show the uploaded logo if present; hide the “Add Logo” text */
.exporting .logo-upload-box.show-logo {
    display: inline-block !important;
    border: 0 !important;
    background: transparent !important;
    width: auto;
    height: auto;
}

.exporting .logo-upload-box.show-logo span {
    display: none !important;
}

.exporting .logo-upload-box.show-logo img {
    display: block !important;
}

/* Make the PDF look like the live layout */
.exporting .invoice-template {
    /* Fill the A4 content area (5mm margins on each side = ~200mm) */
    width: 200mm !important;
    max-width: none !important;
}

/* Keep the 2-column grid exactly as on screen */
.exporting .invoice-sendTo {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 2rem !important;
}

.exporting .invoice-items {
    display: block !important;
}

.exporting .itemBlock,
.exporting .newItemDiv,
.exporting .item-row,
.exporting .item-details,
.exporting .newItemLine {
    display: block !important;
    width: 100% !important;
    break-inside: avoid !important;
    page-break-inside: avoid !important;
}

/* extra safety if inline styles are ever stripped */
.exporting .logo-upload-box.show-logo img {
    max-width: 60mm !important;
    max-height: 28mm !important;
    width: auto !important;
    height: auto !important;
    object-fit: contain !important;
}

/* Keep blocks together */
.no-split,
.exporting .no-split,
.exporting .itemBlock,
.exporting .newItemDiv {
    break-inside: avoid;
    page-break-inside: avoid;
}

/* Force form controls to span full width as text lines */
.exporting .invoice-billTo input,
.exporting .invoice-meta input,
.exporting .from-details input {
    display: block !important;
    width: 100% !important;
    min-height: 40px;
    /* preserves the nice row height */
    padding: 0 !important;
    /* no extra left padding since borders are gone */
    margin: 0 !important;
}

/* utility */
.exporting .hide-on-export {
    display: none !important;
}


.exporting .custom-line {
    margin: 6px 0 !important;
}

.exporting .invoice-sendTo {
    gap: 0.5rem !important;
}

/* less space between the two columns */
.exporting .invoice-billTo,
.exporting .invoice-meta {
    gap: 6px !important;
}

/* shrink row gaps inside each column */

.exporting h2 {
    margin: 0 0 2mm !important;
}

/* shorter section headings */

.exporting .invoice-items {
    margin-top: 6mm !important;
}

/* was 2rem – trim the gap to the table */

/* export-only: same widths, do not grow */
.exporting .item-header,
.exporting .item-inputs {
    grid-template-columns: 2rem 4rem minmax(250px, 0.9fr) 6rem 6rem 6rem !important;
}

/* RATE prefix overlay (export only) */
.exporting .rate-cell {
    position: relative;
    overflow: hidden;
}

.exporting .rate-cell input {
    width: 100%;
    min-width: 0;
    text-align: right;
    padding-left: 1.4em;
    /* make room for prefix */
    background: transparent;
    border: none;
}

.exporting .rate-prefix {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    white-space: nowrap;
}

/* right-align and keep amount in view */
.item-amount {
    text-align: center;
    white-space: nowrap;
}

/* footer */


.site-footer {
    background: var(--card-selection);
    color: var(--text-colour);
    border-top: 1px solid var(--border-lines);
    padding: 1.25rem clamp(1rem, 3vw, 2rem);
}

.footer-inner {
    max-width: clamp(1000px, 100vw, 1440px);
    margin: 0 auto;
    display: grid;
    grid-template-columns: 0.3fr auto;
    gap: 1rem;
    align-items: center;
}

.footer-links {
    display: flex;
    width: fit-content;
    gap: 1rem;
    flex-wrap: wrap;
}

.footer-links a {
    color: var(--text-colour);
    text-decoration: none;
}

.footer-links a:hover {
    color: var(--primary-hover);
}

.footer-social {
    display: flex;
    justify-content: flex-end;
}

.social-link {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    color: var(--text-colour);
    text-decoration: none;
}

.social-link:hover {
    color: var(--primary-hover);
}

.footer-bottom {
    max-width: clamp(1000px, 100vw, 1440px);
    margin: .5rem auto 0;
    padding-top: .75rem;
    border-top: 1px solid var(--border-lines);
    color: var(--muted-text-colour);
    font-size: .9rem;
}

@media (max-width: 768px) {
    .footer-inner {
        grid-template-columns: 1fr;
        gap: .75rem;
    }

    .footer-social {
        justify-content: flex-start;
    }
}