:root {
    color-scheme: light;
    --ink: #1d2732;
    --muted: #5f6975;
    --line: #9aaec1;
    --line-dark: #6d8499;
    --panel: #fffdf4;
    --panel-cool: #eef5fb;
    --page: #c9d7e3;
    --chrome: #174f7f;
    --chrome-dark: #0d3658;
    --chrome-light: #d8e8f5;
    --tab: #e7edf3;
    --entry: #fff6c7;
    --gain: #12633d;
    --loss: #9d261d;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-width: 320px;
    background: var(--page);
    color: var(--ink);
    font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif;
    font-size: 13px;
}

body::before {
    content: "";
    display: block;
    height: 22px;
    background: linear-gradient(#2f74a8, var(--chrome-dark));
    border-bottom: 1px solid #062844;
}

h1,
h2,
p {
    margin: 0;
}

h1 {
    font-size: 20px;
    line-height: 1.1;
}

h2 {
    font-size: 17px;
}

a {
    color: #064f8f;
}

.app-header {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(320px, 720px);
    gap: 18px;
    align-items: end;
    padding: 12px 16px;
    background: linear-gradient(#f7fbff, #d7e6f3);
    border-bottom: 1px solid var(--line-dark);
}

.app-header h1 {
    color: #0a3559;
    text-shadow: 0 1px 0 #fff;
}

.app-header p,
.register-toolbar p,
small {
    color: var(--muted);
}

.import-form,
.search-form,
.budget-form {
    display: grid;
    gap: 8px;
    align-items: end;
}

.import-form {
    grid-template-columns: 1fr 1fr auto;
}

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

label span {
    display: block;
    margin-bottom: 3px;
    color: #33495f;
    font-size: 11px;
    font-weight: 700;
}

input,
select,
button {
    width: 100%;
    min-height: 28px;
    border-radius: 2px;
    font: inherit;
}

input,
select {
    border: 1px solid #8799aa;
    padding: 4px 6px;
    background: #fff;
    box-shadow: inset 1px 1px 2px rgba(0, 0, 0, 0.12);
}

button {
    border: 1px solid #0b3e66;
    padding: 0 12px;
    background: linear-gradient(#3a82b8, #145a8d);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

button:hover {
    background: linear-gradient(#4b91c4, var(--chrome));
}

.notice {
    margin: 10px 14px 0;
    padding: 8px 10px;
    border: 1px solid;
    background: #fff;
}

.success {
    border-color: #719c82;
    color: #07543a;
    background: #edf8ef;
}

.error {
    border-color: #bb7f78;
    color: #8a1f17;
    background: #fff0ee;
}

.auth-layout {
    display: grid;
    min-height: calc(100vh - 22px);
    place-items: center;
    padding: 24px;
}

.auth-panel {
    width: min(100%, 420px);
    padding: 18px;
    background: var(--panel);
    border: 1px solid var(--line-dark);
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.15);
}

.auth-panel h1 {
    margin-bottom: 6px;
    color: var(--chrome-dark);
}

.auth-panel p {
    margin-bottom: 14px;
    color: var(--muted);
}

.auth-panel .notice {
    margin: 0 0 10px;
}

.auth-form {
    display: grid;
    gap: 10px;
}

.auth-divider {
    margin: 16px 0 10px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
    color: var(--chrome-dark);
    font-weight: 700;
}

.layout {
    display: grid;
    grid-template-columns: 292px minmax(0, 1fr);
    gap: 10px;
    padding: 10px 12px 16px;
}

.sidebar,
.register {
    min-width: 0;
}

.summary,
.account-form,
.account-row,
.account-link,
.register {
    background: var(--panel);
    border: 1px solid var(--line-dark);
}

.summary {
    display: grid;
    gap: 2px;
    padding: 10px;
    margin-bottom: 8px;
    background: linear-gradient(#fffef9, #eee5c8);
}

.summary span {
    color: var(--muted);
    font-weight: 700;
}

.summary strong {
    font-size: 24px;
    color: #123a5c;
}

.app-nav {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    margin-bottom: 8px;
    border: 1px solid var(--line-dark);
    background: #b9c9d7;
}

.app-nav a {
    display: flex;
    justify-content: center;
    padding: 7px;
    border-right: 1px solid var(--line-dark);
    background: linear-gradient(#f8fbfd, var(--tab));
    color: var(--ink);
    font-weight: 700;
    text-decoration: none;
}

.app-nav a:last-child {
    border-right: 0;
}

.app-nav a.active {
    background: linear-gradient(#2e73a8, #145781);
    color: #fff;
}

.account-form {
    display: grid;
    gap: 7px;
    padding: 9px;
    margin-bottom: 8px;
    background: #f4f1df;
}

.account-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    margin-bottom: -1px;
    background: #f9fbfd;
}

.account-row:nth-child(even) {
    background: #edf4fa;
}

.account-row.active {
    background: #cfe2f1;
    box-shadow: inset 5px 0 0 var(--chrome);
}

.account-link {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    min-width: 0;
    padding: 8px 9px;
    color: inherit;
    text-decoration: none;
}

.account-link strong,
.account-link small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.account-delete-form {
    padding-right: 6px;
}

.side-heading {
    margin: 10px 0 3px;
    padding: 5px 7px;
    border: 1px solid var(--line-dark);
    background: linear-gradient(#f8fbfd, var(--tab));
    color: var(--chrome-dark);
    font-weight: 700;
}

.register {
    overflow: hidden;
    box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.12);
}

.register-toolbar {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(280px, 440px);
    gap: 14px;
    align-items: end;
    padding: 10px 12px;
    background: linear-gradient(#f9fcff, var(--chrome-light));
    border-bottom: 1px solid var(--line-dark);
}

.register-toolbar h2 {
    color: #103c60;
}

.budget-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1px;
    background: var(--line-dark);
    border-bottom: 1px solid var(--line-dark);
}

.budget-summary div {
    display: grid;
    gap: 3px;
    padding: 12px;
    background: #fffdf4;
}

.budget-summary span {
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
}

.budget-summary strong {
    font-size: 22px;
}

.budget-form {
    grid-template-columns: minmax(180px, 1fr) minmax(160px, 220px) auto;
    padding: 10px 12px;
    background: #f4f1df;
    border-bottom: 1px solid var(--line-dark);
}

.admin-settings {
    display: grid;
    grid-template-columns: minmax(240px, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding: 10px 12px;
    background: #f4f1df;
    border-bottom: 1px solid var(--line-dark);
}

.business-form,
.business-import-form,
.invoice-form,
.tax-form {
    display: grid;
    gap: 8px;
    align-items: end;
    padding: 10px 12px;
    background: #f4f1df;
    border-bottom: 1px solid var(--line-dark);
}

.business-form {
    grid-template-columns: minmax(160px, 1fr) minmax(150px, 1fr) minmax(120px, 160px) minmax(180px, 1fr) auto;
}

.business-import-form {
    grid-template-columns: minmax(180px, 260px) minmax(160px, 1fr) auto;
    background: #edf4fa;
}

.business-form.compact {
    background: #fff8dc;
}

.invoice-form {
    grid-template-columns: minmax(150px, 1.2fr) 110px 130px 130px 120px minmax(220px, 1fr) auto;
}

.tax-form {
    grid-template-columns: minmax(220px, 1fr) 140px minmax(220px, 1fr) auto;
    background: #f4f1df;
}

.tax-note {
    padding: 8px 12px;
    border-bottom: 1px solid var(--line-dark);
    background: #fff8dc;
    color: #604b14;
    font-weight: 700;
}

.tax-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding: 8px 12px;
    border-bottom: 1px solid var(--line-dark);
    background: #edf4fa;
}

.bulk-toolbar {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: flex-end;
    padding: 7px 8px;
    border-bottom: 1px solid var(--line-dark);
    background: #fff8dc;
}

.bulk-toolbar span {
    margin-right: auto;
    color: #604b14;
    font-weight: 700;
}

.select-all-label {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    width: auto;
    color: var(--ink);
    font-weight: 700;
    white-space: nowrap;
}

.select-all-label input {
    width: auto;
    min-height: auto;
    box-shadow: none;
}

.wide-field {
    min-width: 0;
}

.section-title {
    padding: 9px 12px;
    border-bottom: 1px solid var(--line-dark);
    background: linear-gradient(#fffef9, #eee5c8);
}

.section-title h2 {
    color: var(--chrome-dark);
}

.checkbox-label {
    display: flex;
    gap: 8px;
    align-items: center;
    color: var(--ink);
    font-weight: 700;
}

.checkbox-label input {
    width: auto;
    min-height: auto;
    box-shadow: none;
}

.table-wrap {
    overflow: auto;
    background: #fff;
}

table {
    width: 100%;
    min-width: 1120px;
    border-collapse: collapse;
    font-size: 12px;
}

.budget-table {
    min-width: 760px;
}

.admin-table {
    min-width: 820px;
}

.business-table {
    min-width: 1160px;
}

.tax-table {
    min-width: 760px;
}

.tax-detail-table {
    min-width: 1040px;
}

.select-col {
    width: 58px;
    text-align: center;
}

.select-col input {
    width: auto;
    min-height: auto;
    box-shadow: none;
}

th,
td {
    padding: 6px 7px;
    border-right: 1px solid #c8d3dd;
    border-bottom: 1px solid #c8d3dd;
    text-align: left;
    vertical-align: middle;
}

th:last-child,
td:last-child {
    border-right: 0;
}

th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: linear-gradient(#fdfefe, #cddbe8);
    color: #263d52;
    font-size: 11px;
    font-weight: 700;
}

tbody tr:nth-child(even) {
    background: #eef5fb;
}

tbody tr:nth-child(odd) {
    background: #fff;
}

tbody tr:hover {
    background: #dcecf8;
}

.entry-row,
tbody tr.entry-row {
    background: var(--entry);
}

.edit-row,
tbody tr.edit-row {
    background: #dceef7;
}

.entry-row td {
    padding: 4px;
}

.entry-row input {
    min-height: 26px;
    padding: 3px 5px;
}

.money-input {
    text-align: right;
}

.amount {
    text-align: right;
    white-space: nowrap;
    font-family: "Courier New", Consolas, monospace;
}

.muted {
    color: var(--muted);
}

.positive {
    color: var(--gain);
}

.negative {
    color: var(--loss);
}

.empty-state {
    padding: 42px 24px;
    background: #fffdf4;
}

.empty-state h2 {
    margin-bottom: 8px;
    color: var(--chrome-dark);
}

.no-results {
    padding: 22px;
    text-align: center;
    color: var(--muted);
}

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

.inline-form {
    display: inline;
}

.membership-form {
    display: grid;
    grid-template-columns: 120px 130px auto;
    gap: 6px;
    align-items: center;
}

.payment-form {
    display: grid;
    grid-template-columns: 120px 90px auto;
    gap: 5px;
    align-items: center;
}

.split-panels {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(240px, 0.8fr);
    gap: 10px;
    padding: 10px;
    background: #d8e3ec;
}

.split-panels > section {
    min-width: 0;
    border: 1px solid var(--line-dark);
    background: #fff;
}

.unmapped-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px;
}

.unmapped-list span {
    display: inline-flex;
    padding: 4px 7px;
    border: 1px solid #9aaec1;
    background: #eef5fb;
}

.invoice-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    align-items: end;
}

.invoice-sheet {
    max-width: 860px;
    margin: 18px auto;
    padding: 34px;
    background: #fff;
    border: 1px solid #8b9aab;
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.14);
    font-size: 14px;
}

.invoice-head,
.invoice-parties {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 240px;
    gap: 28px;
    margin-bottom: 26px;
}

.invoice-head h1 {
    margin-bottom: 8px;
    color: var(--chrome-dark);
    font-size: 26px;
}

.invoice-number {
    padding: 16px;
    border: 1px solid #9aaec1;
    background: #eef5fb;
    text-align: right;
}

.invoice-number span,
.invoice-parties h2 {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.invoice-number strong {
    display: block;
    margin-top: 6px;
    font-size: 24px;
}

.invoice-parties dl,
.invoice-totals dl {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 6px 18px;
    margin: 0;
}

.invoice-parties dt,
.invoice-totals dt {
    color: var(--muted);
    font-weight: 700;
}

.invoice-parties dd,
.invoice-totals dd {
    margin: 0;
    text-align: right;
}

.invoice-lines,
.invoice-payments table {
    min-width: 0;
    margin-top: 12px;
}

.invoice-totals {
    display: flex;
    justify-content: flex-end;
    margin-top: 18px;
}

.invoice-totals dl {
    min-width: 280px;
    padding: 14px;
    border: 1px solid #9aaec1;
    background: #fffdf4;
}

.invoice-totals dt:last-of-type,
.invoice-totals dd:last-of-type {
    padding-top: 8px;
    border-top: 1px solid #9aaec1;
    color: var(--chrome-dark);
    font-size: 18px;
}

.invoice-payments {
    margin-top: 28px;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

@media print {
    body {
        background: #fff;
    }

    body::before,
    .app-header,
    .sidebar,
    .no-print,
    .notice {
        display: none;
    }

    .layout {
        display: block;
        padding: 0;
    }

    .register {
        border: 0;
        box-shadow: none;
    }

    .invoice-sheet {
        max-width: none;
        margin: 0;
        padding: 0;
        border: 0;
        box-shadow: none;
    }
}

.small-button,
.small-link,
.danger-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    min-height: 24px;
    padding: 0 8px;
    border-radius: 2px;
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
}

.danger-button {
    width: auto;
    border-color: #7f241d;
    background: linear-gradient(#c4574e, #9d261d);
}

.danger-button:hover {
    background: linear-gradient(#d36a62, #8f1f18);
}

.small-link {
    border: 1px solid #8799aa;
    background: linear-gradient(#fff, #e8edf3);
    color: #064f8f;
}

.danger-link {
    border: 1px solid transparent;
    background: transparent;
    color: var(--loss);
}

.danger-link:hover {
    border-color: #d9aaa5;
    background: #fff0ee;
}

.budget-meter {
    width: 150px;
    height: 9px;
    overflow: hidden;
    border: 1px solid #8aa0b3;
    background: #fff;
}

.budget-meter span {
    display: block;
    height: 100%;
    background: linear-gradient(#58a5ce, #176b94);
}

@media (max-width: 860px) {
    .app-header,
    .layout,
    .register-toolbar,
    .budget-summary,
    .budget-form,
    .business-form,
    .business-import-form,
    .invoice-form,
    .tax-form,
    .split-panels,
    .admin-settings {
        grid-template-columns: 1fr;
    }

    .import-form {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 520px) {
    .search-form {
        grid-template-columns: 1fr;
    }
}
