:root,
[data-bs-theme=light] {
    /* Greenfield Coder palette (greenfieldcoder.nl) */
    --bo-bg: #f6f4ef;
    --bo-surface: #ffffff;
    --bo-surface-muted: #f1ede6;
    --bo-border: #dedad1;
    --bo-text: #171513;
    --bo-text-muted: #5f5a52;
    --bo-accent: #fb8122;
    --bo-accent-rgb: 251, 129, 34;
    --bo-accent-hover: #ff953f;
    --bo-accent-soft: #fdeddf;
    --bo-accent-text: #b34a05;
    --bo-on-accent: #121110;
    --bo-success-soft: #e7f3e4;
    --bo-success-text: #2f7a2a;
    --bo-warning-soft: #fdf0d5;
    --bo-warning-text: #8a5a06;
    --bo-sidebar-bg: #121110;
    --bo-sidebar-raised: #1c1a18;
    --bo-sidebar-line: #2e2b27;
    --bo-sidebar-text: #f1ede6;
    --bo-sidebar-muted: #a8a299;
    --bo-radius: 0.5rem;
    --bo-radius-lg: 0.75rem;

    --bs-body-font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --bs-body-font-size: 0.9rem;
    --bs-body-bg: var(--bo-bg);
    --bs-body-color: var(--bo-text);
    --bs-secondary-color: var(--bo-text-muted);
    --bs-border-color: var(--bo-border);
    --bs-border-radius: var(--bo-radius);
    --bs-border-radius-sm: 0.375rem;
    --bs-border-radius-lg: var(--bo-radius-lg);
    --bs-primary: var(--bo-accent);
    --bs-primary-rgb: var(--bo-accent-rgb);
    --bs-link-color: var(--bo-accent-text);
    --bs-link-color-rgb: 179, 74, 5;
    --bs-link-hover-color: var(--bo-accent);
    --bs-focus-ring-color: rgba(var(--bo-accent-rgb), 0.3);
}

[data-bs-theme=dark] {
    --bo-bg: #121110;
    --bo-surface: #1c1a18;
    --bo-surface-muted: #24211e;
    --bo-border: #2e2b27;
    --bo-text: #f1ede6;
    --bo-text-muted: #a8a299;
    --bo-accent-soft: #3a2414;
    --bo-accent-text: #ff953f;
    --bo-success-soft: #18301a;
    --bo-success-text: #7fcf78;
    --bo-warning-soft: #3a2c0d;
    --bo-warning-text: #f1c25b;
    --bo-sidebar-bg: #0b0a09;
    --bo-sidebar-raised: #1c1a18;

    --bs-body-bg: var(--bo-bg);
    --bs-body-color: var(--bo-text);
    --bs-secondary-color: var(--bo-text-muted);
    --bs-border-color: var(--bo-border);
    --bs-link-color: var(--bo-accent-text);
    --bs-link-color-rgb: 255, 149, 63;
}

html, body {
    font-family: var(--bs-body-font-family);
    background-color: var(--bo-bg);
    color: var(--bo-text);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5 {
    font-weight: 600;
    letter-spacing: -0.01em;
}

h3 {
    font-size: 1.35rem;
}

.content {
    padding-top: 1.5rem;
    padding-bottom: 3rem;
}

.ti {
    font-size: 1.1rem;
    vertical-align: -0.15em;
}

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    background-color: var(--bo-accent-soft);
    color: var(--bo-accent-text);
    font-size: 0.7rem;
    font-weight: 600;
}

.app-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    color: var(--bo-text-muted);
}

/* Page header: title with optional subtitle left, actions right */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

    .page-header h3 {
        margin: 0;
    }

.page-subtitle {
    color: var(--bo-text-muted);
    font-size: 0.8rem;
}

.page-toolbar {
    background-color: var(--bo-bg);
}

/* Buttons */
.btn {
    font-weight: 500;
    border-radius: var(--bo-radius);
}

