/*
 * The one stylesheet for RR Ledger. Hand-written: no framework, no build step, no outside fonts.
 *
 * To change the look, start with the colours just below. The brand colour is used for
 * the top bar, links and main buttons; everything else follows from these names.
 */

:root {
    --brand: #1e3a8a;
    --brand-dark: #172b66;
    --brand-soft: #e8eefc;

    --ink: #18212f;
    --muted: #556070;
    --line: #dfe5ee;
    --field-line: #8591a2;
    --surface: #ffffff;
    --page: #f3f5f9;
    --stripe: #f9fafc;
    --hover: #f0f4fc;

    --owes: #a8410b;
    --advance: #0b6b4f;
    /* Money received from a customer: payment amounts, and payment rows in a customer's ledger. */
    --received: #15803d;
    --received-row: #edf9f1;

    /* The paint business. Paint pages swap the brand colour for this one (see "Two businesses" below). */
    --paint: #6b21a8;
    --paint-dark: #581c87;
    --paint-soft: #f3e8ff;

    --error-bg: #fdeaea;
    --error-ink: #9b1c1c;
    --info-bg: #e8eefc;
    --info-ink: #1e3a8a;
    --success-bg: #e3f6ec;
    --success-ink: #0b5a41;
    --warning-bg: #fdf3c8;
    --warning-ink: #6b3a0c;

    --radius: 10px;
    --shadow: 0 1px 2px rgba(24, 33, 47, 0.06), 0 1px 3px rgba(24, 33, 47, 0.04);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 17px;
    line-height: 1.5;
    color: var(--ink);
    background: var(--page);
    -webkit-font-smoothing: antialiased;
}

h1 {
    margin: 0 0 0.25rem;
    font-size: 1.7rem;
    line-height: 1.25;
    letter-spacing: -0.01em;
}

h2 {
    margin: 0;
    font-size: 1.15rem;
    line-height: 1.3;
}

a {
    color: var(--brand);
    text-underline-offset: 2px;
}

a:hover {
    color: var(--brand-dark);
}

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

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.nowrap {
    white-space: nowrap;
}

/* Top bar */

.top-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1.5rem;
    padding: 0.6rem 1.5rem;
    color: #ffffff;
    background: var(--brand);
    box-shadow: 0 1px 4px rgba(24, 33, 47, 0.25);
}

.top-bar-left,
.top-bar-right {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1.75rem;
}

.top-bar-right {
    gap: 1rem;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 700;
    font-size: 1.2rem;
    letter-spacing: -0.01em;
    color: #ffffff;
    text-decoration: none;
}

.brand:hover {
    color: #ffffff;
}

/* The small rupee square beside the name. */
.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--brand);
    background: #ffffff;
    border-radius: 8px;
}

.main-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.15rem;
}

.main-nav a {
    padding: 0.4rem 0.8rem;
    color: rgba(255, 255, 255, 0.88);
    text-decoration: none;
    border-radius: 7px;
}

.main-nav a:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.14);
}

.main-nav a.current {
    font-weight: 600;
    color: var(--brand);
    background: #ffffff;
}

.signed-in {
    color: rgba(255, 255, 255, 0.85);
}

.top-bar form {
    margin: 0;
}

.top-bar .button-plain {
    color: #ffffff;
    background: transparent;
    border-color: rgba(255, 255, 255, 0.55);
    box-shadow: none;
}

.top-bar .button-plain:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.14);
}

.top-bar a:focus-visible,
.top-bar button:focus-visible {
    outline-color: #ffffff;
}

/* Page */

.page {
    max-width: 1080px;
    margin: 0 auto;
    padding: 2rem 1.5rem 3rem;
}

