/* ==========================================================
   Strike - Modern Design System
   Palette: #012F46 · #7EC5E1 · #AB1F78 · #FBB32A · #DBEFF8
   ========================================================== */

/* ---- CSS Variables / Design Tokens ---- */
:root {
    --sidebar-width: 260px;
    --sidebar-bg: #012F46;
    --sidebar-color: #ffffff;
    --sidebar-hover: rgba(126,197,225,0.10);
    --sidebar-active: rgba(126,197,225,0.18);
    --content-bg: #f4f7f9;
    --card-bg: #ffffff;
    --card-radius: 14px;
    --card-shadow: 0 1px 3px rgba(1,47,70,0.04), 0 4px 16px rgba(1,47,70,0.06);
    --card-shadow-hover: 0 4px 24px rgba(1,47,70,0.10);
    --border-color: #e2eaf0;
    --text-primary: #012F46;
    --text-secondary: #5a7a8a;
    --text-muted: #8fa8b7;
    --accent: #012F46;
    --accent-hover: #01405f;
    --accent-light: #DBEFF8;
    --highlight: #7EC5E1;
    --highlight-light: #DBEFF8;
    --magenta: #AB1F78;
    --magenta-light: #f8e4f1;
    --gold: #FBB32A;
    --gold-light: #fff6e0;
    --success: #22c55e;
    --success-light: #f0fdf4;
    --warning: #FBB32A;
    --warning-light: #fff6e0;
    --danger: #ef4444;
    --danger-light: #fef2f2;
    --info: #7EC5E1;
    --info-light: #DBEFF8;
    --transition: 0.2s ease;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ---- Global Reset & Typography ---- */
* {
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background-color: var(--content-bg);
    color: var(--text-primary);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

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

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

.table a {
    color: var(--accent);
    font-weight: 500;
}

.table a:hover {
    color: var(--magenta);
}

/* ---- Sidebar ---- */
#sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #013d5b 0%, #012F46 100%);
    color: var(--sidebar-color);
    transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
    z-index: 1000;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#sidebar.collapsed {
    transform: translateX(-100%);
}

.sidebar-header {
    flex-shrink: 0;
    padding: 1.25rem 1.25rem;
    border-bottom: 1px solid rgba(126,197,225,0.12);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-brand {
    color: var(--sidebar-color);
    text-decoration: none;
    font-size: 1.35rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    letter-spacing: -0.02em;
}

.sidebar-brand:hover {
    color: var(--sidebar-color);
}

.sidebar-brand i {
    color: var(--highlight);
    font-size: 1.4rem;
}

.sidebar-menu {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.75rem 0;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.sidebar-menu::-webkit-scrollbar {
    display: none;
}

.sidebar-menu-item {
    margin: 2px 0;
}

.sidebar-menu-link {
    display: flex;
    align-items: center;
    padding: 0.6rem 1.25rem;
    color: rgba(255,255,255,0.65);
    text-decoration: none;
    transition: all var(--transition);
    border-left: 3px solid transparent;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 0 8px 8px 0;
    margin-right: 8px;
}

.sidebar-menu-link:hover {
    background-color: var(--sidebar-hover);
    color: var(--sidebar-color);
    border-left-color: var(--highlight);
}

.sidebar-menu-link.active {
    background-color: var(--sidebar-active);
    color: var(--sidebar-color);
    border-left-color: var(--highlight);
    font-weight: 500;
}

.sidebar-menu-link i {
    width: 22px;
    margin-right: 0.7rem;
    text-align: center;
    font-size: 1rem;
    opacity: 0.85;
}

.sidebar-menu-link.active i {
    opacity: 1;
    color: var(--highlight);
}

.sidebar-divider {
    height: 1px;
    background-color: rgba(126,197,225,0.10);
    margin: 0.5rem 0;
}

.sidebar-group {
    margin-bottom: 0.25rem;
}

.sidebar-group-header {
    padding: 0.6rem 1.25rem 0.3rem;
    color: rgba(126,197,225,0.55);
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-top: 0.25rem;
}

.sidebar-group-item {
    margin: 1px 0;
    padding-left: 0;
}

.sidebar-footer {
    flex-shrink: 0;
    padding: 0.75rem 1rem;
    border-top: 1px solid rgba(126,197,225,0.10);
    background: rgba(0,0,0,0.15);
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.4rem 0.5rem;
    border-radius: 10px;
    cursor: pointer;
    transition: background-color var(--transition);
}

.user-menu:hover {
    background-color: var(--sidebar-hover);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--highlight), var(--magenta));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 0.8rem;
}

.user-info {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-size: 0.82rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 0.7rem;
    color: rgba(126,197,225,0.6);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---- Main Content ---- */
#main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    background-color: var(--content-bg);
    transition: margin-left 0.3s cubic-bezier(0.4,0,0.2,1);
}

#main-content.expanded {
    margin-left: 0;
}

