html,
body {
    margin: 0;
    font-family: Roboto, "Helvetica Neue", Arial, sans-serif;
}

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    color: #555;
}

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    box-sizing: border-box;
    padding: 0.75rem 1.25rem;
    background: #fff4ce;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 1rem;
    top: 0.75rem;
}

/* Keep a long name from pushing the app bar off a narrow phone screen. */
.user-menu .mud-menu-button-activator {
    max-width: 45vw;
}

.user-menu .mud-menu-button-activator {
    text-transform: none;
}

.user-menu .mud-menu-button-activator .mud-button-label {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-menu .mud-menu-button-activator .mud-button-icon-start {
    display: inline-flex;
    vertical-align: middle;

    /* MudBlazor pulls the icon 4px left, which the label's overflow: hidden (for the ellipsis) then cuts off. */
    margin-left: 0;
    margin-inline-start: 0;
}

/* Read by screen readers but not shown. */
.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ---- App shell (BUD-36) ---- */

.app-title {
    display: inline-flex;
    gap: 0.4rem;
    min-width: 0;
    min-height: 44px;
    align-self: center;
    align-items: center;
    color: inherit;
    text-decoration: none;
    font-size: 1.25rem;
    font-weight: 500;
}

/* The household switcher (BUD-20): the household's name, shortened in code if it's long. It reads as part of the
   title ("Home Budget · Smith Family ▾"), so it uses the title's font and sits on the same line, with only a little
   padding so the gaps either side of the dot match. */
.household-switcher {
    display: inline-flex;
    align-items: center;
    align-self: center;
    min-width: 0;
}

.household-switcher .mud-button-root {
    text-transform: none;
    font-size: 1.25rem;
    font-weight: 500;
    line-height: inherit;
    letter-spacing: normal;
    min-height: 44px;
    min-width: 0;
    padding-left: 6px;
    padding-right: 2px;
    white-space: nowrap;
}

.household-switcher .mud-button-icon-end {
    margin-left: 2px;
    margin-right: 0;
}

.app-title-separator {
    align-self: center;
    opacity: 0.7;
}

/* Blazor moves focus to the page's heading after each navigation so screen readers announce the new page. The
   heading isn't something you can click or tab to, so it shouldn't show a focus ring. */
h1:focus,
h1[tabindex="-1"]:focus-visible {
    outline: none;
}

/* Phones: the bottom bar replaces the side drawer. */
@media (max-width: 599.98px) {
    .app-drawer {
        display: none !important;
    }

    .mud-layout .mud-main-content.app-main {
        margin-left: 0 !important;
        padding-bottom: calc(64px + env(safe-area-inset-bottom));
    }
}

.bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1100;
    padding-bottom: env(safe-area-inset-bottom);
    background-color: var(--mud-palette-surface);
    border-top: 1px solid var(--mud-palette-lines-default);
    box-shadow: 0 -1px 3px rgba(0, 0, 0, 0.08);
}

.bottom-nav-item {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 56px;
    color: var(--mud-palette-text-secondary);
    text-decoration: none;
    font-size: 0.75rem;
    font-weight: 500;
}

.bottom-nav-item.active {
    color: var(--mud-palette-primary);
}

.bottom-nav-item:focus-visible {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: -4px;
}

/* Touch targets of at least 44×44px (BUD-36). Two MudBlazor controls are built from icon buttons
   that must keep their own size:
   - calendar days: at 44px wide only six fit in a row, so dates sit under the wrong weekday (BUD-59);
   - a switch's thumb: at 44px tall it no longer lines up with its track (BUD-60). The whole switch,
     label included, is still the thing you tap. */
.mud-icon-button:not(.mud-picker-calendar-day):not(.mud-switch-base) {
    min-width: 44px;
    min-height: 44px;
}

@media (max-width: 599.98px), (pointer: coarse) {
    .mud-button-root:not(.mud-icon-button) {
        min-height: 44px;
    }
}

.mud-nav-link {
    min-height: 48px;
}

/* The side drawer's groups (BUD-115, BUD-119). */
/* The first group (Home) has no title or divider above it, so it gets the same space the dividers leave between groups
   rather than sitting against the app bar (BUD-158). */
