:root {
    --primary: #0ea5e9;
    --primary-soft: #e0ebff;
    --primary-dark: #12283a;
    --secondary: #3083d9;
    --success: #16a34a;
    --warning: #f59e0b;
    --danger: #dc2626;
    --info: #1d4ed8;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: linear-gradient(180deg, #eff6ff 0%, #dbeafe 100%);
    color: var(--text-primary);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

html {
    scroll-behavior: smooth;
}

.card,
.btn,
.form-control,
.form-select,
.alert {
    transition: all 0.2s ease;
}

.card {
    border: none;
    border-radius: 22px;
    box-shadow: 0 10px 35px rgba(15, 23, 42, 0.14);
    overflow: hidden;
    transition: box-shadow 0.3s ease;
}

.card:hover {
    box-shadow: 0 15px 45px rgba(15, 23, 42, 0.18);
}

.card-header {
    padding: 1.5rem;
    background: #f8fafc;
    border-bottom: 1px solid rgba(15, 23, 42, 0.05);
}

.card-body {
    padding: 1.75rem;
}

.card-body.p-0 {
    padding: 0 !important;
}

.btn {
    border-radius: 12px;
    font-weight: 600;
}

.page-header {
    margin-bottom: 1.75rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.page-header h2 {
    font-weight: 700;
    color: var(--text-primary);
}

.row.g-4 > [class*='col-'] {
    display: flex;
    flex-direction: column;
}

.row.g-4 > [class*='col-'] .card {
    height: 100%;
}

.table th {
    background: var(--surface);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.78rem;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    padding: 1rem !important;
}

.table td {
    padding: 1rem !important;
    vertical-align: middle;
}

.stat-card {
    border: none;
    border-radius: 18px;
    overflow: hidden;
    min-height: 160px;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.12);
}

.stat-card .card-body {
    padding: 1.4rem;
}

.stat-card .stat-icon {
    width: 68px;
    height: 68px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-card .stat-number {
    font-size: clamp(1.15rem, 2vw, 1.45rem);
    font-weight: 700;
    white-space: nowrap;
}

.stat-card .stat-label {
    font-size: 0.82rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.stat-card .small {
    font-size: 0.78rem;
}

.btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--secondary);
    border-color: var(--secondary);
}

.alert {
    border-radius: 14px;
    border: none;
}

.form-control,
.form-select {
    border-radius: 14px;
    border: 1px solid #d7e0ee;
    padding: 0.85rem 1rem;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.18rem rgba(59, 130, 246, 0.18);
}

.badge {
    font-weight: 600;
    padding: 0.45em 0.9em;
    border-radius: 999px;
}

.summary-table {
    max-height: 400px;
    overflow-y: auto;
}

.sales-site-chart-card {
    margin-top: 0;
}

.sales-site-chart-wrap {
    height: 280px;
    max-width: 340px;
    margin: 0 auto;
    position: relative;
}

.sales-site-legend {
    display: grid;
    gap: 0.45rem;
    font-size: 10px;
}

.sales-site-legend-item {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.65rem;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 10px;
    background: #f8fafc;
}

.sales-site-swatch {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.04);
}

.sales-site-legend-main {
    min-width: 0;
}

.sales-site-percent {
    font-size: 10px;
    font-weight: 800;
    color: var(--primary-dark);
}

.sales-site-legend small {
    font-size: 10px;
}

.table-scroll {
    max-height: 340px;
    overflow-y: auto;
}

.table-scroll table {
    margin-bottom: 0;
}

.table-scroll thead th {
    position: sticky;
    top: 0;
    background: var(--surface);
    z-index: 2;
}

.btn-outline-pink {
    color: #d63384;
    border-color: #d63384;
}

.btn-outline-pink:hover,
.btn-outline-pink:focus {
    background-color: #d63384;
    color: #fff;
}

@keyframes blink-icon {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.2; }
}

.blink-icon {
    animation: blink-icon 3s infinite;
}

#loader {
    opacity: 1;
}

.login-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr 1.45fr;
    align-items: stretch;
    gap: 0;
    padding: 2.5rem;
    background: linear-gradient(180deg, #eff6ff 0%, #dbeafe 40%, #f3f6fb 100%);
    border-radius: 28px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.login-hero,
.login-form-panel {
    min-height: 520px;
}

.login-hero {
    position: relative;
    padding: 3rem 2.5rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    background: transparent;
}

.login-form-panel {
    position: relative;
    padding: 2.5rem;
    min-height: 520px;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        linear-gradient(180deg, rgba(239, 246, 255, 0.88) 0%, rgba(219, 234, 254, 0.88) 100%),
        url('icone/sales-bg.svg') center / cover no-repeat;
    box-shadow: none;
    overflow: hidden;
}

.login-form-panel::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 35% 20%, rgba(14, 165, 233, 0.14), transparent 40%),
                radial-gradient(circle at 80% 70%, rgba(29, 78, 216, 0.12), transparent 38%);
    pointer-events: none;
}

