body {
    font-family: Arial, sans-serif;
    background: #f5f7fb;
    padding: 30px;
    color: #222;
}

.hidden {
    display: none;
}

.auth-gate {
    min-height: calc(100vh - 60px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-panel {
    width: min(420px, 100%);
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}

.auth-panel h2 {
    margin: 0 0 14px;
}

.auth-panel p {
    margin: 0 0 18px;
    color: #374151;
    line-height: 1.5;
}

h1 {
    margin-bottom: 25px;
}

.card {
    background: white;
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}

form {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

input {
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 8px;
}

button {
    padding: 10px 14px;
    border: none;
    border-radius: 8px;
    background: #2563eb;
    color: white;
    cursor: pointer;
}

button:hover {
    background: #1d4ed8;
}

.tenant {
    border: 1px solid #ddd;
    padding: 12px;
    border-radius: 10px;
    margin-bottom: 10px;
    background: #fafafa;
}

.tenant-name {
    font-weight: bold;
    margin-bottom: 6px;
}

.account {
    display: grid;
    grid-template-columns: 80px 1fr 140px;
    padding: 8px;
    border-bottom: 1px solid #eee;
}

.account-header,
.account-row {
    display: grid;
    grid-template-columns: 50px 100px 160px 1fr;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid #eee;
}

.account-header {
    font-weight: bold;
    background: #f3f4f6;
    border-radius: 8px;
}

.account-row:hover {
    background: #f9fafb;
}

.account-checkbox {
    width: 18px;
    height: 18px;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.tenant-selector {
    display: flex;
    align-items: center;
    gap: 10px;
}

#tenantDropdown {
    padding: 10px;
    min-width: 280px;
    border-radius: 8px;
    border: 1px solid #ccc;
}

.action-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 20px;
}

.left-panel {
    background: white;
    border-radius: 12px;
    padding: 16px;
    height: calc(100vh - 120px);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}

.right-panel {
    min-width: 0;
}

.nav-item {
    display: block;
    width: 100%;
    text-align: left;
    margin-bottom: 10px;
    background: #f3f4f6;
    color: #111827;
}

.nav-item.active {
    background: #2563eb;
    color: white;
}

.nav-section-label {
    margin: 18px 0 8px;
    padding: 0 4px;
    color: #6b7280;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

.nav-sub-item {
    padding-left: 24px;
    font-size: 14px;
}

.page {
    display: none;
}

.page.active {
    display: block;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.card-header h2 {
    margin: 0;
}

.report-page {
    display: flex;
    flex-direction: column;
    gap: 22px;
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}

.report-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.report-header h2 {
    margin: 0;
    color: #111827;
}

.report-export-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 58px;
    height: 42px;
    border: 2px solid #2563eb;
    border-radius: 999px;
    background: white;
    color: #2563eb;
    padding: 0;
}

.report-export-btn:hover {
    background: #eff6ff;
}

.report-export-btn svg {
    width: 24px;
    height: 24px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linejoin: round;
}

.report-export-btn text {
    fill: currentColor;
    stroke: none;
    font-size: 5px;
    font-weight: 700;
}

.pdf-export-frame {
    position: fixed;
    right: 0;
    bottom: 0;
    width: 1px;
    height: 1px;
    border: 0;
    opacity: 0;
    pointer-events: none;
}

.report-filter-panel {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 18px;
    padding: 28px;
    background: #e9eef3;
    border-radius: 8px;
}

.report-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.report-filter-panel > .report-field:not(.report-period-field) {
    flex: 0 0 220px;
}

.report-period-field {
    display: grid;
    grid-template-columns: auto 260px;
    align-items: center;
    gap: 18px;
    flex: 0 0 auto;
}

.report-account-field {
    flex: 1 1 320px;
    min-width: 280px;
}

.report-field span {
    color: #1f2937;
}

.report-field select,
.report-field input {
    box-sizing: border-box;
    width: 100%;
    min-height: 52px;
    padding: 0 16px;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    background-color: white;
    color: #111827;
    font-size: 16px;
}

.report-run-btn {
    flex: 0 0 132px;
    min-height: 44px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
}

.report-results {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: white;
    color: #4b5563;
    padding: 18px;
}

.report-results-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.report-results-header h3,
.report-section-title h3 {
    margin: 0;
}

.report-results-header span {
    display: inline-block;
    margin-top: 4px;
    color: #6b7280;
    font-size: 14px;
}

.report-results > .report-section,
.report-results > .report-total-row {
    max-width: 720px;
}

.report-section {
    margin-top: 18px;
}

.report-section-title,
.report-group-title,
.report-account-row,
.report-total-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 160px;
    align-items: center;
    gap: 16px;
}

.report-section-title {
    padding: 12px 0;
    border-bottom: 2px solid #e5e7eb;
    color: #111827;
}

.report-group-title {
    padding: 12px 0 8px;
    color: #111827;
    font-weight: 700;
}

.report-account-row {
    padding: 8px 0;
    border-bottom: 1px solid #f3f4f6;
    color: #374151;
}

.report-account-link,
.report-transaction-link {
    justify-self: start;
    border: 0;
    background: transparent;
    color: #2563eb;
    padding: 0;
    font: inherit;
    font-weight: 700;
    text-align: left;
    cursor: pointer;
}

.report-account-link:hover,
.report-transaction-link:hover {
    text-decoration: underline;
}

.report-section-title strong,
.report-group-title strong,
.report-account-row span:last-child,
.report-total-row strong {
    text-align: right;
}

.report-empty-row {
    padding: 12px 0;
    color: #6b7280;
}

.report-net-income-row {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 2px solid #111827;
    color: #111827;
    font-size: 18px;
}

.report-operating-income-row {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid #9ca3af;
    color: #111827;
}

.report-balance-warning {
    color: #b45309;
}

.gst-report-table {
    border: 1px solid #111827;
    border-radius: 0;
    box-shadow: none;
}

.gst-report-table td {
    border: 1px solid #111827;
    color: #111827;
    font-size: 16px;
    vertical-align: top;
}

.gst-report-table td:first-child {
    width: 68%;
}

.gst-report-table td:last-child {
    width: 32%;
    white-space: nowrap;
}

.account-transactions-filter-panel {
    align-items: flex-end;
}

.account-transactions-filter-panel .report-account-field {
    flex: 1 1 300px;
    min-width: 260px;
}

.account-transactions-period-field {
    flex: 0 0 120px;
}

.account-transactions-filter-panel > .report-field:not(.report-account-field) {
    flex: 0 0 150px;
}

.account-transactions-table {
    width: 100%;
    border-collapse: collapse;
}

.account-transactions-table th,
.account-transactions-table td {
    padding: 14px 18px;
    border-bottom: 1px solid #d8e0ea;
    color: #1f2937;
    text-align: left;
    vertical-align: top;
}

.account-transactions-table th {
    font-size: 14px;
    font-weight: 800;
    text-transform: uppercase;
}

.account-transactions-table th:nth-child(3),
.account-transactions-table th:nth-child(4),
.account-transactions-table th:nth-child(5),
.account-transactions-table td:nth-child(3),
.account-transactions-table td:nth-child(4),
.account-transactions-table td:nth-child(5) {
    text-align: right;
    white-space: nowrap;
}

.account-transactions-starting-row,
.account-transactions-total-row {
    background: #eef3f7;
    font-weight: 800;
}

.account-transactions-balance-row {
    background: #d8e1ea;
    font-weight: 800;
}

.account-transactions-balance-row span {
    display: block;
    margin-top: 4px;
    color: #5b6773;
    font-weight: 400;
}

.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;
}

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

.account-type-tab {
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    cursor: pointer;

    background: #2563eb;
    color: white;

    transition: 0.2s;
}

.account-type-tab:hover {
    background: #1d4ed8;
}

.account-type-tab.active {
    background: #111827;
    color: white;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 12px;
    overflow: hidden;
}

thead {
    background: #2563eb;
    color: white;
}

th {
    padding: 14px;
    text-align: left;
    font-size: 14px;
}

td {
    padding: 14px;
    border-bottom: 1px solid #eee;
}

.transaction-row:nth-child(even) {
    background: #f8fafc;
}

.transaction-row:hover {
    background: #eef4ff;
    transition: .2s;
}

.tx-date {
    color: #666;
    white-space: nowrap;
}

.tx-description {
    display: inline-block;
    font-weight: 500;
    max-width: 42ch;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: bottom;
    white-space: nowrap;
}

.account-badge,
.category-badge {
    display: inline-block;
    padding: 6px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.account-badge {
    background: #dbeafe;
    color: #1e40af;
}

.category-badge {
    background: #ecfdf5;
    color: #047857;
}

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

.amount.positive {
    color: #16a34a;
}

.amount.negative {
    color: #dc2626;
}

.transaction-row {
    height: 78px;
    border-bottom: 1px solid #d9e1ea;
    font-size: 26px;
}

.transaction-row td {
    padding: 18px 24px;
    vertical-align: middle;
    border-bottom: 1px solid #d9e1ea;
}

.tx-check {
    width: 45px;
}

.tx-check input {
    width: 24px;
    height: 24px;
    accent-color: #3b82f6;
}

.tx-date,
.tx-desc,
.tx-amount {
    font-weight: 800;
    color: #18202b;
    white-space: nowrap;
}

.tx-account {
    color: #1f2937;
    white-space: nowrap;
}

.tx-category {
    font-weight: 800;
    color: #18202b;
    white-space: nowrap;
}

.category-dot {
    display: inline-block;
    width: 13px;
    height: 13px;
    background: #a855f7;
    border-radius: 50%;
    margin-right: 12px;
    vertical-align: middle;
}

.uncategorized {
    font-weight: 400;
    border-bottom: 2px dashed #333;
}

.tx-amount {
    text-align: right;
}

.tx-amount.income {
    color: #07883f;
}

.tx-amount.expense {
    color: #18202b;
}

.transaction-row {
    font-size: 15px;
    height: 62px;
}

.transaction-row td {
    padding: 12px 16px;
}

.tx-date {
    font-size: 14px;
    font-weight: 600;
}

.tx-desc {
    font-size: 15px;
    font-weight: 600;
}

.tx-account,
.tx-category {
    font-size: 14px;
    font-weight: 400;
}

.tx-amount {
    font-size: 15px;
    font-weight: 700;
}

.tx-check input {
    width: 18px;
    height: 18px;
}

.category-dot {
    width: 9px;
    height: 9px;
    margin-right: 8px;
}

.card {
    overflow: hidden;
}

#transactionsPage .card {
    overflow: visible;
}

.right-panel {
    min-width: 0;
}

.load-more-container {
    text-align: center;
    margin-top: 20px;
}

#loadMoreTransactionsBtn {
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
}