.side-nav-list {
    padding-top: 8px;
}

.side-nav-list .mud-nav-link {
    color: inherit;
    text-decoration: none;
}

.side-nav-list .nav-section-title {
    color: var(--mud-palette-text-secondary);
}

/* The phone's More page (BUD-116): one link per row, the whole row tappable. */
.more-link {
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: 52px;
    padding: 0 12px 0 16px;
    color: inherit;
    text-decoration: none;
}

/* A More row that does something rather than going to a page (BUD-171). */
.more-button {
    width: 100%;
    border: 0;
    background: none;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.more-link:focus-visible {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: -2px;
}

/* A list of rows with dividers, for content that has its own buttons (e.g. the People page). */
.plain-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.plain-list-item {
    padding: 8px 16px;
}

.plain-list-item + .plain-list-item {
    border-top: 1px solid var(--mud-palette-lines-default);
}

/* The import file picker (BUD-67): a real file input inside a label styled as a button, so it works with the
   keyboard and screen readers. */
.import-file-button {
    cursor: pointer;
    min-height: 44px;
}

.import-file-button:focus-within {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: 2px;
}

/* A preview's key facts: label then value, two columns on wider screens. */
.import-facts {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2px 16px;
    margin: 0;
}

.import-facts dt {
    font-weight: 600;
}

.import-facts dd {
    margin: 0 0 6px;
}

@media (min-width: 600px) {
    .import-facts {
        grid-template-columns: max-content 1fr;
    }

    .import-facts dd {
        margin-bottom: 0;
    }
}

/* The category icon picker (BUD-69): a wrapping grid of icon buttons. */
.category-icon-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    margin-top: 8px;
}

/* The home page's getting-started prompts (BUD-68). */
.getting-started {
    border-left: 4px solid var(--mud-palette-primary);
}

.getting-started li + li {
    border-top: 1px solid var(--mud-palette-lines-default);
}

/* An inline "are you sure?" for removing a member (BUD-28). */
.confirm-panel {
    border: 1px solid var(--mud-palette-error);
    border-radius: var(--mud-default-borderradius);
}

/* A category's heading on the Outgoings list: its subtotal lines up with the amounts in the panel below,
   which sit inside the panel's 1px border and the list item's 16px padding. */
.category-heading {
    padding: 0 17px 0 4px;
}

/* An outgoing coming up for renewal (BUD-50, BUD-52). */
.outgoing-coming-up {
    border-left: 4px solid var(--mud-palette-warning);
}

/* Key facts on an outgoing's page (BUD-51): label then value, two columns on wider screens. */
.outgoing-facts {
    display: grid;
    grid-template-columns: minmax(8rem, max-content) 1fr;
    gap: 0.25rem 1rem;
    margin: 0;
}

.outgoing-facts dt {
    color: var(--mud-palette-text-secondary);
}

.outgoing-facts dd {
    margin: 0;
    overflow-wrap: anywhere;
}

/* The monthly budget (BUD-53). */
.budget-table {
    width: 100%;
    border-collapse: collapse;
}

.budget-table th {
    text-align: left;
    font-weight: 400;
    padding: 0.35rem 0;
}

.budget-table td {
    text-align: right;
    white-space: nowrap;
    padding: 0.35rem 0 0.35rem 1rem;
    font-variant-numeric: tabular-nums;
}

.budget-table .budget-left th,
.budget-table .budget-left td {
    font-weight: 600;
    border-top: 1px solid var(--mud-palette-lines-default);
}

.budget-table .budget-final th,
.budget-table .budget-final td {
    font-size: 1.15rem;
    border-top: 2px solid var(--mud-palette-text-primary);
}

.budget-shortfall {
    color: var(--mud-palette-error);
}

.budget-lines li + li {
    border-top: 1px solid var(--mud-palette-lines-default);
}

/* "Every [n] [period]": the number is short, so centre it (BUD-55). */
.every-field input {
    text-align: center;
}

