/*
 * Reunifyr — Custom Styles
 * Extends Bootstrap 5 with the navy/gold classic palette.
 */

/* ===== Design Tokens ===== */
:root {
    --primary-color: #1a3a5c;
    --primary-light: #1e4d78;
    --primary-medium: #2d6a9f;
    --primary-pale: #3d7eb5;
    --accent-color: #ffc107;
    --accent-soft: #fff3cd;
    --secondary-color: #6c757d;
    --surface-light: #f8f9fa;
    --surface-border: #dee2e6;
    --success-color: #198754;
    --danger-color: #dc3545;
}

/* ===== General ===== */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    min-height: 100vh;
    min-height: 100dvh;
    /* Safari dynamic viewport height */
    display: flex;
    flex-direction: column;
    margin: 0;
}

body>nav,
body>.flash-container,
body>footer {
    flex-shrink: 0;
}

body>main {
    flex: 1 1 auto;
    min-height: 0;
}

/* Tree fullscreen: card fills screen, container stretches */
.card:fullscreen,
.card:-webkit-full-screen {
    display: flex;
    flex-direction: column;
    background: #fff;
}

.card:fullscreen .card-body,
.card:-webkit-full-screen .card-body {
    flex: 1 1 auto;
    min-height: 0;
}

.card:fullscreen #treeContainer,
.card:-webkit-full-screen #treeContainer {
    height: 100% !important;
}

/* Full-viewport pages (hero carousel) */
body.fullvp {
    height: 100vh;
    overflow: hidden;
}

body.fullvp>main {
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

@media (max-width: 767px) {
    body.fullvp {
        height: auto;
        overflow: auto;
    }

    body.fullvp>main {
        overflow: visible;
    }
}

body.fullvp>footer {
    margin-top: 0 !important;
    padding: 0.35rem 0 !important;
}

body.fullvp>footer p {
    font-size: 0.78rem;
}

body.fullvp>main.my-4 {
    margin-top: 0.25rem !important;
    margin-bottom: 0 !important;
}

/* ===== Standardized Page Header Bar ===== */
.section-title-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 3px solid var(--primary-color);
}

.section-title-bar .section-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: #333;
    margin-bottom: 0;
}

@media (max-width: 768px) {
    .section-title-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .section-title-bar .section-title {
        font-size: 1.5rem;
        line-height: 1.3;
        width: 100%;
    }
}

/* ===== Bootstrap Primary → Navy Override ===== */
.bg-primary {
    background-color: var(--primary-color) !important;
}

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

.border-primary {
    border-color: var(--primary-color) !important;
}

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

.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active {
    background-color: var(--primary-light) !important;
    border-color: var(--primary-light) !important;
}

.btn-outline-primary {
    color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
}

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

.card-header-navy {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    color: #fff;
}

/* ===== Navbar ===== */
.navbar {
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
    z-index: 1030;
    padding-top: 0.4rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.navbar.sticky-top {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.2rem;
    letter-spacing: 0.025em;
}

.nav-link {
    transition: all 0.3s ease;
    font-size: 0.92rem;
    padding-top: 0.4rem;
    padding-bottom: 0.4rem;
    white-space: nowrap;
}

.nav-link:hover {
    transform: translateY(-1px);
    color: var(--accent-color) !important;
}

.nav-link:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
    border-radius: 4px;
}

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

/* ===== Dropdown Headers ===== */
.navbar-nav .dropdown-menu .dropdown-header {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6c757d;
    padding: 0.5rem 1rem 0.25rem;
}

/* ===== Cards ===== */
.card {
    border-radius: 10px;
    transition: all 0.3s ease;
}

.card:hover {
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}

.card-header {
    font-weight: 600;
    border-top-left-radius: 10px !important;
    border-top-right-radius: 10px !important;
}