.transaction-table tbody tr {
    transition: background-color 0.2s ease;
}

.transaction-table tbody tr:hover {
    background-color: #e8f5e9;
    cursor: pointer;
}

.action-btn {
    padding: 5px 10px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    background: #5b8def;
    color: white;
}

.action-btn:hover {
    opacity: 0.85;
}

.transaction-table-wrap {
    width: 100%;
    overflow-x: auto;
}

.transaction-filter-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 18px;
    padding: 12px 14px;
    border: 1px solid #d8e0ea;
    border-bottom: 0;
    border-radius: 8px 8px 0 0;
    background: #f1f5f9;
}

.show-unreviewed-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: #1f2937;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
}

.show-unreviewed-toggle input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.filter-toggle-switch {
    position: relative;
    width: 46px;
    height: 26px;
    border-radius: 999px;
    background: #94a3b8;
    transition: background-color 0.2s ease;
}

.filter-toggle-knob {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: white;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.25);
    transition: transform 0.2s ease;
}

.show-unreviewed-toggle input:checked + .filter-toggle-switch {
    background: #16a34a;
}

.show-unreviewed-toggle input:checked + .filter-toggle-switch .filter-toggle-knob {
    transform: translateX(20px);
}

.transaction-search {
    display: grid;
    grid-template-columns: minmax(220px, 320px) auto;
    align-items: center;
    overflow: hidden;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    background: white;
}

