:root {
    --primary: #0d4d3c;
    --primary-dark: #093a2d;
    --accent: #c99a3d;
    --sidebar-w: 250px;
}

body {
    background: #f4f6f8;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

.app-navbar {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
}

/* ---- Responsive navbar brand: shrink & truncate instead of overflowing the frame ---- */
.app-navbar .container-fluid {
    flex-wrap: nowrap;
}

.app-navbar .navbar-brand {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    min-width: 0;      /* required for text-overflow to work inside a flex item */
    flex: 1 1 auto;
    overflow: hidden;
    margin-right: 0.5rem;
}

.app-navbar .navbar-brand-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.app-navbar .navbar-user-name {
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
    vertical-align: middle;
}

@media (min-width: 992px) {
    .app-navbar .navbar-user-name { max-width: 220px; }
}

.app-wrapper {
    display: flex;
    min-height: calc(100vh - 56px);
}

.app-sidebar {
    width: var(--sidebar-w);
    background: #ffffff;
    border-right: 1px solid #e2e6ea;
    padding-top: 1rem;
    flex-shrink: 0;
}

.app-sidebar .nav-link {
    color: #333;
    padding: 0.65rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    border-left: 3px solid transparent;
}

.app-sidebar .nav-link:hover {
    background: #f0f4f2;
}

.app-sidebar .nav-link.active {
    background: #e8f3ee;
    border-left-color: var(--primary);
    color: var(--primary);
    font-weight: 600;
}

.app-content {
    flex: 1;
    min-width: 0;
}

.card {
    border: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    border-radius: 0.6rem;
}

.stat-card {
    border-radius: 0.75rem;
    color: #fff;
    padding: 1.25rem;
}

.stat-card.green { background: linear-gradient(135deg,#0d4d3c,#127a5f); }
.stat-card.blue { background: linear-gradient(135deg,#1a4d8f,#2b6cb0); }
.stat-card.orange { background: linear-gradient(135deg,#b5651d,#d98324); }
.stat-card.red { background: linear-gradient(135deg,#8e2626,#b53a3a); }

.btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
}
.btn-primary:hover {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
}

.table thead th {
    background: #f0f4f2;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
}

.login-card {
    width: 100%;
    max-width: 400px;
    border-radius: 1rem;
    padding: 2.5rem;
    background: #fff;
}

@media print {
    .app-navbar, .app-sidebar, .no-print { display: none !important; }
    .app-content { width: 100% !important; }
}

@media (max-width: 991px) {
    .app-sidebar {
        position: fixed;
        left: -260px;
        top: 56px;
        bottom: 0;
        z-index: 1030;
        transition: left 0.25s ease;
        overflow-y: auto;
    }
    .app-sidebar.show { left: 0; }
}

/* ---------------------------------------------------------------------- */
/* PWA / mobile-app-like additions                                        */
/* ---------------------------------------------------------------------- */

/* Respect the notch / gesture bar on installed Android/iOS apps */
body {
    padding-top: env(safe-area-inset-top);
}

.offline-banner {
    background: #8e2626;
    color: #fff;
    text-align: center;
    font-size: 0.85rem;
    padding: 0.4rem 0.75rem;
}

/* Bottom tab bar - only shown on phones, hidden on desktop/tablet (d-lg-none) */
.bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1040;
    display: flex;
    background: #fff;
    border-top: 1px solid #e2e6ea;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
    padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 0.5rem 0 0.4rem;
    color: #555;
    text-decoration: none;
    font-size: 0.68rem;
    -webkit-tap-highlight-color: transparent;
}

.bottom-nav-item i {
    font-size: 1.25rem;
}

.bottom-nav-item:active,
.bottom-nav-item.active {
    color: var(--primary);
}

/* Simple fade/slide-in used for page content so navigation feels native, not a hard reload */
.app-content {
    animation: pageFadeIn 0.18s ease-out;
}
@keyframes pageFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Install banner shown by pwa.js when the browser fires beforeinstallprompt */
.pwa-install-banner {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom));
    z-index: 1050;
    background: #fff;
    border-radius: 0.75rem;
    box-shadow: 0 4px 18px rgba(0,0,0,0.18);
    padding: 0.85rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.pwa-install-banner.d-lg-none.has-bottom-nav { bottom: calc(70px + env(safe-area-inset-bottom)); }

/* Touch-friendly minimum tap targets on small screens */
@media (max-width: 767px) {
    .btn, .form-control, .form-select { min-height: 44px; }
    input[type="checkbox"], input[type="radio"] { width: 1.2em; height: 1.2em; }
}