/* Add and edit forms sit on a white card in the middle of the page. */
.page-narrow {
    max-width: 600px;
    margin-top: 2rem;
    margin-bottom: 3rem;
    padding: 2rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.page-head h1,
.page-head h2 {
    margin: 0;
}

.page-sub {
    margin: 0.15rem 0 0;
}

.back {
    margin: 0 0 0.75rem;
}

.back a {
    text-decoration: none;
}

.back a:hover {
    text-decoration: underline;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1rem;
    margin: 1rem 0 1.25rem;
}

.toolbar input[type="search"] {
    flex: 1 1 240px;
    max-width: 360px;
}

/* Date boxes are typed as dd/mm/yyyy, so they only need to be this wide. */
input[type="text"].date-box {
    width: 9rem;
    max-width: 100%;
}

.toolbar input[type="text"].date-box {
    flex: none;
}

/* Under the toolbar of Sales and Payments: what is showing, and shortcuts to other days. */
.list-showing {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem 1.5rem;
    margin: 0 0 1rem;
    color: var(--muted);
}

.list-showing strong {
    color: var(--ink);
}

.list-shortcuts {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1.25rem;
}

/* Previous / Page 2 of 5 / Next */
.pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin: 1.25rem 0 0;
}

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

.pager-off,
.pager-off:hover {
    opacity: 0.45;
    cursor: default;
}

.head-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
}

.toolbar select {
    width: auto;
    min-width: 220px;
    max-width: 100%;
}

.inline-label {
    margin: 0;
}

.empty {
    padding: 2.5rem 1rem;
    color: var(--muted);
    text-align: center;
    background: var(--surface);
    border: 1px dashed #c3ccd9;
    border-radius: var(--radius);
}

/* Home page: the four figures */

.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
    padding: 0;
    list-style: none;
}

.stat {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    height: 100%;
    padding: 1.1rem 1.25rem;
    color: var(--ink);
    text-decoration: none;
    background: var(--surface);
    border: 1px solid var(--line);
    border-top: 4px solid var(--brand);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.stat:hover {
    color: var(--ink);
    border-color: #b9c6dd;
    border-top-color: var(--brand);
}

.stat-label {
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted);
}

.stat-value {
    font-size: 1.7rem;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -0.01em;
    font-variant-numeric: tabular-nums;
}

.stat-note {
    font-size: 0.95rem;
    color: var(--muted);
}

.stat-due,
.stat-due:hover {
    border-top-color: var(--owes);
}

.stat-received,
.stat-received:hover,
.stat-ok,
.stat-ok:hover {
    border-top-color: var(--advance);
}

.stat-alert,
.stat-alert:hover {
    border-top-color: var(--error-ink);
}

.stat-received .stat-value {
    color: var(--received);
}

.stat-alert .stat-value {
    color: var(--error-ink);
}

/* Home page: the short lists */

.panels {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1rem;
    align-items: start;
}

.panel-stack {
    display: grid;
    gap: 1rem;
}

.panel {
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.panel-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.9rem 1.1rem;
    border-bottom: 1px solid var(--line);
}

.panel-head a {
    font-size: 0.95rem;
    white-space: nowrap;
}

.panel table {
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

.panel th,
.panel td {
    padding-left: 1.1rem;
    padding-right: 1.1rem;
}

.panel-empty,
.panel-more {
    margin: 0;
    padding: 1.1rem;
    color: var(--muted);
}

.panel-more {
    padding-top: 0.6rem;
    padding-bottom: 0.8rem;
    font-size: 0.95rem;
    border-top: 1px solid var(--line);
}

/* Tables */

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

th,
td {
    padding: 0.7rem 1rem;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--line);
}

tbody tr:last-child td {
    border-bottom: 0;
}

thead th {
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted);
    background: var(--stripe);
    border-bottom-color: #cfd7e3;
}

/* Light stripes and a hover colour make long lists easier to read across. */
tbody tr:nth-child(even) td {
    background: var(--stripe);
}

tbody tr:hover td {
    background: var(--hover);
}

td a {
    text-decoration: none;
}

td a:hover {
    text-decoration: underline;
}

.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.notes {
    max-width: 320px;
    color: var(--muted);
    overflow-wrap: anywhere;
}

.actions {
    text-align: right;
    white-space: nowrap;
}

.actions a {
    font-weight: 500;
}

.actions a + a {
    margin-left: 0.9rem;
}

.row-inactive td {
    color: var(--muted);
}

/* Balances: money owed, money paid ahead, and nothing either way. */
.owes {
    font-weight: 600;
    color: var(--owes);
}

.advance {
    font-weight: 600;
    color: var(--advance);
}

