body {
    margin: 0;
    font-family: Arial, sans-serif;
}
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #f0f0f0;
    padding: 10px;
}
header img {
    height: 160px;
}
header nav {
    display: flex;
    align-items: center;
}
header nav a {
    margin-right: 10px;
    text-decoration: none;
}

.header-button {
    background: #000;
    color: #fff;
    padding: 8px 12px;
    border-radius: 4px;
    text-decoration: none;
    display: inline-block;
}

.header-button:hover,
.header-button.active {
    background: #e75502;
}

.link-button {
    background: none;
    border: none;
    color: #0066cc;
    padding: 0;
    font: inherit;
    cursor: pointer;
    text-decoration: underline;
}

.link-button:hover,
.link-button:focus {
    color: #004999;
}

.inline-form {
    display: inline;
    margin: 0;
}

.receipt-action {
    margin-right: 10px;
}

#menu-toggle {
    display: none;
    font-size: 24px;
    background: none;
    border: none;
}
#xero-connection-btn {
    margin-left: 0;
}
#xero-connection-btn.ok {
    background: green;
    color: white;
}
#xero-connection-btn.error {
    background: red;
    color: white;
}
#nav-links.open {
    display: flex !important;
}
.content {
    padding: 20px;
}

.invoice-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.receipts-container {
    display: flex;
}

.receipt-list {
    width: 40%;
}

.receipt-viewer {
    flex: 1;
    padding-left: 20px;
    overflow: auto;
    max-height: 80vh;
    cursor: grab;
}
.receipt-viewer canvas {
    max-width: 100%;
    height: auto;
}
.receipt-viewer.dragging {
    cursor: grabbing;
}

.invoice-box {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.invoice-box .invoice-id {
    grid-column: span 2;
    font-weight: bold;
}

.field-box {
    border: 1px solid #ccc;
    padding: 10px;
    display: flex;
    flex-direction: column;
}

.field-box.full {
    grid-column: span 2;
}

.field-box label {
    margin-bottom: 4px;
    font-weight: bold;
}

.field-box.action-box {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
}

.action-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.status-split {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-weight: bold;
    font-size: 0.9rem;
    background: #f1f1f1;
    text-transform: uppercase;
}

.status-pill--positive {
    background: #e3f6ec;
    color: #126b36;
}

.status-pill--negative {
    background: #fce8e6;
    color: #b3261e;
}

.line-item-box .add-line {
    margin-top: 5px;
    align-self: flex-start;
}

.line-items {
    width: 100%;
    border-collapse: collapse;
}

.line-items th,
.line-items td {
    border: 1px solid #ccc;
    padding: 4px;
}

.line-items input {
    width: 100%;
    box-sizing: border-box;
}

.pdf-page {
    display: block;
    margin: 0 auto 20px;
    max-width: 100%;
}

.pdf-page.selected {
    border: 2px solid blue;
}


#group-controls {
    margin: 10px 0;
    position: sticky;
    top: 0;
    background: #fff;
    padding: 10px 0;
    z-index: 1;
}

.receipt-table tr {
    cursor: pointer;
}

.invoice-match {
    background-color: #90ee90;
}

.invoice-no-match {
    background-color: #ffbf00;
}

.invoice-group {
    border: 2px solid #ddd;
    padding: 10px;
    margin-bottom: 30px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.invoice-group h3 {
    width: 100%;
    margin-top: 0;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: #fff;
    padding: 10px;
    max-height: 90vh;
    overflow: auto;
    position: relative;
}

.modal-content .close {
    position: absolute;
    top: 5px;
    right: 10px;
    cursor: pointer;
    font-size: 24px;
}

.magnifier { position: absolute; width: 200px; height: 200px; border: 2px solid #333; border-radius: 50%; pointer-events: none; overflow: hidden; display: none; box-shadow: 0 0 8px rgba(0,0,0,0.6); z-index: 1001; background-repeat: no-repeat; }

@media (max-width: 600px) {
    header nav {
        display: none;
        flex-direction: column;
        width: 100%;
        background: #f0f0f0;
    }
    .header-button {
        margin: 5px 0;
        text-align: center;
        padding: 12px;
    }
    #menu-toggle {
        display: block;
        font-size: 28px;
        padding: 8px;
    }
    #nav-links.open {
        display: flex !important;
    }
}

.home-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-top: 20px;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.home-button {
    background: #000;
    color: #fff;
    padding: 20px;
    font-size: 1.2em;
    border-radius: 8px;
    text-decoration: none;
    width: 100%;
    height: 200px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.home-button:hover,
.home-button.active {
    background: #e75502;
}

@media (max-width: 600px) {
    .home-buttons {
        grid-template-columns: repeat(2, 1fr);
    }
    .home-button {
        height: auto;
        padding: 16px;
    }
}

@media (max-width: 400px) {
    .home-buttons {
        grid-template-columns: 1fr;
    }
}

.login-container {
    max-width: 400px;
    margin: 40px auto;
    padding: 20px;
    text-align: center;
}

.login-container form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}

.login-container label {
    display: flex;
    justify-content: space-between;
}

/* General button styling for better tap targets */
button {
    padding: 10px 16px;
    font-size: 1em;
    border-radius: 4px;
    background: #000;
    color: #fff;
    cursor: pointer;
}

button:hover {
    background: #e75502;
}

@media (max-width: 600px) {
    button {
        width: 100%;
        box-sizing: border-box;
        margin-bottom: 10px;
        padding: 12px 20px;
        font-size: 1.1em;
    }
}

/* Input fields styled similar to buttons but using black/grey colours */
input[type="text"],
input[type="password"],
input[type="date"],
input[type="file"],
select,
textarea {
    padding: 10px 16px;
    font-size: 1em;
    border-radius: 4px;
    background: #f0f0f0;
    color: #000;
    border: 1px solid #ccc;
}

@media (max-width: 600px) {
    input[type="text"],
    input[type="password"],
    input[type="date"],
    input[type="file"],
    select,
    textarea {
        width: 100%;
        box-sizing: border-box;
        margin-bottom: 10px;
    }
}

/* Override button hover colour so new styles keep orange hover */
button:hover {
    background: #e75502 !important;
}

/* General table styling for invoice and receipt lists */
.invoice-table,
.receipt-table {
    width: 100%;
    border-collapse: collapse;
}
.invoice-table th,
.invoice-table td,
.receipt-table th,
.receipt-table td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
}
.invoice-table th,
.receipt-table th {
    background: #f0f0f0;
}
.invoice-table tr:nth-child(even),
.receipt-table tr:nth-child(even) {
    background: #fafafa;
}

/* Styles specific to invoice list */
.invoice-table select[name="supplier"] {
    min-width: 25ch;
}

.invoice-table input[name="amount"] {
    width: 100%;
}
.invoice-table .date-col {
    display: flex;
    flex-direction: column;
}
.invoice-table .date-col input {
    width: 120px;
    margin-bottom: 2px;
}

.invoice-table .action-btn {
    width: 100px;
}

.invoice-table input[name="invoice_number"] {
    width: 100%;
}

.invoice-table .amount-col {
    min-width: 125px;
}

.invoice-table input[name="account_code"] {
    width: 100%;
}

.invoice-table .narrative-col {
    min-width: 150px;
}

.invoice-table button[data-save] {
    display: none;
    background: #ffd27f;
    color: #000;
}

.invoice-table button[data-save]:hover {
    background: #ffd27f;
}

@media (max-width: 600px) {
    body {
        font-size: 1.2em;
    }

    header {
        display: none;
    }

    button {
        padding: 14px 24px;
        font-size: 1.2em;
    }
}
