* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #06b6d4;
    --dark: #1e293b;
    --darker: #0f172a;
    --light: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --sidebar-width: 260px;
    --touch-target: 44px;
    --touch-target-tv: 56px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
}
html {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--gray-100);
    color: var(--dark);
    line-height: 1.6;
    font-size: 14px;
    width: 100%;
    max-width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    overscroll-behavior-x: none;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
img, svg, video, canvas, iframe {
    max-width: 100%;
}
input, select, textarea, button {
    font: inherit;
}
a,
button,
.btn,
.mobile-toggle,
.user-dropdown,
.sidebar-menu a,
.modal-close,
.pagination .nav-link {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
a:focus-visible,
button:focus-visible,
.btn:focus-visible,
.form-control:focus-visible,
.user-dropdown:focus-visible,
.sidebar-menu a:focus-visible,
.mobile-toggle:focus-visible,
.modal-close:focus-visible {
    outline: 2px solid rgba(59, 130, 246, 0.9);
    outline-offset: 2px;
}

.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #1e3a8a 0%, #0f172a 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.login-box {
    background: #fff;
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
}
.login-logo {
    text-align: center;
    margin-bottom: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}
.login-logo p { color: var(--gray-500); font-size: 14px; }

.form-group { margin-bottom: 18px; }
.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: var(--gray-700);
    font-size: 13px;
}
.form-control {
    width: 100%;
    min-height: var(--touch-target);
    padding: 12px 14px;
    border: 1.5px solid var(--gray-300);
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s;
    background: #fff;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}
textarea.form-control { resize: vertical; min-height: 80px; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: var(--touch-target);
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}
.btn-primary { background: var(--primary); color: #fff; width: 100%; padding: 12px; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-info { background: var(--info); color: #fff; }
.btn-info:hover { background: #0891b2; color: #fff; }
.btn-secondary { background: var(--gray-500); color: #fff; }
.btn-secondary:hover { background: var(--gray-600); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-outline {
    background: transparent;
    border: 1.5px solid var(--gray-300);
    color: var(--gray-600);
}
.btn-outline:hover {
    background: var(--gray-100);
    border-color: var(--gray-400);
}

.app-layout {
    display: flex;
    min-height: 100vh;
    width: 100%;
    max-width: 100%;
    overflow-x: clip;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--darker);
    color: #fff;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
    transition: all 0.3s;
    z-index: 220;
    flex-shrink: 0;
    padding-bottom: max(16px, var(--safe-bottom));
}
.sidebar-brand {
    padding: 24px 20px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}
.sidebar-brand h2 { font-size: 20px; color: #fff; }
.logo-icon {
    width: 56px; height: 56px;
    background: radial-gradient(circle at top, #60a5fa, var(--primary) 55%, #4338ca 100%);
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 18px;
    letter-spacing: 0.08em;
    box-shadow: 0 12px 30px rgba(37, 99, 235, 0.35);
    border: 1px solid rgba(255,255,255,0.22);
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
    text-transform: uppercase;
}
.logo-icon img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
    padding: 8px;
}
.logo-icon.has-image {
    background: radial-gradient(circle at top, rgba(96, 165, 250, 0.92), rgba(59, 130, 246, 0.82) 55%, rgba(67, 56, 202, 0.92) 100%);
}
.login-logo .logo-icon {
    width: 112px;
    height: 112px;
    font-size: 34px;
    box-shadow: 0 22px 46px rgba(37, 99, 235, 0.34);
}
.login-logo .logo-icon img {
    padding: 14px;
}
.sidebar-menu { list-style: none; padding: 15px 10px; }
.sidebar-menu li { margin-bottom: 6px; }
.sidebar-menu a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    color: #cbd5e1;
    border-radius: 14px;
    transition: all 0.18s ease;
    font-size: 14px;
    font-weight: 500;
    border: 1px solid transparent;
    background: rgba(255,255,255,0.02);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
}
.sidebar-menu a:hover {
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.08);
    color: #fff;
    transform: translateX(3px);
}
.sidebar-menu a.active {
    background: linear-gradient(135deg, var(--primary), #6366f1);
    color: #fff;
    border-color: rgba(255,255,255,0.14);
    box-shadow: 0 10px 24px rgba(59,130,246,0.28);
}
.sidebar-menu .menu-icon {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 16px;
    border-radius: 10px;
    background: rgba(255,255,255,0.08);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
}
.sidebar-menu a:hover .menu-icon,
.sidebar-menu a.active .menu-icon {
    background: rgba(255,255,255,0.16);
}
.sidebar-divider {
    height: 1px;
    background: rgba(255,255,255,0.08);
    margin: 18px 10px 14px;
}

.main-content {
    margin-left: var(--sidebar-width);
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-width: 0;
    width: calc(100% - var(--sidebar-width));
    max-width: calc(100% - var(--sidebar-width));
}
.topbar {
    background: #fff;
    border-bottom: 1px solid var(--gray-200);
    padding: calc(14px + var(--safe-top)) calc(28px + var(--safe-right)) 14px calc(28px + var(--safe-left));
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 170;
    min-width: 0;
    max-width: 100%;
}
.topbar-left {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}
.expiry-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    border-radius: 999px;
    border: 1px solid #bfdbfe;
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    color: #1d4ed8;
    box-shadow: 0 6px 18px rgba(59, 130, 246, 0.12);
}
.expiry-chip__icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.7);
    color: currentColor;
    flex-shrink: 0;
}
.expiry-chip__icon svg {
    width: 15px;
    height: 15px;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.expiry-chip__label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #475569;
}
.expiry-chip__value {
    font-size: 13px;
    font-weight: 700;
    color: currentColor;
}
.expiry-chip--unlimited {
    border-color: #a7f3d0;
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
    color: #059669;
    box-shadow: 0 6px 18px rgba(16, 185, 129, 0.14);
}
.expiry-chip--dated {
    border-color: #bfdbfe;
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    color: #1d4ed8;
}
.expiry-chip--empty {
    border-color: #e2e8f0;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    color: #64748b;
    box-shadow: none;
}
.expiry-chip--credit {
    border-color: #c4b5fd;
    background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%);
    color: #6d28d9;
    box-shadow: 0 6px 18px rgba(109, 40, 217, 0.16);
}
.expiry-chip--warning {
    border-color: #fcd34d;
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    color: #b45309;
    box-shadow: 0 6px 18px rgba(245, 158, 11, 0.18);
}
.topbar-right {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}
.user-dropdown {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: var(--touch-target);
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    text-decoration: none;
    color: inherit;
    min-width: 0;
    max-width: 100%;
}
.user-dropdown:hover { background: var(--gray-100); }
.user-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 600;
    font-size: 14px;
}
.mobile-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: var(--touch-target);
    height: var(--touch-target);
    min-width: var(--touch-target);
    min-height: var(--touch-target);
    border-radius: 12px;
    background: #fff;
    border: 1px solid var(--gray-200);
    font-size: 22px;
    cursor: pointer;
    color: var(--dark);
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
}