/* ---- Topbar ---- */
.topbar {
    background-color: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(1,47,70,0.03);
    min-height: 60px;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.topbar-left h4 {
    margin-bottom: 0;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
}

.sidebar-toggle {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.4rem;
    border-radius: 8px;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
}

.sidebar-toggle:hover {
    background-color: var(--accent-light);
    color: var(--text-primary);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.notification-badge {
    position: relative;
}

.notification-icon {
    font-size: 1.15rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.4rem;
    border-radius: 8px;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    text-decoration: none;
}

.notification-icon:hover {
    background-color: var(--accent-light);
    color: var(--text-primary);
}

/* ---- Content Wrapper ---- */
.content-wrapper {
    padding: 1.5rem;
    max-width: 1600px;
}

/* ---- Cards ---- */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    transition: box-shadow var(--transition);
    overflow: hidden;
}

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

.card-header {
    background: var(--card-bg) !important;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
    font-weight: 600;
}

.card-header h5 {
    margin-bottom: 0;
    font-size: 0.95rem;
    font-weight: 600;
}

.card-body {
    padding: 1.25rem;
}

/* ---- KPI Cards (Dashboard) ---- */
.kpi-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    padding: 1.25rem;
    transition: all var(--transition);
    height: 100%;
}

.kpi-card:hover {
    box-shadow: var(--card-shadow-hover);
    transform: translateY(-2px);
}

.kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    margin-bottom: 1rem;
}

.kpi-icon.accent {
    background: var(--accent-light);
    color: var(--accent);
}

.kpi-icon.success {
    background: var(--success-light);
    color: var(--success);
}

.kpi-icon.warning {
    background: var(--gold-light);
    color: #d49a00;
}

.kpi-icon.info {
    background: var(--highlight-light);
    color: #2a8fb0;
}

.kpi-icon.danger {
    background: var(--danger-light);
    color: var(--danger);
}

.kpi-icon.magenta {
    background: var(--magenta-light);
    color: var(--magenta);
}

.kpi-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.kpi-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-top: 0.25rem;
}

.kpi-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.kpi-sub .trend-up {
    color: var(--success);
    font-weight: 600;
}

.kpi-sub .trend-down {
    color: var(--danger);
    font-weight: 600;
}

/* ---- Quick Actions (Dashboard) ---- */
.quick-action-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.25rem 1rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--card-radius);
    text-decoration: none;
    color: var(--text-primary);
    transition: all var(--transition);
    height: 100%;
    gap: 0.6rem;
}

.quick-action-card:hover {
    box-shadow: var(--card-shadow-hover);
    transform: translateY(-2px);
    border-color: var(--highlight);
    color: var(--accent);
}

.quick-action-card i {
    font-size: 1.5rem;
    opacity: 0.8;
}

.quick-action-card span {
    font-size: 0.8rem;
    font-weight: 500;
    text-align: center;
}

