:root {
    --sidebar-width: 260px;
    --primary-color: #0d6efd;
    --bottom-nav-height: 4.25rem;
    --mobile-topbar-height: 3.25rem;
    --app-radius: 0.875rem;
    --app-shadow: 0 0.125rem 0.75rem rgba(15, 23, 42, 0.08);
}

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

html {
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: #f4f6f9;
    min-height: 100vh;
    min-height: 100dvh;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

body.app-authenticated {
    padding-bottom: 0;
}

.auth-page {
    background: linear-gradient(160deg, #eef4ff 0%, #f4f6f9 45%, #e9ecef 100%);
}

/* ── Layout desktop ── */
@media (min-width: 992px) {
    .sidebar {
        width: var(--sidebar-width);
        min-height: 100vh;
        position: sticky;
        top: 0;
        flex-shrink: 0;
    }

    .sidebar.offcanvas-lg {
        position: sticky;
        transform: none !important;
        visibility: visible !important;
        border-right: 1px solid rgba(255, 255, 255, 0.1);
    }

    .main-content {
        min-height: 100vh;
        max-width: calc(100% - var(--sidebar-width));
    }

    .app-container {
        padding: 1.5rem 1.75rem;
    }
}

/* ── Mobile top bar ── */
.mobile-topbar {
    position: sticky;
    top: 0;
    z-index: 1025;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--mobile-topbar-height);
    padding: 0 1rem;
    padding-top: env(safe-area-inset-top);
    background: #fff;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: var(--app-shadow);
}

.mobile-topbar__brand {
    display: flex;
    align-items: center;
    min-width: 0;
    flex: 1;
}

.mobile-topbar__brand .brand-logo {
    max-width: 11rem;
}

.mobile-topbar__user {
    color: #64748b;
    font-size: 1.75rem;
    line-height: 1;
    padding: 0;
    border: 0;
    text-decoration: none;
}

.mobile-topbar__user:hover {
    color: var(--primary-color);
}

/* ── Bottom navigation (mobile) ── */
.bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1030;
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    height: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 -4px 24px rgba(15, 23, 42, 0.08);
}

.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    padding: 0.35rem 0.25rem;
    border: 0;
    background: transparent;
    color: #64748b;
    font-size: 0.65rem;
    font-weight: 500;
    text-decoration: none;
    transition: color 0.15s ease;
    min-width: 0;
}

.bottom-nav-item i {
    font-size: 1.35rem;
    line-height: 1;
}

.bottom-nav-item span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.bottom-nav-item.active {
    color: var(--primary-color);
    font-weight: 600;
}

.bottom-nav-item--primary {
    position: relative;
    color: var(--primary-color);
}

.bottom-nav-item--primary i {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    margin-top: -1.25rem;
    border-radius: 50%;
    background: linear-gradient(145deg, #3d8bfd, #0d6efd);
    color: #fff;
    font-size: 1.4rem;
    box-shadow: 0 4px 14px rgba(13, 110, 253, 0.45);
}

.bottom-nav-item--primary.active i {
    background: linear-gradient(145deg, #0d6efd, #0a58ca);
}

.bottom-nav-item--primary span {
    margin-top: 0.1rem;
}

@media (max-width: 991.98px) {
    .main-content {
        padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom) + 0.5rem);
    }

    .app-container {
        padding: 1rem 0.875rem 0.5rem;
    }

    .page-header h1,
    .page-header .h3 {
        font-size: 1.25rem;
    }

    .display-6 {
        font-size: 1.75rem;
    }

    .display-4 {
        font-size: 2.25rem;
    }

    .card-body.p-4 {
        padding: 1.15rem !important;
    }

    .table-responsive {
        font-size: 0.875rem;
    }

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

/* ── Logomarca ── */
.brand-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, #ffffff 0%, #f1f5f9 100%);
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 0.625rem;
    padding: 0.4rem 0.75rem;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

.brand-logo__img {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    object-fit: contain;
}

.brand-logo--sm .brand-logo__img {
    max-height: 1.85rem;
}

.brand-logo--md .brand-logo__img,
.brand-logo--sidebar .brand-logo__img {
    max-height: 2.75rem;
}

.brand-logo--sidebar {
    width: 100%;
    padding: 0.55rem 0.85rem;
}

.brand-logo--lg .brand-logo__img {
    max-height: 3.75rem;
}

.brand-logo--xl .brand-logo__img {
    max-height: 4.75rem;
    max-width: min(100%, 18rem);
}

.brand-logo--xl {
    padding: 0.85rem 1.25rem;
    border-radius: 0.875rem;
}

.auth-logo .brand-logo {
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
}

.sidebar.bg-dark .brand-logo {
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

/* ── Sidebar ── */
.sidebar-link {
    color: rgba(255, 255, 255, 0.75);
    padding: 0.55rem 1rem;
    border-radius: 0.375rem;
    margin: 0.1rem 0.5rem;
    display: flex;
    align-items: center;
    font-size: 0.925rem;
    transition: background-color 0.15s, color 0.15s;
}

.sidebar-link:hover:not(.disabled) {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.08);
}

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

.sidebar-link.disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.avatar-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* ── Components ── */
.page-header h1 {
    font-weight: 600;
}

.card {
    border-radius: var(--app-radius);
    box-shadow: var(--app-shadow);
    border: 0;
}

.card-header {
    border-top-left-radius: var(--app-radius) !important;
    border-top-right-radius: var(--app-radius) !important;
}

.stat-card .fs-4 {
    letter-spacing: -0.02em;
}

/* Registrar ponto — tela principal mobile */
.registrar-page .registrar-clock {
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.03em;
}

/* Forms touch-friendly */
@media (max-width: 991.98px) {
    .form-control,
    .form-select {
        min-height: 2.75rem;
        font-size: 1rem;
    }

    input[type="time"].form-control {
        min-height: 2.75rem;
    }
}

/* PWA install banner */
.pwa-install-banner {
    position: fixed;
    left: 0.75rem;
    right: 0.75rem;
    bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom) + 0.75rem);
    z-index: 1040;
    display: none;
    animation: slideUp 0.3s ease;
}

.pwa-install-banner.show {
    display: block;
}

@media (min-width: 992px) {
    .pwa-install-banner {
        left: auto;
        right: 1.25rem;
        bottom: 1.25rem;
        max-width: 320px;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Safe areas for notched phones */
@supports (padding: max(0px)) {
    .app-authenticated .app-shell {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
}