/* ===== Buttons ===== */
.btn {
    border-radius: 8px;
    padding: 0.5rem 1.5rem;
    transition: all 0.3s ease;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

/* ===== Hero / Jumbotron ===== */
.jumbotron {
    border-radius: 15px;
    background: linear-gradient(135deg, #1a3a5c 0%, #2d6a9f 100%);
    color: white;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.jumbotron.bg-light {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%) !important;
    color: #333;
}

/* ===== Forms ===== */
.form-control,
.form-select {
    border-radius: 8px;
    border: 1px solid #ced4da;
    padding: 0.6rem 1rem;
}

.form-select {
    padding-right: 2.25rem;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(26, 58, 92, 0.15);
}

label {
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: #495057;
}

/* ===== Tables ===== */
.table {
    border-radius: 10px;
    overflow: hidden;
}

.table thead {
    font-weight: 600;
}

.table tbody tr {
    transition: background-color 0.2s ease;
}

.table tbody tr:hover {
    background-color: #f8f9fa;
}

/* ===== Family Tree ===== */
.family-card {
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.family-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.generation-badge {
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
    border-radius: 20px;
}

/* ===== Photo Gallery ===== */
.gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: 10px;
    cursor: pointer;
    aspect-ratio: 4 / 3;
}

.gallery-item img {
    transition: transform 0.3s ease;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery-item:hover img {
    transform: scale(1.1);
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

/* ===== Photo Albums ===== */
.album-card {
    position: relative;
    overflow: hidden;
    border-radius: 12px;
}

.album-card .album-cover {
    position: relative;
    height: 200px;
    overflow: hidden;
    width: 100%;
}

.album-card .album-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.album-card .album-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
    color: #fff;
    padding: 1rem;
}

/* Category filter pills */
.nav-pills .nav-link {
    color: var(--primary-color);
    font-weight: 500;
}

.nav-pills .nav-link:hover {
    color: var(--primary-light);
    background-color: var(--accent-soft);
}

.nav-pills .nav-link.active {
    background-color: var(--primary-color);
    color: #fff;
}

/* ===== Album Reorder Mode ===== */
.reorder-mode .gallery-item {
    cursor: grab;
    outline: 2px dashed var(--primary-color, #0d6efd);
    outline-offset: 2px;
    transition: transform 0.15s ease;
}

.reorder-mode .gallery-item:active {
    cursor: grabbing;
}

.sortable-ghost {
    opacity: 0.35;
}

/* ===== Memorial Pages ===== */
.memorial-hero {
    background: linear-gradient(135deg, #2c3e50 0%, #4a6741 100%);
    color: #fff;
    padding: 3rem 0;
    text-align: center;
}

.memorial-photo {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    border: 4px solid rgba(255, 255, 255, 0.8);
    object-fit: cover;
    margin: 0 auto;
}

.memorial-dates {
    font-size: 1.2rem;
    opacity: 0.9;
    margin-top: 0.5rem;
}

.memorial-bio {
    font-size: 1.05rem;
    line-height: 1.8;
    white-space: pre-wrap;
}

.timeline-event {
    position: relative;
    padding-left: 2rem;
    margin-bottom: 1.5rem;
    border-left: 3px solid var(--primary-color);
}

.timeline-event::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 0.3rem;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: var(--primary-color);
}

/* ===== Contact Directory ===== */
.contact-card {
    border: 1px solid var(--surface-border);
    border-radius: 10px;
    transition: all 0.3s ease;
}

.contact-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.contact-card .card-footer {
    border-radius: 0 0 10px 10px;
}

.birthday-item:hover {
    background-color: rgba(0, 0, 0, 0.04);
}

.alpha-nav .alpha-btn {
    min-width: 32px;
    padding: 0.2rem 0.4rem;
    font-weight: 600;
    font-size: 0.8rem;
    border-radius: 6px;
}

@media (max-width: 576px) {
    .alpha-nav .alpha-btn {
        min-width: 26px;
        padding: 0.15rem 0.25rem;
        font-size: 0.7rem;
    }
}

.alpha-header {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--primary-color);
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
    border-radius: 8px;
    flex-shrink: 0;
}

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

/* ===== Footer ===== */
footer {
    margin-top: auto;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.2);
}

/* ===== Alerts ===== */
.alert {
    border-radius: 10px;
    border: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* ===== Breadcrumbs ===== */
.breadcrumb {
    background-color: #f8f9fa;
    border-radius: 8px;
    padding: 0.75rem 1rem;
}

/* ===== Badges ===== */
.badge {
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-weight: 500;
}

/* ===== Shadows ===== */
.shadow-sm {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08) !important;
}

.shadow {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
}

.shadow-lg {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15) !important;
}

/* ===== Hover Effects ===== */
.hover-shadow {
    transition: all 0.3s ease;
}

.hover-shadow:hover {
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
    transform: translateY(-3px);
}

/* ===== Admin Section ===== */
.admin-section {
    background-color: #f8f9fa;
    border-left: 4px solid var(--primary-color);
    padding: 1rem;
    border-radius: 5px;
    margin-bottom: 1rem;
}

/* ===== Utility ===== */
.cursor-pointer {
    cursor: pointer;
}

.mt-6 {
    margin-top: 4rem !important;
}

.mb-6 {
    margin-bottom: 4rem !important;
}

.profile-image {
    border: 5px solid #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* ===== Loading Spinner ===== */
.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 2rem auto;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* ===== Family Select ===== */
.family-select {
    min-width: 250px;
}

select.family-select {
    width: 100%;
    max-width: none;
}

/* ===== Mobile Responsive ===== */
@media (max-width: 768px) {
    .navbar-brand {
        font-size: 1.1rem;
    }

    .jumbotron {
        padding: 2rem 1rem !important;
    }

    .jumbotron h1 {
        font-size: 2rem !important;
    }

    .btn-lg {
        padding: 0.5rem 1rem;
        font-size: 1rem;
    }
}

@media (max-width: 991.98px) {
    .navbar-collapse {
        max-height: calc(100vh - 56px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .navbar-nav .dropdown-menu {
        max-height: none;
        overflow-y: visible;
    }

    .navbar-nav .dropdown-menu .dropdown-item {
        padding: 0.75rem 1.25rem;
        font-size: 1.05rem;
        line-height: 1.6;
    }

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

    .navbar-nav .dropdown-menu .dropdown-header {
        font-size: 0.75rem;
        padding: 0.6rem 1.25rem 0.25rem;
        color: #adb5bd;
    }

    .navbar-nav .nav-link {
        padding: 0.75rem 1rem;
        font-size: 1.05rem;
    }

    .navbar-nav .dropdown-toggle {
        padding: 0.75rem 1rem;
    }
}

/* ===== Navbar density (desktop) ===== */
@media (min-width: 992px) {
    .navbar .navbar-nav .nav-link {
        font-size: 0.85rem;
        padding-left: 0.45rem;
        padding-right: 0.45rem;
    }
}

/* ===== Rotating Arrow Toggle ===== */
.navbar-toggler.menu-toggle {
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 0.375rem;
    padding: 0.35rem 0.75rem;
    font-size: 0.9rem;
    color: #fff;
    align-items: center;
    gap: 0.4rem;
    background: transparent;
}

/* Only apply inline-flex below the lg breakpoint so Bootstrap can hide it on desktop */
@media (max-width: 991.98px) {
    .navbar-toggler.menu-toggle {
        display: inline-flex;
    }
}

.navbar-toggler.menu-toggle:focus {
    box-shadow: 0 0 0 0.2rem rgba(255, 255, 255, 0.25);
}

.navbar-toggler.menu-toggle .toggle-arrow {
    display: inline-block;
    transition: transform 0.3s ease;
    font-size: 0.75rem;
}

.navbar-toggler.menu-toggle[aria-expanded="true"] .toggle-arrow {
    transform: rotate(180deg);
}

/* Smooth rotate for dropdown chevrons */
.dropdown-toggle .chevron-arrow {
    display: inline-block;
    transition: transform 0.3s ease;
    font-size: 0.65rem;
    margin-left: 0.2rem;
    vertical-align: middle;
}

.dropdown-toggle[aria-expanded="true"] .chevron-arrow {
    transform: rotate(180deg);
}

/* Hide Bootstrap's default dropdown caret when using custom chevron */
.dropdown-toggle.no-caret::after {
    display: none;
}

/* ===== Step Progress Bar ===== */
.step-progress {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0;
    margin-bottom: 2rem;
    padding: 0;
    list-style: none;
    counter-reset: step;
}

.step-progress li {
    display: flex;
    align-items: center;
    font-size: 0.85rem;
    color: var(--secondary-color);
}

.step-progress li .step-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid var(--surface-border);
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--secondary-color);
    flex-shrink: 0;
}

.step-progress li.active .step-circle {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
}

.step-progress li.completed .step-circle {
    background: var(--success-color);
    border-color: var(--success-color);
    color: #fff;
}

.step-progress li .step-line {
    width: 48px;
    height: 2px;
    background: var(--surface-border);
    margin: 0 0.25rem;
}

.step-progress li.completed .step-line {
    background: var(--success-color);
}

@media (max-width: 480px) {
    .step-progress li .step-line {
        width: 24px;
    }

    .step-progress li .step-circle {
        width: 30px;
        height: 30px;
        font-size: 0.8rem;
    }
}

/* ===== Popular Plan Badge ===== */
.popular-badge {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary-color);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    z-index: 1;
    white-space: nowrap;
    letter-spacing: 0.03em;
}

/* ===== Home Page — Clean Dashboard Layout ===== */
:root {
    --home-accent-blue: #dbe4ee;
    --home-accent-gold: #fce4b8;
}

.home-greeting {
    padding: 1rem 0 0.75rem;
    margin-bottom: 1.5rem;
}

.home-greeting h1 {
    font-size: 1.5rem;
    color: #333;
}

.home-greeting-links a {
    text-decoration: none;
}

.home-greeting-links a:hover {
    text-decoration: underline;
}

.home-section {
    padding: 1.25rem 0;
    border-bottom: 1px solid var(--surface-border);
}

.home-section:last-child {
    border-bottom: none;
}

.home-section-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--primary-color);
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--primary-color);
    margin-bottom: 0.75rem;
}

