:root {
    --bs-primary: #0f4c81;
    --bs-secondary: #5b6b7a;
    --bs-success: #1f7a4c;
    --bs-info: #0b7285;
    --bs-warning: #b7791f;
    --bs-danger: #b42318;
    --bs-light: #f5f7fa;
    --bs-dark: #1f2937;
    --bs-body-bg: #eef2f6;
    --bs-body-color: #17212b;
    --bs-border-radius: 0.65rem;
    --bs-border-radius-lg: 0.9rem;
    --bs-box-shadow: 0 0.5rem 1.5rem rgba(15, 23, 42, 0.08);
}

body {
    min-height: 100vh;
    color: var(--bs-body-color);
    background:
        radial-gradient(circle at top left, rgba(15, 76, 129, 0.09), transparent 28%),
        linear-gradient(180deg, #f8fbfd 0%, #edf3f8 100%);
}

.app-shell {
    padding-bottom: 3rem;
}

.app-navbar {
    background: linear-gradient(135deg, #12355b 0%, #0d2744 100%);
    box-shadow: 0 0.75rem 2rem rgba(15, 23, 42, 0.18);
}

.app-navbar .container {
    min-height: 4.75rem;
}

.app-navbar .navbar-brand,
.app-navbar .nav-link,
.app-navbar .navbar-text,
.app-navbar .dropdown-toggle {
    color: rgba(255, 255, 255, 0.92);
}

.app-navbar .nav-link:hover,
.app-navbar .nav-link:focus,
.app-navbar .navbar-brand:hover,
.app-navbar .navbar-brand:focus,
.app-navbar .nav-link.active,
.app-navbar .show > .nav-link {
    color: #fff;
}

.app-navbar .dropdown-menu {
    margin-top: 0.75rem;
    padding: 0.5rem;
    border: 1px solid rgba(15, 23, 42, 0.1);
    border-radius: 0.9rem;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 1rem 2rem rgba(15, 23, 42, 0.15);
}

.app-navbar .dropdown-item {
    color: #17324d;
    border-radius: 0.65rem;
    padding: 0.55rem 0.8rem;
}

.app-navbar .dropdown-item:hover,
.app-navbar .dropdown-item:focus,
.app-navbar .dropdown-item.active {
    color: #0d2744;
    background: #e5edf5;
}

.app-navbar .dropdown-divider {
    margin: 0.35rem 0;
}

.app-navbar .form-control {
    border: 0;
    background: rgba(255, 255, 255, 0.92);
}

.app-navbar .btn-light {
    color: #12355b;
    border-color: transparent;
    font-weight: 600;
}

.app-surface {
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 1rem;
    box-shadow: 0 1rem 2.5rem rgba(15, 23, 42, 0.08);
}

.page-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
}

.page-toolbar-title {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 700;
}

.table-responsive {
    border-bottom-left-radius: 1rem;
    border-bottom-right-radius: 1rem;
}

.table thead th {
    white-space: nowrap;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #486581;
}

.incident-list-table {
    table-layout: fixed;
}

.incident-list-table th,
.incident-list-table td {
    vertical-align: top;
}

.incident-list-table tbody tr[data-href] {
    cursor: pointer;
}

.incident-list-table th {
    white-space: normal;
}

.incident-list-col-id {
    width: 5rem;
}

.incident-list-col-when {
    width: 6.5rem;
}

.incident-list-col-flags {
    width: 8rem;
}

.incident-list-col-reportable {
    width: 8.5rem;
}

.incident-list-main {
    min-width: 0;
}

.incident-list-title a {
    display: inline-block;
    margin-bottom: 0.2rem;
    font-weight: 600;
    color: #102a43;
    text-decoration: none;
    overflow-wrap: anywhere;
}

.incident-list-title a:hover,
.incident-list-title a:focus {
    text-decoration: underline;
}

.incident-list-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.75rem;
    font-size: 0.84rem;
    color: #627d98;
}

.incident-list-meta span {
    overflow-wrap: anywhere;
}

.incident-list-flags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.pagination {
    margin-bottom: 0;
}

.page-toolbar-subtitle {
    margin: 0.35rem 0 0;
    color: #6b7c93;
}

.app-card {
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 1rem;
    box-shadow: 0 1rem 2.5rem rgba(15, 23, 42, 0.08);
}

.app-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.85rem;
    padding: 1rem 1.2rem;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.app-card-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: #102a43;
}

.app-card-subtitle {
    margin: 0.2rem 0 0;
    color: #7b8794;
    font-size: 0.88rem;
}

