:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --secondary: #64748b;
    --accent: #f43f5e;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --sidebar-bg: #0f172a;
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.2);
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--background);
    color: var(--text-main);
    overflow-x: hidden;
}

/* Auth Pages */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top left, #6366f1, transparent),
        radial-gradient(circle at bottom right, #f43f5e, transparent);
    background-color: #0f172a;
    padding: 20px;
}

.auth-card {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 40px;
    width: 100%;
    max-width: 450px;
    box-shadow: var(--shadow-lg);
    animation: fadeIn 0.8s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.brand-section {
    text-align: center;
    margin-bottom: 30px;
}

.brand-logo {
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(135deg, #6366f1, #f43f5e);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-main);
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    background: white;
    transition: all 0.3s;
    font-size: 1rem;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.btn {
    width: 100%;
    padding: 12px;
    border-radius: 12px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(99, 102, 241, 0.4);
}

/* Dashboard Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 280px;
    background: var(--sidebar-bg);
    color: white;
    padding: 24px;
    display: flex;
    flex-direction: column;
    transition: all 0.3s;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--background);
}

.navbar {
    height: 70px;
    background: white;
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
}

.content-body {
    padding: 32px;
    overflow-y: auto;
}

/* Dashboard Widgets */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.kpi-card {
    background: white;
    border-radius: 20px;
    padding: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid #f1f5f9;
    transition: all 0.3s;
}

.kpi-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
}

.kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    font-size: 1.5rem;
}

.kpi-value {
    font-size: 1.75rem;
    font-weight: 800;
    margin-bottom: 4px;
}

.kpi-label {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Charts & Tables placeholder style */
.data-card {
    background: white;
    border-radius: 20px;
    padding: 24px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
}

.section-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.status-badge {
    padding: 4px 12px;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-active {
    background: #dcfce7;
    color: #166534;
}

.status-pending {
    background: #fef9c3;
    color: #854d0e;
}

.status-danger {
    background: #fee2e2;
    color: #991b1b;
}

/* Utilities */
.hidden {
    display: none !important;
}

.text-primary {
    color: var(--primary);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: #94a3b8;
    text-decoration: none;
    border-radius: 12px;
    margin-bottom: 4px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 500;
}

.nav-link i {
    font-size: 1.25rem;
}

.nav-link:hover,
.nav-link.active {
    background: rgba(99, 102, 241, 0.1);
    color: white;
}

.nav-link.active {
    background: var(--primary) !important;
    color: white !important;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4), 0 0 10px rgba(99, 102, 241, 0.2);
}

.close-sidebar {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: none;
    /* Hidden on desktop */
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 10;
}

@media screen and (max-width: 1024px) {
    .close-sidebar {
        display: flex;
    }
}

.close-sidebar:hover {
    background: rgba(255, 255, 255, 0.2);
}

.close-sidebar i {
    font-size: 1.25rem;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    text-align: left;
    padding: 12px 0;
    color: var(--text-muted);
    font-size: 0.75rem;
    border-bottom: 1px solid #f1f5f9;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.data-table td {
    padding: 16px 8px 16px 0;
    font-size: 0.875rem;
    border-bottom: 1px solid #f8fafc;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    animation: fadeIn 0.2s ease-out;
}

.modal-card {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 20px;
    width: 90%;
    max-width: 600px;
    z-index: 1001;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    animation: modalSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}

@keyframes modalSlideUp {
    from {
        opacity: 0;
        transform: translate(-50%, -40%);
    }

    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

.modal-header {
    padding: 24px 32px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: #0f172a;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #94a3b8;
    cursor: pointer;
}

.modal-body {
    padding: 32px;
    overflow-y: auto;
    flex: 1;
}

/* =====================================================
   RESPONSIVE UTILITIES & GRID SYSTEM
   ===================================================== */

.grid {
    display: grid;
    gap: 1.5rem;
}

.grid-cols-1 {
    grid-template-columns: repeat(1, minmax(0, 1fr));
}

.grid-cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-cols-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-cols-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.flex-responsive {
    display: flex;
    flex-direction: row;
    gap: 1rem;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.w-full {
    width: 100% !important;
}

/* Responsive Grid Adapters */
@media screen and (max-width: 992px) {
    .grid-cols-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media screen and (max-width: 640px) {

    .grid-cols-4,
    .grid-cols-3,
    .grid-cols-2 {
        grid-template-columns: repeat(1, minmax(0, 1fr));
    }

    .mobile-stack-grid {
        grid-template-columns: 1fr !important;
    }

    .flex-responsive {
        flex-direction: column;
    }

    .flex-responsive.keep-row {
        flex-direction: row;
    }

    .mobile-stack {
        flex-direction: column !important;
        align-items: flex-start !important;
    }
}

/* =====================================================
   RESPONSIVE STYLES - TABLET & MOBILE
   ===================================================== */

/* Hamburger Menu Toggle */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: background 0.2s;
}

.menu-toggle:hover {
    background: #f1f5f9;
}

.menu-toggle i {
    font-size: 1.5rem;
    color: var(--text-muted);
}

/* Mobile Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 998;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease-out;
}

.sidebar-overlay.active {
    display: block;
}

/* Mobile Brand in Navbar - Hidden by default (desktop) */
.mobile-brand {
    display: none;
    flex-direction: row !important;
    align-items: center !important;
    gap: 10px;
    flex-shrink: 0;
    white-space: nowrap;
}

/* Mobile navbar left section - Horizontal alignment */
.navbar-left {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 12px;
}

/* =====================================================
   TABLET BREAKPOINT (max-width: 900px)
   ===================================================== */
@media screen and (max-width: 900px) {

    /* Sidebar - Collapsible */
    .sidebar {
        position: fixed;
        left: -300px;
        top: 0;
        bottom: 0;
        width: 280px;
        z-index: 999;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: none;
    }

    .sidebar.active {
        left: 0;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
    }

    .menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }

    /* Show mobile brand in navbar */
    .mobile-brand {
        display: flex;
    }

    /* Main Content - Full Width */
    .main-content {
        margin-left: 0;
        width: 100%;
    }

    /* Navbar adjustments */
    .navbar {
        padding: 0 20px;
    }

    /* Content Body */
    .content-body {
        padding: 24px;
    }

    /* Dashboard Grid */
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
        margin-bottom: 24px;
    }

    /* Modal adjustments */
    .modal-card {
        width: 95%;
        max-width: 650px;
    }
}

/* =====================================================
   MOBILE BREAKPOINT (max-width: 640px)
   ===================================================== */
@media screen and (max-width: 640px) {

    /* Sidebar further optimized */
    .sidebar {
        width: 260px;
        padding: 20px;
    }

    .brand-section {
        margin-bottom: 24px !important;
    }

    .nav-link {
        padding: 10px 14px;
        font-size: 0.9rem;
    }

    /* Content Body */
    .content-body {
        padding: 16px;
    }

    /* Navbar */
    .navbar {
        height: auto;
        min-height: 60px;
        padding: 12px 16px;
        flex-wrap: nowrap;
        gap: 8px;
    }

    .navbar h2 {
        font-size: 1.1rem !important;
    }

    /* KPI Cards */
    .kpi-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    .kpi-card {
        padding: 16px;
        border-radius: 16px;
    }

    .kpi-icon {
        width: 40px;
        height: 40px;
        font-size: 1.25rem;
        margin-bottom: 12px;
    }

    .kpi-value {
        font-size: 1.5rem;
    }

    .kpi-label {
        font-size: 0.75rem;
    }

    /* Data Card */
    .data-card {
        padding: 16px;
        border-radius: 16px;
        margin-bottom: 16px;
    }

    .section-title {
        font-size: 1rem;
        margin-bottom: 16px !important;
        flex-direction: column;
        align-items: flex-start !important;
        gap: 12px;
    }

    /* Tables - Horizontal Scroll */
    .data-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
    }

    .data-table th,
    .data-table td {
        padding: 12px 10px;
        font-size: 0.8rem;
    }

    /* Modal - Center & Wide */
    .modal-card {
        width: 95%;
        max-width: none;
        max-height: 90vh;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        border-radius: 16px;
    }

    .modal-header {
        padding: 16px 20px;
    }

    .modal-header h3 {
        font-size: 1.1rem;
    }

    .modal-body {
        padding: 20px;
    }

    .form-group {
        margin-bottom: 16px;
    }

    .form-control {
        padding: 10px 14px;
        font-size: 0.95rem;
    }

    /* Buttons */
    .btn {
        padding: 10px;
        font-size: 0.9rem;
    }

    /* Status badges */
    .status-badge {
        font-size: 0.7rem;
        padding: 3px 8px;
    }

    /* Summary cards */
    #consumers-summary,
    #documents-summary {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
    }

    /* Auth wrapper - Login page */
    .auth-wrapper {
        padding: 16px;
    }

    .auth-card {
        padding: 24px;
        border-radius: 16px;
    }

    .brand-logo {
        font-size: 1.5rem;
    }
}