/* List pages (Outgoings, Income): the title and actions stay at the top while the list
   scrolls. Larger screens with room to spare keep the summary and filters too (BUD-79). */
:root {
    --app-sticky-top: var(--mud-appbar-height);
}

.list-head {
    display: contents;
}

.list-head-title {
    position: sticky;
    top: var(--app-sticky-top);
    z-index: 3;
    padding: 0.5rem 0;
    background-color: var(--mud-palette-background);
}

.list-head-heading {
    min-width: 0;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (min-width: 960px) and (min-height: 720px) {
    .list-head {
        display: block;
        position: sticky;
        top: var(--app-sticky-top);
        z-index: 3;
        background-color: var(--mud-palette-background);
    }

    .list-head .list-head-title {
        position: static;
    }
}

@media (max-width: 599.98px) {
    :root {
        --app-sticky-top: calc(var(--mud-appbar-height) - var(--mud-appbar-height) / 8);
    }

    /* Buttons shrink to their icons, keeping their names for screen readers. */
    .icon-only-xs.mud-button-root {
        min-width: 0;
        padding-left: 10px;
        padding-right: 10px;
    }

    .icon-only-xs .button-label {
        display: none;
    }

    .icon-only-xs .mud-button-icon-start {
        margin: 0;
    }
}

/* Outgoings group headers open and close their group (BUD-88). */
.group-header {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 4px 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.group-header:focus-visible {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: 2px;
    border-radius: 4px;
}

.group-header .group-total {
    font-weight: 400;
    white-space: nowrap;
}

/* An account's pots as subgroups when outgoings are grouped by Paid from (BUD-101). The subtotal lines up with
   the amounts below it. */
.pot-group + .pot-group {
    border-top: 1px solid var(--mud-palette-lines-default);
}

.pot-heading {
    padding: 4px 16px 4px 12px;
    background: var(--mud-palette-background-gray);
    font-weight: 600;
}

.pot-heading + .plain-list .plain-list-item:first-child {
    border-top: 1px solid var(--mud-palette-lines-default);
}

/* Amounts never wrap, least of all between the sign and the number (BUD-128). */
.text-nowrap {
    white-space: nowrap !important;
}

/* A page's toolbar (BUD-124): toggles on the left, a menu filling the rest, all on one line even on a phone. */
.page-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
}

.page-toolbar > .mud-button-group-root {
    flex-shrink: 0;
}

.page-toolbar .toolbar-menu {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    justify-content: flex-end;
}

/* A menu on its own, e.g. Upcoming payments' account (BUD-135), starts on the left like any other toolbar. */
.page-toolbar .toolbar-menu:only-child {
    justify-content: flex-start;
}

/* The button's text is cut short with an ellipsis rather than wrapping (BUD-135). MudBlazor puts the text straight in
   the label, so the label itself truncates, and the icons sit in the button's padding either side of it. */
.page-toolbar .toolbar-menu > * {
    min-width: 0;
    max-width: 100%;
}

.page-toolbar .toolbar-menu .mud-button-root {
    position: relative;
    max-width: 100%;
    text-transform: none;
    padding-left: 34px;
    padding-right: 30px;
}

.page-toolbar .toolbar-menu .mud-button-label {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.page-toolbar .toolbar-menu .mud-button-icon-start,
.page-toolbar .toolbar-menu .mud-button-icon-end {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    margin: 0;
    /* Only as tall as the icon, so the icon itself is centred, not a line of text around it. */
    display: flex;
    align-items: center;
    line-height: 0;
}

.page-toolbar .toolbar-menu .mud-button-icon-start {
    left: 10px;
}

.page-toolbar .toolbar-menu .mud-button-icon-end {
    right: 6px;
}

/* The period navigator's menu (BUD-135). It opens in the popover layer, outside the navigator's scoped styles. */
.period-menu {
    min-width: 180px;
}

/* Text that stops at two lines with an ellipsis, e.g. a long name in a list (BUD-126). */
.two-lines {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
    overflow-wrap: anywhere;
    min-width: 0;
}

/* Styles for one page or component live beside it in a .razor.css file (scoped), not here, so features don't all
   add to the end of this file. */