.app-card-body {
    padding: 1.1rem 1.2rem;
}

.app-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem 1.25rem;
}

.app-detail-list {
    display: grid;
    gap: 0;
    border: 1px solid #d9e2ec;
    border-radius: 0.95rem;
    overflow: hidden;
    background: #fcfdff;
}

.app-detail-row {
    display: grid;
    grid-template-columns: minmax(160px, 220px) 1fr;
    gap: 0.85rem;
    padding: 0.72rem 0.95rem;
    border-bottom: 1px solid #e6edf5;
}

.app-detail-row:last-child {
    border-bottom: 0;
}

.app-detail-row:nth-child(even) {
    background: #f8fbfd;
}

.app-detail-key {
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #627d98;
}

.app-detail-content {
    color: #102a43;
    min-width: 0;
}

.app-detail-content p:last-child {
    margin-bottom: 0;
}

.app-detail-span {
    grid-column: 1 / -1;
}

.app-narrative-grid {
    display: grid;
    gap: 0.85rem;
    margin-top: 0.9rem;
}

.app-detail-item {
    padding: 0.75rem 0.85rem;
    border-radius: 0.85rem;
    background: #f8fbfd;
    border: 1px solid #e3ebf3;
}

.app-detail-label {
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #627d98;
}

.app-detail-value {
    color: #102a43;
    word-break: break-word;
}

.app-detail-value p:last-child {
    margin-bottom: 0;
}

.app-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.app-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.65rem;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 700;
    line-height: 1;
}

.app-chip-danger,
.text-bg-danger {
    color: #7a0916 !important;
    background: #fde7ea !important;
}

.app-chip-warning,
.text-bg-warning {
    color: #7a4b00 !important;
    background: #fff1d6 !important;
}

.app-chip-info,
.text-bg-info {
    color: #0b4668 !important;
    background: #dff2fb !important;
}

.app-chip-success,
.text-bg-success {
    color: #0f5132 !important;
    background: #dff3e8 !important;
}

.app-chip-neutral,
.text-bg-secondary,
.text-bg-light {
    color: #334e68 !important;
    background: #e9eef5 !important;
}

.app-section-stack {
    display: grid;
    gap: 1.5rem;
}

.app-dashboard-stack {
    display: grid;
    gap: 1.5rem;
}

.app-hero-card {
    background:
        radial-gradient(circle at top right, rgba(15, 76, 129, 0.14), transparent 34%),
        linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(245, 249, 253, 0.96));
}

.app-eyebrow {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #486581;
}

.app-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}

.app-stat-card {
    display: grid;
    gap: 0.35rem;
    padding: 1rem 1.05rem;
    color: inherit;
    text-decoration: none;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 1rem;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 1rem 2.5rem rgba(15, 23, 42, 0.06);
    transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}

.app-stat-card:hover,
.app-stat-card:focus {
    transform: translateY(-2px);
    border-color: rgba(15, 76, 129, 0.22);
    box-shadow: 0 1.2rem 2.4rem rgba(15, 23, 42, 0.1);
}

.app-stat-kicker {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #627d98;
}

.app-stat-number {
    font-size: 1.85rem;
    line-height: 1;
    color: #102a43;
}

.app-stat-note {
    font-size: 0.86rem;
    color: #627d98;
}

