@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&display=swap');

:root {
    --bg: #f1f1f3;
    --fg: #18181b;
    --card: #ffffff;
    --muted: #71717a;
    --muted-bg: #f4f4f6;
    --border: #e0e0e4;
    --input-border: #c4c4cc;
    --primary: #c62828;
    --primary-hover: #b71c1c;
    --primary-soft: rgba(198, 40, 40, 0.08);
    --primary-fg: #ffffff;
    --sidebar-bg: #1c1917;
    --sidebar-fg: #e7e5e4;
    --sidebar-muted: #a8a29e;
    --sidebar-hover: #292524;
    --sidebar-active: #c62828;
    --success-bg: #dcfce7;
    --success-fg: #166534;
    --danger-bg: #fee2e2;
    --danger-fg: #991b1b;
    --warn-bg: #fef3c7;
    --warn-fg: #92400e;
    --info-bg: #dbeafe;
    --info-fg: #1e40af;
    --radius: 0.75rem;
    --shadow: 0 1px 2px rgba(24, 24, 27, 0.04), 0 4px 12px rgba(24, 24, 27, 0.04);
    --shadow-hover: 0 4px 18px rgba(24, 24, 27, 0.08);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    font-size: 15px;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "DM Sans", ui-sans-serif, system-ui, sans-serif;
    background: var(--bg);
    color: var(--fg);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
    color: var(--primary-hover);
}

img {
    max-width: 100%;
    height: auto;
}

/* ========== App shell ========== */
.app-shell {
    display: flex;
    min-height: 100vh;
    background:
        radial-gradient(1200px 500px at 100% -10%, rgba(198, 40, 40, 0.05), transparent 55%),
        radial-gradient(900px 420px at 0% 100%, rgba(24, 24, 27, 0.035), transparent 50%),
        var(--bg);
}

.app-sidebar {
    width: 16.25rem;
    flex-shrink: 0;
    background: var(--sidebar-bg);
    color: var(--sidebar-fg);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 40;
}

.app-sidebar__brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.15rem 1.1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    color: #fff !important;
    text-decoration: none !important;
    font-weight: 700;
    font-size: 0.98rem;
    letter-spacing: -0.02em;
}

.app-sidebar__brand:hover {
    color: #fff !important;
}

.app-sidebar__brand--logo {
    padding: 0.75rem 1.1rem;
    min-height: 4rem;
}

.app-logo {
    display: block;
    width: 100%;
    height: 2.5rem;
    max-height: none;
    object-fit: contain;
    object-position: left center;
    background: transparent;
}

.app-sidebar__nav {
    padding: 0.85rem 0.65rem;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.app-sidebar__label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--sidebar-muted);
    padding: 0.75rem 0.7rem 0.35rem;
}

.app-nav-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.58rem 0.75rem;
    border-radius: calc(var(--radius) - 2px);
    color: var(--sidebar-fg) !important;
    text-decoration: none !important;
    font-weight: 500;
    font-size: 0.92rem;
}

.app-nav-link:hover {
    background: var(--sidebar-hover);
    color: #fff !important;
}

.app-nav-link.is-active {
    background: var(--sidebar-active);
    color: #fff !important;
    font-weight: 600;
}

.app-sidebar__footer {
    padding: 0.95rem 1rem 1.15rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: grid;
    gap: 0.65rem;
    color: var(--sidebar-fg);
}

.app-sidebar__footer .text-muted,
.app-sidebar__footer .small {
    color: var(--sidebar-muted) !important;
}

.app-sidebar__footer .d-flex {
    gap: 0.4rem;
}

.app-sidebar__footer .btn {
    flex: 1;
    justify-content: center;
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.18);
    color: #fff !important;
}

.app-sidebar__footer .btn:hover {
    background: var(--sidebar-hover);
    border-color: rgba(255, 255, 255, 0.3);
}

.app-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: transparent;
}

.app-topbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.8rem 1.5rem;
    border-bottom: 1px solid rgba(228, 228, 231, 0.9);
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 30;
}

.impersonation-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.65rem 1.5rem;
    background: #92400e;
    color: #fffbeb;
    font-size: 0.9rem;
}

.impersonation-banner a.btn {
    text-decoration: none;
}

.app-sidebar__footer .text-warning {
    color: #fbbf24 !important;
}

.app-topbar .global-search {
    flex: 1;
    min-width: 0;
}

.app-content {
    padding: 1.5rem 1.5rem 2.75rem;
    width: 100%;
    max-width: 78rem;
    margin: 0 auto;
}

.app-mobile-toggle {
    display: none;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--fg);
    border-radius: var(--radius);
    padding: 0.4rem 0.65rem;
    cursor: pointer;
    font-size: 1.1rem;
}

.app-sidebar-backdrop {
    display: none;
}

/* ========== Typography ========== */
h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
    color: var(--fg);
    margin: 0 0 0.75rem;
    line-height: 1.25;
}