.home-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid #eee;
}

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

.home-row-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 64px;
    padding: 0.5rem;
    border-radius: 0.5rem;
    text-align: center;
    flex-shrink: 0;
}

/* Activity Center grid */
.home-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.home-grid-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 1rem 0.5rem;
    border: 1px solid #e0e0e0;
    border-radius: 0.5rem;
    text-decoration: none;
    color: #555;
    background: #fafafa;
    transition: background 0.15s, box-shadow 0.15s;
}

.home-grid-tile:hover {
    background: #f0f0f0;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    color: var(--primary-color);
    text-decoration: none;
}

.home-grid-tile i {
    font-size: 1.5rem;
    margin-bottom: 0.35rem;
}

.home-grid-tile span {
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.2;
}

.home-grid-tile--accent {
    border-color: var(--success-color);
    color: var(--success-color);
}

.birthday-balloon-icon {
    font-size: 1.1rem;
    margin-right: 0.15rem;
    display: inline-block;
    transform: rotate(-10deg);
}

.home-birthday-item {
    font-size: 0.9rem;
    font-weight: 400;
}

/* ===== Clean Form Layout (BoA-inspired) ===== */
.clean-form {
    max-width: 520px;
    margin: 0 auto;
}

.clean-form .form-section {
    padding: 1.5rem 0;
    border-bottom: 1px solid var(--surface-border);
}

