/* ==========================================================================
   ACTIVE HUB - DESIGN SYSTEM & STYLESHEET
   High Security, Deep Sleek Aesthetic, Zero Clutter
   ========================================================================== */

:root {
    --bg-main: #090d16;
    --bg-surface: #111726;
    --bg-surface-elevated: #182238;
    --bg-input: #0d121f;
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-focus: #2563eb;
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-active: #1e40af;
    --primary-glow: rgba(37, 99, 235, 0.25);
    
    --accent-cyan: #06b6d4;
    --accent-emerald: #10b981;
    --accent-amber: #f59e0b;
    --accent-rose: #f43f5e;
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    
    --font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --transition-smooth: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    font-family: var(--font-family);
    background-color: var(--bg-main);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* ==========================================================================
   AUTH PAGES (LOGIN & CHANGE PASSWORD)
   ========================================================================== */

.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px 16px;
    position: relative;
    background: radial-gradient(circle at 50% 0%, #172554 0%, #090d16 65%);
}

.auth-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    background-image: radial-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px);
    background-size: 32px 32px;
    opacity: 0.6;
    z-index: 0;
}

.auth-container {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 460px;
}

.auth-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    padding: 40px 36px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(12px);
    animation: fadeInScale 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.auth-header {
    text-align: center;
    margin-bottom: 28px;
}

.brand-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 5px 12px;
    background: rgba(37, 99, 235, 0.12);
    border: 1px solid rgba(37, 99, 235, 0.25);
    border-radius: 9999px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: #60a5fa;
    text-transform: uppercase;
    margin-bottom: 18px;
}

.brand-badge.warning-badge {
    background: rgba(245, 158, 11, 0.12);
    border-color: rgba(245, 158, 11, 0.3);
    color: #fbbf24;
}

.pulse-indicator {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background-color: #3b82f6;
    box-shadow: 0 0 8px #3b82f6;
    animation: pulseGlow 2s infinite ease-in-out;
}

.pulse-indicator.warning-pulse {
    background-color: #f59e0b;
    box-shadow: 0 0 8px #f59e0b;
}

.pulse-indicator.success-pulse {
    background-color: #10b981;
    box-shadow: 0 0 8px #10b981;
}

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

.logo-area {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 8px;
}

.logo-icon-wrapper {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, #1e3a8a 0%, #1e293b 100%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #93c5fd;
}

.logo-icon-wrapper.warning-icon-wrapper {
    background: linear-gradient(135deg, #78350f 0%, #1e293b 100%);
    color: #fcd34d;
}

.logo-icon-wrapper.small {
    width: 32px;
    height: 32px;
}

.logo-icon {
    width: 22px;
    height: 22px;
}

.auth-title {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.auth-subtitle {
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.45;
}

.alert-box {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    font-size: 0.85rem;
    line-height: 1.4;
    transition: var(--transition-smooth);
}

.alert-box.alert-error {
    background-color: rgba(244, 63, 94, 0.12);
    border: 1px solid rgba(244, 63, 94, 0.35);
    color: #fda4af;
}

.alert-box.alert-success {
    background-color: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.35);
    color: #6ee7b7;
}

.alert-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    margin-top: 1px;
}

.alert-text {
    flex: 1;
}

.d-none {
    display: none !important;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.form-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.01em;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 14px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    pointer-events: none;
}

.input-icon svg {
    width: 18px;
    height: 18px;
}

.form-control {
    width: 100%;
    padding: 13px 14px 13px 44px;
    background-color: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.92rem;
    transition: var(--transition-smooth);
    outline: none;
}

.form-control:focus {
    border-color: var(--border-focus);
    background-color: rgba(13, 18, 31, 0.95);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.form-control::placeholder {
    color: #475569;
}

.btn-toggle-pwd {
    position: absolute;
    right: 12px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    border-radius: var(--radius-sm);
    transition: var(--transition-smooth);
}

.btn-toggle-pwd:hover {
    color: var(--text-primary);
}

.btn-toggle-pwd svg {
    width: 18px;
    height: 18px;
}

.btn-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 14px 20px;
    background: linear-gradient(135deg, var(--primary) 0%, #1d4ed8 100%);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-md);
    color: #ffffff;
    font-family: inherit;
    font-size: 0.94rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    cursor: pointer;
    transition: var(--transition-smooth);
    margin-top: 6px;
    box-shadow: 0 4px 12px var(--primary-glow);
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #3b82f6 0%, var(--primary) 100%);
    box-shadow: 0 6px 18px rgba(37, 99, 235, 0.4);
    transform: translateY(-1px);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 2px 6px var(--primary-glow);
}

.btn-primary:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    filter: grayscale(20%);
}