.login-form-panel > * {
    position: relative;
    z-index: 1;
}

.login-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at top left, rgba(59, 130, 246, 0.18), transparent 28%),
                radial-gradient(circle at bottom right, rgba(14, 165, 233, 0.16), transparent 26%);
    pointer-events: none;
}

.login-hero > * {
    position: relative;
    z-index: 1;
}

.login-hero img {
    width: 150px;
    max-width: 100%;
    display: block;
    margin: 0 auto 1.75rem;
}

.login-hero h1 {
    margin-bottom: 1rem;
    font-size: clamp(2rem, 3vw, 2.8rem);
    line-height: 1.05;
    color: var(--primary-dark);
}

.login-hero p {
    max-width: 36rem;
    margin-bottom: 2.5rem;
    color: var(--text-secondary);
    font-size: 1rem;
    line-height: 1.75;
}

.hero-highlights {
    display: grid;
    gap: 1rem;
}

.hero-highlights .highlight {
    background: rgba(255,255,255,0.88);
    border-radius: 16px;
    padding: 1rem 1.15rem;
    border: 1px solid rgba(15, 23, 42, 0.05);
}

.hero-highlights .highlight strong {
    display: block;
    font-size: 1.05rem;
    color: var(--text-primary);
}

.login-form-card {
    width: 100%;
    max-width: 420px;
    background: rgba(255,255,255,0.84);
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow);
    border: 1px solid rgba(255,255,255,0.9);
}

.login-form-card .card-body {
    padding: 2rem;
}

.login-form-card .form-label {
    font-weight: 700;
}

.login-form-card .input-group-text {
    border-radius: 14px 0 0 14px;
    border: 1px solid #d7e0ee;
    background: #f8fafc;
}

.login-form-card .form-control {
    border-left: 0;
}

.login-form-card .btn {
    padding: 0.95rem 1rem;
}

.login-form-card .help-text {
    color: var(--text-secondary);
    margin-top: 1rem;
    font-size: 0.95rem;
}

.kpi-card {
    border: none;
    border-radius: 18px;
    min-height: 160px;
    overflow: hidden;
    box-shadow: var(--shadow);
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid rgba(15, 23, 42, 0.06);
}

.kpi-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.12);
}

.kpi-card .card-body {
    padding: 1.35rem;
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

.kpi-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.kpi-icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(14, 165, 233, 0.14);
    color: var(--primary);
    font-size: 1.45rem;
    flex: 0 0 auto;
}

.kpi-label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    font-weight: 800;
    margin: 0;
}

.kpi-value {
    font-size: clamp(1.5rem, 2.3vw, 1.9rem);
    font-weight: 800;
    color: var(--primary-dark);
    margin: 0;
    line-height: 1.05;
}

.kpi-trend {
    margin-top: auto;
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.kpi-link {
    display: block;
    height: 100%;
    color: inherit;
    text-decoration: none;
}

.kpi-link:hover,
.kpi-link:focus {
    color: inherit;
}

.navbar {
    border-radius: 0 0 0 0;
}

.navbar-brand {
    font-size: 1.05rem;
}

.navbar-nav .nav-link {
    color: rgba(255,255,255,0.92);
}

.navbar-nav .nav-link:hover,
.navbar-nav .nav-link.active {
    color: #fff;
}

.dashboard-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 250px;
    background: var(--primary);
    color: white;
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    transition: width 0.3s ease;
    z-index: 1000;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.sidebar.collapsed {
    width: 70px;
}

.sidebar-header {
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-toggle {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 0 0.5rem;
}

.sidebar-toggle.mobile-only {
    display: none;
}

.sidebar-brand {
    color: white;
    text-decoration: none;
    font-weight: bold;
    display: flex;
    align-items: center;
    flex: 1;
}

.sidebar-close {
    margin-left: auto;
}

.sidebar-brand img {
    margin-right: 0.5rem;
}

.sidebar.collapsed .sidebar-brand span {
    display: none;
}

.sidebar.collapsed .sidebar-brand img {
    margin-right: 0;
}

.sidebar-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex: 1;
    flex-direction: column;
    min-height: 100%;
}

.sidebar-nav {
    display: flex;
    flex: 1;
    min-height: 0;
}

.sidebar-nav li {
    position: relative;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: rgba(255,255,255,0.9);
    text-decoration: none;
    transition: background 0.2s;
}

.sidebar-nav a:hover {
    background: rgba(255,255,255,0.1);
}

.sidebar-nav a.active {
    background: rgba(255,255,255,0.18);
    color: #fff;
    font-weight: 700;
}

.sidebar-nav a i {
    margin-right: 0.75rem;
    width: 20px;
    text-align: center;
}

.sidebar.collapsed .sidebar-nav a span {
    display: none;
}

.sidebar.collapsed .sidebar-nav a i {
    margin-right: 0;
}

.sidebar-nav .dropdown-menu {
    display: none;
    position: static;
    float: none;
    min-width: 0;
    width: 100%;
    list-style: none;
    padding: 0.35rem 0 0.35rem 0.35rem;
    margin: 0.15rem 0 0.35rem;
    background: rgba(255, 255, 255, 0.08);
    border: 0;
    border-radius: 0.85rem;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08);
}