/* ---- Page Headers ---- */
.content-wrapper > .row:first-child h1 {
    font-size: 1.35rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.content-wrapper > .row:first-child h1 i {
    font-size: 1.2rem;
    color: var(--highlight);
}

.content-wrapper > .row:first-child hr {
    border-color: var(--border-color);
    opacity: 0.5;
    margin-top: 0.75rem;
    margin-bottom: 0;
}

/* ---- Tables ---- */
.table {
    margin-bottom: 0;
    font-size: 0.875rem;
}

.table > thead > tr > th {
    background-color: #f7fafb;
    border-bottom: 2px solid var(--border-color);
    border-top: none;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.75rem 1rem;
    white-space: nowrap;
}

.table > tbody > tr > td {
    padding: 0.75rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid #eef3f6;
    color: var(--text-primary);
}

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

.table-hover > tbody > tr:hover > td {
    background-color: #f5fafb;
}

/* Table Sort */
th.sortable {
    cursor: pointer;
    position: relative;
    transition: background-color 0.15s ease;
    user-select: none;
}

th.sortable:hover {
    background-color: #edf4f7 !important;
}

th.sort-asc,
th.sort-desc {
    background-color: var(--accent-light) !important;
    color: var(--accent) !important;
}

th.sortable .sort-icon {
    transition: opacity 0.15s ease;
}

th.sortable:hover .sort-icon {
    opacity: 0.7 !important;
}

/* Row Click - Righe cliccabili */
tr.row-clickable {
    cursor: pointer;
}

tr.row-clickable:hover td {
    background-color: var(--accent-light) !important;
    transition: background-color 0.15s ease;
}

/* ---- Badges ---- */
.badge {
    font-weight: 500;
    font-size: 0.72rem;
    padding: 0.35em 0.7em;
    border-radius: 6px;
    letter-spacing: 0.01em;
}

.badge.bg-success {
    background-color: var(--success-light) !important;
    color: var(--success) !important;
}

.badge.bg-warning {
    background-color: var(--gold-light) !important;
    color: #9a7000 !important;
}

.badge.bg-danger {
    background-color: var(--danger-light) !important;
    color: var(--danger) !important;
}

.badge.bg-info {
    background-color: var(--highlight-light) !important;
    color: #2a8fb0 !important;
}

.badge.bg-primary {
    background-color: var(--accent-light) !important;
    color: var(--accent) !important;
}

.badge.bg-secondary {
    background-color: #eef3f6 !important;
    color: var(--text-secondary) !important;
}

/* ---- Buttons ---- */
.btn {
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: 8px;
    padding: 0.45rem 1rem;
    transition: all var(--transition);
    letter-spacing: 0.01em;
}

.btn-sm {
    font-size: 0.78rem;
    padding: 0.3rem 0.65rem;
    border-radius: 7px;
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
    box-shadow: 0 1px 3px rgba(1,47,70,0.15);
}

.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    box-shadow: 0 2px 8px rgba(1,47,70,0.25);
}

.btn-success {
    background: var(--success);
    border-color: var(--success);
}

.btn-info {
    background: var(--highlight);
    border-color: var(--highlight);
    color: var(--accent);
}

.btn-info:hover {
    color: white;
    background: #5db8d6;
    border-color: #5db8d6;
}

.btn-outline-primary {
    color: var(--accent);
    border-color: #c2d9e4;
}

.btn-outline-primary:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.btn-outline-secondary {
    color: var(--text-secondary);
    border-color: #c2d9e4;
}

.btn-outline-secondary:hover {
    background: var(--accent-light);
    border-color: #c2d9e4;
    color: var(--text-primary);
}

.btn-outline-danger {
    color: var(--danger);
    border-color: #fecaca;
}

.btn-outline-danger:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: white;
}

.btn-outline-success {
    color: var(--success);
    border-color: #bbf7d0;
}

.btn-outline-success:hover {
    background: var(--success);
    border-color: var(--success);
    color: white;
}

.btn-group .btn {
    border-radius: 7px;
    margin-left: 3px;
}

.btn-group .btn:first-child {
    margin-left: 0;
}

.btn-group {
    gap: 0;
}

/* ---- Forms ---- */
.form-control,
.form-select {
    border-radius: 8px;
    border: 1px solid #c2d9e4;
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
    color: var(--text-primary);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--highlight);
    box-shadow: 0 0 0 3px rgba(126,197,225,0.2);
}

