* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: #f3f4f6;
    color: #1f2937;
    font-size: 13px;
    min-height: 100vh;
}

/* ==================== LOGIN MODAL ==================== */
.login-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(8px);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    background: #ffffff;
    width: 100%;
    max-width: 400px;
    padding: 32px;
    border-radius: 16px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.login-header {
    text-align: center;
    margin-bottom: 24px;
}

.login-logo {
    max-width: 220px;
    height: auto;
    margin-bottom: 12px;
}

.title-logo {
    max-width: 160px;
    height: auto;
}

.login-header h3 {
    font-size: 18px;
    color: #dc2626;
    font-weight: 800;
}

.login-header p {
    color: #6b7280;
    font-size: 13px;
    margin-top: 4px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    color: #374151;
}

.input-icon-wrapper {
    position: relative;
}

.input-icon-wrapper i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
}

.input-icon-wrapper input {
    width: 100%;
    height: 42px;
    padding: 0 12px 0 38px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    outline: none;
    font-size: 14px;
    transition: all 0.2s;
}

.input-icon-wrapper input:focus {
    border-color: #dc2626;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15);
}

.btn-login {
    width: 100%;
    height: 44px;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
    margin-top: 8px;
}

.btn-login:hover {
    background: #b91c1c;
}

.login-error-msg {
    color: #dc2626;
    font-size: 13px;
    margin-bottom: 12px;
    display: none;
}

/* ==================== LAYOUT ARCHITECTURE ==================== */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* SIDEBAR */
.sidebar {
    width: 250px;
    background: #ffffff;
    border-right: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    padding: 20px 16px;
    flex-shrink: 0;
    transition: margin-left 0.3s ease;
}

.sidebar.collapsed {
    margin-left: -250px;
}

.brand {
    text-align: center;
    padding-bottom: 16px;
    border-bottom: 1px solid #f3f4f6;
    margin-bottom: 20px;
}

.menu-category {
    font-size: 11px;
    font-weight: 700;
    color: #9ca3af;
    margin-bottom: 8px;
    padding-left: 8px;
}

.sidebar-menu {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    color: #4b5563;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.2s;
}