.app-action-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.app-action-grid-sm {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.app-empty {
    padding: 1rem 1.1rem;
    border-radius: 0.85rem;
    color: #52606d;
    background: #f8fbfd;
    border: 1px dashed #c8d6e5;
}

.app-table-muted {
    color: #627d98;
}

.app-stat-list {
    display: grid;
    gap: 0.8rem;
    padding: 0;
    margin: 0;
    list-style: none;
}

.app-stat-list li {
    margin: 0;
}

.app-stat-item {
    padding: 0.9rem 1rem;
    border: 1px solid #e3ebf3;
    border-radius: 0.9rem;
    background: #f8fbfd;
}

.app-stat-title {
    font-weight: 700;
    color: #102a43;
}

.app-stat-meta {
    color: #627d98;
}

.app-stat-children {
    margin-top: 0.65rem;
    padding-left: 1rem;
    border-left: 2px solid #d9e2ec;
}

.app-inline-form {
    display: grid;
    gap: 1rem;
}

.app-inline-form .form-check {
    margin-bottom: 0.5rem;
}

.app-inline-form .form-check:last-child {
    margin-bottom: 0;
}

.app-form-stack .form-group,
.app-form-stack .mb-3 {
    margin-bottom: 1rem;
}

.app-form-stack label,
.app-form-stack .form-label {
    margin-bottom: 0.35rem;
    font-weight: 600;
    color: #102a43;
}

.app-form-stack textarea {
    min-height: 8rem;
}

.app-form-hint {
    padding: 0.85rem 1rem;
    border: 1px dashed #c8d6e5;
    border-radius: 0.85rem;
    color: #52606d;
    background: #f8fbfd;
    font-size: 0.92rem;
}

.app-card-muted {
    opacity: 0.72;
}

.app-form-stack > .form-errors,
.app-form-stack > ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.app-form-stack > ul li {
    margin-bottom: 1rem;
    padding: 0.9rem 1rem;
    border-radius: 0.85rem;
    background: #fde7ea;
    color: #7a0916;
}

.app-year-shortcuts {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.app-analytics-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}

.app-analytics-kpi {
    display: grid;
    gap: 0.35rem;
    padding: 1rem 1.05rem;
    border-radius: 1rem;
    border: 1px solid #d9e2ec;
    background:
        linear-gradient(180deg, rgba(248, 251, 253, 0.98), rgba(255, 255, 255, 0.98));
}

.app-analytics-split {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.5rem;
}

.app-analytics-aging-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.85rem;
}

.app-report-range {
    display: grid;
    gap: 1rem;
}

.app-report-range-shell {
    display: grid;
    grid-template-columns: minmax(240px, 0.95fr) minmax(0, 1.55fr);
    gap: 1rem;
    padding: 1rem;
    border: 1px solid #d9e2ec;
    border-radius: 1rem;
    background:
        radial-gradient(circle at top right, rgba(15, 76, 129, 0.12), transparent 32%),
        linear-gradient(180deg, rgba(248, 251, 253, 0.98), rgba(255, 255, 255, 0.98));
}

.app-report-range-hero {
    padding: 0.25rem;
}

.app-report-range-summary {
    padding: 0.85rem 1rem;
    border-radius: 0.95rem;
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid #d9e2ec;
    color: #102a43;
    font-weight: 600;
}

.app-report-range-panels {
    display: grid;
    gap: 1rem;
}

.app-report-range-panel {
    padding: 1rem;
    border-radius: 1rem;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #d9e2ec;
}

.app-report-range-panel-title {
    margin-bottom: 0.75rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #627d98;
}

.app-report-preset-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.65rem;
}

.app-report-preset {
    justify-content: center;
}

.app-report-quarter-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.85rem;
}

.app-report-range-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.app-report-field {
    padding: 0.95rem 1rem 0.25rem;
    border-radius: 1rem;
    border: 1px solid #d9e2ec;
    background: #fcfdff;
}

.app-report-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.9rem 1.4rem;
    padding: 0.95rem 1rem;
    border-radius: 1rem;
    border: 1px solid #d9e2ec;
    background: #f8fbfd;
}

.app-report-options .form-check {
    margin-bottom: 0;
}

.modal-content {
    border: 0;
    border-radius: 1rem;
    box-shadow: 0 1.25rem 3rem rgba(15, 23, 42, 0.24);
}

.modal-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
    background: linear-gradient(180deg, rgba(248, 251, 253, 0.98), rgba(244, 248, 252, 0.96));
}

.modal-title {
    font-weight: 700;
    color: #102a43;
}

.modal-body {
    padding: 1.2rem 1.25rem;
}

.modal-footer {
    padding: 0.95rem 1.25rem;
    border-top: 1px solid rgba(15, 23, 42, 0.08);
    background: #f8fbfd;
}

.app-modal-copy {
    margin-bottom: 1rem;
    padding: 0.85rem 1rem;
    border: 1px solid #d9e2ec;
    border-radius: 0.85rem;
    background: #f8fbfd;
    color: #486581;
}

.app-modal-link {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: #102a43;
    overflow-wrap: anywhere;
}

.app-modal-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    width: 100%;
}

.app-modal-actions .btn {
    min-width: 7rem;
}

@media (max-width: 767.98px) {
    .app-analytics-split {
        grid-template-columns: 1fr;
    }

    .app-report-range-shell,
    .app-report-range-fields,
    .app-report-quarter-grid {
        grid-template-columns: 1fr;
    }

    .app-detail-row {
        grid-template-columns: 1fr;
        gap: 0.35rem;
    }

    .app-modal-actions {
        flex-direction: column-reverse;
        align-items: stretch;
    }

    .app-modal-actions .btn {
        width: 100%;
    }
}