.form-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.35rem;
}

/* ---- Filter Card ---- */
.card .card-body form.row {
    align-items: flex-end;
}

/* ---- Alerts ---- */
.alert {
    border-radius: 10px;
    border: none;
    font-size: 0.875rem;
    padding: 0.75rem 1rem;
}

.alert-success {
    background: var(--success-light);
    color: #166534;
}

.alert-danger {
    background: var(--danger-light);
    color: #991b1b;
}

.alert-warning {
    background: var(--gold-light);
    color: #92400e;
}

.alert-info {
    background: var(--highlight-light);
    color: #0e5a73;
}

/* ---- Dropdown ---- */
.dropdown-menu {
    border-radius: 10px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 24px rgba(1,47,70,0.1);
    padding: 0.5rem;
}

.dropdown-item {
    border-radius: 6px;
    font-size: 0.85rem;
    padding: 0.5rem 0.75rem;
}

.dropdown-item:hover {
    background-color: var(--accent-light);
}

/* ---- PWA Install Banner ---- */
.pwa-install-banner {
    position: fixed;
    bottom: -120px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--card-bg);
    border-radius: var(--card-radius);
    box-shadow: 0 8px 32px rgba(1,47,70,0.15);
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    z-index: 9999;
    max-width: 400px;
    width: calc(100% - 2rem);
    transition: bottom 0.4s cubic-bezier(0.4,0,0.2,1);
    border: 1px solid var(--border-color);
}

.pwa-install-banner.show {
    bottom: 1rem;
}

.pwa-install-banner .btn-install {
    background: var(--accent);
    color: white;
    border: none;
    padding: 0.45rem 1rem;
    border-radius: 8px;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    font-size: 0.85rem;
}

.pwa-install-banner .btn-install:hover {
    background: var(--accent-hover);
}

.pwa-install-banner .btn-close-pwa {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    font-size: 0.9rem;
}

.pwa-install-banner .btn-close-pwa:hover {
    color: var(--text-primary);
}

/* ---- Login Page ---- */
.login-page {
    min-height: 100vh;
    display: flex;
    background: var(--content-bg);
}

.login-left {
    flex: 1;
    background: linear-gradient(135deg, #013d5b 0%, #012F46 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    position: relative;
    overflow: hidden;
}

.login-left::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 30% 40%, rgba(126,197,225,0.15) 0%, transparent 50%),
                radial-gradient(circle at 70% 60%, rgba(171,31,120,0.08) 0%, transparent 50%),
                radial-gradient(circle at 50% 80%, rgba(251,179,42,0.06) 0%, transparent 40%);
    animation: float 20s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(-2%, 2%); }
}

.login-left .lightning-icon {
    position: relative;
    z-index: 1;
    font-size: 5rem;
    color: var(--highlight);
    margin-bottom: 1.5rem;
    filter: drop-shadow(0 4px 16px rgba(126,197,225,0.4));
}

.login-left h2 {
    position: relative;
    z-index: 1;
    color: white;
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 0.5rem;
}

.login-left p {
    position: relative;
    z-index: 1;
    color: rgba(126,197,225,0.7);
    font-size: 0.95rem;
}

.login-right {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.login-form-container {
    width: 100%;
    max-width: 400px;
}

.login-form-container h3 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.35rem;
    color: var(--accent);
}

.login-form-container .subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 2rem;
}

.login-form-container .form-control {
    padding: 0.65rem 0.85rem;
    font-size: 0.9rem;
}

.login-form-container .btn-primary {
    padding: 0.7rem 1.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    width: 100%;
    margin-top: 0.5rem;
}

.login-footer {
    margin-top: 2rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.78rem;
}

/* ---- Responsive (Tablet ≤ 992px) ---- */
@media (max-width: 992px) {
    .content-wrapper {
        padding: 1.25rem;
    }
}