.menu-item i {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.menu-item:hover, .menu-item.active {
    background: #fef2f2;
    color: #dc2626;
    font-weight: 700;
}

.sidebar-shield-box {
    margin-top: auto;
    background: #fff;
    border: 1px dashed #fca5a5;
    border-radius: 12px;
    padding: 16px;
    text-align: center;
}

.shield-icon-wrapper {
    width: 48px;
    height: 48px;
    background: #fef2f2;
    color: #dc2626;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    margin: 0 auto 8px;
}

.sidebar-shield-box h4 {
    color: #dc2626;
    font-size: 12px;
    font-weight: 800;
}

.sidebar-shield-box p {
    color: #6b7280;
    font-size: 10px;
    margin-top: 4px;
}

/* MAIN CONTENT */
.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    height: 60px;
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.btn-toggle-menu {
    background: none;
    border: none;
    font-size: 18px;
    color: #4b5563;
    cursor: pointer;
}

.page-title {
    font-size: 16px;
    font-weight: 700;
    color: #111827;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.notification-badge {
    position: relative;
    font-size: 18px;
    color: #4b5563;
    cursor: pointer;
}

.notification-badge .count {
    position: absolute;
    top: -6px;
    right: -8px;
    background: #dc2626;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-profile .avatar {
    font-size: 32px;
    color: #9ca3af;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-info .username {
    font-weight: 700;
    color: #111827;
    line-height: 1.1;
}

.user-info .user-role {
    font-size: 11px;
    color: #6b7280;
}

.content-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* STATS GRID */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.card-stat {
    background: #ffffff;
    border-radius: 12px;
    padding: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.stat-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 18px;
    flex-shrink: 0;
}

.bg-red { background: #dc2626; }
.bg-orange { background: #f97316; }
.bg-blue { background: #0284c7; }
.bg-green { background: #16a34a; }
.bg-red-bright { background: #ef4444; }
.bg-purple { background: #7c3aed; }

.stat-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.stat-label {
    font-size: 9px;
    font-weight: 700;
    color: #6b7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-value {
    font-size: 18px;
    font-weight: 800;
    color: #111827;
    line-height: 1.2;
}

.stat-sub {
    font-size: 11px;
    color: #6b7280;
}

.stat-trend {
    font-size: 10px;
    font-weight: 600;
}

.trend-up { color: #16a34a; }
.trend-down { color: #dc2626; }

/* PANELS & GRIDS */
.middle-grid, .bottom-grid {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.flex-3 { flex: 3; min-width: 300px; }
.flex-2 { flex: 2; min-width: 260px; }

.panel-box {
    background: #ffffff;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.panel-header h3 {
    font-size: 13px;
    font-weight: 800;
    color: #111827;
}

.chart-container {
    height: 200px;
    position: relative;
}

.donut-chart-wrapper {
    position: relative;
    height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.donut-center-text {
    position: absolute;
    text-align: center;
}

.donut-center-text .percent {
    font-size: 18px;
    font-weight: 800;
    color: #111827;
}

.donut-center-text .label {
    font-size: 10px;
    color: #6b7280;
}

.donut-legend {
    display: flex;
    justify-content: space-around;
    margin-top: 12px;
    font-size: 11px;
}

.dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 4px;
}

.dot.green { background: #16a34a; }
.dot.red { background: #ef4444; }

.top-api-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.top-api-list li {
    display: flex;
    align-items: center;
    padding-bottom: 8px;
    border-bottom: 1px dashed #f3f4f6;
}

.top-api-list .rank {
    font-weight: 700;
    color: #9ca3af;
    width: 24px;
}

.top-api-list .api-name {
    font-weight: 700;
    color: #374151;
    flex: 1;
}

.top-api-list .api-count {
    font-weight: 600;
    color: #111827;
}

/* TABLES & FILTERS */
.filter-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.input-sm, .select-sm {
    height: 32px;
    padding: 0 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 12px;
    outline: none;
}

.search-box {
    display: flex;
    align-items: center;
}

.search-box input {
    border-radius: 6px 0 0 6px;
}

.btn-search, .btn-export {
    height: 32px;
    padding: 0 10px;
    border: 1px solid #d1d5db;
    background: #f9fafb;
    cursor: pointer;
    border-radius: 0 6px 6px 0;
}

.btn-export {
    border-radius: 6px;
    background: #dc2626;
    color: #fff;
    border: none;
}

.table-responsive {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.data-table th, .data-table td {
    padding: 10px 8px;
    border-bottom: 1px solid #f3f4f6;
    white-space: nowrap;
}

.data-table th {
    background: #f9fafb;
    color: #6b7280;
    font-weight: 700;
    font-size: 11px;
}

.badge {
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.badge-success { background: #dcfce7; color: #15803d; }
.badge-danger { background: #fee2e2; color: #b91c1c; }

.btn-icon {
    cursor: pointer;
    margin: 0 4px;
    color: #4b5563;
}

.text-danger { color: #dc2626; }
.text-truncate { max-width: 140px; overflow: hidden; text-overflow: ellipsis; }

/* SWITCH TOGGLE */
.switch {
    position: relative;
    display: inline-block;
    width: 34px;
    height: 18px;
}

.switch input { opacity: 0; width: 0; height: 0; }

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #ccc;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 12px; width: 12px;
    left: 3px; bottom: 3px;
    background-color: white;
    transition: .4s;
}

input:checked + .slider { background-color: #16a34a; }
input:checked + .slider:before { transform: translateX(16px); }
.slider.round { border-radius: 18px; }
.slider.round:before { border-radius: 50%; }

.btn-primary-sm {
    background: #dc2626;
    color: #fff;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    font-weight: 700;
    cursor: pointer;
}

.pagination-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 12px;
    font-size: 11px;
    color: #6b7280;
    flex-wrap: wrap;
    gap: 8px;
}

.pagination {
    display: flex;
    gap: 4px;
}

.pagination button {
    padding: 4px 8px;
    border: 1px solid #d1d5db;
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
}

.pagination button.active {
    background: #dc2626;
    color: #fff;
    border-color: #dc2626;
}

.footer {
    padding: 16px;
    text-align: center;
    color: #9ca3af;
    font-size: 11px;
    border-top: 1px solid #e5e7eb;
    margin-top: auto;
}