.transaction-search input {
    width: 100%;
    min-width: 0;
    border: 0;
    outline: none;
    padding: 12px 14px;
    color: #1f2937;
    font-size: 16px;
}

.transaction-search span {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    background: #e2e8f0;
    color: #475569;
    font-size: 22px;
}

.transactions-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}

.transactions-header h2 {
    margin: 0;
}

.add-transaction-menu {
    position: relative;
    flex: 0 0 auto;
}

.add-transaction-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 46px;
    padding: 0 22px;
    border: 0;
    border-radius: 999px;
    background: #0048ff;
    color: white;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
}

.add-transaction-btn:hover {
    background: #003bd1;
}

.add-transaction-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 20;
    width: 230px;
    padding: 8px 0;
    border: 1px solid #cfd8e3;
    border-radius: 8px;
    background: white;
    box-shadow: 0 12px 26px rgba(15, 23, 42, 0.16);
}

.add-transaction-dropdown.hidden {
    display: none;
}

.add-transaction-dropdown button {
    display: block;
    width: 100%;
    padding: 12px 18px;
    border: 0;
    background: transparent;
    color: #1f2937;
    font-size: 16px;
    text-align: left;
    cursor: pointer;
}

.add-transaction-dropdown button:hover {
    background: #f1f5f9;
}

.transaction-control-row {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) minmax(260px, 360px);
    gap: 12px;
    margin-bottom: 14px;
}

.account-filter,
.reconciliation-toggle {
    min-height: 76px;
    border: 1px solid #cfd8e3;
    border-radius: 8px;
    background: #ffffff;
}

.account-filter {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
        "label balance"
        "select select";
    gap: 6px 14px;
    padding: 12px 14px;
    box-sizing: border-box;
}

.account-filter-label {
    grid-area: label;
    color: #4b5563;
    font-size: 13px;
    font-weight: 700;
}

.account-filter-balance {
    grid-area: balance;
    color: #1f2937;
    font-size: 14px;
    font-weight: 700;
}