/* =====================================================
   SMALL MOBILE BREAKPOINT (max-width: 480px)
   ===================================================== */
@media screen and (max-width: 480px) {

    /* Sidebar */
    .sidebar {
        width: 300px;
        left: -300px;
        max-width: 85%;
    }

    .sidebar.active {
        left: 0;
    }

    /* Content */
    .content-body {
        padding: 12px;
    }

    /* Navbar */
    .navbar {
        padding: 10px 12px;
    }

    .navbar h2 {
        font-size: 1rem !important;
    }

    /* User info in navbar - simplify */
    .navbar>div:last-child>div:first-child {
        display: none;
    }

    /* KPI Grid - Single Column for very small screens */
    .kpi-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .kpi-card {
        display: flex;
        align-items: center;
        gap: 16px;
        padding: 14px;
    }

    .kpi-icon {
        margin-bottom: 0;
        flex-shrink: 0;
    }

    .kpi-card>div:last-child {
        display: flex;
        flex-direction: column;
    }

    /* Data cards */
    .data-card {
        padding: 14px;
        border-radius: 12px;
    }

    .section-title {
        font-size: 0.95rem;
    }

    /* Modal - Sliding from bottom for mobile feel */
    .modal-card {
        width: 100%;
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
        top: 0;
        left: 0;
        transform: none !important;
        transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
    }

    #modal-overlay.hidden+.modal-card:not(.hidden) {
        transform: translateY(100%) !important;
    }

    .modal-header {
        padding: 14px 16px;
    }

    .modal-body {
        padding: 16px;
    }

    /* Form elements */
    .form-group label {
        font-size: 0.8rem;
    }

    .form-control {
        padding: 10px 12px;
        font-size: 0.9rem;
    }
}

/* =====================================================
   UTILITY CLASSES FOR RESPONSIVE
   ===================================================== */
.hide-mobile {
    display: block;
}

.show-mobile {
    display: none !important;
}

@media screen and (max-width: 640px) {
    .hide-mobile {
        display: none !important;
    }

    .show-mobile {
        display: block !important;
    }

    /* Custom scroll for horizontal elements */
    .scroll-x-mobile {
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 8px;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {

    .btn,
    .nav-link,
    .form-control,
    select {
        min-height: 44px;
    }

    .status-badge {
        min-height: 28px;
        display: inline-flex;
        align-items: center;
    }
}

/* Smooth transitions for responsive elements */
.sidebar,
.main-content,
.modal-card {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}