:root {
    --bg-color: #f4f6f8;
    --card-bg: #ffffff;
    --border-color: #e5e7eb;
    --primary-color: #8bc34a; /* Light Green */
    --primary-hover: #7cb342;
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --alert-color: #ef4444;
    --warning-color: #f59e0b;
    --success-color: #10b981;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* TOP NAVBAR */
.top-navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--card-bg);
    padding: 0 2rem;
    height: 70px;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    z-index: 900;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: var(--primary-color);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
}

.logo h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
}

.logo span {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-left: 0.25rem;
}

.hamburger-btn {
    display: none;
    cursor: pointer;
    color: var(--text-main);
    align-items: center;
    justify-content: center;
}

.nav-links {
    display: flex;
    list-style: none;
    height: 100%;
}

.nav-links li {
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-muted);
    border-bottom: 3px solid transparent;
    transition: all 0.2s ease;
}

.nav-links li:hover {
    color: var(--primary-color);
}

.nav-links li.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

/* Submenu Styles */
.nav-links li.has-submenu {
    position: relative;
}

.nav-links li.has-submenu > .menu-title {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.nav-links li.has-submenu .chevron {
    margin-left: 6px;
    transition: transform 0.2s ease;
}

.nav-links li.has-submenu.open .chevron {
    transform: rotate(180deg);
}

.nav-links .submenu {
    position: absolute;
    top: 100%;
    left: 0;
    list-style: none;
    margin: 0;
    padding: 8px 0;
    display: none;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    min-width: 220px;
    z-index: 100;
}

.nav-links li.has-submenu.open .submenu {
    display: block;
}

.nav-links .submenu li {
    padding: 8px 16px;
    margin: 0;
    border: none;
    border-radius: 0;
    color: var(--text-main);
    display: flex;
    align-items: center;
    white-space: nowrap;
}

.nav-links .submenu li:hover {
    background: #f3f4f6;
    color: var(--primary-color);
}
.nav-links .submenu li.active {
    background: rgba(37, 99, 235, 0.05);
    color: var(--primary-color);
    border-left: 3px solid var(--primary-color);
}

.user-profile {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #ccc;
    overflow: hidden;
    position: relative;
}

.user-profile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-menu-container {
    position: relative;
}

.user-profile {
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.2s;
}

.user-menu-container:hover .user-profile {
    border-color: var(--primary-color);
}

.user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 10px;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    min-width: 180px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 100;
}

.user-menu-container:hover .user-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.profile-modal-avatar-container:hover .avatar-overlay {
    opacity: 1;
}

.user-dropdown ul {
    list-style: none;
    padding: 0.5rem 0;
    margin: 0;
}

.user-dropdown li {
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
    color: var(--text-main);
    cursor: pointer;
    display: flex;
    align-items: center;
    white-space: nowrap;
}

.user-dropdown li:hover {
    background: var(--bg-color);
}

.dropdown-divider {
    height: 1px;
    background-color: var(--border-color);
    margin: 0.25rem 0;
    padding: 0 !important;
    cursor: default !important;
}

.user-dropdown li.text-danger {
    color: var(--alert-color);
}

/* MAIN CONTENT */
.content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    flex: 1;
    width: 100%;
}

.view-section {
    display: none;
    animation: fadeIn 0.3s ease forwards;
}