#transactionAccountFilter {
    grid-area: select;
    width: 100%;
    border: 0;
    background: transparent;
    color: #111827;
    font-size: 18px;
    font-weight: 700;
    outline: none;
}

.reconciliation-toggle {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
    color: #1f2937;
    font-size: 18px;
    font-weight: 700;
    text-align: left;
}

.reconciliation-toggle:disabled {
    cursor: not-allowed;
}

.reconciliation-toggle:hover {
    background: #f8fafc;
}

.reconciliation-toggle.disabled {
    color: #7b8794;
    background: #f8fafc;
}

.reconciliation-toggle.active {
    border-color: #2563eb;
    background: #eff6ff;
}

.reconciliation-status-text {
    display: block;
    margin-top: 4px;
    color: #64748b;
    font-size: 14px;
    font-weight: 600;
}

.reconciliation-toggle.active .reconciliation-status-text {
    color: #2563eb;
}

.reconciliation-icon {
    font-size: 22px;
}

.toggle-switch {
    position: relative;
    width: 54px;
    height: 30px;
    border-radius: 999px;
    background: #94a3b8;
    transition: background-color 0.2s ease;
}

.toggle-knob {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: white;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.25);
    transition: transform 0.2s ease;
}

.reconciliation-toggle.active .toggle-switch {
    background: #2563eb;
}

.reconciliation-toggle.active .toggle-knob {
    transform: translateX(24px);
}

.reconciliation-toggle.disabled .toggle-switch {
    background: #cbd5e1;
}

.reconciliation-panel {
    display: grid;
    grid-template-columns: minmax(320px, 1fr) auto;
    gap: 28px;
    align-items: center;
    margin-bottom: 16px;
    padding: 22px 24px;
    border: 1px solid #2563eb;
    border-radius: 8px;
    background: #ffffff;
}

.reconciliation-panel.hidden {
    display: none;
}

.reconciliation-panel-copy {
    display: flex;
    gap: 18px;
    align-items: flex-start;
}

.reconciliation-panel-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    border-radius: 6px;
    background: #bfdbfe;
    color: #1d4ed8;
    font-size: 30px;
    font-weight: 700;
    flex: 0 0 auto;
}

.reconciliation-panel h3 {
    margin: 0 0 8px;
    color: #1f2937;
    font-size: 20px;
}

.reconciliation-panel p {
    margin: 0;
    max-width: 560px;
    color: #334155;
    line-height: 1.45;
}

.reconciliation-panel-fields {
    display: grid;
    grid-template-columns: 130px 190px 190px auto;
    gap: 18px;
    align-items: end;
}

.reconciliation-panel-fields span,
.reconciliation-panel-fields label {
    display: grid;
    gap: 8px;
    color: #4b5563;
    font-size: 14px;
    font-weight: 700;
}

.reconciliation-panel-fields strong {
    color: #111827;
    font-size: 20px;
}

.reconciliation-panel-fields input {
    width: 100%;
    box-sizing: border-box;
    border-color: #bfdbfe;
}

.start-reconciliation-btn {
    min-width: 160px;
    background: #0048ff;
    color: white;
    font-weight: 700;
    border-radius: 999px;
}

.start-reconciliation-btn:hover,
.end-reconciliation-btn:hover {
    background: #003bd1;
}

.reconciliation-workspace {
    margin-bottom: 18px;
}

.reconciliation-workspace.hidden {
    display: none;
}

.reconciliation-error {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 14px;
    padding: 14px 18px;
    border: 1px solid #fecaca;
    border-left: 8px solid #c53030;
    border-radius: 8px;
    background: #fff1f2;
    color: #1f2937;
}

.reconciliation-error.hidden {
    display: none;
}

.reconciliation-summary {
    display: grid;
    grid-template-columns: 1fr 1.4fr auto 1.4fr 1fr auto;
    gap: 18px;
    align-items: center;
    margin-bottom: 14px;
    padding: 20px;
    border: 1px solid #2563eb;
    border-radius: 8px;
    background: white;
}

.reconciliation-summary > div {
    display: grid;
    gap: 8px;
    text-align: center;
}

.reconciliation-summary span {
    color: #4b5563;
    font-size: 14px;
    font-weight: 700;
}

.reconciliation-summary strong {
    color: #111827;
    font-size: 20px;
}

.reconciliation-summary small {
    color: #64748b;
    font-size: 13px;
}

.reconciliation-summary .balance-operator {
    color: #111827;
    font-size: 22px;
    font-weight: 800;
}

.reconciliation-summary .balanced {
    color: #047857;
}

.reconciliation-summary .unbalanced {
    color: #9a6700;
}

.end-reconciliation-btn {
    min-width: 170px;
    background: #0048ff;
    color: white;
    font-weight: 700;
    border-radius: 999px;
    font-size: 18px;
}