.h3, h1.h3 {
    font-size: 1.55rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

.h4 { font-size: 1.2rem; font-weight: 650; }
.h5 { font-size: 1rem; font-weight: 650; margin: 0; }
.h6 { font-size: 0.9rem; font-weight: 650; margin: 0; }

p { margin: 0 0 0.75rem; }

.text-muted {
    color: var(--muted) !important;
}

.small,
small {
    font-size: 0.84rem;
}

.fw-semibold { font-weight: 600; }
.fw-normal { font-weight: 400; }
.fs-3 { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.03em; color: var(--fg); }
.fs-4 { font-size: 1.35rem; font-weight: 700; color: var(--fg); }
.fs-6 { font-size: 0.9rem; }

/* ========== Page chrome ========== */
.page-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.35rem;
}

.page-header h1,
.page-header .h3 {
    margin-bottom: 0.2rem;
}

.page-header__meta {
    margin: 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.page-actions,
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    align-items: center;
}

.filter-stack {
    display: grid;
    gap: 0.45rem;
    margin-bottom: 1rem;
}

.filter-stack .filter-bar {
    margin-bottom: 0;
}

.filter-bar {
    margin-bottom: 0.85rem;
    padding: 0.35rem;
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) + 2px);
    box-shadow: var(--shadow);
}

.filter-bar .btn {
    border-radius: calc(var(--radius) - 2px);
    box-shadow: none;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.filter-bar .btn-outline-secondary {
    background: transparent;
    border-color: transparent;
    color: var(--muted) !important;
}

.filter-bar .btn-outline-secondary:hover {
    background: var(--muted-bg);
    color: var(--fg) !important;
}

.filter-bar .btn-danger {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--primary-fg) !important;
    box-shadow: 0 1px 2px rgba(198, 40, 40, 0.2);
}

.filter-bar .btn-danger:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    color: #fff !important;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.35rem;
}

@media (min-width: 768px) {
    .stat-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 1200px) {
    .stat-grid {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }
}

.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.05rem;
    box-shadow: var(--shadow);
    min-height: 5.5rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

a.stat-card--link {
    display: flex;
    color: inherit;
    text-decoration: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

a.stat-card--link:hover {
    border-color: #ef9a9a;
    box-shadow: var(--shadow-hover);
    transform: translateY(-1px);
    text-decoration: none;
    color: inherit;
    background: linear-gradient(180deg, #fff 0%, #fff8f8 100%);
}

.stat-card__label {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 0.45rem;
    line-height: 1.3;
}

.stat-card__value {
    font-size: 1.7rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.1;
    color: var(--fg);
}

.quick-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
}

.quick-actions .btn {
    justify-content: flex-start;
    white-space: normal;
    text-align: left;
    min-height: 2.6rem;
}

/* ========== Cards ========== */
.card,
.ui-card {
    background: var(--card);
    color: var(--fg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card.shadow-sm,
.shadow-sm {
    box-shadow: var(--shadow);
}

.card-header,
.card-footer {
    padding: 0.95rem 1.15rem;
    background: transparent;
    color: var(--fg);
}

.card-header {
    border-bottom: 1px solid var(--border);
    font-weight: 650;
    letter-spacing: -0.01em;
}

.card-header.bg-white {
    background: linear-gradient(180deg, #fff 0%, #fafafa 100%) !important;
}

.card-footer {
    border-top: 1px solid var(--border);
    background: #fafafa;
}

.card-body {
    padding: 1.15rem;
    color: var(--fg);
}

.bg-white { background: var(--card) !important; }
.bg-light { background: var(--muted-bg) !important; }

/* ========== Buttons ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    border-radius: calc(var(--radius) - 2px);
    border: 1px solid transparent;
    font-weight: 600;
    font-size: 0.9rem;
    line-height: 1.2;
    padding: 0.55rem 0.95rem;
    cursor: pointer;
    text-decoration: none !important;
    white-space: nowrap;
    font-family: inherit;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.btn-danger,
.btn-primary {
    background: var(--primary);
    color: var(--primary-fg) !important;
    border-color: var(--primary);
}

.btn-danger:hover,
.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    color: #fff !important;
}

.btn-outline-danger,
.btn-outline-secondary,
.btn-outline-light,
.btn-outline-primary,
.btn-outline-success {
    background: var(--card);
    color: var(--fg) !important;
    border-color: var(--border);
}

.btn-outline-danger:hover {
    background: var(--primary-soft);
    border-color: #ef9a9a;
    color: var(--primary) !important;
}

.btn-outline-secondary:hover,
.btn-outline-light:hover,
.btn-outline-primary:hover {
    background: var(--muted-bg);
    border-color: #c8c8ce;
    color: var(--fg) !important;
}

.btn.disabled,
.btn[aria-disabled="true"] {
    opacity: 0.45;
    pointer-events: none;
}

.btn-outline-success {
    border-color: #86efac;
    color: var(--success-fg) !important;
}

.btn-sm {
    font-size: 0.8rem;
    padding: 0.35rem 0.65rem;
}

.btn-link {
    background: none;
    border: none;
    color: var(--primary) !important;
    padding: 0;
}

.w-100 { width: 100%; }
.w-auto { width: auto !important; }
.flex-grow-1 { flex: 1; }

/* ========== Forms ========== */
.form-label,
label.required,
.col-form-label {
    display: block;
    font-size: 0.84rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
    color: var(--fg);
}

.form-control,
.form-select,
input.form-control,
select.form-select,
textarea.form-control,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
input[type="file"],
select,
textarea {
    width: 100%;
    display: block;
    border: 1px solid var(--input-border);
    background: #fff;
    color: var(--fg);
    border-radius: calc(var(--radius) - 2px);
    padding: 0.55rem 0.75rem;
    font: inherit;
}

.form-control:focus,
.form-select:focus,
input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(198, 40, 40, 0.18);
}

.form-control-sm,
.form-select-sm {
    padding: 0.35rem 0.6rem;
    font-size: 0.85rem;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    margin-bottom: 0;
    min-height: 1.5rem;
}

.form-check-input {
    width: 1.05rem;
    height: 1.05rem;
    flex-shrink: 0;
    margin: 0;
    accent-color: var(--primary);
    cursor: pointer;
}

.form-check-label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--fg);
    margin: 0;
    cursor: pointer;
}

.form-check .form-label {
    display: inline;
    margin-bottom: 0;
    font-weight: 500;
}

.choice-grid {
    display: grid;
    gap: 0.45rem;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) - 2px);
    background: var(--muted-bg);
}