.btn-primary {
    --bs-btn-color: var(--bo-on-accent);
    --bs-btn-hover-color: var(--bo-on-accent);
    --bs-btn-active-color: var(--bo-on-accent);
    --bs-btn-disabled-color: var(--bo-on-accent);
    --bs-btn-bg: var(--bo-accent);
    --bs-btn-border-color: var(--bo-accent);
    --bs-btn-hover-bg: var(--bo-accent-hover);
    --bs-btn-hover-border-color: var(--bo-accent-hover);
    --bs-btn-active-bg: var(--bo-accent-hover);
    --bs-btn-active-border-color: var(--bo-accent-hover);
    --bs-btn-disabled-bg: var(--bo-accent);
    --bs-btn-disabled-border-color: var(--bo-accent);
}

.btn-outline-primary {
    --bs-btn-color: var(--bo-accent-text);
    --bs-btn-border-color: var(--bo-border);
    --bs-btn-bg: var(--bo-surface);
    --bs-btn-hover-color: var(--bo-accent-text);
    --bs-btn-hover-bg: var(--bo-accent-soft);
    --bs-btn-hover-border-color: var(--bo-accent);
    --bs-btn-active-color: var(--bo-accent-text);
    --bs-btn-active-bg: var(--bo-accent-soft);
    --bs-btn-active-border-color: var(--bo-accent);
}

.btn-outline-secondary,
.btn-secondary {
    --bs-btn-color: var(--bo-text);
    --bs-btn-bg: var(--bo-surface);
    --bs-btn-border-color: var(--bo-border);
    --bs-btn-hover-color: var(--bo-text);
    --bs-btn-hover-bg: var(--bo-surface-muted);
    --bs-btn-hover-border-color: var(--bo-border);
    --bs-btn-active-color: var(--bo-text);
    --bs-btn-active-bg: var(--bo-surface-muted);
    --bs-btn-active-border-color: var(--bo-border);
}

.btn-success {
    --bs-btn-color: var(--bo-on-accent);
    --bs-btn-hover-color: var(--bo-on-accent);
    --bs-btn-bg: var(--bo-accent);
    --bs-btn-border-color: var(--bo-accent);
    --bs-btn-hover-bg: var(--bo-accent-hover);
    --bs-btn-hover-border-color: var(--bo-accent-hover);
}

/* Icon-only buttons in table rows */
.btn-icon,
td > .btn:not([class*="btn-"]) {
    color: var(--bo-text-muted);
    border: 0;
    padding: 0.2rem 0.35rem;
    line-height: 1;
}

    .btn-icon:hover,
    td > .btn:not([class*="btn-"]):hover {
        color: var(--bo-accent-text);
        background-color: var(--bo-accent-soft);
    }

/* Forms */
.form-control,
.form-select {
    background-color: var(--bo-surface);
    border-color: var(--bo-border);
}

    .form-control:focus,
    .form-select:focus {
        border-color: var(--bo-accent);
        box-shadow: 0 0 0 3px var(--bs-focus-ring-color);
    }

.form-label,
label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--bo-text-muted);
}