.end-reconciliation-btn:disabled {
    cursor: not-allowed;
    background: #a9c2ff;
    opacity: 1;
}

.reconciliation-table-wrap {
    overflow-x: auto;
    border: 1px solid #2563eb;
    border-radius: 8px;
}

.reconciliation-table {
    min-width: 920px;
}

.reconciliation-table thead {
    background: white;
    color: #4b5563;
}

.reconciliation-table th,
.reconciliation-table td {
    padding: 16px 18px;
    font-size: 15px;
}

.reconciliation-table tbody tr {
    background: #f0f8ff;
}

.reconciliation-line-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.reconciliation-history {
    margin-top: 18px;
}

.reconciliation-history.hidden {
    display: none;
}

.reconciliation-history h3 {
    margin: 0 0 18px;
    color: #1f2937;
    font-size: 22px;
}

.reconciliation-history-table-wrap {
    width: 100%;
    overflow-x: auto;
}

.reconciliation-history-table {
    min-width: 980px;
    border-collapse: collapse;
}

.reconciliation-history-table th,
.reconciliation-history-table td {
    padding: 18px 22px;
    border-bottom: 1px solid #d8e0ea;
    color: #1f2937;
    font-size: 18px;
    text-align: left;
}

.reconciliation-history-table th {
    font-weight: 800;
}

.reconciliation-history-table td:nth-child(3),
.reconciliation-history-table td:nth-child(4),
.reconciliation-history-table th:nth-child(3),
.reconciliation-history-table th:nth-child(4) {
    text-align: right;
}

.reconciliation-history-table th:last-child,
.reconciliation-history-table td:last-child {
    text-align: right;
}

.history-balance {
    display: inline-flex;
    gap: 12px;
    align-items: center;
    justify-content: flex-end;
}

.history-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border: 2px solid currentColor;
    border-radius: 50%;
    font-size: 14px;
    font-weight: 800;
    line-height: 1;
}

.history-status.completed {
    color: #2f7d46;
}

.history-status.draft {
    color: #9a6700;
}

.match-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 2px solid #07549b;
    border-radius: 50%;
    background: white;
    color: #07549b;
    font-size: 20px;
}

.match-toggle.matched {
    background: #07549b;
    color: white;
}

.match-toggle:disabled {
    cursor: not-allowed;
    opacity: 0.65;
}

.reconciliation-success-modal {
    width: 780px;
    max-width: 92vw;
    padding: 56px 48px;
    border-radius: 12px;
    background: white;
    text-align: center;
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.3);
}

.success-check {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 130px;
    height: 130px;
    margin-bottom: 42px;
    border-radius: 50%;
    background: #07883f;
    color: white;
    font-size: 92px;
    font-weight: 800;
}

.reconciliation-success-modal h2 {
    margin: 0 0 22px;
    color: #111827;
    font-size: 42px;
}

.reconciliation-success-modal p {
    max-width: 620px;
    margin: 0 auto 34px;
    color: #1f2937;
    font-size: 24px;
    line-height: 1.35;
}

.reconciliation-success-modal button {
    padding: 16px 32px;
    border-radius: 999px;
    background: #0057ff;
    font-size: 20px;
    font-weight: 700;
}

.transaction-table {
    width: 100%;
    min-width: 900px;
    border-collapse: collapse;
}

.transaction-table th,
.transaction-table td {
    font-size: 15px;
    white-space: nowrap;
}

.transaction-has-split-results td {
    border-bottom: none;
}

.transaction-split-results-row td {
    background: #f8fafc;
    border-bottom: 1px solid #e5eaf0;
    padding-top: 0;
}

.transaction-split-results {
    display: grid;
    gap: 6px;
    margin: 0 0 4px;
    max-width: 920px;
}

.transaction-split-result {
    display: grid;
    grid-template-columns: 10px minmax(180px, 0.8fr) minmax(220px, 1.2fr) minmax(90px, auto);
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-radius: 8px;
    background: white;
    color: #52606d;
}

.transaction-split-result.matched {
    background: #edf5ff;
}

.transaction-split-result-marker {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #93a4b8;
}

.transaction-split-result.matched .transaction-split-result-marker {
    background: #0057ff;
}

.transaction-split-result-category {
    color: #111827;
    font-weight: 700;
}

.transaction-split-result-memo {
    overflow: hidden;
    text-overflow: ellipsis;
}

.transaction-split-result-amount {
    color: #111827;
    font-weight: 700;
    text-align: right;
}