.choice-grid .form-check {
    padding: 0.45rem 0.55rem;
    border-radius: calc(var(--radius) - 4px);
    background: #fff;
    border: 1px solid var(--border);
}

.choice-grid .form-check:hover {
    border-color: #c4c4c8;
}

@media (min-width: 640px) {
    .choice-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.form-text {
    color: var(--muted);
    font-size: 0.82rem;
    margin-top: 0.3rem;
}

.invalid-feedback {
    color: var(--danger-fg);
    font-size: 0.82rem;
    margin-top: 0.35rem;
}

.d-block { display: block !important; }

.input-group {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
}

.input-group .form-control { flex: 1; }

/* ========== Spacing / layout utils ========== */
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.35rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.35rem; }
.me-2 { margin-right: 0.5rem; }
.me-3 { margin-right: 0.85rem; }
.p-0 { padding: 0 !important; }
.p-2 { padding: 0.5rem; }
.p-4 { padding: 1.25rem; }
.pb-3 { padding-bottom: 1rem; }
.pt-0 { padding-top: 0 !important; }
.px-3 { padding-left: 1rem; padding-right: 1rem; }
.py-3 { padding-top: 1rem; padding-bottom: 1rem; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.85rem; }
.g-2, .g-3, .g-4 { --gutter: 0.85rem; }

.row {
    display: flex;
    flex-wrap: wrap;
    margin: calc(var(--gutter, 0.85rem) / -2);
}

.row > * {
    flex-shrink: 0;
    max-width: 100%;
    padding: calc(var(--gutter, 0.85rem) / 2);
}

.col-auto { flex: 0 0 auto; width: auto; }
.col-6 { flex: 0 0 auto; width: 50%; }
.col-12 { flex: 0 0 auto; width: 100%; }
.col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-8,
.col-lg-2, .col-lg-3, .col-lg-4, .col-lg-6, .col-lg-9 {
    flex: 0 0 auto;
    width: 100%;
}

@media (min-width: 768px) {
    .col-md-2 { width: 16.666%; }
    .col-md-3 { width: 25%; }
    .col-md-4 { width: 33.333%; }
    .col-md-5 { width: 41.666%; }
    .col-md-6 { width: 50%; }
    .col-md-8 { width: 66.666%; }
}

@media (min-width: 992px) {
    .col-lg-2 { width: 16.666%; }
    .col-lg-3 { width: 25%; }
    .col-lg-4 { width: 33.333%; }
    .col-lg-6 { width: 50%; }
    .col-lg-9 { width: 75%; }
}

.d-flex { display: flex; }
.d-grid { display: grid; }
.d-inline { display: inline; }
.d-inline-flex { display: inline-flex; }
.d-none { display: none !important; }
.flex-wrap { flex-wrap: wrap; }
.flex-column { flex-direction: column; }
.flex-lg-column { flex-direction: row; }

@media (min-width: 992px) {
    .flex-lg-column { flex-direction: column; }
}
.align-items-center { align-items: center; }
.align-items-start { align-items: flex-start; }
.align-items-end { align-items: flex-end; }
.align-middle { vertical-align: middle; }
.align-self-start { align-self: flex-start; }
.justify-content-between { justify-content: space-between; }
.justify-content-center { justify-content: center; }
.text-end { text-align: right; }
.text-center { text-align: center; }
.text-nowrap { white-space: nowrap; }
.text-dark { color: var(--fg) !important; }
.text-decoration-none { text-decoration: none !important; }
.text-decoration-none:hover { text-decoration: none !important; }
.position-relative { position: relative; }
.h-100 { height: 100%; }

/* ========== Tables ========== */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
    box-shadow: var(--shadow);
    max-width: 100%;
}