.spinner-icon {
    width: 20px;
    height: 20px;
    animation: rotateSpinner 1s linear infinite;
}

.spinner-path {
    stroke: #ffffff;
    stroke-linecap: round;
    stroke-dasharray: 60;
    stroke-dashoffset: 45;
}

@keyframes rotateSpinner {
    100% { transform: rotate(360deg); }
}

.password-rules {
    background-color: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 14px;
}

.rules-header {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.rules-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.rule-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
    transition: var(--transition-smooth);
}

.rule-bullet {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--text-muted);
    transition: var(--transition-smooth);
}

.rule-item.valid {
    color: #34d399;
}

.rule-item.valid .rule-bullet {
    background-color: #10b981;
    box-shadow: 0 0 6px #10b981;
}

.auth-footer {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border-subtle);
    text-align: center;
}

.security-grid {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.security-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    font-size: 0.74rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.security-tag svg {
    width: 13px;
    height: 13px;
    color: #60a5fa;
}

.copyright-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.logout-link {
    color: #94a3b8;
    text-decoration: none;
    font-size: 0.82rem;
    transition: var(--transition-smooth);
}

.logout-link:hover {
    color: #f8fafc;
    text-decoration: underline;
}

/* ==========================================================================
   DASHBOARD CORE & TABS
   ========================================================================== */

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

.dash-navbar {
    background-color: rgba(17, 23, 38, 0.95);
    border-bottom: 1px solid var(--border-subtle);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-info {
    display: flex;
    flex-direction: column;
}

.brand-name {
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    color: var(--text-primary);
}

.brand-desc {
    font-size: 0.74rem;
    color: var(--text-muted);
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background-color: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: 9999px;
    font-size: 0.82rem;
}

.status-dot-active {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #10b981;
    box-shadow: 0 0 6px #10b981;
}

.user-name {
    font-weight: 600;
    color: var(--text-primary);
}

.role-badge {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 6px;
    background: rgba(37, 99, 235, 0.2);
    color: #60a5fa;
    border-radius: var(--radius-sm);
    letter-spacing: 0.05em;
}

.btn-logout {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    background-color: rgba(244, 63, 94, 0.1);
    border: 1px solid rgba(244, 63, 94, 0.25);
    border-radius: var(--radius-md);
    color: #fda4af;
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none;
    transition: var(--transition-smooth);
}

.btn-logout svg {
    width: 16px;
    height: 16px;
}

.btn-logout:hover {
    background-color: rgba(244, 63, 94, 0.2);
    color: #ffffff;
    border-color: rgba(244, 63, 94, 0.5);
}

.dash-main {
    flex: 1;
    padding: 32px 24px;
}

.dash-container {
    max-width: 1280px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 28px;
}

/* Tabs Bar */
.dash-tabs-bar {
    display: flex;
    gap: 8px;
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 4px;
    overflow-x: auto;
}

.dash-tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
    white-space: nowrap;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.dash-tab-btn svg {
    width: 18px;
    height: 18px;
}

.dash-tab-btn:hover {
    color: var(--text-primary);
    background-color: rgba(255, 255, 255, 0.03);
}

.dash-tab-btn.active {
    color: #60a5fa;
    border-bottom-color: #3b82f6;
    background-color: rgba(37, 99, 235, 0.08);
}

/* Tab Panes */
.tab-pane {
    display: flex;
    flex-direction: column;
    gap: 24px;
    animation: fadeIn 0.3s ease;
}

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

.section-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
}

.section-title-group h2 {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.section-title-group p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Buttons */
.btn-secondary, .btn-primary-sm, .btn-action-outline {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
    text-decoration: none;
}

.btn-secondary {
    background-color: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background-color: #243048;
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-primary-sm {
    background: linear-gradient(135deg, var(--primary) 0%, #1d4ed8 100%);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #ffffff;
}

.btn-primary-sm:hover {
    background: linear-gradient(135deg, #3b82f6 0%, var(--primary) 100%);
    box-shadow: 0 4px 12px var(--primary-glow);
}

.btn-action-outline {
    background: none;
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
}

.btn-action-outline:hover {
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.25);
}

/* ==========================================================================
   INSTANCES TAB
   ========================================================================== */

.instances-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.instance-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    transition: var(--transition-smooth);
}

.instance-card:hover {
    transform: translateY(-2px);
    border-color: rgba(37, 99, 235, 0.4);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.3);
}

.instance-card.selected {
    border-color: #3b82f6;
    background: linear-gradient(180deg, var(--bg-surface) 0%, rgba(30, 41, 59, 0.5) 100%);
}

.instance-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.instance-avatar-wrapper {
    position: relative;
    width: 48px;
    height: 48px;
    flex-shrink: 0;
}

.instance-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    background-color: var(--bg-surface-elevated);
    border: 2px solid var(--border-subtle);
    color: transparent;
}

.status-indicator-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--bg-surface);
}