@media (max-width: 900px) {
    .transactions-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .transaction-filter-bar {
        align-items: stretch;
        flex-direction: column;
    }

    .transaction-split-result {
        grid-template-columns: 10px 1fr auto;
    }

    .transaction-split-result-memo {
        grid-column: 2 / 4;
    }

    .transaction-search {
        grid-template-columns: 1fr auto;
    }

    .transaction-control-row {
        grid-template-columns: 1fr;
    }

    .reconciliation-panel {
        grid-template-columns: 1fr;
    }

    .reconciliation-panel-fields {
        grid-template-columns: 1fr;
    }

    .reconciliation-summary {
        grid-template-columns: 1fr;
    }

    .report-filter-panel {
        align-items: stretch;
        flex-direction: column;
        padding: 22px;
    }

    .report-period-field {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .report-filter-panel > .report-field:not(.report-period-field) {
        flex-basis: auto;
    }

    .report-run-btn {
        width: 100%;
        margin-left: 0;
    }

    .report-section-title,
    .report-group-title,
    .report-account-row,
    .report-total-row {
        grid-template-columns: minmax(0, 1fr) 120px;
    }
}

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(20, 40, 70, 0.55);
    z-index: 999;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.transaction-modal {
    width: 1040px;
    max-width: 96vw;
    max-height: 92vh;
    background: white;
    border-radius: 10px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 22px 28px;
    border-bottom: 1px solid #e5eaf0;
}

.modal-header h2 {
    margin: 0;
    font-size: 22px;
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 32px;
    cursor: pointer;
    color: #475569;
}

.modal-body {
    padding: 24px 28px;
    overflow-y: auto;
    min-height: 0;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px 22px;
}

.form-grid label {
    font-weight: 700;
    color: #52606d;
}

.form-grid input,
.form-grid select {
    width: 100%;
    margin-top: 8px;
    padding: 12px 14px;
    border: 1px solid #b9d4f5;
    border-radius: 8px;
    font-size: 16px;
    box-sizing: border-box;
}

.form-grid .account-search-input {
    margin-top: 8px;
}

.account-search {
    position: relative;
    width: 100%;
}

.account-search-input {
    width: 100%;
    box-sizing: border-box;
    padding: 12px 14px;
    border: 1px solid #b9d4f5;
    border-radius: 8px;
    font-size: 16px;
    font-family: inherit;
    background: white;
}

.account-search-input:focus {
    border-color: #60a5fa;
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.22);
    outline: none;
}

.account-search-results {
    position: fixed;
    z-index: 10000;
    max-height: 260px;
    overflow-y: auto;
    border: 1px solid #bfd7ff;
    border-radius: 8px;
    background: white;
    box-shadow: 0 14px 34px rgba(15, 23, 42, 0.18);
}

.account-search.open-up .account-search-results {
    bottom: auto;
}

.account-search-option {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    border-radius: 0;
    padding: 10px 12px;
    background: white;
    color: #111827;
    text-align: left;
}

.account-search-option:hover,
.account-search-option.selected {
    background: #eff6ff;
    color: #1d4ed8;
}

.account-search-option span {
    font-weight: 700;
}

.account-search-option small {
    margin-top: 3px;
    color: #6b7280;
    font-size: 12px;
}

.account-search-empty {
    padding: 12px;
    color: #6b7280;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 28px;
    border-top: 1px solid #e5eaf0;
    flex-shrink: 0;
}

.cancel-btn,
.save-btn {
    padding: 12px 28px;
    border-radius: 24px;
    font-weight: 700;
    cursor: pointer;
}

.cancel-btn {
    background: white;
    color: #0057ff;
    border: 1px solid #0057ff;
}

.save-btn {
    background: #0057ff;
    color: white;
    border: 1px solid #0057ff;
}

.save-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.amount-debit {
    color: #1f9d55;
    font-weight: 600;
}

.amount-credit {
    color: #222;
}

.delete-btn {
    background: #dc2626;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 6px 10px;
    cursor: pointer;
}

.delete-btn:hover {
    background: #b91c1c;
}

.delete-btn:hover {
    background: #fee2e2;
}

.delete-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}

.delete-modal-overlay.active {
    display: flex;
}

.delete-modal {
    width: 480px;
    max-width: 90vw;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}