.card-body.p-0 > .table-responsive,
.card .table-responsive {
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

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

.table {
    width: 100%;
    min-width: 28rem;
    border-collapse: collapse;
    background: var(--card);
    color: var(--fg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.table th,
.table td,
.person-table th,
.person-table td {
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    color: var(--fg);
    text-align: left;
}

.table thead th,
.person-table thead th {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
    background: linear-gradient(180deg, #fafafa 0%, #f4f4f5 100%);
}

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

.table-striped > tbody > tr:nth-of-type(odd) > * {
    background: #fafafa;
}

.table-hover > tbody > tr:hover > * {
    background: #f4f4f5;
}

.table-sm th,
.table-sm td {
    padding: 0.55rem 0.8rem;
}

.align-middle { vertical-align: middle; }

/* Sortable table headers */
.table--sortable thead th.table-sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    position: relative;
    padding-right: 1.5rem;
}

.table--sortable thead th.table-sortable:hover {
    color: var(--fg);
    background: #ebebef;
}

.table--sortable thead th.table-sortable:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}

.table-sort-indicator {
    position: absolute;
    right: 0.45rem;
    top: 50%;
    transform: translateY(-50%);
    width: 0.65rem;
    height: 0.85rem;
    opacity: 0.35;
}

.table-sort-indicator::before,
.table-sort-indicator::after {
    content: "";
    position: absolute;
    left: 50%;
    border-left: 0.28rem solid transparent;
    border-right: 0.28rem solid transparent;
    transform: translateX(-50%);
}

.table-sort-indicator::before {
    top: 0.05rem;
    border-bottom: 0.3rem solid currentColor;
}

.table-sort-indicator::after {
    bottom: 0.05rem;
    border-top: 0.3rem solid currentColor;
}

.table--sortable thead th.is-sorted-asc .table-sort-indicator,
.table--sortable thead th.is-sorted-desc .table-sort-indicator {
    opacity: 1;
    color: var(--primary);
}

.table--sortable thead th.is-sorted-asc .table-sort-indicator::after {
    opacity: 0.25;
}

.table--sortable thead th.is-sorted-desc .table-sort-indicator::before {
    opacity: 0.25;
}

/* ========== Alerts / badges ========== */
.alert {
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 0.85rem 1rem;
    margin-bottom: 1rem;
    background: var(--card);
    color: var(--fg);
}

.alert-success { background: var(--success-bg); border-color: #86efac; color: var(--success-fg); }
.alert-danger { background: var(--danger-bg); border-color: #fca5a5; color: var(--danger-fg); }
.alert-warning { background: var(--warn-bg); border-color: #fcd34d; color: var(--warn-fg); }
.alert-light { background: var(--muted-bg); color: var(--fg); }

.alert-dismissible { position: relative; padding-right: 2.5rem; }

.btn-close {
    position: absolute;
    right: 0.75rem;
    top: 0.65rem;
    border: 0;
    background: transparent;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    opacity: 0.65;
    color: inherit;
    padding: 0;
}

.btn-close::before { content: "×"; }

.badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 0.2rem 0.55rem;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    border: 1px solid transparent;
    vertical-align: middle;
}

.ms-1 { margin-left: 0.35rem !important; }

.text-bg-success { background: var(--success-bg); color: var(--success-fg); border-color: #bbf7d0; }
.text-bg-secondary { background: #f4f4f5; color: #52525b; border-color: #e4e4e7; }
.text-bg-primary { background: var(--info-bg); color: var(--info-fg); border-color: #bfdbfe; }
.text-bg-danger { background: var(--danger-bg); color: var(--danger-fg); border-color: #fecaca; }
.text-bg-warning { background: var(--warn-bg); color: var(--warn-fg); border-color: #fde68a; }

/* ========== Lists / breadcrumb ========== */
.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    list-style: none;
    padding: 0;
    margin: 0 0 0.85rem;
    font-size: 0.85rem;
    color: var(--muted);
}

.breadcrumb-item + .breadcrumb-item::before {
    content: "/";
    margin-right: 0.35rem;
    color: var(--muted);
}

.breadcrumb a { color: var(--muted); }
.breadcrumb .active { color: var(--fg); font-weight: 600; }

.list-group { list-style: none; padding: 0; margin: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--card); }
.list-group-item {
    padding: 0.85rem 1.15rem;
    border-top: 1px solid var(--border);
    color: var(--fg);
    background: var(--card);
}
.list-group-item:first-child { border-top: 0; }
.list-group-item:hover { background: #fafafa; }
.list-group-flush { border: 0; border-radius: 0; }
.list-group-flush .list-group-item:hover { background: #fafafa; }

.pagination-bar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1rem;
    padding: 0.75rem 0.95rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.btn-group {
    display: inline-flex;
    gap: 0;
}

.btn-group > .btn {
    border-radius: 0;
}

.btn-group > .btn:first-child {
    border-top-left-radius: calc(var(--radius) - 2px);
    border-bottom-left-radius: calc(var(--radius) - 2px);
}

.btn-group > .btn:last-child {
    border-top-right-radius: calc(var(--radius) - 2px);
    border-bottom-right-radius: calc(var(--radius) - 2px);
    margin-left: -1px;
}

/* ========== Person detail ========== */
.person-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.15rem;
}

.person-header__title {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.45rem;
}

.person-header__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 0;
    list-style: none;
    margin: 0;
    padding: 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.person-header__meta li + li::before {
    content: "·";
    margin: 0 0.55rem;
    color: #c4c4cc;
}

.person-header__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.person-tabs {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.2rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    margin-bottom: 1rem;
    padding: 0.3rem;
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) + 2px);
    box-shadow: var(--shadow);
}

.person-tabs__link {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    border: 0;
    background: transparent;
    color: var(--muted);
    border-radius: calc(var(--radius) - 2px);
    padding: 0.55rem 0.9rem;
    cursor: pointer;
    font: inherit;
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    transition: background 0.15s ease, color 0.15s ease;
}

.person-tabs__link:hover {
    background: var(--muted-bg);
    color: var(--fg);
}

.person-tabs__link.active {
    background: var(--primary);
    color: #fff;
}

.person-tabs__count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.35rem;
    padding: 0.05rem 0.35rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    background: rgba(24, 24, 27, 0.08);
    color: inherit;
}

.person-tabs__link.active .person-tabs__count {
    background: rgba(255, 255, 255, 0.22);
}

.person-panels {
    min-width: 0;
}

.person-panel {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.15rem 1.25rem;
}

.person-panel--flush {
    padding: 0;
    overflow: hidden;
}

.person-panel__pad {
    padding: 1.15rem 1.25rem 0.85rem;
}

.person-panel__title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 650;
    letter-spacing: -0.01em;
}

.person-panel__subtitle {
    margin: 0.2rem 0 0;
    color: var(--muted);
    font-size: 0.86rem;
}

.person-panel__toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.person-panel__table {
    margin: 0 -1.25rem -1.15rem;
    border: 0;
    border-top: 1px solid var(--border);
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: none;
}

.person-panel__meta {
    margin: 1.1rem 0 0;
    padding-top: 0.85rem;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.82rem;
}

.person-facts {
    display: grid;
    gap: 0.8rem;
    margin: 0;
}

.person-facts--grid {
    grid-template-columns: repeat(auto-fill, minmax(11.5rem, 1fr));
    gap: 0.95rem 1.25rem;
}

.person-facts > div { display: grid; gap: 0.15rem; }
.person-facts dt {
    font-size: 0.72rem;
    color: var(--muted);
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}
.person-facts dd {
    margin: 0;
    font-weight: 650;
    color: var(--fg);
    word-break: break-word;
}

.person-bemerkung {
    background: var(--muted-bg);
    border-radius: calc(var(--radius) - 2px);
    padding: 0.85rem 1rem;
    border: 1px solid var(--border);
    color: var(--fg);
}

.person-entwurf {
    margin-bottom: 0.85rem;
    padding: 0.95rem 1.1rem;
    background: #fff8f8;
    border: 1px solid #f1b0b0;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.person-entwurf__head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
}

.person-entwurf__head strong {
    display: block;
}

.person-entwurf__group {
    margin-top: 0.85rem;
    padding-top: 0.75rem;
    border-top: 1px solid #f1b0b0;
}

.person-entwurf__label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 0.35rem;
}

.person-entwurf__list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.person-entwurf__list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.35rem 0;
}

.person-issue-form__fields {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
    margin-top: 0.85rem;
    align-items: end;
}

@media (min-width: 768px) {
    .person-issue-form__fields {
        grid-template-columns: minmax(0, 1.6fr) minmax(0, 0.8fr) auto;
    }

    .person-issue-form__submit {
        min-width: 8.5rem;
        padding-bottom: 0.05rem;
    }
}

tr.is-prueffaellig-row > * {
    background: #fffbeb;
}

tr.is-pending-row {
    opacity: 0.7;
}

.ausruestung-row-actions {
    display: inline-block;
    text-align: left;
    max-width: 16rem;
}

.ausruestung-row-actions > summary {
    list-style: none;
    cursor: pointer;
}

.ausruestung-row-actions > summary::-webkit-details-marker {
    display: none;
}

.ausruestung-row-actions[open] {
    display: block;
    width: 100%;
    max-width: 16rem;
    margin-left: auto;
}

.ausruestung-row-form {
    margin-top: 0.55rem;
    padding: 0.75rem;
    background: var(--muted-bg);
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) - 2px);
}