.user-dropdown > div:last-child,
.user-dropdown > div:last-child > div,
.expiry-chip,
.expiry-chip__value {
    min-width: 0;
}
.user-dropdown > div:last-child > div,
.expiry-chip__value {
    overflow-wrap: anywhere;
}

.page-content {
    padding: 28px max(28px, calc(20px + var(--safe-right))) max(28px, calc(20px + var(--safe-bottom))) max(28px, calc(20px + var(--safe-left)));
    flex: 1;
    min-width: 0;
    max-width: 100%;
}
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 14px;
    min-width: 0;
    max-width: 100%;
}
.page-title h1 { font-size: 22px; margin-bottom: 4px; }
.page-title p { color: var(--gray-500); font-size: 13px; }

.card {
    background: #fff;
    border-radius: 12px;
    padding: 22px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    border: 1px solid var(--gray-200);
    margin-bottom: 22px;
    min-width: 0;
    max-width: 100%;
}
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
    flex-wrap: wrap;
    gap: 10px;
    min-width: 0;
}
.card-header h3 { font-size: 16px; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
    margin-bottom: 28px;
}
.stat-card {
    background: #fff;
    border-radius: 12px;
    padding: 22px;
    border: 1px solid var(--gray-200);
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 4px; height: 100%;
}
.stat-card.stat-primary::before { background: var(--primary); }
.stat-card.stat-success::before { background: var(--success); }
.stat-card.stat-warning::before { background: var(--warning); }
.stat-card.stat-danger::before { background: var(--danger); }
.stat-card.stat-info::before { background: var(--info); }
.stat-label { color: var(--gray-500); font-size: 13px; margin-bottom: 6px; }
.stat-value { font-size: 30px; font-weight: 700; color: var(--dark); }
.stat-foot { margin-top: 8px; font-size: 12px; }
.stat-foot.positive { color: var(--success); }
.stat-foot.negative { color: var(--danger); }

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}
.badge-success { background: #d1fae5; color: #065f46; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info { background: #cffafe; color: #155e75; }
.badge-secondary { background: var(--gray-200); color: var(--gray-600); }
.badge-admin { background: #ede9fe; color: #5b21b6; }
.badge-reseller { background: #dbeafe; color: #1e40af; }
.badge-client { background: #d1fae5; color: #065f46; }

.table-wrapper {
    overflow-x: auto;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}
table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    min-width: max-content;
}
table.data-table th,
table.data-table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}
table.data-table th {
    background: var(--gray-100);
    font-weight: 600;
    color: var(--gray-600);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
table.data-table tbody tr:hover { background: var(--gray-50); }
.table-actions { display: flex; gap: 6px; }

.filters-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 18px;
    padding: 14px;
    background: var(--gray-50);
    border-radius: 10px;
    min-width: 0;
    max-width: 100%;
}
.filters-bar .form-group { margin-bottom: 0; flex: 1; min-width: 160px; }
.filters-bar .btn { margin-top: 26px; }

.alert {
    padding: 14px 18px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
    border: 1px solid transparent;
}
.alert-success { background: #d1fae5; color: #065f46; border-color: #a7f3d0; }
.alert-danger { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.alert-warning { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.alert-info { background: #cffafe; color: #155e75; border-color: #a5f3fc; }

body.page-is-loading {
    cursor: progress;
}

.page-loader {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(15, 23, 42, 0.34);
    backdrop-filter: blur(6px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.28s ease, visibility 0.28s ease;
    z-index: 1400;
}

.page-loader.is-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.page-loader__card {
    min-width: min(280px, 100%);
    padding: 24px 26px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(226, 232, 240, 0.9);
    box-shadow: 0 28px 60px rgba(15, 23, 42, 0.22);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    text-align: center;
    transform: translateY(12px) scale(0.98);
    transition: transform 0.28s ease;
}

.page-loader.is-visible .page-loader__card {
    transform: translateY(0) scale(1);
}

.page-loader__spinner {
    position: relative;
    width: 56px;
    height: 56px;
}

.page-loader__spinner::before,
.page-loader__spinner::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
}

.page-loader__spinner::before {
    border: 4px solid rgba(59, 130, 246, 0.14);
}

.page-loader__spinner::after {
    border: 4px solid transparent;
    border-top-color: var(--primary);
    border-right-color: #8b5cf6;
    animation: pageLoaderSpin 0.85s linear infinite;
}

.page-loader__dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    box-shadow: 0 0 0 10px rgba(59, 130, 246, 0.08);
    animation: pageLoaderPulse 1.25s ease-in-out infinite;
}

.page-loader__title {
    font-size: 16px;
    font-weight: 700;
    color: var(--dark);
}

.page-loader__text {
    font-size: 13px;
    color: var(--gray-500);
}

@keyframes pageLoaderSpin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes pageLoaderPulse {
    0%, 100% {
        transform: scale(0.9);
        opacity: 0.85;
    }
    50% {
        transform: scale(1.12);
        opacity: 1;
    }
}

.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
    background: #fff;
    border-radius: 16px;
    border: 1px solid var(--gray-200);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 50px rgba(15, 23, 42, 0.18);
}
.modal-header {
    padding: 18px 22px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    background: #fff;
}
.modal-header h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--dark);
}
.modal-body {
    padding: 22px;
    overflow-y: auto;
}
.modal-footer {
    padding: 16px 22px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background: #fff;
}
.modal-close {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: transparent;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    color: var(--gray-500);
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}
.modal-close:hover {
    color: var(--dark);
    background: var(--gray-100);
    border-color: var(--gray-200);
}

.credentials-stack .form-group:last-child {
    margin-bottom: 0;
}

.credential-input {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 13px;
    background: #f8fafc;
    color: var(--dark);
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px;
}

.tabs {
    display: flex;
    gap: 2px;
    border-bottom: 2px solid var(--gray-200);
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.tab-item {
    padding: 10px 18px;
    cursor: pointer;
    font-weight: 500;
    color: var(--gray-500);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.15s;
}
.tab-item.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}
.tab-item:hover { color: var(--dark); }
.tab-content { display: none; }
.tab-content.active { display: block; }

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 220px;
    overflow-y: auto;
    padding: 12px;
    background: var(--gray-50);
    border-radius: 8px;
    border: 1px solid var(--gray-200);
}
.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 400;
    padding: 4px 0;
}
.checkbox-group input[type="checkbox"] {
    width: 16px; height: 16px;
    accent-color: var(--primary);
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray-500);
}
.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.6;
}

.pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 22px;
    flex-wrap: wrap;
    align-items: center;
}
.pagination a, .pagination span {
    min-width: 40px;
    height: 40px;
    padding: 7px 12px;
    border-radius: 10px;
    background: #fff;
    border: 1px solid var(--gray-200);
    color: var(--gray-600);
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.pagination a:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination .current { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination .nav-link {
    min-width: auto;
    padding: 7px 14px;
}
.pagination .disabled {
    color: var(--gray-400);
    background: var(--gray-100);
    border-color: var(--gray-200);
    cursor: not-allowed;
    box-shadow: none;
}
.pagination .ellipsis {
    min-width: 28px;
    padding: 0;
    border: none;
    background: transparent;
    box-shadow: none;
}

.expired-warning {
    background: #fef2f2;
    color: #b91c1c;
}

@media (max-width: 992px) {
    .app-layout {
        display: block;
    }
    .sidebar {
        width: min(82vw, 320px);
        max-width: 320px;
        transform: translateX(-100%);
        box-shadow: 18px 0 40px rgba(15, 23, 42, 0.28);
        z-index: 220;
    }
    .sidebar.open { transform: translateX(0); }
    .main-content {
        margin-left: 0;
        min-width: 0;
        width: 100%;
        max-width: 100%;
    }
    .mobile-toggle { display: inline-flex; align-items: center; justify-content: center; }
    .topbar {
        padding: calc(12px + var(--safe-top)) calc(16px + var(--safe-right)) 12px calc(16px + var(--safe-left));
        gap: 12px;
        flex-wrap: wrap;
    }
    .topbar-left,
    .topbar-right {
        min-width: 0;
    }
    .topbar-left {
        gap: 10px;
        flex: 1 1 100%;
        justify-content: space-between;
    }
    .topbar-right {
        flex: 1 1 100%;
        justify-content: flex-end;
    }
    .expiry-chip {
        padding: 6px 10px;
        gap: 6px;
        max-width: 100%;
    }
    .expiry-chip__icon { width: 24px; height: 24px; }
    .expiry-chip__label { font-size: 9px; }
    .expiry-chip__value { font-size: 12px; }
    .user-dropdown {
        max-width: 100%;
        padding: 6px 10px;
    }
    .page-content { padding: 18px max(16px, calc(14px + var(--safe-right))) max(18px, calc(16px + var(--safe-bottom))) max(16px, calc(14px + var(--safe-left))); }
    .page-header,
    .card-header,
    .modal-header,
    .modal-footer {
        gap: 10px;
        flex-wrap: wrap;
    }
    .filters-bar .form-group {
        min-width: min(220px, 100%);
    }
    .filters-bar .btn,
    .table-actions .btn {
        width: auto;
    }
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    table.data-table {
        min-width: 760px;
    }
}
@media (max-width: 768px) {
    body {
        font-size: 13px;
    }
    .form-control,
    select.form-control,
    textarea.form-control {
        font-size: 16px;
    }
    .page-content {
        padding: 14px;
    }
    .page-title h1 {
        font-size: 20px;
        line-height: 1.2;
    }
    .card,
    .stat-card,
    .modal-body,
    .modal-header,
    .modal-footer {
        padding: 16px;
    }
    .grid-2,
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .filters-bar {
        padding: 12px;
    }
    .filters-bar .form-group,
    .filters-bar .btn,
    .btn,
    .btn-sm,
    .btn-outline,
    .btn-success,
    .btn-danger,
    .btn-warning,
    .btn-info,
    .btn-secondary {
        width: 100%;
    }
    .table-actions {
        flex-wrap: wrap;
    }
    .pagination {
        justify-content: flex-start;
    }
    .pagination .nav-link {
        width: auto;
    }
    .modal {
        max-width: 100%;
        border-radius: 14px;
    }
}
@media (max-width: 576px) {
    .login-box { padding: 26px 20px; }
    .card, .stat-card { padding: 14px; }
    .filters-bar { padding: 10px; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .topbar {
        padding: calc(10px + var(--safe-top)) calc(12px + var(--safe-right)) 10px calc(12px + var(--safe-left));
    }
    .topbar-left {
        align-items: flex-start;
        flex-direction: column;
    }
    .topbar-right {
        justify-content: stretch;
    }
    .user-dropdown {
        width: 100%;
        justify-content: flex-start;
    }
    .expiry-chip {
        width: 100%;
        border-radius: 14px;
        justify-content: flex-start;
        flex-wrap: wrap;
    }
    .sidebar-menu {
        padding: 12px 8px 24px;
    }
    .sidebar-menu a {
        padding: 11px 12px;
        border-radius: 12px;
    }
    .page-loader__card {
        padding: 20px 18px;
    }
    .modal-overlay {
        padding: 12px;
    }
    .modal-close {
        width: 38px;
        height: 38px;
        border-radius: 12px;
    }
    .credential-input {
        font-size: 12px;
    }
    table.data-table {
        min-width: 680px;
    }
}


body.sidebar-open {
    overflow: hidden;
}
body.sidebar-open::after {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.48);
    backdrop-filter: blur(2px);
    z-index: 180;
}

@media (max-height: 620px) and (orientation: landscape) {
    .topbar {
        position: relative;
    }
    .page-content {
        padding-top: 16px;
    }
    .sidebar-brand {
        padding: 16px 18px 14px;
    }
    .sidebar-menu a {
        min-height: 42px;
        padding-top: 10px;
        padding-bottom: 10px;
    }
}

@media (hover: none) and (pointer: coarse) and (min-width: 960px) {
    body {
        font-size: 16px;
    }
    .topbar,
    .page-content,
    .card,
    .stat-card,
    .filters-bar,
    .modal-body,
    .modal-header,
    .modal-footer {
        font-size: 15px;
    }
    .page-title h1 {
        font-size: 28px;
    }
    .sidebar {
        width: 320px;
    }
    .main-content {
        margin-left: 320px;
        width: calc(100% - 320px);
        max-width: calc(100% - 320px);
    }
    .sidebar-menu a,
    .btn,
    .form-control,
    .user-dropdown,
    .mobile-toggle,
    .modal-close {
        min-height: var(--touch-target-tv);
    }
    .sidebar-menu a {
        font-size: 16px;
        padding: 14px 16px;
    }
    .sidebar-menu .menu-icon {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
    .btn,
    .form-control {
        font-size: 16px;
    }
    table.data-table th,
    table.data-table td {
        padding: 15px 16px;
    }
}