.delete-modal-header {
    background: #b72b2b;
    color: white;
    padding: 16px 22px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.delete-modal-header h2 {
    margin: 0;
    font-size: 18px;
}

.delete-modal-close {
    display: flex;
    align-items: center;
    justify-content: center;

    background: transparent;
    border: 2px solid rgba(255, 255, 255, 0.35);
    color: white;

    border-radius: 50%;

    width: 42px;
    height: 42px;

    font-size: 28px;
    font-weight: 700;
    line-height: 1;

    cursor: pointer;

    padding: 0;
}

.delete-modal-body {
    padding: 28px 22px;
    font-size: 16px;
    line-height: 1.5;
    color: #222;
}

.delete-modal-footer {
    padding: 18px 22px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.cancel-delete-btn,
.confirm-delete-btn {
    padding: 10px 24px;
    border-radius: 24px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}


.review-btn:not(:disabled):hover {
    transform: scale(1.05);
}

.transaction-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.icon-btn {
    width: 30px;
    height: 30px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 18px;
    padding: 0;
    border-radius: 6px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    transition:
        background 0.15s ease,
        border-color 0.15s ease,
        color 0.15s ease,
        transform 0.15s ease;
}

.icon-btn:hover {
    background: #f1f5f9;
}

.review-btn {
    width: 30px;
    height: 30px;
    border: 2px solid #111827;
    border-radius: 50%;
    background: white;
    box-sizing: border-box;
    color: #111827;
    font-size: 18px;
    font-weight: 700;
    line-height: 1;
}

.review-btn.reviewed {
    border-color: #16c65b;
    background: #16c65b;
    color: white;
}

.review-btn:disabled {
    border-color: #d6dee7;
    background: white;
    color: #d6dee7;
    cursor: not-allowed;
}

.review-btn:disabled:hover {
    background: white;
    transform: none;
}

.edit-btn {
    color: #111827;
}

.edit-btn:hover {
    background: #dbeafe;
}

.delete-icon-btn {
    color: #dc2626;
}

.delete-icon-btn:hover {
    background: #fee2e2;
}

/* =========================
   JOURNAL MODAL
   ========================= */

#journalModal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(15, 23, 42, 0.55);
    align-items: center;
    justify-content: center;
}

#journalModal.hidden {
    display: none;
}

#journalModal.active {
    display: flex;
}

#journalModal .modal-content {
    background: white;
    border-radius: 12px;

    width: 65vw;
    max-width: 1100px;

    max-height: 80vh;

    overflow: auto;
    padding: 20px;

    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

.journal-modal-content {
    display: flex;
    flex-direction: column;
}

.journal-form-row {
    display: flex;
    gap: 20px;
    margin: 24px;
}

.journal-form-row label {
    display: flex;
    flex-direction: column;
    font-size: 13px;
    font-weight: 600;
    color: #475569;
}

.journal-form-row input {
    margin-top: 6px;
    height: 40px;
    padding: 8px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
}

.journal-description-field {
    width: 500px;
}

/* Table */
.journal-table {
    width: calc(100% - 48px);
    margin: 0 24px;
    table-layout: fixed;
    border-collapse: collapse;
    background: white;
}

.journal-table thead {
    background: #f8fafc !important;
}

.journal-table th {
    background: #f8fafc !important;
    color: #111827 !important;
    font-weight: 700;
    font-size: 14px;
    text-align: left;
    padding: 14px 16px;
    border-bottom: 1px solid #e5e7eb;
}

.journal-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #e5e7eb;
    vertical-align: middle;
}

.journal-table th:nth-child(1),
.journal-table td:nth-child(1) {
    width: 28%;
}

.journal-table th:nth-child(2),
.journal-table td:nth-child(2) {
    width: 15%;
}

.journal-table th:nth-child(3),
.journal-table td:nth-child(3) {
    width: 15%;
}

.journal-table th:nth-child(4),
.journal-table td:nth-child(4) {
    width: 34%;
}

.journal-table th:nth-child(5),
.journal-table td:nth-child(5) {
    width: 8%;
    text-align: center;
}

.journal-table input,
.journal-table select {
    height: 44px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    box-sizing: border-box;
}

.journal-line-memo,
.journal-line-account {
    width: 100%;
}

.journal-line-debit,
.journal-line-credit {
    width: 100%;
    text-align: right;
    padding: 0 14px;
}

.journal-line-memo {
    padding: 0 12px;
}

/* Bottom row */
.journal-bottom-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin: 20px 24px 16px;
}

.add-line-btn {
    border: 1px solid #2563eb;
    color: #2563eb;
    background: white;
    border-radius: 999px;
    padding: 8px 18px;
    font-weight: 600;
}

.add-line-btn:hover {
    background: #eff6ff;
}

.journal-total-box {
    background: #eef7fb;
    border-radius: 12px;
    padding: 20px 28px;
    display: grid;
    grid-template-columns: auto auto auto;
    gap: 20px;
    align-items: center;
    width: fit-content;
}

.journal-total-box span {
    display: block;
    color: #64748b;
    margin-bottom: 6px;
}

.journal-total-box strong {
    font-size: 18px;
}

.journal-difference {
    grid-column: 1 / -1;
    text-align: center;
    font-size: 18px;
    color: #64748b;
}

#journalDifference.balanced {
    color: #22c55e;
}

#journalDifference.unbalanced {
    color: #dc2626;
}

.journal-line-action {
    text-align: center;
    padding-left: 4px !important;
    padding-right: 4px !important;
}