/* Legacy kleidung detail sidebar (shared class names) */
.person-menu .nav {
    display: flex;
    flex-direction: row;
    gap: 0.25rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    padding-bottom: 0.15rem;
}

.person-menu .nav-link {
    display: block;
    flex: 0 0 auto;
    min-width: 9.5rem;
    width: auto;
    text-align: left;
    border: 1px solid transparent;
    background: transparent;
    color: var(--fg);
    border-radius: calc(var(--radius) - 2px);
    padding: 0.7rem 0.8rem;
    cursor: pointer;
    font: inherit;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

@media (min-width: 992px) {
    .person-menu .nav {
        flex-direction: column;
        overflow: visible;
        padding-bottom: 0;
    }

    .person-menu .nav-link {
        width: 100%;
        min-width: 0;
        flex: none;
    }
}

.person-menu .nav-link .person-menu-label {
    display: block;
    font-weight: 650;
    font-size: 0.9rem;
    color: inherit;
}

.person-menu .nav-link .person-menu-hint {
    display: block;
    font-size: 0.75rem;
    color: var(--muted);
}

.person-menu .nav-link:hover {
    background: var(--muted-bg);
}

.person-menu .nav-link.active {
    background: var(--primary-soft);
    border-color: #f1b0b0;
    color: var(--primary);
}

.person-menu .nav-link.active .person-menu-label {
    color: var(--primary);
}

.person-menu .nav-link.active .person-menu-hint {
    color: #b45353;
}

.tab-pane { display: none; }
.tab-pane.active,
.tab-pane.show.active { display: block; }
.fade { opacity: 1; }

/* ========== Tom Select ========== */
.ts-wrapper.form-select,
.ts-wrapper.single,
.ts-wrapper.multi {
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
}

.ts-wrapper .ts-control {
    min-height: 2.45rem;
    border: 1px solid var(--input-border) !important;
    border-radius: calc(var(--radius) - 2px) !important;
    background: #fff !important;
    color: var(--fg) !important;
    box-shadow: none !important;
}

.ts-wrapper .ts-control input {
    color: var(--fg) !important;
}

.ts-wrapper.focus .ts-control {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(198, 40, 40, 0.18) !important;
}

.ts-dropdown {
    border: 1px solid var(--border) !important;
    border-radius: var(--radius) !important;
    background: #fff !important;
    color: var(--fg) !important;
    box-shadow: 0 10px 30px rgba(24, 24, 27, 0.14) !important;
}

.ts-dropdown .option {
    color: var(--fg) !important;
}

.ts-dropdown .active {
    background: var(--primary) !important;
    color: #fff !important;
}

/* ========== Global search ========== */
.global-search { position: relative; flex: 1; max-width: 28rem; }
.global-search--page { max-width: none; width: 100%; }

.global-search .form-control {
    background: #fff;
    border-color: var(--border);
    box-shadow: inset 0 1px 2px rgba(24, 24, 27, 0.03);
}

.global-search .form-control:focus {
    background: #fff;
}

.global-search-panel {
    position: absolute;
    top: calc(100% + 0.4rem);
    left: 0;
    right: 0;
    z-index: 1080;
    max-height: 22rem;
    overflow: auto;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 12px 32px rgba(24, 24, 27, 0.16);
    color: var(--fg);
}

.global-search-group-label {
    padding: 0.5rem 0.8rem 0.2rem;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted);
}