/* ---- Responsive (Mobile ≤ 768px) ---- */
@media (max-width: 768px) {
    /* -- Sidebar: slide over on mobile -- */
    #sidebar {
        transform: translateX(-100%);
    }

    #sidebar.show {
        transform: translateX(0);
    }

    #main-content {
        margin-left: 0;
        /* Add padding at bottom for bottom nav bar */
        padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    }

    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(1,47,70,0.5);
        z-index: 999;
        display: none;
        backdrop-filter: blur(2px);
    }

    .sidebar-overlay.show {
        display: block;
    }

    /* -- Topbar mobile -- */
    .topbar {
        padding: 0.5rem 0.75rem;
        padding-top: max(0.5rem, env(safe-area-inset-top, 0px));
        min-height: 52px;
    }

    .topbar-left h4 {
        font-size: 0.92rem;
        max-width: 160px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* -- Content -- */
    .content-wrapper {
        padding: 0.75rem;
    }

    /* -- Page header -- */
    .content-wrapper > .row:first-child h1 {
        font-size: 1.15rem;
    }

    /* -- Cards -- */
    .card {
        border-radius: 12px;
    }

    .card-header {
        padding: 0.75rem 1rem;
    }

    .card-body {
        padding: 0.85rem;
    }

    /* -- KPI Cards -- */
    .kpi-card {
        padding: 1rem;
        margin-bottom: 0;
    }

    .kpi-icon {
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
        margin-bottom: 0.75rem;
        border-radius: 10px;
    }

    .kpi-value {
        font-size: 1.4rem;
    }

    .kpi-label {
        font-size: 0.75rem;
    }

    /* -- Quick Actions (Dashboard) -- */
    .quick-action-card {
        padding: 1rem 0.5rem;
        border-radius: 12px;
        gap: 0.4rem;
    }

    .quick-action-card i {
        font-size: 1.3rem;
    }

    .quick-action-card span {
        font-size: 0.72rem;
    }

    /* -- Tables: horizontal scroll + compact -- */
    .table {
        font-size: 0.8rem;
    }

    .table > thead > tr > th {
        font-size: 0.7rem;
        padding: 0.6rem 0.5rem;
        letter-spacing: 0.02em;
    }

    .table > tbody > tr > td {
        padding: 0.6rem 0.5rem;
    }

    /* Auto table scroll on mobile */
    .card-body {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table-responsive {
        -webkit-overflow-scrolling: touch;
    }

    /* Table: prevent columns from collapsing too much */
    .table th,
    .table td {
        white-space: nowrap;
    }

    /* Allow wrapping for description columns */
    .table td:has(> .text-muted),
    .table td .truncate-mobile {
        white-space: normal;
        min-width: 100px;
    }

    /* -- Buttons: touch-friendly -- */
    .btn {
        min-height: 38px;
        padding: 0.5rem 0.85rem;
    }

    .btn-sm {
        min-height: 34px;
        padding: 0.35rem 0.55rem;
    }

    .btn-group .btn {
        margin-left: 2px;
    }

    /* -- Forms -- */
    .form-control,
    .form-select {
        font-size: 16px; /* Prevents iOS zoom on focus */
        min-height: 42px;
        padding: 0.5rem 0.75rem;
    }

    .form-label {
        font-size: 0.72rem;
        margin-bottom: 0.25rem;
    }

    /* -- Badges -- */
    .badge {
        font-size: 0.68rem;
        padding: 0.3em 0.6em;
    }

    /* -- Alerts -- */
    .alert {
        font-size: 0.82rem;
        padding: 0.65rem 0.85rem;
    }

    /* -- Login page -- */
    .login-left {
        display: none;
    }

    .login-right {
        flex: 1;
        padding: 1.5rem;
    }

    .login-form-container h3 {
        font-size: 1.3rem;
    }

    /* -- Dropdowns -- */
    .dropdown-menu {
        font-size: 0.85rem;
    }
}

/* ---- Bottom Navigation Bar (Mobile) ---- */
.mobile-bottom-nav {
    display: none;
}

/* Hidden by default on desktop */
.mobile-more-drawer {
    display: none;
}

.mobile-more-overlay {
    display: none;
}

@media (max-width: 768px) {
    .mobile-bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: calc(64px + env(safe-area-inset-bottom, 0px));
        background: var(--card-bg);
        border-top: 1px solid var(--border-color);
        box-shadow: 0 -2px 12px rgba(1,47,70,0.08);
        z-index: 1050;
        padding-bottom: env(safe-area-inset-bottom, 0px);
        justify-content: space-around;
        align-items: stretch;
    }

    .mobile-bottom-nav .nav-item {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .mobile-bottom-nav .nav-link {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        color: var(--text-muted);
        text-decoration: none;
        font-size: 0.62rem;
        font-weight: 500;
        padding: 6px 4px;
        width: 100%;
        transition: color 0.15s ease;
        position: relative;
        border-radius: 8px;
        margin: 4px 2px;
    }

    .mobile-bottom-nav .nav-link i {
        font-size: 1.25rem;
        transition: transform 0.15s ease;
    }

    .mobile-bottom-nav .nav-link.active {
        color: var(--accent);
    }

    .mobile-bottom-nav .nav-link.active::before {
        content: '';
        position: absolute;
        top: 0;
        left: 25%;
        right: 25%;
        height: 2.5px;
        background: var(--accent);
        border-radius: 0 0 3px 3px;
    }

    .mobile-bottom-nav .nav-link:active {
        background: var(--accent-light);
    }

    .mobile-bottom-nav .nav-link:active i {
        transform: scale(0.9);
    }

    /* Badge for notifications in bottom nav */
    .mobile-bottom-nav .nav-badge {
        position: absolute;
        top: 2px;
        right: calc(50% - 18px);
        font-size: 0.5rem;
        background: var(--danger);
        color: #fff;
        border-radius: 10px;
        padding: 1px 5px;
        line-height: 1.2;
        min-width: 14px;
        text-align: center;
    }

    /* "More" bottom sheet drawer */
    .mobile-more-drawer {
        display: block; /* Override desktop display:none */
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--card-bg);
        border-top-left-radius: 20px;
        border-top-right-radius: 20px;
        box-shadow: 0 -8px 32px rgba(1,47,70,0.15);
        z-index: 1100;
        transform: translateY(100%);
        transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
        max-height: 70vh;
        overflow-y: auto;
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    .mobile-more-drawer.open {
        transform: translateY(0);
    }

    .mobile-more-drawer-handle {
        width: 40px;
        height: 4px;
        border-radius: 2px;
        background: var(--border-color);
        margin: 10px auto 6px;
    }

    .mobile-more-drawer .drawer-section {
        padding: 0.25rem 1rem;
    }

    .mobile-more-drawer .drawer-section-title {
        color: var(--text-muted);
        font-size: 0.65rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.06em;
        padding: 0.5rem 0 0.25rem;
    }

    .mobile-more-drawer .drawer-link {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        padding: 0.7rem 0.5rem;
        color: var(--text-primary);
        text-decoration: none;
        font-size: 0.88rem;
        font-weight: 500;
        border-radius: 10px;
        transition: background 0.15s ease;
    }

    .mobile-more-drawer .drawer-link:active {
        background: var(--accent-light);
    }

    .mobile-more-drawer .drawer-link i {
        font-size: 1.15rem;
        width: 24px;
        text-align: center;
        color: var(--text-secondary);
    }

    .mobile-more-drawer .drawer-link.active i {
        color: var(--accent);
    }

    .mobile-more-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(1,47,70,0.4);
        backdrop-filter: blur(2px);
        z-index: 1099;
        display: none;
    }

    .mobile-more-overlay.open {
        display: block;
    }

    /* --- Mobile: card view for data tables --- */
    .mobile-card-view .table {
        display: block;
    }

    .mobile-card-view .table thead {
        display: none;
    }

    .mobile-card-view .table tbody {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }

    .mobile-card-view .table tbody tr {
        display: flex;
        flex-direction: column;
        background: var(--card-bg);
        border: 1px solid var(--border-color);
        border-radius: 12px;
        padding: 0.75rem;
        gap: 0.25rem;
    }

    .mobile-card-view .table tbody tr td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.25rem 0;
        border-bottom: 1px solid #f0f3f5;
        font-size: 0.82rem;
    }

    .mobile-card-view .table tbody tr td:last-child {
        border-bottom: none;
        justify-content: flex-end;
        padding-top: 0.5rem;
    }

    .mobile-card-view .table tbody tr td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 0.72rem;
        color: var(--text-secondary);
        text-transform: uppercase;
        letter-spacing: 0.03em;
        flex-shrink: 0;
        margin-right: 0.5rem;
    }

    /* Hide sidebar toggle text on mobile, keep icon */
    .sidebar-toggle {
        width: 40px;
        height: 40px;
    }

    /* Notification list optimizations */
    .list-group-item {
        padding: 0.75rem !important;
    }

    .list-group-item h6 {
        font-size: 0.82rem !important;
    }

    .list-group-item p {
        font-size: 0.78rem !important;
    }

    /* Notification buttons: horizontal on mobile */
    .list-group-item .btn-group-vertical,
    .list-group-item .d-flex.d-md-block {
        max-width: 100% !important;
    }

    .list-group-item .btn-group-vertical .btn,
    .list-group-item .d-flex.d-md-block .btn,
    .list-group-item .d-flex.d-md-block form {
        width: auto !important;
        flex: 0 0 auto;
    }

    /* Filter form stacking on mobile */
    .card-body form.row .col-md-2,
    .card-body form.row .col-md-3,
    .card-body form.row .col-md-4 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    /* Page action buttons: stack on mobile */
    .d-flex.gap-2.mb-3 {
        flex-wrap: wrap;
    }

    .d-flex.gap-2.mb-3 .btn {
        flex: 1 1 auto;
        min-width: 120px;
    }

    /* Time Tracker mobile optimizations */
    .display-5 {
        font-size: 2rem !important;
    }

    /* PWA install banner mobile adjustments */
    .pwa-install-banner {
        bottom: calc(-120px);
        max-width: 100%;
        width: calc(100% - 1rem);
        border-radius: 12px;
    }

    .pwa-install-banner.show {
        bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    }
}