.sidebar-nav .dropdown.open > .dropdown-menu {
    display: block;
}

.sidebar-nav .dropdown-menu li {
    width: 100%;
}

.sidebar-nav .dropdown-menu li a {
    display: flex;
    align-items: center;
    padding: 0.7rem 1rem 0.7rem 3rem;
    margin: 0.1rem 0.35rem;
    font-size: 0.9rem;
    color: rgba(255,255,255,0.85);
    border-radius: 0.65rem;
}

.sidebar-nav .dropdown-menu li a:hover {
    background: rgba(255,255,255,0.14);
    color: #fff;
}

.sidebar-nav .dropdown-menu li a.active {
    background: rgba(255,255,255,0.22);
    color: #fff;
    font-weight: 700;
}

.sidebar.collapsed .sidebar-nav .dropdown-menu li a {
    padding-left: 1rem;
    justify-content: center;
}

.sidebar-invoice-item {
    margin-top: auto;
    padding: 1rem;
}

.sidebar-nav .sidebar-invoice-link {
    border: 1px solid rgb(243, 232, 232);
    border-radius: 14px;
    gap: 0.75rem;
    padding: 0.65rem 0.75rem;
    transition: all 0.3s ease;
}

.sidebar-nav .sidebar-invoice-link:hover,
.sidebar-nav .sidebar-invoice-link:focus {
    background-color: rgba(255, 255, 255, 0.1);
}

.sidebar-invoice-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 40px;
    overflow: hidden;
}

.sidebar-invoice-icon img {
    width: 27px;
    height: 27px;
    object-fit: contain;
}

.sidebar.collapsed .sidebar-invoice-item {
    padding: 0.75rem 0.5rem;
}

.sidebar.collapsed .sidebar-nav .sidebar-invoice-link {
    justify-content: center;
    padding: 0.55rem;
}

.sidebar.collapsed .sidebar-nav a .sidebar-invoice-icon {
    display: inline-flex;
}

.main-content {
    flex: 1;
    margin-left: 250px;
    transition: margin-left 0.3s ease;
    min-height: 100vh;
    padding-bottom: 2rem;
}

.main-content.expanded {
    margin-left: 70px;
}

.site-footer {
    margin-left: 250px;
    width: calc(100% - 250px);
    transition: margin-left 0.3s ease, width 0.3s ease;
}

body.sidebar-collapsed .site-footer {
    margin-left: 70px;
    width: calc(100% - 70px);
}

.top-navbar {
    background: var(--primary);
    color: white;
    padding: 0.5rem 1rem;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-info .nav-link {
    color: white !important;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
}

.user-info .nav-link:hover {
    color: white !important;
    background-color: #29aae5;
    border-radius: 8px;
}

.logout-btn {
    background: transparent !important;
    color: #000 !important;
    border: 1px solid rgb(247, 244, 244);
    padding: 0.5rem 1rem !important;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.logout-btn:hover {
    background: rgba(0, 0, 0, 0.05) !important;
    border-color: rgba(0, 0, 0, 0.4) !important;
    color: #000 !important;
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .main-content.expanded {
        margin-left: 0;
    }

    .site-footer,
    body.sidebar-collapsed .site-footer {
        margin-left: 0;
        width: 100%;
    }

    .sidebar-toggle {
        background: none;
        color: white;
        border: none;
        padding: 0 0.5rem;
        border-radius: 4px;
        display: flex;
        align-items: center;
        justify-content: center;
        height: 100%;
    }

    .sidebar-toggle.mobile-only {
        display: flex;
        margin-right: auto;
    }

    .sidebar-header .sidebar-toggle.mobile-only {
        margin-right: 0;
        margin-left: auto;
    }

    .sidebar-toggle:not(.mobile-only) {
        display: none;
    }

    .top-navbar {
        justify-content: space-between;
        padding-left: 0;
    }
}

@media (max-width: 1100px) {
    .login-page {
        grid-template-columns: 1fr;
        padding: 1.5rem;
    }

    .login-hero,
    .login-form-panel {
        min-height: auto;
    }

    .login-hero {
        display: none;
    }

    .login-form-panel {
        padding: 1.75rem 1.5rem 2rem;
    }
}

@media (max-width: 768px) {
    .login-page {
        padding: 1.5rem;
    }

    .login-hero img {
        width: 120px;
        margin-bottom: 1.25rem;
    }

    .hero-highlights {
        display: none;
    }

    .login-form-panel {
        padding: 2rem 1.5rem;
    }
}

@media (max-width: 576px) {
    .login-page {
        padding: 1.25rem;
    }

    .login-form-panel {
        padding: 1.75rem 1.25rem;
    }

    .hero-highlights {
        grid-template-columns: 1fr;
    }
}