.global-search-item {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    padding: 0.6rem 0.8rem;
    color: var(--fg) !important;
    text-decoration: none !important;
    border-top: 1px solid var(--border);
}

.global-search-item:hover,
.global-search-item.is-active {
    background: var(--muted-bg);
}

.global-search-item-title { font-weight: 650; font-size: 0.9rem; color: var(--fg); }
.global-search-item-meta { font-size: 0.75rem; color: var(--muted); }

.global-search-all,
.global-search-empty {
    display: block;
    padding: 0.7rem 0.8rem;
    font-size: 0.85rem;
    color: var(--primary);
    text-decoration: none;
    border-top: 1px solid var(--border);
}

.global-search-empty { color: var(--muted); }

/* ========== Login ========== */
.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
    background:
        radial-gradient(1100px 480px at 8% -8%, rgba(198, 40, 40, 0.14), transparent 60%),
        radial-gradient(900px 400px at 100% 0%, rgba(120, 113, 108, 0.16), transparent 55%),
        var(--bg);
}

.login-card {
    width: min(100%, 26rem);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-hover);
}

.login-card .card-body {
    padding: 1.6rem 1.5rem;
}

.install-card {
    width: min(100%, 36rem);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-hover);
}

.install-section__title {
    margin: 0 0 0.75rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted);
}

.install-checks {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.4rem;
}

.install-checks__item {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) - 2px);
    background: #fafafa;
    font-size: 0.88rem;
}

.install-checks__item.is-ok {
    border-color: #bbf7d0;
    background: #f0fdf4;
}

.install-checks__item.is-fail {
    border-color: #fecaca;
    background: #fef2f2;
}

.install-checks__label {
    font-weight: 600;
}

.install-checks__detail {
    color: var(--muted);
    text-align: right;
    word-break: break-word;
}

.install-checks__item.is-ok .install-checks__detail { color: var(--success-fg); }
.install-checks__item.is-fail .install-checks__detail { color: var(--danger-fg); }

.login-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.65rem;
    margin-bottom: 1.25rem;
    text-align: center;
}

.login-brand img {
    height: 2.5rem;
    width: auto;
}

.login-brand__name {
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--fg);
}

code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.85em;
    background: var(--muted-bg);
    color: var(--fg);
    padding: 0.1rem 0.35rem;
    border-radius: 0.3rem;
    border: 1px solid var(--border);
}

/* ========== Responsive ========== */
body.sidebar-open {
    overflow: hidden;
}