/* ---- Small phones (≤ 400px) ---- */
@media (max-width: 400px) {
    .content-wrapper {
        padding: 0.5rem;
    }

    .topbar-left h4 {
        font-size: 0.82rem;
        max-width: 120px;
    }

    .kpi-value {
        font-size: 1.2rem;
    }

    .kpi-label {
        font-size: 0.7rem;
    }

    .mobile-bottom-nav .nav-link {
        font-size: 0.58rem;
    }

    .mobile-bottom-nav .nav-link i {
        font-size: 1.15rem;
    }

    .quick-action-card {
        padding: 0.75rem 0.25rem;
    }

    .quick-action-card span {
        font-size: 0.65rem;
    }
}

/* ---- PWA standalone mode ---- */
@media (display-mode: standalone) {
    body {
        -webkit-user-select: none;
        user-select: none;
    }

    /* Extra safe area for standalone PWA */
    .topbar {
        padding-top: max(0.75rem, env(safe-area-inset-top, 0px));
    }

    .mobile-bottom-nav {
        padding-bottom: max(8px, env(safe-area-inset-bottom, 0px));
    }

    /* Allow text selection in forms */
    input, textarea, select, .table td, .table th {
        -webkit-user-select: text;
        user-select: text;
    }
}

/* ---- Scrollbar Custom ---- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #c2d9e4;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ---- Misc Utilities ---- */
.text-accent {
    color: var(--accent) !important;
}

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

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

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

.bg-accent-light {
    background-color: var(--accent-light) !important;
}

/* Card header colored variants for backward compat */
.card-header.bg-primary {
    background: var(--accent) !important;
    color: white !important;
    border-bottom: none;
}

.card-header.bg-primary h5 {
    color: white;
}

/* Empty state */
.table tbody tr td.text-center.text-muted {
    padding: 2.5rem 1rem;
    font-size: 0.9rem;
}

/* ---- Progress Bar ---- */
.progress {
    background-color: var(--accent-light);
}

.progress-bar {
    background-color: var(--highlight) !important;
}

/* End of file */
