h1:focus {
    outline: none;
}

.validation-message {
    color: #c62828;
}

/* Login: a static page without MudBlazor, so it follows the system color scheme by itself. */
.login-page {
    min-height: 100vh;
    margin: 0;
    padding: 10vh 16px 0;
    box-sizing: border-box;
    font-family: Roboto, system-ui, sans-serif;
    background: #fafafa;
    color: #212121;
}

.login {
    max-width: 360px;
    margin: 0 auto;
}

.login h1 {
    margin: 0 0 24px;
    font-size: 1.5rem;
    font-weight: 500;
}

.login form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.login .login-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.login input:not([type=checkbox]) {
    min-height: 44px;
    padding: 0 12px;
    font-size: 1rem;
    border: 1px solid #9e9e9e;
    border-radius: 4px;
    background: transparent;
    color: inherit;
}

.login .login-remember {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
}

.login .login-remember input {
    width: 20px;
    height: 20px;
}

.login button {
    min-height: 44px;
    font-size: 1rem;
    border: none;
    border-radius: 4px;
    background: #2e7d32;
    color: #ffffff;
    cursor: pointer;
}

.login-error {
    color: #c62828;
}

@media (prefers-color-scheme: dark) {
    .login-page {
        background: #121212;
        color: #e0e0e0;
    }

    .login-error,
    .validation-message {
        color: #ef9a9a;
    }
}

body {
    margin: 0;
}

/* Once the layout is there, the theme decides the page background, not the early script in App.razor. */
html:has(.mud-layout) {
    background: var(--mud-palette-background) !important;
}

/* Main navigation in the app bar from 600 px on; below that the drawer menu takes over. */
.top-nav {
    gap: 4px;
    align-self: stretch;
}

.top-nav a {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 0 12px;
    color: inherit;
    text-decoration: none;
    border-bottom: 3px solid transparent;
}

.top-nav a.active {
    border-bottom-color: currentColor;
    font-weight: 500;
}

.text-nowrap {
    white-space: nowrap;
}

.cursor-pointer {
    cursor: pointer;
}

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

/* Filters side by side, stacked on phones. */
.inventory-filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0 16px;
}

.inventory-description {
    font-size: 0.8125rem;
}

.text-break {
    overflow-wrap: anywhere;
}

/* Choices of the new-list dialog. */
.choice-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
}

.choice-card {
    padding: 16px;
    min-height: 44px;
    cursor: pointer;
}

.choice-card:hover,
.choice-card:focus-visible {
    border-color: var(--mud-palette-primary);
}

.choice-card-static {
    cursor: default;
}

/* Head of a list: fields side by side, stacked on phones. */
.list-head {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 0 16px;
}

.list-head-wide {
    grid-column: span 2;
}

/* Weight bar: base and pack weight large, worn small. */
.weight-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 8px 32px;
    padding: 12px 16px;
}

.weight-label {
    font-size: 0.8125rem;
    color: var(--mud-palette-text-secondary);
}

.weight-value {
    font-size: 1.75rem;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.weight-small {
    color: var(--mud-palette-text-secondary);
    font-variant-numeric: tabular-nums;
}

/* Rows of the list editor. Phones: title and weight, then the item, then the switches.
   Wide screens: everything in one line. */
.entry-group-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding: 0 4px 4px;
}

.entry-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
        "title weight"
        "item item"
        "actions actions";
    align-items: center;
    gap: 4px 12px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--mud-palette-lines-default);
}

.entry-row:last-child {
    border-bottom: none;
}

@media (min-width: 960px) {
    .entry-row {
        grid-template-columns: 220px minmax(0, 1fr) auto 90px;
        grid-template-areas: "title item actions weight";
    }
}

.entry-title {
    grid-area: title;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px 8px;
    min-width: 0;
}

.entry-name {
    font-weight: 500;
    overflow-wrap: anywhere;
}

.entry-type {
    font-size: 0.8125rem;
}

.entry-required {
    font-size: 0.75rem;
    color: var(--mud-palette-primary);
}

.entry-weight {
    grid-area: weight;
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.entry-item {
    grid-area: item;
    min-width: 0;
}

.entry-actions {
    grid-area: actions;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.entry-toggle {
    min-height: 44px;
}

.entry-quantity {
    min-width: 2.5em;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.entry-skipped .entry-name {
    text-decoration: line-through;
    opacity: 0.7;
}

/* Chart: label, bar and value in one line; on phones the bar moves below. */
.chart-row {
    display: grid;
    grid-template-columns: 160px minmax(0, 1fr) 140px;
    grid-template-areas: "label track value";
    align-items: center;
    gap: 4px 12px;
    margin-bottom: 10px;
}

@media (max-width: 599.98px) {
    .chart-row {
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas:
            "label value"
            "track track";
    }
}

.chart-label {
    grid-area: label;
    overflow-wrap: anywhere;
}

.chart-track {
    grid-area: track;
    height: 20px;
    border-radius: 4px;
    background: var(--mud-palette-action-disabled-background);
    overflow: hidden;
}

.chart-bar {
    height: 100%;
    background: var(--mud-palette-primary);
}

.chart-bar-consumables {
    background: var(--mud-palette-info);
}

.chart-value {
    grid-area: value;
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

/* Check panel */
.check-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.check-item {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    padding: 4px 0;
}

.check-note {
    font-size: 0.8125rem;
}

.personal-offset {
    max-width: 200px;
}

/* Rule forms read like a sentence; the inputs flow with the text and wrap on phones. */
.rule-sentence {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 8px;
    line-height: 2.5;
}

.rule-input {
    flex: 0 0 150px;
}

.rule-input-wide {
    flex: 1 1 180px;
}

.rule-input-number {
    flex: 0 0 110px;
}

.rule-disabled {
    opacity: 0.55;
}

.export-preview {
    max-height: 50vh;
    overflow: auto;
    margin: 0;
    padding: 12px;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 4px;
    font-size: 0.8125rem;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* File upload: a button-styled label around a hidden file input. */
.file-button {
    position: relative;
    min-height: 44px;
    cursor: pointer;
}

.file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    overflow: hidden;
}

/* Touch targets of at least 44 px, as the spec asks for phones. */
.mud-button-root.mud-button,
.mud-nav-link,
.mud-switch,
.mud-tab {
    min-height: 44px;
}

/* Small icon buttons inside inputs (like clearing a selection) get a larger hit area without moving the layout. */
.mud-input-adornment .mud-icon-button,
.mud-input-clear-button {
    padding: 12px;
    margin: -12px 0;
}

/* Tabs read like the rest of the interface instead of in capitals. */
.mud-tab {
    text-transform: none;
}

.settings-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding-bottom: 12px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--mud-palette-lines-default);
}

/* Rows in the settings lists: text left, buttons right; on narrow screens the buttons wrap below. */
.settings-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0 8px;
    padding: 4px 4px 4px 16px;
    border-bottom: 1px solid var(--mud-palette-lines-default);
}

.settings-row:last-child {
    border-bottom: none;
}

.settings-row-main {
    flex: 1 1 120px;
    min-width: 0;
    padding: 6px 0;
}

.settings-row-actions {
    display: flex;
    align-items: center;
    margin-left: auto;
}

.settings-group-title {
    padding: 12px 16px 4px;
}

/* Forms in dialogs fill the screen on phones (below 600 px), like MudBlazor's own full-screen dialogs. */
@media (max-width: 599.98px) {
    .mud-dialog.form-dialog {
        width: 100%;
        height: 100%;
        margin: 0;
        max-width: 100%;
        max-height: none;
        border-radius: 0;
    }
}