.clean-form .form-section:last-of-type {
    border-bottom: none;
}

.clean-form .form-section-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.clean-form .form-group {
    margin-bottom: 1.25rem;
}

.clean-form .form-label {
    font-weight: 500;
    margin-bottom: 0.35rem;
}

.clean-form .form-hint {
    font-size: 0.8rem;
    color: var(--secondary-color);
    margin-top: 0.25rem;
}

.clean-form .form-cta {
    padding-top: 1.5rem;
}

/* Trust badge for secure forms */
.trust-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8rem;
    color: var(--success-color);
    font-weight: 500;
}

.trust-badge i {
    font-size: 0.95rem;
}

/* ===== Platform Admin — Monitoring Dashboard ===== */
.platform-filter-bar {
    background: #fff;
    border: 1px solid var(--surface-border);
    border-radius: 0.5rem;
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
}

.platform-filter-bar .form-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--secondary-color);
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.platform-table .table {
    font-size: 0.85rem;
}

.platform-table .table thead th {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--secondary-color);
    font-weight: 600;
    border-bottom: 2px solid var(--surface-border);
    padding: 0.6rem 0.75rem;
    white-space: nowrap;
}

.platform-table .table td {
    vertical-align: middle;
    padding: 0.55rem 0.75rem;
}

.platform-table .table tbody tr {
    border-bottom: 1px solid #f0f0f0;
}

.platform-table .table tbody tr:hover {
    background: #f7f9fb;
}