.journal-line-delete-btn {
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 50%;
    cursor: pointer;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    background: #fee2e2;
    color: #b91c1c;
    font-size: 14px;
    font-weight: bold;
}

.journal-line-delete-btn:hover {
    background: #fecaca;
}

.split-transaction-button {
    display: inline-flex;
    margin-top: 18px;
    font-size: 16px;
}

.split-section {
    margin-top: 20px;
    padding: 18px;
    border-radius: 8px;
    background: #f0f7fb;
}

.split-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 12px;
}

.split-header h3 {
    margin: 0;
    font-size: 18px;
}

#splitRows {
    max-height: min(36vh, 420px);
    overflow-y: auto;
    padding-right: 6px;
}

.split-row {
    display: grid;
    grid-template-columns: minmax(150px, 0.65fr) minmax(260px, 1fr) minmax(260px, 1fr) 52px;
    gap: 16px;
    align-items: end;
    margin-top: 14px;
}

.split-row input,
.split-row select {
    width: 100%;
}

.split-row .form-field label {
    margin-bottom: 6px;
}

.split-delete-btn {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: 2px solid #0057ff;
    background: white;
    color: #0057ff;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    align-self: end;
}

.split-delete-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.split-validation {
    margin: 10px 0 2px;
    padding: 12px 14px;
    border-left: 5px solid #8a6400;
    border-radius: 6px;
    background: #fff8e5;
    color: #1f2933;
    font-weight: 600;
}

.split-add-btn {
    margin-top: 16px;
}

@media (max-width: 900px) {
    .split-row {
        grid-template-columns: 1fr 1fr 52px;
    }

    .split-row .form-field:nth-child(3) {
        grid-column: 1 / 3;
    }
}

@media (max-width: 640px) {
    .split-row {
        grid-template-columns: 1fr 52px;
    }

    .split-row .form-field {
        grid-column: 1 / 2;
    }
}

.gst-divider {
    border-top: 1px solid #d9e2ec;
    margin: 24px 0 18px;
}

.gst-section h3 {
    margin: 0 0 14px;
    font-size: 18px;
}

.gst-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
}

.gst-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

.link-button {
    margin-top: 10px;
    background: none;
    border: none;
    color: #0057ff;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
}

.gst-include-button {
    display: inline-flex;
    margin-top: 18px;
    font-size: 16px;
}

.gst-include-button.hidden {
    display: none;
}

.gst-exclude-button {
    color: #c2410c;
}

.link-button:hover {
    text-decoration: underline;
    background: none;
}

.link-button:focus {
    outline: none;
}

.form-field {
    display: flex;
    flex-direction: column;
}

.form-field label {
    font-weight: 700;
    color: #52606d;
    margin-bottom: 8px;
}

.form-field input,
.form-field select {
    width: 100%;
    box-sizing: border-box;
    padding: 12px 14px;
    border: 1px solid #b9d4f5;
    border-radius: 8px;
    font-size: 16px;
    font-family: inherit;
    background: white;
}

.import-page {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.import-header,
.import-panel {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}

.import-header h2,
.import-section-header h3 {
    margin: 0;
}

.import-header p {
    margin: 8px 0 0;
    color: #6b7280;
}

.import-controls,
.import-section-header {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
}

.import-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 240px;
    color: #374151;
    font-weight: 700;
    font-size: 13px;
}

.import-field select,
.import-field input,
#importBatchSelect,
.import-category-select,
.import-gst-input {
    padding: 10px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: white;
    color: #111827;
}

.import-file-field {
    min-width: 320px;
}

.import-primary-btn {
    min-height: 40px;
}

.import-summary {
    margin-top: 14px;
    color: #4b5563;
}

.import-account-summary {
    margin-top: 8px;
    color: #6b7280;
    font-size: 13px;
}

.import-table-wrap {
    overflow-x: auto;
    margin-top: 14px;
}

.import-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 980px;
}

.import-table th,
.import-table td {
    padding: 11px 10px;
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
    vertical-align: top;
}

.import-table th {
    background: #f9fafb;
    color: #374151;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0;
}

.import-review-table small {
    display: block;
    margin-top: 4px;
    color: #6b7280;
}

.import-row-muted {
    color: #6b7280;
    background: #f9fafb;
}

.import-category-select {
    min-width: 230px;
}

.import-gst-input {
    width: 100px;
}

.confidence-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 52px;
    padding: 4px 8px;
    border-radius: 999px;
    background: #ecfdf5;
    color: #047857;
    font-weight: 700;
    font-size: 12px;
}

.import-row-actions {
    display: flex;
    gap: 8px;
}

.secondary-btn {
    background: #e5e7eb;
    color: #111827;
}

.secondary-btn:hover {
    background: #d1d5db;
}