@media (max-width: 991px) {
    .app-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        width: min(18rem, 88vw);
        transform: translateX(-105%);
        transition: transform 0.2s ease;
        box-shadow: 0 0 40px rgba(0, 0, 0, 0.35);
    }

    .app-sidebar.is-open {
        transform: translateX(0);
    }

    .app-mobile-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        min-width: 2.5rem;
        min-height: 2.5rem;
        border: 1px solid var(--border);
        background: var(--card);
        border-radius: var(--radius);
        cursor: pointer;
        color: var(--fg);
        font-size: 1.15rem;
        line-height: 1;
    }

    .app-sidebar-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(24, 24, 27, 0.45);
        z-index: 35;
    }

    .app-sidebar-backdrop.is-open {
        display: block;
    }

    .app-topbar {
        padding: 0.7rem 0.85rem;
        gap: 0.65rem;
    }

    .app-content {
        padding: 1rem 0.85rem 2rem;
    }

    .global-search {
        max-width: none;
    }

    .page-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .page-actions {
        width: 100%;
    }

    .page-actions .btn {
        flex: 1 1 auto;
    }

    .person-header {
        flex-direction: column;
        align-items: stretch;
    }

    .person-header__actions {
        width: 100%;
    }

    .person-header__actions .btn {
        flex: 1 1 auto;
        justify-content: center;
    }

    .person-menu .card-footer {
        display: none;
    }

    .stat-card__value {
        font-size: 1.45rem;
    }

    .table {
        font-size: 0.88rem;
    }

    .table > :not(caption) > * > * {
        padding: 0.65rem 0.7rem;
    }

    .btn {
        white-space: normal;
    }

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

    /* Inline forms in tables / cards – stack on small phones */
    @media (max-width: 575px) {
        form.d-flex {
            flex-wrap: wrap;
            width: 100%;
        }

        form.d-flex .form-select,
        form.d-flex .form-control,
        form.d-flex .btn {
            flex: 1 1 100%;
            width: 100%;
            min-width: 0;
        }

        .w-auto {
            width: 100% !important;
        }
    }

    .login-shell {
        padding: 1rem;
        align-content: center;
    }
}

@media (max-width: 575px) {
    html {
        font-size: 14px;
    }

    .stat-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.65rem;
    }

    .stat-card {
        padding: 0.75rem 0.85rem;
    }

    .h1, h1.h3, .h3 {
        font-size: 1.3rem;
    }

    .filter-bar .btn,
    .page-actions .btn {
        font-size: 0.82rem;
    }

    .breadcrumb {
        font-size: 0.78rem;
    }

    .person-tabs__link {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }

    .person-menu .nav-link {
        min-width: 8.25rem;
        padding: 0.55rem 0.7rem;
    }

    .person-menu .nav-link .person-menu-hint {
        display: none;
    }

    .person-panel {
        padding: 1rem;
    }

    .person-panel__table {
        margin-left: -1rem;
        margin-right: -1rem;
        margin-bottom: -1rem;
    }

    .ausruestung-row-actions,
    .ausruestung-row-actions[open] {
        max-width: none;
        width: 100%;
    }

    .table-actions,
    td.text-end {
        text-align: left !important;
    }

    td.text-end .btn,
    .table-actions .btn {
        display: inline-flex;
        margin: 0.15rem 0.15rem 0.15rem 0;
    }
}

/* ========== Lager status tiles ========== */
.lager-status-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

@media (min-width: 640px) {
    .lager-status-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 992px) {
    .lager-status-grid {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }
}

.lager-status-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    min-height: 5.25rem;
    padding: 0.95rem 0.7rem;
    background: linear-gradient(180deg, #fff 0%, #fafafa 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-decoration: none !important;
    color: var(--fg) !important;
    text-align: center;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease, background 0.15s ease;
}

.lager-status-tile:hover {
    border-color: #ef9a9a;
    box-shadow: var(--shadow-hover);
    transform: translateY(-1px);
    color: var(--fg) !important;
}

.lager-status-tile.is-active {
    border-color: var(--primary);
    background: linear-gradient(180deg, #fff 0%, #fff5f5 100%);
    box-shadow: 0 0 0 2px rgba(198, 40, 40, 0.12);
}

.lager-status-tile__value {
    font-size: 1.45rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.1;
}

.lager-status-tile__label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--muted);
    line-height: 1.25;
}

.lager-status-tile.is-active .lager-status-tile__label {
    color: var(--primary);
}

/* ========== Admin ========== */
.admin-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.85rem;
}