/* A payment received from a customer. */
.received {
    font-weight: 600;
    color: var(--received);
}

table.ledger tbody tr.row-payment td,
table.ledger tbody tr.row-payment:hover td {
    background: var(--received-row);
}

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

.badge {
    display: inline-block;
    margin-left: 0.4rem;
    padding: 0.05rem 0.55rem;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.5;
    color: var(--muted);
    vertical-align: middle;
    background: #edf0f5;
    border-radius: 999px;
}

.badge-voided {
    color: var(--error-ink);
    background: var(--error-bg);
}

h1 .badge {
    font-size: 0.85rem;
}

/* Forms and buttons */

label {
    display: block;
    margin: 0 0 0.3rem;
    font-weight: 600;
}

.field {
    margin-top: 1.25rem;
}

.optional {
    font-weight: 400;
    color: var(--muted);
}

.hint {
    margin: 0 0 0.35rem;
    font-size: 0.95rem;
    color: var(--muted);
}

.field-error {
    margin: 0.35rem 0 0;
    font-weight: 600;
    color: var(--error-ink);
}

input[type="text"],
input[type="password"],
input[type="search"],
input[type="tel"],
input[type="number"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 0.6rem 0.75rem;
    font: inherit;
    color: inherit;
    background: var(--surface);
    border: 1px solid var(--field-line);
    border-radius: 8px;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--brand);
}

input[aria-invalid="true"],
select[aria-invalid="true"] {
    border-color: var(--error-ink);
    border-width: 2px;
}

label.check {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    font-weight: 500;
}

label.check input {
    width: 1.15rem;
    height: 1.15rem;
    accent-color: var(--brand);
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible,
a:focus-visible {
    outline: 3px solid #93b4f5;
    outline-offset: 2px;
}

button,
.button {
    display: inline-block;
    padding: 0.6rem 1.25rem;
    font: inherit;
    font-weight: 600;
    line-height: 1.4;
    color: #ffffff;
    text-decoration: none;
    background: var(--brand);
    border: 1px solid var(--brand);
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(24, 33, 47, 0.15);
    cursor: pointer;
}

button:hover,
.button:hover {
    color: #ffffff;
    background: var(--brand-dark);
    border-color: var(--brand-dark);
}

.button-plain {
    padding: 0.35rem 0.8rem;
    font-weight: 500;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid #b4bdcb;
    box-shadow: 0 1px 2px rgba(24, 33, 47, 0.05);
}

.button-plain:hover {
    color: var(--ink);
    background: var(--hover);
    border-color: #98a4b6;
}

a.button-plain {
    display: inline-block;
}

.toolbar .button-plain,
.form-actions .button-plain,
.quick-actions .button-plain,
.page-head .button-plain {
    padding: 0.6rem 1rem;
}

.button-danger {
    color: var(--error-ink);
    background: var(--surface);
    border: 1px solid var(--error-ink);
    box-shadow: none;
}

.button-danger:hover {
    color: #ffffff;
    background: var(--error-ink);
    border-color: var(--error-ink);
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
    margin-top: 1.75rem;
}

.form-actions form {
    margin: 0;
}

.danger-zone {
    margin-top: 2.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--line);
}

fieldset.plain {
    margin: 0;
    padding: 0;
    border: 0;
    min-width: 0;
}

fieldset.plain:disabled {
    opacity: 0.65;
}

/* The chosen date in words, under a date box. The height is kept so the page does not jump. */
.date-words {
    margin: 0.3rem 0 0;
    min-height: 1.4em;
}

/* Messages */

.alert {
    margin: 1rem 0;
    padding: 0.7rem 0.9rem;
    border-left: 4px solid currentColor;
    border-radius: 8px;
}

.alert-error {
    color: var(--error-ink);
    background: var(--error-bg);
}

.alert-info {
    color: var(--info-ink);
    background: var(--info-bg);
}

.alert-success {
    color: var(--success-ink);
    background: var(--success-bg);
}

.alert-warning {
    color: var(--warning-ink);
    background: var(--warning-bg);
}

.alert p {
    margin: 0;
}

.alert p + p {
    margin-top: 0.35rem;
    font-weight: 600;
}

/* Bills */