.status-indicator-dot.online {
    background-color: var(--accent-emerald);
    box-shadow: 0 0 8px var(--accent-emerald);
}

.status-indicator-dot.offline {
    background-color: var(--accent-rose);
}

.status-badge {
    font-size: 0.68rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 9999px;
    letter-spacing: 0.05em;
}

.status-badge.online {
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #34d399;
}

.status-badge.offline {
    background: rgba(244, 63, 94, 0.12);
    border: 1px solid rgba(244, 63, 94, 0.3);
    color: #fda4af;
}

.instance-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.instance-profile {
    font-size: 0.84rem;
    color: var(--text-secondary);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.instance-stats-row {
    margin-top: 12px;
    padding: 10px 12px;
    background-color: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
}

.inst-stat {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
}

.stat-lbl {
    color: var(--text-muted);
}

.stat-num.active-num {
    color: #38bdf8;
    font-weight: 700;
}

.instance-footer {
    margin-top: auto;
    padding-top: 12px;
}

.btn-manage-groups {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px;
    background-color: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: #93c5fd;
    font-family: inherit;
    font-size: 0.86rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.btn-manage-groups svg {
    width: 18px;
    height: 18px;
}

.btn-manage-groups:hover {
    background-color: #2563eb;
    color: #ffffff;
    border-color: #2563eb;
}

/* ==========================================================================
   GROUPS TAB & TOGGLES
   ========================================================================== */

.groups-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
}

.groups-filter-col {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 260px;
}

.search-input-wrapper {
    position: relative;
    flex: 1;
}

.search-input {
    width: 100%;
    padding: 10px 14px 10px 38px;
    background-color: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.86rem;
    outline: none;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    width: 16px;
    height: 16px;
}

.groups-actions-col {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.badge-instance-selected {
    background-color: rgba(37, 99, 235, 0.15);
    border: 1px solid rgba(37, 99, 235, 0.3);
    color: #93c5fd;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.76rem;
}

.groups-list-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.group-item-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    transition: var(--transition-smooth);
}

.group-item-card.is-active {
    border-color: rgba(16, 185, 129, 0.3);
    background: linear-gradient(90deg, rgba(17, 23, 38, 0.95) 0%, rgba(16, 185, 129, 0.05) 100%);
}

.group-item-card.is-inactive {
    opacity: 0.7;
}

.group-info-col {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1;
    min-width: 0;
}

.group-img {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    background-color: var(--bg-surface-elevated);
    flex-shrink: 0;
    border: 1px solid var(--border-subtle);
}

.group-meta {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.group-name {
    font-size: 0.96rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.group-details-row {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.group-jid {
    font-family: monospace;
    color: #64748b;
}

.group-size {
    color: #94a3b8;
}

.group-action-col {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: 16px;
}

/* Modern iOS Style Switch */
.switch-control {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
}

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

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

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

input:checked + .switch-slider {
    background-color: #10b981;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.4);
}

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

.switch-status-label {
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--text-secondary);
    min-width: 28px;
}

/* ==========================================================================
   WEBHOOK RULES TAB
   ========================================================================== */

.rules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 20px;
}

.rule-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.rule-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.rule-badge-group {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.rule-type-badge, .rule-inst-badge, .rule-delay-badge {
    font-size: 0.7rem;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    font-weight: 600;
}

.rule-type-badge {
    background: rgba(37, 99, 235, 0.15);
    color: #60a5fa;
}

.rule-inst-badge {
    background: var(--bg-surface-elevated);
    color: #93c5fd;
}

.rule-delay-badge {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
}

.rule-name {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text-primary);
}

.webhook-url-box {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.url-label {
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--text-muted);
}

.url-input-group {
    display: flex;
    gap: 6px;
}

.url-display {
    flex: 1;
    padding: 9px 12px;
    background-color: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: #38bdf8;
    font-family: monospace;
    font-size: 0.8rem;
    outline: none;
}

.btn-copy-url {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background-color: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
}

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

.btn-copy-url:hover, .btn-copy-url.copied {
    background-color: #2563eb;
    color: #ffffff;
    border-color: #2563eb;
}

.rule-preview-box {
    background-color: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 12px;
    font-size: 0.78rem;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.preview-title {
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.preview-item strong {
    color: var(--text-secondary);
}

.rule-actions {
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid var(--border-subtle);
}

/* ==========================================================================
   HISTORY TAB & TABLE
   ========================================================================== */

.table-responsive {
    width: 100%;
    overflow-x: auto;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
}

.hub-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    text-align: left;
}

.hub-table th {
    padding: 14px 18px;
    background-color: var(--bg-surface-elevated);
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-subtle);
}

.hub-table td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-secondary);
}

