body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: #f5f7fb;
}
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;
}

body.list_invoices .content {
    max-width: none;
    width: 100%;
    margin: 32px 0 80px;
    padding: 0 20px 40px;
}

body.list_invoices .invoice-toolbar,
body.list_invoices .invoice-workspace {
    width: 100%;
}

body.list_invoices .invoice-workspace {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 32px;
    align-items: flex-start;
    justify-content: center;
}

body.list_invoices .invoice-workspace__details,
body.list_invoices .invoice-workspace__viewer {
    width: 100%;
    flex: 1 1 0%;
    min-width: 0;
    max-width: 1100px;
}

body.list_invoices .invoice-workspace__details {
    max-width: none;
}

body.list_invoices .invoice-workspace__viewer {
    position: static;
    height: auto;
}

body.list_invoices .invoice-viewer {
    width: 100%;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    height: 100%;
    margin: 0 auto;
}

body.list_invoices .invoice-viewer__content,
body.list_invoices .invoice-viewer__pages,
body.list_invoices #preview-wrapper {
    width: 100%;
}

body.list_invoices .invoice-viewer__pages,
body.list_invoices #preview-wrapper {
    overflow: auto;
}

.invoice-toolbar {
    background: #fff;
    border: 1px solid #e4e7ec;
    border-radius: 24px;
    padding: 20px;
    margin-bottom: 24px;
    box-shadow: 0 25px 70px rgba(15, 23, 42, 0.08);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.invoice-toolbar__row {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-start;
}

.invoice-toolbar__title {
    max-width: 560px;
}

.invoice-toolbar__eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
    font-size: 0.8rem;
    margin: 0 0 4px;
    color: #64748b;
}

.invoice-toolbar__title h1 {
    margin: 0;
    font-size: 1.9rem;
    color: #0f172a;
}

.invoice-toolbar__description {
    margin: 4px 0 0;
    color: #4b5563;
}

.invoice-toolbar__nav,
.invoice-toolbar__actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.invoice-toolbar__counter {
    font-weight: 600;
    color: #0f172a;
    min-width: 140px;
}

.invoice-toolbar__filters {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.invoice-toolbar__recipient {
    display: none;
    align-items: center;
    gap: 8px;
}

.invoice-toolbar__recipient select {
    min-width: 200px;
}

.receipts-container {
    display: grid;
    grid-template-columns: minmax(380px, calc(50% - 100px)) minmax(580px, calc(50% + 100px));
    gap: 24px;
    align-items: stretch;
    width: 100%;
}

.receipts-container .receipt-list.invoice-flow {
    min-width: 380px;
}

.receipts-container .invoice-viewer.receipt-viewer {
    min-width: 580px;
}

.invoice-workspace {
    width: 100%;
}

.invoice-workspace__details,
.invoice-workspace__viewer {
    min-width: 0;
}

.invoice-workspace__details {
    width: 100%;
}

.invoice-workspace__viewer {
    width: 100%;
    position: sticky;
    top: 120px;
    height: 100%;
    align-self: start;
}

.receipt-list {
    width: 100%;
    min-width: 0;
}

.invoice-flow {
    display: flex;
    flex-direction: column;
    gap: 30px;
    width: 100%;
}

.invoice-box {
    display: block;
}

.invoice-card {
    border: 1px solid #e5e7eb;
    border-radius: 24px;
    background: #fff;
    box-shadow: 0 35px 80px rgba(15, 23, 42, 0.07);
    overflow: hidden;
}

.invoice-card__header {
    padding: 24px;
    border-bottom: 1px solid #edf0f7;
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: space-between;
}

.invoice-card__title {
    flex: 1;
    min-width: 220px;
}

.invoice-card__eyebrow {
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin: 0;
    color: #475569;
}

.invoice-card__meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px 24px;
    margin-top: 8px;
}

.invoice-card__meta span {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: #94a3b8;
    letter-spacing: 0.08em;
}