.section-title {
    margin: 2rem 0 0.25rem;
}

.field-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0 1.5rem;
}

.field-row .field {
    flex: 1 1 200px;
}

.field-row .field-wide {
    flex: 3 1 320px;
}

/* The rows of the bill form hold boxes to type in, so they get no stripes or hover colour. */
table.lines tbody tr td,
table.lines tbody tr:hover td {
    vertical-align: top;
    background: var(--surface);
}

table.lines .line-number {
    width: 150px;
}

table.lines .line-number input {
    text-align: right;
}

table.lines .line-amount-cell {
    width: 170px;
    padding-top: 1.2rem;
}

table.lines tfoot td,
table.lines tfoot th,
table.bill tfoot td,
table.bill tfoot th,
table.ledger tfoot td,
table.ledger tfoot th {
    border-top: 2px solid #cfd7e3;
    border-bottom: 0;
    vertical-align: middle;
    font-size: 1rem;
    font-weight: 600;
    color: var(--ink);
    background: var(--surface);
}

.bill-total {
    font-size: 1.2rem;
    font-weight: 700;
}

.bill-voided td {
    color: var(--muted);
}

.bill-voided .bill-total,
.struck {
    text-decoration: line-through;
}

.bill-notes {
    margin: 1rem 0 0;
}

/* Ledgers */

/* Customers / Items / Day book, under the Ledgers heading. */
.sub-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin: 0.75rem 0 1rem;
    border-bottom: 2px solid var(--line);
}

.sub-tabs a {
    margin-bottom: -2px;
    padding: 0.55rem 1.1rem;
    font-weight: 600;
    color: var(--muted);
    text-decoration: none;
    border-bottom: 3px solid transparent;
}

.sub-tabs a:hover {
    color: var(--brand);
}

.sub-tabs a.current {
    color: var(--brand);
    border-bottom-color: var(--brand);
}

h2.section-head {
    font-size: 1.15rem;
}

.day-note {
    margin-top: 1.5rem;
}

/* On the Day book the four figures are not links, so they do not react to the mouse. */
div.stat:hover {
    border-color: var(--line);
    border-top-color: var(--brand);
}

div.stat.stat-received:hover {
    border-top-color: var(--advance);
}

.section-head {
    margin-top: 2.25rem;
    margin-bottom: 0.75rem;
}

.ledger-summary {
    margin: 0 0 1rem;
    font-size: 1.1rem;
}

table.ledger tbody tr.ledger-start td {
    color: var(--muted);
    background: var(--brand-soft);
}

.ledger-total {
    font-weight: 700;
}

/* Sign-in and error pages */

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1.5rem;
    background: linear-gradient(160deg, var(--brand) 0%, var(--brand-dark) 100%);
}

.login-card {
    width: 100%;
    max-width: 400px;
    padding: 2.25rem 2rem 2rem;
    background: var(--surface);
    border-radius: 14px;
    box-shadow: 0 12px 32px rgba(10, 18, 40, 0.35);
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    margin-bottom: 0.25rem;
}

.login-brand .brand-mark {
    width: 2.5rem;
    height: 2.5rem;
    font-size: 1.4rem;
    color: #ffffff;
    background: var(--brand);
    border-radius: 10px;
}

.login-brand h1 {
    margin: 0;
}

.login-tagline {
    margin: 0 0 1rem;
    color: var(--muted);
}

.login-card label {
    margin-top: 1rem;
}

.login-card button {
    width: 100%;
    margin-top: 1.5rem;
}

/* Printing a ledger or a bill: just the page, no bar, buttons or links. */

@media print {
    body {
        font-size: 11pt;
        background: #ffffff;
    }

    .top-bar,
    .toolbar,
    .form-actions,
    .quick-actions,
    .back,
    .button,
    .actions,
    .alert-success {
        display: none !important;
    }

    .page {
        max-width: none;
        padding: 0;
    }

    table,
    .panel,
    .stat {
        box-shadow: none;
    }

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

    a {
        color: inherit;
        text-decoration: none;
    }
}

/* Two businesses: cement and paint */

/*
 * Cement pages use the brand blue. Paint pages (the header has the class "site-paint")
 * swap the brand colour for the paint colour, so the top bar, links and main buttons
 * all change and the owner can tell at a glance which business he is entering.
 */