.hub-table tr:hover td {
    background-color: rgba(255, 255, 255, 0.02);
}

.history-title-cell {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-width: 320px;
}

.hist-title {
    font-weight: 700;
    color: var(--text-primary);
}

.hist-link {
    font-size: 0.75rem;
    color: #60a5fa;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.badge-success {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #34d399;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 9999px;
}

.badge-warning {
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: #fbbf24;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 9999px;
}

.btn-view-details {
    padding: 6px 12px;
    background: none;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: #93c5fd;
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.btn-view-details:hover {
    background-color: rgba(37, 99, 235, 0.15);
    border-color: #3b82f6;
    color: #ffffff;
}

/* ==========================================================================
   MODAL WINDOWS
   ========================================================================== */

.modal-backdrop {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 580px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    animation: fadeInScale 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.btn-close-modal {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.5rem;
    line-height: 1;
    transition: var(--transition-smooth);
}

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

.modal-body {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.test-result-box {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    line-height: 1.4;
}

.test-result-box.success {
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #6ee7b7;
}

.test-result-box.error {
    background: rgba(244, 63, 94, 0.12);
    border: 1px solid rgba(244, 63, 94, 0.3);
    color: #fda4af;
}

.details-meta-header {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px;
    background-color: var(--bg-input);
    border-radius: var(--radius-md);
    font-size: 0.84rem;
}

.details-group-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 300px;
    overflow-y: auto;
}

.details-group-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    background-color: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    font-size: 0.82rem;
}

.details-group-item.ok .d-status-icon {
    color: #10b981;
}

.details-group-item.fail .d-status-icon {
    color: #f43f5e;
}

.d-info {
    display: flex;
    flex-direction: column;
}

.d-time {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* ==========================================================================
   TOAST NOTIFICATIONS & SPINNERS
   ========================================================================== */

.hub-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 20px;
    border-radius: var(--radius-md);
    background-color: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    font-size: 0.86rem;
    font-weight: 600;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    z-index: 2000;
    transform: translateY(20px);
    opacity: 0;
    transition: var(--transition-smooth);
}

.hub-toast.show {
    transform: translateY(0);
    opacity: 1;
}

.hub-toast.toast-success {
    border-color: rgba(16, 185, 129, 0.5);
    color: #6ee7b7;
}

.hub-toast.toast-error {
    border-color: rgba(244, 63, 94, 0.5);
    color: #fda4af;
}

.spinner-sm {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner {
    width: 28px;
    height: 28px;
    border: 3px solid rgba(37, 99, 235, 0.3);
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 10px;
}

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

.loading-state, .empty-state, .error-state {
    padding: 40px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    background-color: var(--bg-surface);
    border: 1px dashed var(--border-subtle);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.empty-state svg {
    width: 36px;
    height: 36px;
    color: var(--text-muted);
}

.dash-footer {
    padding: 24px;
    text-align: center;
    border-top: 1px solid var(--border-subtle);
    font-size: 0.78rem;
    color: var(--text-muted);
}

@media (max-width: 768px) {
    .groups-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .group-item-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 14px;
    }
    .group-action-col {
        margin-left: 0;
        width: 100%;
        justify-content: space-between;
    }
}