.platform-card {
    border: 1px solid var(--surface-border);
    border-radius: 0.5rem;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.platform-card .card-header {
    background: #fff;
    font-weight: 600;
    font-size: 0.85rem;
    border-bottom: 1px solid #f0f0f0;
    padding: 0.65rem 1rem;
}

.platform-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.platform-toolbar .btn {
    font-size: 0.8rem;
    padding: 0.3rem 0.65rem;
    white-space: nowrap;
    line-height: 1.5;
    height: auto;
    min-height: 1.875rem;
}

.platform-table .table td,
.platform-table .table th {
    overflow: hidden;
    text-overflow: ellipsis;
}

.platform-table .btn-group .btn {
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
    white-space: nowrap;
    line-height: 1.5;
}

.export-dropdown .dropdown-menu {
    min-width: 18rem;
    padding: 1rem;
}

.export-dropdown .form-check {
    font-size: 0.82rem;
}

.platform-badge {
    font-size: 0.7rem;
    padding: 0.2em 0.55em;
    font-weight: 500;
    letter-spacing: 0.02em;
}

/* ── Dashboard: Title + Health Banner ── */
.pd-dash {
    max-width: 1440px;
}

.pd-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.pd-health-badge {
    font-size: 0.75rem;
    padding: 0.3em 0.7em;
    font-weight: 600;
    letter-spacing: 0.02em;
}

/* ── Dashboard: KPI Cards ── */
.pd-kpi {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    background: #fff;
    border: 1px solid var(--surface-border);
    border-radius: 0.625rem;
    padding: 1rem 1.1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    height: 100%;
}

.pd-kpi-icon {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    flex-shrink: 0;
}

.pd-kpi-body {
    flex: 1;
    min-width: 0;
}

.pd-kpi-label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6c757d;
    font-weight: 600;
    line-height: 1;
}

.pd-kpi-value {
    font-size: 1.65rem;
    font-weight: 700;
    line-height: 1.2;
    margin-top: 0.15rem;
}

.pd-kpi-sub {
    font-size: 0.75rem;
    margin-top: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
}

/* ── Dashboard: Cards ── */
.pd-card {
    background: #fff;
    border: 1px solid var(--surface-border);
    border-radius: 0.625rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    overflow: hidden;
}

.pd-card-header {
    font-weight: 600;
    font-size: 0.88rem;
    padding: 0.75rem 1.1rem;
    border-bottom: 1px solid #f0f0f0;
    color: var(--text-primary);
}

.pd-card-body {
    padding: 1.1rem;
}

.pd-section-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6c757d;
    font-weight: 600;
    margin-bottom: 0.6rem;
}

/* ── Dashboard: Revenue Bar Rows ── */
.pd-bar-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin-bottom: 0.75rem;
}

.pd-bar-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    min-width: 140px;
    font-size: 0.8rem;
}

.pd-bar-track {
    flex: 1;
    height: 8px;
    background: #f0f2f5;
    border-radius: 4px;
    overflow: hidden;
}

.pd-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.4s ease;
}

.pd-bar-value {
    font-weight: 700;
    font-size: 0.88rem;
    min-width: 55px;
    text-align: right;
}

/* ── Dashboard: Finance Summary Rows ── */
.pd-finance-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    padding: 0.2rem 0;
}

/* ── Dashboard: Health Grid (Dynatrace-inspired) ── */
.pd-health-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
}

.pd-health-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    padding: 0.75rem 0.5rem;
    border-radius: 0.5rem;
    text-align: center;
    font-size: 0.78rem;
    font-weight: 500;
    transition: background 0.15s ease;
}

.pd-health-tile i {
    font-size: 1.3rem;
}

.pd-health-tile small {
    font-size: 0.68rem;
    font-weight: 600;
}

.pd-health-ok {
    background: rgba(25, 135, 84, 0.06);
    border: 1px solid rgba(25, 135, 84, 0.15);
    color: #198754;
}

.pd-health-warn {
    background: rgba(255, 193, 7, 0.08);
    border: 1px solid rgba(255, 193, 7, 0.2);
    color: #856404;
}

.pd-health-err {
    background: rgba(220, 53, 69, 0.06);
    border: 1px solid rgba(220, 53, 69, 0.15);
    color: #dc3545;
}

/* ── Dashboard: CSS Bar Chart ── */
.pd-chart {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    height: 180px;
    padding-bottom: 2rem;
    position: relative;
}

.pd-chart-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    position: relative;
}

.pd-chart-bars {
    flex: 1;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    gap: 2px;
}

.pd-chart-bar {
    width: 65%;
    min-height: 2px;
    border-radius: 3px 3px 0 0;
    transition: height 0.3s ease;
}

.pd-chart-label {
    font-size: 0.7rem;
    color: #6c757d;
    font-weight: 500;
    margin-top: 0.35rem;
}

.pd-chart-count {
    font-size: 0.65rem;
    color: #adb5bd;
    font-weight: 600;
}

.pd-legend-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 2px;
    margin-right: 3px;
    vertical-align: middle;
}

/* ── Dashboard: Mini Stats ── */
.pd-mini-stat {
    text-align: center;
    padding: 0.5rem;
    background: #f8f9fa;
    border-radius: 0.4rem;
}

.pd-mini-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
}