@media (min-width: 640px) {
    .admin-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.admin-tile {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 1.2rem 1.25rem;
    background: linear-gradient(180deg, #fff 0%, #fafafa 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-decoration: none !important;
    color: var(--fg) !important;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease, background 0.15s ease;
}

.admin-tile:hover {
    border-color: #ef9a9a;
    box-shadow: var(--shadow-hover);
    transform: translateY(-1px);
    background: linear-gradient(180deg, #fff 0%, #fff8f8 100%);
    color: var(--fg) !important;
}

.admin-tile__title {
    font-size: 1.05rem;
    font-weight: 650;
    letter-spacing: -0.01em;
}

.admin-tile__desc {
    font-size: 0.88rem;
    color: var(--muted);
    line-height: 1.4;
}

.extra-artikel-list {
    display: grid;
    gap: 0.85rem;
}

.extra-artikel-row {
    padding: 0.9rem 1rem;
    background: linear-gradient(180deg, #fff 0%, #fafafa 100%);
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) - 2px);
}

.dashboard-side {
    display: grid;
    gap: 0.85rem;
}

.dashboard-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
}

.dashboard-list-item a {
    font-weight: 600;
    color: var(--fg);
    text-decoration: none;
}

.dashboard-list-item a:hover {
    color: var(--primary);
}

.status-count {
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    color: var(--fg);
}

.filter-card .card-body {
    padding: 1rem 1.1rem;
}

.empty-hint {
    color: var(--muted);
    font-size: 0.92rem;
    padding: 0.35rem 0;
}

.extra-artikel-form {
    display: grid;
    gap: 0.55rem;
}

.extra-artikel-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.admin-form-card {
    max-width: 36rem;
}

.admin-form-card--wide {
    max-width: 48rem;
}

.checkliste-editor {
    display: grid;
    gap: 0.65rem;
}

.checkliste-editor__row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 0.65rem;
    align-items: center;
    padding: 0.65rem 0.75rem;
    background: var(--muted-bg);
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) - 2px);
}

.checkliste-editor__label .form-control {
    width: 100%;
}

.checkliste-editor__pflicht {
    white-space: nowrap;
    margin: 0;
}

.checkliste-preview {
    list-style: none;
    padding: 0;
    margin: 0 0 0.75rem;
    display: grid;
    gap: 0.4rem;
}

.checkliste-preview li {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.75rem;
    background: var(--muted-bg);
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) - 2px);
}

.checkliste-runtime {
    display: grid;
    gap: 0.55rem;
}

.checkliste-runtime__item {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    padding: 0.75rem 0.85rem;
    background: linear-gradient(180deg, #fff 0%, #fafafa 100%);
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) - 2px);
    cursor: pointer;
    margin: 0;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.checkliste-runtime__item:hover {
    border-color: #c8c8ce;
}

.checkliste-runtime__item:has(input:checked) {
    border-color: #86efac;
    background: linear-gradient(180deg, #f0fdf4 0%, #dcfce7 100%);
}

.checkliste-runtime__item span {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
}

.checkliste-runtime__label {
    font-weight: 550;
}

.typ-bild-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
    gap: 0.75rem;
}

.typ-bild-card {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin: 0;
    padding: 0.4rem;
    background: var(--muted-bg);
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) - 2px);
    overflow: hidden;
}

.typ-bild-card img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: calc(var(--radius) - 4px);
    background: #fff;
}

.typ-bild-card__meta {
    display: grid;
    gap: 0.25rem;
}

.typ-bild-card__caption {
    font-size: 0.78rem;
    color: var(--muted);
    padding: 0 0.15rem 0.15rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.typ-bild-card--link {
    color: inherit;
    text-decoration: none;
}

.typ-bild-card--link:hover {
    border-color: var(--primary);
    text-decoration: none;
}

@media (max-width: 640px) {
    .checkliste-editor__row {
        grid-template-columns: 1fr auto;
    }

    .checkliste-editor__pflicht {
        grid-column: 1;
    }
}

.admin-logo-preview {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1rem;
    background: var(--muted-bg);
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) - 2px);
}

.admin-logo-preview img {
    max-height: 64px;
    max-width: 180px;
    object-fit: contain;
}

.admin-preview {
    margin-top: 0.5rem;
    padding: 0.85rem 1rem;
    background: var(--muted-bg);
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) - 2px);
}

.admin-preview__label {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 0.25rem;
}

.admin-preview__value {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 1.05rem;
    font-weight: 650;
    color: var(--fg);
}

.badge-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}

.card-footer.page-actions {
    border-top: 1px solid var(--border);
    padding: 0.9rem 1.1rem;
}

/* ========== Environment badge (dev / debug) ========== */
.env-badge {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    padding: 0.28rem 0.55rem;
    border-radius: 0.4rem;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    line-height: 1;
    user-select: none;
    cursor: default;
}

.env-badge--dev {
    background: #dbeafe;
    color: #1e40af;
}

.env-badge--debug {
    background: #fef3c7;
    color: #92400e;
}

.env-badge--floating {
    position: fixed;
    top: 0.75rem;
    right: 0.75rem;
    z-index: 50;
    box-shadow: var(--shadow);
}

/* Safe area for notched phones */
@supports (padding: max(0px)) {
    @media (max-width: 991px) {
        .app-sidebar {
            padding-top: env(safe-area-inset-top);
            padding-bottom: env(safe-area-inset-bottom);
        }

        .app-topbar {
            padding-left: max(0.85rem, env(safe-area-inset-left));
            padding-right: max(0.85rem, env(safe-area-inset-right));
        }

        .app-content {
            padding-left: max(0.85rem, env(safe-area-inset-left));
            padding-right: max(0.85rem, env(safe-area-inset-right));
            padding-bottom: max(2rem, env(safe-area-inset-bottom));
        }
    }
}