body:has(.site-paint) {
    --brand: var(--paint);
    --brand-dark: var(--paint-dark);
    --brand-soft: var(--paint-soft);
    --info-bg: var(--paint-soft);
    --info-ink: var(--paint);
    --hover: #f8f1ff;
}

/* The strip under the top bar with the pages of the business being looked at. */
.section-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem;
    padding: 0 1.5rem;
    background: var(--brand-soft);
    border-bottom: 1px solid var(--line);
}

.section-name {
    margin-right: 0.75rem;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--brand);
}

.section-nav a {
    padding: 0.55rem 0.9rem;
    font-weight: 600;
    color: var(--muted);
    text-decoration: none;
    border-bottom: 3px solid transparent;
}

.section-nav a:hover {
    color: var(--brand);
}

.section-nav a.current {
    color: var(--brand);
    border-bottom-color: var(--brand);
}

/* "Cement" and "Paint" tags in lists that show both businesses. */
.badge-cement {
    color: #1e3a8a;
    background: #e8eefc;
}

.badge-paint {
    color: var(--paint);
    background: var(--paint-soft);
}

td > .badge:first-child {
    margin-left: 0;
}

/* A main button that leads to a paint page from a page that is not a paint page. */
.button-paint,
.button-paint:hover {
    background: var(--paint);
    border-color: var(--paint);
}

.button-paint:hover {
    background: var(--paint-dark);
    border-color: var(--paint-dark);
}

/* The paint bill has seven columns, so its page is wider than the others. */
.page-wide {
    max-width: 1280px;
}

table.paint-lines .item-pick {
    position: relative;
    min-width: 17rem;
}

table.paint-lines .line-number {
    width: 118px;
}

table.paint-lines .line-size {
    width: 96px;
}

table.paint-lines .line-unit {
    width: 88px;
}

table.paint-lines .line-amount-cell {
    width: 140px;
}

table.paint-lines input,
table.paint-lines select {
    width: 100%;
}

/* The list of matching paint items under the box being typed in. */
.item-matches {
    position: absolute;
    z-index: 20;
    top: calc(100% - 0.55rem);
    left: 0.75rem;
    width: max(100%, 30rem);
    max-width: 90vw;
    max-height: 21rem;
    margin: 0;
    padding: 0.3rem;
    overflow-y: auto;
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--field-line);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(24, 33, 47, 0.18);
}

.item-match {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.1rem 1rem;
    padding: 0.45rem 0.6rem;
    border-radius: 6px;
    cursor: pointer;
}

.item-match:hover,
.item-match.marked {
    background: var(--brand-soft);
}

.item-match-name {
    font-weight: 600;
}

.item-match-note {
    font-size: 0.85rem;
    color: var(--muted);
}

.item-matches-note {
    padding: 0.45rem 0.6rem;
    font-size: 0.85rem;
    color: var(--muted);
}

.item-match + .item-matches-note {
    margin-top: 0.3rem;
    border-top: 1px solid var(--line);
}

.item-new {
    margin: 0.3rem 0 0;
    font-weight: 600;
    color: var(--paint);
}

/* "Payment for: Cement / Paint" on the payment form. */
fieldset.choice {
    min-width: 0;
    padding: 0;
    border: 0;
}

fieldset.choice legend {
    padding: 0;
    font-weight: 600;
}

.choice-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 0.35rem;
}

.choice-option {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 9rem;
    padding: 0.6rem 1rem;
    font-weight: 600;
    background: var(--surface);
    border: 1px solid var(--field-line);
    border-radius: 8px;
    cursor: pointer;
}

.choice-option:has(input:checked) {
    color: #1e3a8a;
    background: #e8eefc;
    border-color: #1e3a8a;
}

.choice-paint:has(input:checked) {
    color: var(--paint);
    background: var(--paint-soft);
    border-color: var(--paint);
}

fieldset.choice[aria-invalid="true"] .choice-option {
    border-color: var(--error-ink);
}

/* Cement / Paint switch above the customer balances on the Ledgers page. */
.business-switch {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin: 0 0 1rem;
}