.view-section.active {
    display: block;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.page-header p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.filter-actions {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

/* BUTTONS */
.btn {
    padding: 0.6rem 1.25rem;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.btn.primary {
    background: var(--primary-color);
    color: white;
}

.btn.primary:hover {
    background: var(--primary-hover);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn.secondary {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

.btn.secondary:hover {
    background: #f9fafb;
}

.pagination-container {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 0;
    margin-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.pagination-btn {
    padding: 0.4rem 0.8rem;
    border: 1px solid var(--border-color);
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    color: var(--text-color);
    transition: all 0.2s;
}

.pagination-btn:hover:not(:disabled) {
    background: var(--bg-color);
    border-color: #cbd5e1;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.spin-animation {
    animation: spin 1s linear infinite;
}

.pagination-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn.danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--alert-color);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn.danger:hover {
    background: rgba(239, 68, 68, 0.2);
}

/* DROPDOWN COMPONENT */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    background-color: var(--card-bg);
    min-width: 140px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.1);
    z-index: 1000;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.dropdown-content a {
    color: var(--text-main);
    padding: 10px 16px;
    text-decoration: none;
    display: block;
    font-size: 0.85rem;
    transition: background 0.2s ease;
}

.dropdown-content a:hover {
    background-color: var(--bg-color);
}

.dropdown:hover .dropdown-content {
    display: block;
}

/* STATS GRID */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.stat-card-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: rgba(139, 195, 74, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
}

.stat-card.alert .stat-icon {
    background: rgba(239, 68, 68, 0.1);
    color: var(--alert-color);
}

.stat-title {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.stat-trend {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.stat-trend span {
    font-weight: 600;
}

.stat-trend span.up { color: var(--success-color); }
.stat-trend span.down { color: var(--alert-color); }

/* CHARTS GRID */
.charts-grid-top {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.chart-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    min-width: 0; /* Prevents grid blowout from Chart.js canvas */
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.chart-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.live-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary-color);
    padding: 4px 12px;
    border: 1px solid rgba(139, 195, 74, 0.4);
    border-radius: 20px;
    background: rgba(139, 195, 74, 0.1);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 0 8px rgba(139, 195, 74, 0.15);
}

.pulse {
    width: 8px;
    height: 8px;
    background-color: var(--primary-color);
    border-radius: 50%;
    animation: blink 1.2s infinite ease-in-out;
    box-shadow: 0 0 6px var(--primary-color);
}

@keyframes blink {
    0% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.85); }
    100% { opacity: 1; transform: scale(1); }
}

/* Map Toast Notification System */
.map-toast-container {
    position: absolute;
    bottom: 10px;
    left: 10px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 8px;
    pointer-events: none;
    z-index: 10;
    max-height: 90%;
    overflow: hidden;
}

.map-toast {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(4px);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--text-muted);
    font-size: 0.75rem;
    color: var(--text-main);
    animation: slideInLeft 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.map-toast.toast-attack {
    border-left-color: var(--alert-color);
}

.map-toast.toast-clean {
    border-left-color: var(--primary-color);
}

.map-toast.fade-out {
    opacity: 0;
    transform: translateY(10px) scale(0.95);
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

/* TABLE CARD */
.table-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    margin-bottom: 3rem;
    min-width: 0;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.table-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.85rem;
    white-space: nowrap;
}

td {
    font-size: 0.85rem;
    color: var(--text-main);
}

.severity-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    font-weight: 500;
}

.severity-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.severity-High .severity-dot { background: var(--alert-color); }
.severity-Medium .severity-dot { background: var(--warning-color); }
.severity-Low .severity-dot { background: var(--success-color); }

.badge {
    display: inline-block;
    padding: 0.35em 0.65em;
    font-size: 0.75em;
    font-weight: 600;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: 0.375rem;
}
.badge-critical { background-color: #fee2e2; color: #991b1b; border: 1px solid #f87171; }
.badge-error { background-color: #ffedd5; color: #9a3412; border: 1px solid #fdba74; }
.badge-warning { background-color: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.badge-notice { background-color: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }
.badge-unknown { background-color: #f3f4f6; color: #4b5563; border: 1px solid #d1d5db; }

/* Redesigned Alert Detail Modal */
.alert-detail-card {
    max-width: 800px !important;
    width: 95%;
    border-radius: 12px;
    overflow: hidden;
    padding: 0 !important;
    border: none;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.alert-detail-card .modal-header {
    background: #f9fafb;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-icon {
    width: 48px;
    height: 48px;
    background: #fee2e2;
    color: #ef4444;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-icon i, .header-icon svg {
    width: 26px;
    height: 26px;
}

.header-title-group h2 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
}

.badge-type {
    font-size: 0.75rem;
    background: #fff1f2;
    color: #e11d48;
    padding: 2px 8px;
    border-radius: 9999px;
    font-weight: 600;
    border: 1px solid #ffe4e6;
    display: inline-block;
    margin-top: 0.2rem;
}

.close-modal {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-modal i {
    width: 20px;
    height: 20px;
}

.close-modal:hover {
    background: #f3f4f6;
    color: var(--text-main);
}

.alert-detail-card .modal-body {
    padding: 1.5rem;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #f3f4f6;
}

.detail-label {
    font-size: 0.75rem;
    letter-spacing: 0.025em;
    color: var(--text-muted);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.detail-label i, .detail-label svg {
    width: 14px;
    height: 14px;
    color: #5fab2b;
}

.detail-value {
    font-size: 0.95rem;
    color: var(--text-main);
    font-weight: 500;
    word-break: break-all;
}

.matched-data-section {
    background: #f7f9f5;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
    padding: 0.5rem;
}

.matched-data-header {
    background: transparent;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    font-weight: 600;
    color: #475569;
}

.matched-data-header span {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.matched-data-header span i, .matched-data-header span svg {
    width: 16px;
    height: 16px;
}

.btn-copy {
    background: white;
    border: 1px solid #cbd5e1;
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    transition: all 0.2s;
    color: #475569;
}

.btn-copy i, .btn-copy svg {
    width: 14px;
    height: 14px;
}

.btn-copy:hover {
    background: #f8fafc;
    border-color: #94a3b8;
    color: #0f172a;
}

.matched-data-box {
    background: #f6f7f9;
    padding: 1rem;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.85rem;
    color: #1e293b;
    white-space: pre-wrap;
    max-height: 200px;
    overflow-y: auto;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
}

.alert-detail-card .modal-footer {
    padding: 0 1.5rem 1.5rem;
}

.btn.success.full-width {
    width: 100%;
    padding: 0.75rem;
    font-weight: 600;
    font-size: 1rem;
    border-radius: 8px;
    justify-content: center;
    background-color: #5fab2b !important;
    color: #ffffff !important;
}

.btn.success.full-width:hover {
    background-color: #4a8a20 !important;
}

/* FOOTER */
.footer {
    background: #111827;
    color: #9ca3af;
    padding: 2rem 3rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
}

.footer-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: white;
    font-weight: 600;
}

.footer-links {
    display: flex;
    gap: 2rem;
}

.footer-links a {
    color: #9ca3af;
    text-decoration: none;
}

.footer-links a:hover {
    color: white;
}

/* SITES CONFIG OVERRIDES */
.sites-header {
    display: grid;
    grid-template-columns: 1.5fr 1fr 1.5fr 1fr 1fr 1fr 1fr;
    gap: 1rem;
    padding: 0 1.5rem 0.75rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

.sites-grid {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    width: 100%;
}

.site-card {
    background: #FFFFFF;
    border: 1px solid #E5E7EB;
    border-radius: 12px;
    padding: 1.25rem 1.5rem 0.5rem 1.5rem;
    display: grid;
    grid-template-columns: 1.5fr 1fr 1.5fr 1fr 1fr 1fr 1fr;
    align-items: center;
    gap: 1rem;
    width: 100%;
    box-sizing: border-box;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    transition: all 0.2s ease;
}

.site-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    border-color: #D1D5DB;
}

.site-card-footer-item {
    display: flex;
    align-items: center;
    gap: 4px;
}
.site-card-footer-item .toggle-switch {
    width: 36px;
    height: 20px;
    flex-shrink: 0;
}
.site-card-footer-item .toggle-slider:before {
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
}
.site-card-footer-item .toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(16px);
}
.footer-label {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}
.footer-label b {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-main);
}
.footer-label small {
    font-size: 0.62rem;
    color: var(--text-muted);
}
.status-led {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 6px currentColor;
    animation: led-pulse 2s infinite;
}
@keyframes led-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}
.site-card-footer-item .toggle-switch {
    width: 36px;
    height: 20px;
}
.site-card-footer-item .toggle-slider:before {
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
}
.site-card-footer-item .toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(16px);
}

/* Col 1: Domain */
.col-domain {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.col-domain .domain-icon {
    width: 48px;
    height: 48px;
    background: #ECFDF5;
    color: #10B981;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.col-domain .domain-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.col-domain .domain-name {
    font-size: 0.9rem;
    font-weight: 700;
    color: #111827;
    margin: 0;
    line-height: 1.2;
}


/* Col 2: Mode */
.col-mode .mode-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}
.mode-badge.proxy {
    background: #ECFDF5;
    color: #059669;
}
.mode-badge.static {
    background: #EFF6FF;
    color: #2563EB;
}
.mode-badge.php {
    background: #F5F3FF;
    color: #8B5CF6;
}
.mode-badge.redirect {
    background: #FEF3C7;
    color: #D97706;
}

/* Col 3: Forward */
.col-forward {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.col-forward .upstream-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: #374151;
    font-family: monospace;
}
.col-forward .upstream-dot {
    width: 8px;
    height: 8px;
    background: #10B981;
    border-radius: 50%;
}
.col-forward .add-upstream-btn {
    background: white;
    border: 1px dashed #D1D5DB;
    color: #6B7280;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    cursor: pointer;
    width: max-content;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Col 4: SSL */
.col-ssl {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.ssl-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    font-weight: 600;
}
.ssl-status.active { color: #059669; }
.ssl-status.inactive { color: #6B7280; }
.ssl-expire { font-size: 0.75rem; color: #9CA3AF; }

/* Col 5 & 6: Metrics */
.col-metric {
    display: flex;
    flex-direction: column;
}
.metric-value {
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1.2;
}
.metric-value.black { color: #111827; }
.metric-value.red { color: #DC2626; }
.metric-label {
    font-size: 0.75rem;
    color: #6B7280;
    margin-top: 4px;
    margin-bottom: 0;
}
.metric-sparkline {
    width: 80px;
    height: 20px;
}

/* Col 7: Status */
.col-status {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}
.status-label {
    font-size: 0.75rem;
    font-weight: 600;
}
.status-label.enabled { color: #059669; }
.status-label.disabled { color: #9CA3AF; }

/* Col 8: Actions */
.col-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
}
.btn-outline {
    background: #EFF6FF;
    border: 1px solid #BFDBFE;
    color: #2563EB;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s;
}
.btn-outline:hover { background: #DBEAFE; border-color: #93C5FD; }
.btn-icon {
    background: #FEF2F2;
    border: 1px solid #FECACA;
    color: #DC2626;
    padding: 6px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.btn-icon:hover { background: #FEE2E2; border-color: #FCA5A5; color: #B91C1C; }

@media (max-width: 1200px) {
    .sites-header {
        display: none;
    }
    .site-card {
        grid-template-columns: 1fr 1fr;
        gap: 1.5rem;
    }
}

@media (max-width: 768px) {
    .site-card {
        grid-template-columns: 1fr;
        gap: 1.25rem;
        padding: 1.25rem;
        text-align: center;
    }
    .col-domain, .col-actions {
        justify-content: center;
    }
    .col-mode {
        display: flex;
        justify-content: center;
    }
    .col-forward {
        display: flex;
        flex-direction: column;
        align-items: center;
    }
    .upstream-item {
        justify-content: center;
    }
    .col-ssl {
        display: flex;
        flex-direction: column;
        align-items: center;
    }
    .col-metric {
        align-items: center;
    }
    .col-status {
        justify-content: center;
    }
}


/* MODAL */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--card-bg);
    width: 100%;
    max-width: 750px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 2rem;
    border-radius: 16px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    animation: slideUp 0.3s ease forwards;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
}

.modal-header h2 {
    margin-bottom: 0.25rem;
    color: var(--text-main);
}

.modal-header p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem;
}

.modal-close:hover {
    color: var(--text-main);
}

.form-section-card {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    background: #fff;
}

.form-section-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--text-main);
}

.form-section-header svg {
    color: var(--success-color);
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.grid-3-col {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1.5rem;
}

.grid-4-col {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: 1rem;
}

.flex-responsive {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.flex-responsive-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.form-grid-full {
    grid-column: 1 / -1;
}

.ddos-inner-box {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 8px;
    padding: 1.5rem;
    margin-top: 1.5rem;
}

/* Custom iOS Style Toggle */
.toggle-wrapper {
    display: flex;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: #65a30d;
}

.toggle-switch input:disabled + .toggle-slider {
    opacity: 0.5;
    cursor: not-allowed;
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(20px);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-row {
    display: flex;
    gap: 1rem;
}

.form-row .form-group {
    flex: 1;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
}

input, select {
    width: 100%;
    padding: 0.75rem 1rem;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-main);
    font-size: 1rem;
}

input[type="checkbox"] {
    width: auto;
    padding: 0;
    margin: 0;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(139, 195, 74, 0.2);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 2rem;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* =========================================
   LOGIN PAGE STYLES
   ========================================= */

.login-body {
    background: #fff;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.login-container {
    display: flex;
    flex: 1;
    min-height: calc(100vh - 80px); /* Minus footer */
}

/* LEFT SIDE */
.login-left {
    flex: 1;
    background: linear-gradient(180deg, #f8fcf3 0%, #ffffff 100%);
    position: relative;
    padding: 3rem;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.login-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 5rem;
    position: relative;
    z-index: 10;
}

.login-logo .logo-text {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
}

.login-logo .logo-text span {
    color: var(--primary-color);
}

.hero-content {
    position: relative;
    z-index: 10;
    max-width: 500px;
}

.hero-content h1 {
    font-size: 2.5rem;
    font-weight: 600;
    color: var(--text-main);
    line-height: 1.2;
    margin-bottom: 1.5rem;
}

.hero-content h1 .highlight {
    color: var(--primary-color);
}

.hero-content p {
    font-size: 1.1rem;
    color: var(--text-muted);
    line-height: 1.6;
}

.illustration {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 10;
    margin-top: 3rem;
}

.browser-mockup {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    width: 100%;
    max-width: 450px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.05);
    overflow: hidden;
}

.browser-header {
    background: #f9fafb;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem;
    display: flex;
    gap: 8px;
}

.browser-header span {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #e5e7eb;
}

.browser-header span:nth-child(1) { background: #ef4444; }
.browser-header span:nth-child(2) { background: #f59e0b; }
.browser-header span:nth-child(3) { background: #10b981; }

.browser-body {
    padding: 3rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
    background: #fafafa;
}

.shield-icon {
    width: 100px;
    height: 100px;
    background: rgba(139, 195, 74, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mock-lines {
    width: 100%;
}

.m-line {
    height: 12px;
    background: #e5e7eb;
    border-radius: 6px;
    margin-bottom: 1rem;
    width: 100%;
}

.m-line.short {
    width: 60%;
}

/* Decorative background elements */
.decorative-waves {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 300px;
    background-image: radial-gradient(circle at 0% 100%, rgba(139, 195, 74, 0.05) 0%, transparent 70%);
    z-index: 1;
}

/* RIGHT SIDE */
.login-right {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fafafa;
    padding: 2rem;
}

.login-card {
    background: #fff;
    padding: 3rem;
    border-radius: 16px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.03);
    border: 1px solid var(--border-color);
    width: 100%;
    max-width: 450px;
}

.login-card h2 {
    font-size: 1.8rem;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

.login-card .subtitle {
    color: var(--text-muted);
    margin-bottom: 2.5rem;
    font-size: 0.95rem;
}

.input-icon {
    position: relative;
}

.input-icon svg {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.input-icon input {
    padding-left: 2.75rem;
    padding-right: 2.75rem;
}

.toggle-password {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: var(--text-muted);
}

.toggle-password:hover {
    color: var(--text-main);
}

.form-row-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    font-size: 0.9rem;
}

.remember-me {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    cursor: pointer;
}

.remember-me input {
    width: 16px;
    height: 16px;
    margin: 0;
    cursor: pointer;
}

.forgot-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.forgot-link:hover {
    text-decoration: underline;
}

.btn-block {
    width: 100%;
    padding: 0.85rem;
    font-size: 1rem;
}

.divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 2rem 0;
}

.divider::before, .divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border-color);
}

.divider span {
    padding: 0 1rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.sso-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.terms-text {
    margin-top: 2rem;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.terms-text a {
    color: var(--primary-color);
    text-decoration: none;
}

.terms-text a:hover {
    text-decoration: underline;
}

.login-error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--alert-color);
    padding: 0.75rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    border: 1px solid rgba(239, 68, 68, 0.2);
    text-align: center;
}

/* =========================================
   RESPONSIVE STYLES
   ========================================= */

@media (max-width: 992px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .charts-grid-top,
    .charts-grid-bottom {
        grid-template-columns: 1fr !important;
    }

    .login-container {
        flex-direction: column;
    }
    
    .login-left {
        padding: 2rem;
        min-height: auto;
        background-size: cover !important;
        background-position: center top !important;
    }
    
    .login-logo {
        margin-bottom: 2rem;
    }
    
    .hero-content h1 {
        font-size: 2rem;
    }
    
    .login-right {
        padding: 2rem 1rem;
    }
}

@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .top-navbar {
        height: 70px;
        padding: 0 1rem;
        flex-wrap: nowrap;
        position: relative;
    }
    
    .hamburger-btn {
        display: flex;
    }
    
    .nav-links {
        display: none;
        flex-direction: column;
        position: absolute;
        top: 70px;
        left: 0;
        width: 100%;
        height: auto;
        background: #ffffff !important;
        border-bottom: 1px solid var(--border-color);
        box-shadow: 0 4px 10px rgba(0,0,0,0.15);
        z-index: 99999;
        padding: 0;
    }
    
    .nav-links.show {
        display: flex;
    }
    
    .nav-links li {
        width: 100%;
        padding: 1rem;
        justify-content: center;
        border-bottom: 1px solid var(--border-color);
    }
    
    .nav-links li.active {
        background: rgba(139, 195, 74, 0.05);
        border-bottom: 1px solid var(--border-color);
    }
    
    .page-header {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
        text-align: center;
    }
    
    .page-header .btn {
        width: 100%;
        justify-content: center;
    }
    
    .filter-actions {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
    }
    
    .filter-actions .form-group,
    .filter-actions .btn,
    .filter-actions .dropdown {
        width: 100%;
    }
    
    .page-header .dropdown {
        width: 100%;
    }
    
    .page-header .dropdown-content {
        width: 100%;
    }
    
    .table-card {
        padding: 1rem;
    }
    
    .table-header {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    
    .table-header .btn {
        width: 100%;
    }
    
    .form-grid, .grid-3-col, .grid-4-col {
        grid-template-columns: 1fr !important;
    }
    
    .flex-responsive {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 1rem !important;
    }

    .flex-responsive > div {
        display: none; /* Hide any vertical dividers */
    }

    .flex-responsive > .toggle-wrapper {
        display: flex; /* keep toggle wrappers visible */
    }

    .flex-responsive-between {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 1rem !important;
    }
    
    .footer {
        flex-direction: column;
        gap: 1.5rem;
        padding: 2rem 1rem;
        text-align: center;
    }
    
    .form-row {
        flex-direction: column;
        gap: 0;
    }
    
    .modal-content {
        margin: 1rem;
        padding: 1.5rem;
        width: calc(100% - 2rem);
    }
}

/* ===== Site Editor Full-Size Modal ===== */
.site-editor-modal {
    background: rgba(0,0,0,0.5) !important;
    backdrop-filter: blur(6px) !important;
}
.site-editor-modal.active {
    display: flex !important;
}
.site-editor-modal .modal-content {
    max-width: none !important;
    width: 100vw !important;
    height: 100vh !important;
    border-radius: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: hidden !important;
    display: flex !important;
    max-height: 100vh !important;
    box-shadow: none !important;
    animation: none !important;
}
.site-editor-layout {
    display: flex;
    width: 100%;
    height: 100%;
    min-height: 0;
}
.site-editor-sidebar {
    width: 240px;
    min-width: 240px;
    max-width: 240px;
    height: 100%;
    background: #1e293b;
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem;
    border-bottom: 1px solid #334155;
    flex-shrink: 0;
}
.sidebar-brand h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: #f1f5f9;
}
.sidebar-brand .modal-close {
    background: rgba(255,255,255,0.1);
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 0.35rem;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.sidebar-brand .modal-close:hover {
    background: rgba(255,255,255,0.2);
    color: #f1f5f9;
}
.sidebar-nav {
    display: flex;
    flex-direction: column;
    padding: 0.75rem;
    gap: 2px;
    flex: 1;
    overflow-y: auto;
}
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0.65rem 0.75rem;
    border-radius: 8px;
    color: #94a3b8;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.15s;
    cursor: pointer;
    flex-shrink: 0;
}
.sidebar-link:hover {
    background: rgba(255,255,255,0.08);
    color: #e2e8f0;
}
.sidebar-link.active {
    background: rgba(139, 195, 74, 0.15);
    color: #8bc34a;
}
.sidebar-link.active svg {
    stroke: #8bc34a;
}
.site-editor-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-color);
    min-width: 0;
}
.site-editor-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 2rem 2.5rem;
    scroll-behavior: smooth;
    height: 0;
}
.editor-section {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.editor-section:last-child {
    margin-bottom: 0;
}
.section-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-main);
    margin: 0 0 1.25rem 0;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}
.editor-section .form-section-card {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
    margin-bottom: 1.5rem;
}
.editor-section .form-section-card:last-child {
    margin-bottom: 0;
}
.editor-section .form-section-header {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.6rem 1rem;
    margin-bottom: 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: #475569;
}
.editor-footer {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    padding: 1rem 2.5rem;
    background: var(--card-bg);
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}
.editor-footer .btn {
    padding: 0.65rem 2rem;
    font-size: 0.9rem;
}
@media (max-width: 768px) {
    .site-editor-sidebar {
        display: none;
    }
    .site-editor-content {
        padding: 1rem;
    }
    .editor-footer {
        padding: 1rem;
    }
}