.invoice-card__meta strong {
    font-size: 1.1rem;
    color: #0f172a;
}

.invoice-card__status {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 14px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

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

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

.invoice-card__controls {
    padding: 16px 24px;
    border-bottom: 1px solid #edf0f7;
}

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

.invoice-card__body {
    padding: 24px;
}

.invoice-card__form-fields {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.field-box {
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 12px;
    background: #f9fafb;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field-box.full {
    grid-column: 1 / -1;
}

.field-box label {
    margin: 0;
    font-weight: 600;
    color: #475569;
}

.field-box input,
.field-box select {
    border: 1px solid #cbd5f5;
    border-radius: 8px;
    padding: 8px;
    font-size: 1rem;
    background: #fff;
}


.invoice-viewer {
    border: 1px solid #e2e8f0;
    border-radius: 24px;
    padding: 20px;
    background: #fff;
    box-shadow: 0 25px 60px rgba(15, 23, 42, 0.08);
}

.invoice-viewer__meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}

.invoice-viewer__meta p {
    margin: 0;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #94a3b8;
}

.invoice-viewer__meta strong {
    display: block;
    margin-top: 4px;
    font-size: 1.1rem;
    color: #0f172a;
}

.invoice-viewer__placeholder {
    margin: 0 0 16px;
    color: #64748b;
}

.invoice-viewer__controls {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.invoice-viewer__pages {
    margin-bottom: 16px;
}

.invoice-viewer__thumbnails {
    max-height: 80vh;
    overflow: auto;
}

.invoice-card__line-items {
    border-top: 1px solid #edf0f7;
    padding: 0 24px 24px;
}

.line-item-box {
    background: #f9fafb;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.line-item-box.total-match,
.field-box.total-match {
    background: #ecfdf3;
    border-color: #4ade80;
    box-shadow: 0 0 0 1px #4ade80;
}

.line-item-box.total-match input,
.field-box.total-match input {
    background: #ecfdf3;
}

.invoice-card__line-items-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.invoice-card__line-items-header h3 {
    margin: 0;
}

.invoice-card__line-items-header p {
    margin: 4px 0 0;
    color: #475569;
    font-size: 0.9rem;
}

.line-item-box__table-wrapper {
    overflow-x: auto;
}

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

.line-items th,
.line-items td {
    border: 1px solid #cbd5f5;
    padding: 6px;
    white-space: nowrap;
    background: #fff;
}

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

.line-items td:nth-child(2) input {
    min-width: 240px;
}

.line-items td:nth-child(3) input,
.line-items td:nth-child(5) input,
.line-items td:nth-child(6) input {
    min-width: 120px;
}

.invoice-empty {
    border: 1px dashed #cbd5f5;
    padding: 40px;
    text-align: center;
    border-radius: 16px;
    color: #475569;
    background: #fff;
}

.receipt-viewer {
    width: 100%;
    padding-left: 0;
    overflow: auto;
    max-height: 70vh;
    cursor: grab;
}

@media (max-width: 1200px) {
    .invoice-workspace__viewer {
        position: static;
        height: auto;
    }
}

@media (max-width: 1100px) {
    .invoice-workspace {
        grid-template-columns: 1fr;
    }

    body.list_invoices .invoice-workspace {
        flex-direction: column;
    }

    .receipts-container {
        grid-template-columns: 1fr;
    }

    .receipt-viewer {
        max-height: none;
    }
}
.receipt-viewer canvas {
    max-width: 100%;
    height: auto;
}
.receipt-viewer.dragging {
    cursor: grabbing;
}

.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 .logo {
    max-width: 240px;
    width: 100%;
    height: auto;
    display: block;
    margin: 0 auto 24px;
}

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

.login_container label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

@media (max-width: 600px) {
    .login_container {
        margin: 20px;
    }

    .login_container .logo {
        max-width: 180px;
    }
}

/* 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;
    }
}