.business-switch a {
    padding: 0.4rem 1.1rem;
    font-weight: 600;
    color: var(--ink);
    text-decoration: none;
    background: var(--surface);
    border: 1px solid #b4bdcb;
    border-radius: 999px;
}

.business-switch a.current {
    color: #ffffff;
    background: var(--brand);
    border-color: var(--brand);
}

.business-switch a.switch-paint.current {
    background: var(--paint);
    border-color: var(--paint);
}

.business-switch .muted {
    margin-left: 0.5rem;
    font-size: 0.9rem;
}

/* What one customer owes for cement, for paint and together, at the top of their ledger. */
.due-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin: 1rem 0 0.5rem;
    padding: 0;
    list-style: none;
}

.due-cards li {
    flex: 1 1 180px;
    padding: 0.7rem 1rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-left: 4px solid var(--brand);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.due-cards li.due-paint {
    border-left-color: var(--paint);
}

.due-cards li:last-child {
    border-left-color: var(--ink);
}

.due-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted);
}

.due-amount {
    font-size: 1.25rem;
    font-weight: 700;
}

.business-ledger {
    margin-top: 2rem;
    padding-top: 0.25rem;
    border-top: 3px solid var(--brand);
}

.business-ledger.ledger-paint {
    border-top-color: var(--paint);
}

.business-ledger.ledger-paint h2 {
    color: var(--paint);
}

/* The total of the cement and paint columns on the Customers list. */
td.due-total {
    font-weight: 700;
}

.split-note {
    display: block;
    font-size: 0.8rem;
    font-weight: 400;
    color: var(--muted);
}

.panel-links a + a {
    margin-left: 0.9rem;
}

@media (max-width: 720px) {
    .section-nav {
        padding: 0 0.75rem;
    }
}

/* ---- Calendar on date boxes ----
   date-picker.js puts every date box in a .date-field with a calendar button beside it,
   and opens a .calendar under them. Typing the date still works. */

.date-field {
    position: relative;
    display: inline-flex;
    align-items: stretch;
    gap: 0.35rem;
    max-width: 100%;
    vertical-align: middle;
}

.toolbar .date-field {
    flex: none;
}

.date-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.6rem;
    color: var(--brand);
    background: var(--surface);
    border: 1px solid var(--field-line);
    box-shadow: none;
}

.date-button:hover,
.date-button[aria-expanded="true"] {
    color: var(--brand);
    background: var(--brand-soft);
    border-color: var(--brand);
}

.calendar {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 30;
    width: 17.5rem;
    padding: 0.75rem;
    font-weight: 400;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 12px 30px rgba(24, 33, 47, 0.18);
}

.calendar[hidden] {
    display: none;
}

/* Near the right edge of the window the calendar lines up with the right of the box instead. */
.calendar.opens-left {
    left: auto;
    right: 0;
}

.calendar button {
    padding: 0;
    font-weight: 500;
    color: var(--ink);
    background: transparent;
    border: 1px solid transparent;
    box-shadow: none;
}

.calendar button:hover {
    color: var(--ink);
    background: var(--hover);
    border-color: transparent;
}

.calendar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.calendar-month {
    font-weight: 600;
}

.calendar .calendar-move {
    width: 2.2rem;
    height: 2.2rem;
    font-size: 1.3rem;
    line-height: 1;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    text-align: center;
}

.calendar-weekday {
    padding: 0.25rem 0;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted);
}

.calendar .calendar-day {
    height: 2.2rem;
    font-variant-numeric: tabular-nums;
}

.calendar .is-today {
    border-color: var(--brand);
}

.calendar .is-chosen,
.calendar .is-chosen:hover {
    font-weight: 600;
    color: #ffffff;
    background: var(--brand);
    border-color: var(--brand);
}

.calendar-foot {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    text-align: right;
    border-top: 1px solid var(--line);
}

.calendar .calendar-today {
    padding: 0.3rem 0.8rem;
    font-weight: 600;
    color: var(--brand);
}

/* ---------- Error page ---------- */

/* The reference to read out when reporting a problem: spaced so the letters are not run together. */
.problem-reference {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 1.15rem;
    letter-spacing: 0.15em;
}