.pd-mini-stat-label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6c757d;
    font-weight: 600;
}

/* ── Dashboard: Activity Feed ── */
.pd-feed {
    max-height: 380px;
    overflow-y: auto;
    padding: 0.5rem 1.1rem;
}

.pd-feed-item {
    display: flex;
    gap: 0.65rem;
    padding: 0.6rem 0;
    border-bottom: 1px solid #f5f5f5;
}

.pd-feed-item:last-child {
    border-bottom: none;
}

.pd-feed-icon {
    width: 1.75rem;
    height: 1.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0f2f5;
    border-radius: 50%;
    flex-shrink: 0;
    font-size: 0.75rem;
    color: #6c757d;
}

.pd-feed-body {
    flex: 1;
    min-width: 0;
}

.pd-feed-text {
    font-size: 0.82rem;
    line-height: 1.3;
}

.pd-feed-desc {
    font-size: 0.75rem;
    color: #6c757d;
    margin-top: 0.15rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pd-feed-time {
    font-size: 0.68rem;
    color: #adb5bd;
    margin-top: 0.15rem;
}

/* ── Dashboard responsive ── */
@media (max-width: 767.98px) {
    .pd-kpi {
        padding: 0.75rem;
    }

    .pd-kpi-value {
        font-size: 1.3rem;
    }

    .pd-kpi-icon {
        width: 2rem;
        height: 2rem;
        font-size: 0.95rem;
    }

    .pd-chart {
        height: 140px;
    }

    .pd-bar-label {
        min-width: 100px;
    }

    .pd-health-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.4rem;
    }
}

/* ===== Print ===== */
@media print {

    html {
        height: auto !important;
        overflow: visible !important;
    }

    body {
        display: block !important;
        min-height: auto !important;
        height: auto !important;
        overflow: visible !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .navbar,
    footer,
    .btn,
    .no-print,
    .modal-backdrop {
        display: none !important;
    }

    .card {
        border: 2px solid #000;
        box-shadow: none;
        page-break-inside: avoid;
    }

    @page {
        margin: 1in;
    }

    h1, h2, h3, h4 {
        page-break-after: avoid;
    }

    a[href]::after {
        content: " (" attr(href) ")";
        font-size: 0.85em;
        color: #555;
    }

    img {
        max-width: 100% !important;
    }

    * {
        color: #000 !important;
        background: transparent !important;
        box-shadow: none !important;
    }

    /* ===== Document Viewer PDF print ===== */
    body.dv-printing,
    body.dv-printing.modal-open {
        height: auto !important;
        overflow: visible !important;
        overflow-y: visible !important;
        padding: 0 !important;
        margin: 0 !important;
        min-height: auto !important;
    }

    body.dv-printing > *:not(#document-viewer-print) {
        display: none !important;
    }

    body.dv-printing .modal,
    body.dv-printing .modal-backdrop {
        display: none !important;
    }

    body.dv-printing > #document-viewer-print {
        display: block !important;
        height: auto !important;
        overflow: visible !important;
        margin: 0;
        padding: 0;
    }

    @page {
        size: letter;
        margin: 0.5in;
    }

    #document-viewer-print img {
        max-width: 100%;
        height: auto;
        display: block;
        margin: 0 auto;
        page-break-inside: avoid;
    }

    #document-viewer-print img + img {
        break-before: page;
        page-break-before: always;
    }

    #document-viewer-print img:last-child {
        break-after: avoid;
        page-break-after: avoid;
        margin-bottom: 0;
        padding-bottom: 0;
    }
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ===== Disabled Buttons ===== */
.btn:disabled,
.btn.disabled {
    opacity: 0.55;
    cursor: not-allowed;
    pointer-events: none;
}

/* ===== Back to Top ===== */
.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 1040;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.18);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.back-to-top.show {
    display: flex;
    opacity: 1;
}

/* ===== Skip to Content ===== */
.skip-to-content {
    position: absolute;
    top: -100%;
    left: 0;
    z-index: 9999;
    padding: 0.75rem 1.5rem;
    background: var(--primary-color, #1a3a5c);
    color: #fff;
    text-decoration: none;
    font-weight: 600;
}

.skip-to-content:focus {
    top: 0;
}

/* ===== Mobile Responsiveness Fixes ===== */
@media (max-width: 767.98px) {
    .table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .search-bar,
    .search-bar input[type="search"],
    .search-bar input[type="text"] {
        max-width: 100% !important;
    }
}
}