/* Cards and stat tiles */
.card {
    --bs-card-bg: var(--bo-surface);
    --bs-card-border-color: var(--bo-border);
    --bs-card-border-radius: var(--bo-radius-lg);
    box-shadow: none !important;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.stat-card {
    background: var(--bo-surface);
    border: 1px solid var(--bo-border);
    border-top: 3px solid var(--bo-accent);
    border-radius: var(--bo-radius-lg);
    padding: 1rem 1.25rem;
}

.stat-label {
    color: var(--bo-text-muted);
    font-size: 0.8rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

.stat-hint {
    color: var(--bo-text-muted);
    font-size: 0.75rem;
}

.panel {
    background: var(--bo-surface);
    border: 1px solid var(--bo-border);
    border-radius: var(--bo-radius-lg);
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    font-weight: 600;
}

/* Segmented control */
.segmented {
    display: inline-flex;
    background: var(--bo-surface-muted);
    border-radius: var(--bo-radius);
    padding: 3px;
    gap: 2px;
}

    .segmented .btn {
        border: 0;
        padding: 0.25rem 0.75rem;
        font-size: 0.8rem;
        color: var(--bo-text-muted);
        background: transparent;
    }

        .segmented .btn.active,
        .segmented .btn:hover {
            color: var(--bo-text);
            background: var(--bo-surface);
        }

/* Tables: card-like, horizontal rules only */
.table {
    --bs-table-bg: var(--bo-surface);
    --bs-table-color: var(--bo-text);
    --bs-table-border-color: var(--bo-border);
    --bs-table-striped-bg: transparent;
    --bs-table-striped-color: var(--bo-text);
    --bs-table-hover-bg: var(--bo-surface-muted);
    --bs-table-hover-color: var(--bo-text);
    border-collapse: separate;
    border-spacing: 0;
    border: 1px solid var(--bo-border);
    border-radius: var(--bo-radius-lg);
    overflow: hidden;
}

    .table > :not(caption) > * > * {
        padding: 0.6rem 0.85rem;
        border-width: 0 0 1px 0;
    }

    .table.table-sm > :not(caption) > * > * {
        padding: 0.45rem 0.75rem;
    }

    .table > tbody > tr:last-child > * {
        border-bottom-width: 0;
    }

    .table > thead > tr > th {
        background-color: var(--bo-surface-muted);
        color: var(--bo-text-muted);
        font-size: 0.75rem;
        font-weight: 500;
        white-space: nowrap;
    }

.table-bordered > :not(caption) > * {
    border-width: 0;
}

    .table-bordered > :not(caption) > * > * {
        border-width: 0 0 1px 0;
    }

.table > :not(caption) > tr.table-light > *,
.table > tbody > tr.total-row > * {
    --bs-table-bg: var(--bo-surface-muted);
    --bs-table-color: var(--bo-text);
    font-weight: 600;
}

.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Badges */
.badge {
    font-weight: 500;
    border-radius: 999px;
    padding: 0.3em 0.65em;
}

    .badge.bg-success {
        background-color: var(--bo-success-soft) !important;
        color: var(--bo-success-text) !important;
    }

    .badge.bg-light {
        background-color: var(--bo-surface-muted) !important;
        color: var(--bo-text) !important;
    }

    .badge.badge-open {
        background-color: var(--bo-warning-soft) !important;
        color: var(--bo-warning-text) !important;
    }

/* Alerts and modals */
.alert {
    border-radius: var(--bo-radius-lg);
}

.alert-info {
    --bs-alert-bg: var(--bo-accent-soft);
    --bs-alert-color: var(--bo-accent-text);
    --bs-alert-border-color: transparent;
}

.modal-content {
    border: 1px solid var(--bo-border);
    border-radius: var(--bo-radius-lg);
    background-color: var(--bo-surface);
}

.modal.show.d-block {
    backdrop-filter: blur(2px);
}

.blazored-modal {
    background-color: var(--bo-surface) !important;
    color: var(--bo-text);
    border-radius: var(--bo-radius-lg) !important;
}

/* Radzen charts follow the theme */
.rz-chart {
    padding-left: 1rem;
    --rz-chart-axis-color: var(--bo-border);
    --rz-chart-axis-label-color: var(--bo-text-muted);
}

    .rz-chart text {
        fill: var(--bo-text-muted);
        font-size: 0.75rem;
    }

    /* Radzen sizes the axis gutter for its own font; give wider labels room on the left */
    .rz-chart svg {
        overflow: visible;
    }

    .rz-chart .rz-grid-line line,
    .rz-chart .rz-axis line,
    .rz-chart .rz-tick line {
        stroke: var(--bo-border);
    }

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid red;
}

.validation-message {
    color: red;
}

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }

.page-toolbar.sticky-top {
    top: 3.5rem;
    z-index: 5;
}
