/* ======================================================================
   SHOPEE AUTO TOPUP SaaS - Design System
   Theme: Professional Ops Console
   ====================================================================== */

/* --- Google Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

/* --- Root Variables --- */
:root {
    /* Colors - Dark Mode */
    --bg-primary: #0d131d;
    --bg-secondary: #121a26;
    --bg-tertiary: #182233;
    --bg-card: #151f2d;
    --bg-glass: #1a2638;
    --bg-hover: #233249;

    /* Accent - Core Accent */
    --accent-primary: #2f7ef7;
    --accent-secondary: #5fa3ff;
    --accent-gradient: linear-gradient(135deg, #2f7ef7 0%, #65b4ff 100%);
    --accent-glow: 0 0 18px rgba(47, 126, 247, 0.25);

    /* Status Colors */
    --success: #1f9d63;
    --success-bg: rgba(31, 157, 99, 0.15);
    --warning: #d8a23a;
    --warning-bg: rgba(216, 162, 58, 0.14);
    --danger: #d14b4b;
    --danger-bg: rgba(209, 75, 75, 0.16);
    --info: #2f7ef7;
    --info-bg: rgba(47, 126, 247, 0.14);

    /* Text */
    --text-primary: #e8eef7;
    --text-secondary: #a7b3c4;
    --text-muted: #7e8ca0;
    --text-accent: #69b2ff;

    /* Borders */
    --border-primary: rgba(130, 147, 172, 0.16);
    --border-secondary: rgba(130, 147, 172, 0.24);
    --border-accent: rgba(47, 126, 247, 0.34);

    /* Effects */
    --blur-sm: blur(3px);
    --blur-md: blur(6px);
    --blur-lg: blur(10px);
    --shadow-sm: 0 2px 8px rgba(5, 9, 16, 0.3);
    --shadow-md: 0 8px 22px rgba(5, 9, 16, 0.42);
    --shadow-lg: 0 20px 52px rgba(5, 9, 16, 0.55);
    --shadow-glow: 0 0 20px rgba(47, 126, 247, 0.15);

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;

    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    /* Transition */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms ease;

    /* Fonts */
    --font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'IBM Plex Mono', 'Consolas', monospace;
}

/* --- Reset & Base --- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(ellipse 640px 420px at 12% 18%, rgba(47, 126, 247, 0.12) 0%, transparent 72%),
        radial-gradient(ellipse 520px 520px at 84% 82%, rgba(31, 157, 99, 0.08) 0%, transparent 72%);
    pointer-events: none;
    z-index: 0;
}

a {
    color: var(--text-accent);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--accent-secondary);
}

img {
    max-width: 100%;
    height: auto;
}

button {
    cursor: pointer;
    font-family: inherit;
}

input,
select,
textarea {
    font-family: inherit;
}

/* --- Utility Classes --- */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 var(--space-lg);
}

.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.flex-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.gap-sm {
    gap: var(--space-sm);
}

.gap-md {
    gap: var(--space-md);
}

.gap-lg {
    gap: var(--space-lg);
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.text-muted {
    color: var(--text-muted);
}

.text-secondary {
    color: var(--text-secondary);
}

.text-accent {
    color: var(--text-accent);
}

.text-success {
    color: var(--success);
}

.text-warning {
    color: var(--warning);
}

.text-danger {
    color: var(--danger);
}

.font-mono {
    font-family: var(--font-mono);
}

.font-medium {
    font-weight: 500;
}

.font-semibold {
    font-weight: 600;
}

.font-bold {
    font-weight: 700;
}

.hidden {
    display: none !important;
}

.w-full {
    width: 100%;
}

.mt-sm {
    margin-top: var(--space-sm);
}

.mt-md {
    margin-top: var(--space-md);
}

.mt-lg {
    margin-top: var(--space-lg);
}

.mb-sm {
    margin-bottom: var(--space-sm);
}

.mb-md {
    margin-bottom: var(--space-md);
}

.mb-lg {
    margin-bottom: var(--space-lg);
}

/* --- Glass Card --- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    transition: all var(--transition-normal);
}

.card:hover {
    border-color: var(--border-secondary);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--border-primary);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.625rem 1.25rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 0.84rem;
    font-weight: 650;
    letter-spacing: 0.02em;
    transition: all var(--transition-fast);
    outline: none;
    white-space: nowrap;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--accent-primary);
    color: #f7fbff;
    border-color: rgba(95, 163, 255, 0.6);
    box-shadow: var(--accent-glow);
}

.btn-primary:hover {
    background: #3e8fff;
    border-color: rgba(95, 163, 255, 0.95);
    box-shadow: 0 0 18px rgba(47, 126, 247, 0.35);
}

.btn-secondary {
    background: #1f2b3f;
    color: var(--text-primary);
    border-color: var(--border-secondary);
}

.btn-secondary:hover {
    background: #283851;
    border-color: rgba(130, 147, 172, 0.4);
}

.btn-success {
    background: rgba(31, 157, 99, 0.14);
    color: var(--success);
    border-color: rgba(31, 157, 99, 0.45);
}

.btn-success:hover {
    background: rgba(31, 157, 99, 0.24);
}

.btn-danger {
    background: rgba(209, 75, 75, 0.14);
    color: var(--danger);
    border-color: rgba(209, 75, 75, 0.4);
}

.btn-danger:hover {
    background: rgba(209, 75, 75, 0.25);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8rem;
}

.btn-lg {
    padding: 0.875rem 1.75rem;
    font-size: 1rem;
}

.btn-block {
    width: 100%;
}

.btn:disabled {
    opacity: 0.5;
    pointer-events: none;
}

/* Loading state */
.btn.loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn.loading::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* --- Form Controls --- */
.form-group {
    margin-bottom: var(--space-lg);
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--space-sm);
}

.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-secondary);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: all var(--transition-fast);
    outline: none;
}

.form-input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(238, 77, 45, 0.15);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.form-error {
    font-size: 0.8rem;
    color: var(--danger);
    margin-top: var(--space-xs);
}

/* OTP Input Special */
.otp-inputs {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

.otp-input {
    width: 48px;
    height: 56px;
    background: var(--bg-tertiary);
    border: 1.5px solid var(--border-secondary);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 1.5rem;
    font-weight: 600;
    text-align: center;
    outline: none;
    transition: all var(--transition-fast);
}

.otp-input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(238, 77, 45, 0.15);
}

/* --- Status Badges --- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.25rem 0.7rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.badge-success {
    background: var(--success-bg);
    color: var(--success);
}

.badge-warning {
    background: var(--warning-bg);
    color: var(--warning);
}

.badge-danger {
    background: var(--danger-bg);
    color: var(--danger);
}

.badge-info {
    background: var(--info-bg);
    color: var(--info);
}

.badge-neutral {
    background: rgba(156, 163, 175, 0.12);
    color: var(--text-secondary);
}

.badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.badge-success::before {
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }
}

/* --- Tables --- */
.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-primary);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.table th {
    background: #1b2638;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.875rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-primary);
}

.table td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border-primary);
    color: var(--text-primary);
    vertical-align: middle;
}

.table tr:last-child td {
    border-bottom: none;
}

.table tr:hover td {
    background: rgba(130, 147, 172, 0.08);
}

/* --- Sidebar Layout --- */
.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: #111a28;
    border-right: 1px solid var(--border-primary);
    padding: var(--space-lg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform var(--transition-normal);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding-bottom: var(--space-lg);
    margin-bottom: var(--space-lg);
    border-bottom: 1px solid var(--border-primary);
}

.sidebar-logo-icon {
    width: 36px;
    height: 36px;
    background: #25354e;
    border: 1px solid rgba(130, 147, 172, 0.35);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    color: #e4ecf8;
}

.sidebar-logo-text {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.sidebar-logo-text span {
    font-size: 0.7rem;
    font-weight: 400;
    color: var(--text-muted);
    display: block;
}

.sidebar-nav {
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: 0.7rem 0.875rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all var(--transition-fast);
    margin-bottom: 2px;
    border: 1px solid transparent;
}

.nav-item:hover {
    background: #1d2b41;
    color: var(--text-primary);
    border-color: rgba(130, 147, 172, 0.22);
}

.nav-item.active {
    background: rgba(47, 126, 247, 0.16);
    color: #8fc2ff;
    border-left: 3px solid var(--accent-primary);
    border-color: rgba(47, 126, 247, 0.34);
}

.nav-icon {
    font-size: 0.62rem;
    width: 30px;
    min-width: 30px;
    height: 20px;
    border-radius: 5px;
    border: 1px solid rgba(130, 147, 172, 0.28);
    background: #1a2739;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    letter-spacing: 0.06em;
    font-weight: 700;
    color: #93a5bd;
}

.sidebar-footer {
    padding-top: var(--space-lg);
    border-top: 1px solid var(--border-primary);
}

.main-content {
    flex: 1;
    margin-left: 260px;
    padding: var(--space-xl);
    position: relative;
    z-index: 1;
}

/* --- Page Header --- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-xl);
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 2px;
}

/* --- Stat Cards Grid --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--space-lg);
    margin-bottom: var(--space-xl);
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    transition: all var(--transition-normal);
}

.stat-card:hover {
    border-color: var(--border-accent);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.stat-icon {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: #90a2ba;
    margin-bottom: var(--space-sm);
    font-weight: 700;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 800;
    line-height: 1.2;
    color: #f0f5fb;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* --- Device Card --- */
.device-card {
    background: var(--bg-card);
    backdrop-filter: var(--blur-md);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all var(--transition-normal);
}

.device-card:hover {
    border-color: var(--border-accent);
    box-shadow: var(--shadow-glow);
}

.device-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--border-primary);
    background: rgba(255, 255, 255, 0.02);
}

.device-card-body {
    padding: var(--space-lg);
}

.device-video {
    width: 100%;
    aspect-ratio: 9 / 16;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    overflow: hidden;
    position: relative;
}

.device-video iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.device-video-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    gap: var(--space-sm);
}

.device-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-sm);
    margin-top: var(--space-md);
}

.device-stat {
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    padding: var(--space-sm) var(--space-md);
}

.device-stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.device-stat-value {
    font-size: 1rem;
    font-weight: 700;
}

/* --- Notification Toast --- */
.toast-container {
    position: fixed;
    top: var(--space-lg);
    right: var(--space-lg);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border-secondary);
    border-radius: var(--radius-md);
    padding: var(--space-md) var(--space-lg);
    min-width: 300px;
    box-shadow: var(--shadow-lg);
    animation: toast-in 0.3s ease-out;
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.toast.toast-success {
    border-left: 3px solid var(--success);
}

.toast.toast-error {
    border-left: 3px solid var(--danger);
}

.toast.toast-warning {
    border-left: 3px solid var(--warning);
}

.toast-tag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    height: 22px;
    border-radius: 6px;
    font-size: 0.63rem;
    letter-spacing: 0.06em;
    font-weight: 700;
    color: #cad7e8;
    border: 1px solid var(--border-secondary);
    background: #1a2739;
}

.toast-message {
    font-size: 0.875rem;
}

.toast-close {
    opacity: 0.5;
    cursor: pointer;
}

.toast-close:hover {
    opacity: 1;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateX(30px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* --- Modal --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(6, 10, 16, 0.72);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fade-in 0.2s ease;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-secondary);
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
    max-width: 480px;
    width: 90vw;
    box-shadow: 0 24px 52px rgba(6, 10, 16, 0.58);
    animation: modal-in 0.3s ease-out;
}

.modal-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: var(--space-lg);
}

.modal-actions {
    display: flex;
    gap: var(--space-md);
    justify-content: flex-end;
    margin-top: var(--space-xl);
}

@keyframes fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes modal-in {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-secondary);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* --- Mobile Responsive --- */
.mobile-menu-btn {
    display: none;
    background: #1d2b41;
    border: 1px solid var(--border-secondary);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 0.45rem 0.7rem;
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.06em;
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
        z-index: 200;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .mobile-menu-btn {
        display: flex;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-md);
    }

    .otp-input {
        width: 42px;
        height: 48px;
        font-size: 1.2rem;
    }

    .device-stats {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .card {
        padding: var(--space-lg);
    }
}

/* --- Animations --- */
@keyframes fade-up {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-up {
    animation: fade-up 0.4s ease-out forwards;
    opacity: 0;
}

.animate-delay-1 {
    animation-delay: 0.1s;
}

.animate-delay-2 {
    animation-delay: 0.2s;
}

.animate-delay-3 {
    animation-delay: 0.3s;
}

.animate-delay-4 {
    animation-delay: 0.4s;
}

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(90deg, var(--bg-tertiary) 25%, rgba(255, 255, 255, 0.05) 50%, var(--bg-tertiary) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes skeleton-shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* --- Bot Control Panel Extras --- */
.grid-2-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-lg);
}

@media (max-width: 768px) {
    .grid-2-cols {
        grid-template-columns: 1fr;
    }
}

.flex-1 {
    flex: 1;
}

.gap-xs {
    gap: var(--space-xs);
}

.items-center {
    align-items: center;
}

.text-sm {
    font-size: 0.8rem;
}

.mt-xs {
    margin-top: var(--space-xs);
}

.p-md {
    padding: var(--space-md) !important;
}

.bg-darker {
    background: var(--bg-primary) !important;
}

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-secondary);
}

.btn-outline:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--accent-primary);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: var(--space-md);
    margin-bottom: var(--space-md);
    border-bottom: 1px solid var(--border-primary);
}

.modal-header .modal-title {
    margin-bottom: 0;
}

/* Stat Mini Boxes (inside control panel) */
.stat-mini {
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    padding: var(--space-sm) var(--space-md);
    text-align: center;
}

.stat-mini .label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.stat-mini .value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: 2px;
}

/* Log Window */
.log-window {
    scrollbar-width: thin;
    scrollbar-color: var(--border-secondary) transparent;
}

.log-window>div {
    padding: 2px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    word-break: break-all;
}

/* Video Overlay */
.video-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
    color: var(--text-muted);
    text-align: center;
    padding: var(--space-md);
    font-size: 0.75rem;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.video-overlay:hover {
    background: linear-gradient(transparent, rgba(238, 77, 45, 0.3));
    color: var(--text-primary);
}

/* Animate Pulse (for running status) */
@keyframes badge-pulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4);
    }

    50% {
        box-shadow: 0 0 0 6px rgba(34, 197, 94, 0);
    }
}

.animate-pulse {
    animation: badge-pulse 2s ease-in-out infinite;
}

/* btn-success btn-lg overrides for big start button */
.btn-success.btn-lg {
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: 0.03em;
}

.btn-danger.btn-lg {
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: 0.03em;
}

/* --- Bot Control Panel V2 --- */
#controlPanelModal {
    align-items: flex-start;
    overflow-y: auto;
    padding: var(--space-md) var(--space-sm);
}

.bot-panel-modal {
    --cp-runtime-rgb: 86, 168, 186;
    --cp-activity-rgb: 111, 135, 172;
    --cp-config-rgb: 191, 153, 88;
    --cp-manual-rgb: 95, 138, 188;
    --cp-stat-rgb: 98, 130, 172;
    max-width: 1160px;
    width: min(96vw, 1160px);
    margin: 0 auto var(--space-2xl);
    padding: 1.1rem;
    border-color: #2a3648;
    background: #141b24;
    box-shadow: 0 24px 56px rgba(0, 0, 0, 0.5);
}

.bot-panel-header {
    padding: 0.2rem 0 0.9rem;
    margin-bottom: var(--space-md);
    border-bottom: 1px solid rgba(130, 147, 172, 0.26);
}

.bot-panel-title {
    margin: 0;
    font-size: 1.1rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.bot-panel-subtitle {
    margin-top: 0.3rem;
    color: #9ba9be;
    font-size: 0.84rem;
    font-family: var(--font-mono);
    letter-spacing: 0.02em;
}

.bot-panel-header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.cp-close-btn {
    min-width: 84px;
}

.bot-panel-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(320px, 1fr);
    gap: var(--space-md);
    align-items: start;
}

.bot-panel-main,
.bot-panel-side {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.bot-panel-primary-actions {
    display: flex;
    gap: var(--space-sm);
}

.cp-action-btn {
    position: relative;
    overflow: hidden;
    isolation: isolate;
    min-height: 48px;
    font-size: 0.98rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    transition: border-color var(--transition-fast), background-color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
}

.cp-action-btn::before {
    content: "";
    position: absolute;
    inset: -35% -12%;
    background: linear-gradient(112deg, rgba(255, 255, 255, 0) 30%, rgba(255, 255, 255, 0.22) 50%, rgba(255, 255, 255, 0) 70%);
    transform: translateX(-140%);
    opacity: 0;
    pointer-events: none;
    z-index: 0;
}

.cp-action-btn.signal-live::before {
    opacity: 0.56;
    animation: cp-signal-sweep 2.35s linear infinite;
}

.cp-action-btn.cp-signal-start.signal-live {
    box-shadow: 0 0 0 0 rgba(31, 157, 99, 0.44), 0 0 24px rgba(31, 157, 99, 0.16);
    animation: cp-signal-pulse-start 1.85s ease-out infinite;
}

.cp-action-btn.cp-signal-stop.signal-live {
    box-shadow: 0 0 0 0 rgba(209, 75, 75, 0.44), 0 0 24px rgba(209, 75, 75, 0.16);
    animation: cp-signal-pulse-stop 1.6s ease-out infinite;
}

.cp-action-btn.loading {
    color: #e8eef8 !important;
}

.cp-action-btn.loading::after {
    content: "";
    position: absolute;
    inset: 0;
    width: auto;
    height: auto;
    border: 0;
    border-radius: inherit;
    background: linear-gradient(112deg, rgba(255, 255, 255, 0) 24%, rgba(255, 255, 255, 0.24) 50%, rgba(255, 255, 255, 0) 76%);
    animation: cp-signal-loading 1.15s linear infinite;
}

.cp-action-btn.signal-pending {
    filter: saturate(1.1);
}

@keyframes cp-signal-sweep {
    0% {
        transform: translateX(-140%);
    }

    100% {
        transform: translateX(140%);
    }
}

@keyframes cp-signal-pulse-start {
    0% {
        box-shadow: 0 0 0 0 rgba(31, 157, 99, 0.48), 0 0 14px rgba(31, 157, 99, 0.2);
    }

    70% {
        box-shadow: 0 0 0 12px rgba(31, 157, 99, 0), 0 0 26px rgba(31, 157, 99, 0.24);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(31, 157, 99, 0), 0 0 16px rgba(31, 157, 99, 0.16);
    }
}

@keyframes cp-signal-pulse-stop {
    0% {
        box-shadow: 0 0 0 0 rgba(209, 75, 75, 0.48), 0 0 14px rgba(209, 75, 75, 0.2);
    }

    70% {
        box-shadow: 0 0 0 12px rgba(209, 75, 75, 0), 0 0 26px rgba(209, 75, 75, 0.24);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(209, 75, 75, 0), 0 0 16px rgba(209, 75, 75, 0.16);
    }
}

@keyframes cp-signal-loading {
    0% {
        transform: translateX(-140%);
    }

    100% {
        transform: translateX(140%);
    }
}

@media (prefers-reduced-motion: reduce) {
    .cp-action-btn,
    .cp-action-btn::before,
    .cp-action-btn::after,
    .cp-action-btn.signal-live,
    .cp-action-btn.cp-signal-start.signal-live,
    .cp-action-btn.cp-signal-stop.signal-live,
    .cp-ticker.is-ticking .cp-ticker-current,
    .cp-ticker.is-ticking .cp-ticker-incoming {
        animation: none !important;
    }
}

.bot-panel-quick-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-sm);
}

.bot-panel-quick-actions .btn {
    min-height: 40px;
}

.bot-panel-stats-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) repeat(3, minmax(0, 1fr));
    gap: var(--space-sm);
}

.cp-stat-card {
    --cp-stat-accent: var(--cp-stat-rgb);
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-md);
    border: 1px solid rgba(130, 147, 172, 0.2);
    background:
        radial-gradient(260px 72px at 0% -16%, rgba(var(--cp-stat-accent), 0.14) 0%, rgba(var(--cp-stat-accent), 0) 72%),
        linear-gradient(180deg, rgba(var(--cp-stat-rgb), 0.11) 0%, #161e2b 70%);
    padding: 0.7rem 0.9rem;
    min-height: 70px;
}

.cp-stat-card::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 2px;
    background: linear-gradient(90deg, rgba(var(--cp-stat-accent), 0.78) 0%, rgba(var(--cp-stat-accent), 0.14) 55%, rgba(var(--cp-stat-accent), 0) 100%);
}

.cp-stat-card:nth-child(1) {
    --cp-stat-accent: 96, 145, 210;
    min-height: 76px;
    padding: 0.76rem 1rem;
}

.cp-stat-card:nth-child(2) {
    --cp-stat-accent: 84, 168, 186;
}

.cp-stat-card:nth-child(3) {
    --cp-stat-accent: 68, 162, 111;
}

.cp-stat-card:nth-child(4) {
    --cp-stat-accent: 196, 102, 102;
}

.cp-stat-card > * {
    position: relative;
    z-index: 1;
}

.cp-stat-label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #8e9db2;
    margin-bottom: 0.35rem;
}

.cp-stat-value {
    color: #e8eef7;
    font-size: 0.94rem;
    font-weight: 650;
    line-height: 1.2;
}

.cp-stat-note {
    margin-top: 0.22rem;
    font-size: 0.66rem;
    line-height: 1.25;
    color: #8ea0b8;
    letter-spacing: 0.01em;
}

.cp-ticker {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.2ch;
    min-height: 1.06em;
    overflow: hidden;
    font-variant-numeric: tabular-nums;
}

.cp-ticker-current,
.cp-ticker-incoming {
    display: block;
    line-height: 1.05;
}

.cp-ticker-incoming {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: translateY(118%);
    opacity: 0;
}

.cp-ticker.is-ticking .cp-ticker-current {
    animation: cp-ticker-out 0.28s cubic-bezier(0.2, 0.7, 0.18, 1) both;
}

.cp-ticker.is-ticking .cp-ticker-incoming {
    animation: cp-ticker-in 0.28s cubic-bezier(0.2, 0.7, 0.18, 1) both;
}

.cp-stat-card:nth-child(2) .cp-ticker.is-ticking .cp-ticker-incoming {
    text-shadow: 0 0 12px rgba(84, 168, 186, 0.38);
}

.cp-stat-card:nth-child(3) .cp-ticker.is-ticking .cp-ticker-incoming {
    text-shadow: 0 0 12px rgba(68, 162, 111, 0.42);
}

.cp-stat-card:nth-child(4) .cp-ticker.is-ticking .cp-ticker-incoming {
    text-shadow: 0 0 12px rgba(196, 102, 102, 0.44);
}

@keyframes cp-ticker-out {
    0% {
        transform: translateY(0);
        opacity: 1;
    }

    100% {
        transform: translateY(-118%);
        opacity: 0;
    }
}

@keyframes cp-ticker-in {
    0% {
        transform: translateY(118%);
        opacity: 0;
    }

    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

.cp-connection-line {
    border: 1px solid rgba(130, 147, 172, 0.24);
    background: #161f2b;
    color: #9aa8bc;
    border-radius: var(--radius-sm);
    padding: 0.56rem 0.75rem;
    font-size: 0.8rem;
    letter-spacing: 0.02em;
}

.cp-connection-line[data-state="connected"] {
    color: #79d7a4;
    border-color: rgba(31, 157, 99, 0.42);
    background: rgba(31, 157, 99, 0.1);
}

.cp-connection-line[data-state="connecting"] {
    color: #f1c067;
    border-color: rgba(216, 162, 58, 0.42);
    background: rgba(216, 162, 58, 0.1);
}

.cp-connection-line[data-state="error"] {
    color: #f0a2a2;
    border-color: rgba(209, 75, 75, 0.45);
    background: rgba(209, 75, 75, 0.11);
}

.cp-runtime-card {
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(var(--cp-runtime-rgb), 0.24);
    border-radius: var(--radius-md);
    background:
        radial-gradient(420px 108px at 0% -12%, rgba(var(--cp-runtime-rgb), 0.15) 0%, rgba(var(--cp-runtime-rgb), 0.02) 58%, rgba(var(--cp-runtime-rgb), 0) 100%),
        #131e2d;
    padding: 0.66rem;
}

.cp-runtime-card::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 2px;
    background: linear-gradient(90deg, rgba(var(--cp-runtime-rgb), 0.82) 0%, rgba(var(--cp-runtime-rgb), 0.14) 58%, rgba(var(--cp-runtime-rgb), 0) 100%);
}

.cp-runtime-card > * {
    position: relative;
    z-index: 1;
}

.cp-runtime-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-sm);
    margin-bottom: 0.55rem;
    padding-bottom: 0.34rem;
    border-bottom: 1px solid rgba(var(--cp-runtime-rgb), 0.18);
}

.cp-runtime-title {
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: #98c3d3;
}

.cp-runtime-meta {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 600;
    color: #7fb7ff;
    text-transform: lowercase;
}

.cp-runtime-window {
    height: 238px;
    border: 1px solid rgba(var(--cp-runtime-rgb), 0.23);
    background:
        radial-gradient(220px 70px at 100% 0%, rgba(var(--cp-runtime-rgb), 0.08) 0%, rgba(var(--cp-runtime-rgb), 0) 65%),
        #0f1622;
    border-radius: var(--radius-sm);
    padding: 0.58rem 0.66rem;
    color: #dce8f8;
    font-size: 0.8rem;
    font-family: var(--font-mono);
    line-height: 1.45;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-gutter: stable;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.cp-runtime-window > div {
    padding: 0.22rem 0;
    border-bottom: 1px solid rgba(130, 147, 172, 0.16);
}

.cp-log-card {
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(var(--cp-activity-rgb), 0.2);
    border-radius: var(--radius-md);
    background:
        radial-gradient(360px 92px at 0% -12%, rgba(var(--cp-activity-rgb), 0.12) 0%, rgba(var(--cp-activity-rgb), 0.03) 58%, rgba(var(--cp-activity-rgb), 0) 100%),
        #121a26;
    padding: 0.66rem;
}

.cp-log-card::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 2px;
    background: linear-gradient(90deg, rgba(var(--cp-activity-rgb), 0.8) 0%, rgba(var(--cp-activity-rgb), 0.12) 56%, rgba(var(--cp-activity-rgb), 0) 100%);
}

.cp-log-card > * {
    position: relative;
    z-index: 1;
}

.cp-log-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-sm);
    margin-bottom: 0.55rem;
    padding-bottom: 0.34rem;
    border-bottom: 1px solid rgba(var(--cp-activity-rgb), 0.18);
}

.cp-log-title {
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: #9eb0c9;
}

.cp-log-window {
    height: 138px;
    border: 1px solid rgba(var(--cp-activity-rgb), 0.2);
    background:
        radial-gradient(220px 68px at 100% 0%, rgba(var(--cp-activity-rgb), 0.08) 0%, rgba(var(--cp-activity-rgb), 0) 64%),
        #0f1520;
    border-radius: var(--radius-sm);
    padding: 0.58rem 0.66rem;
    color: #dde7f6;
    font-size: 0.79rem;
    font-family: var(--font-mono);
    line-height: 1.45;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-gutter: stable;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.cp-log-window > div {
    padding: 0.2rem 0;
    border-bottom: 1px solid rgba(130, 147, 172, 0.16);
}

.cp-activity-card {
    background:
        radial-gradient(340px 88px at 0% -12%, rgba(var(--cp-activity-rgb), 0.11) 0%, rgba(var(--cp-activity-rgb), 0.03) 58%, rgba(var(--cp-activity-rgb), 0) 100%),
        #101924;
}

.cp-config-card,
.cp-manual-card {
    position: relative;
    overflow: hidden;
    margin: 0;
    border-color: rgba(130, 147, 172, 0.2);
    background: #161f2c;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: none;
    padding: 0.85rem;
}

.cp-config-card {
    border-color: rgba(var(--cp-config-rgb), 0.24);
    background:
        radial-gradient(360px 96px at 0% -12%, rgba(var(--cp-config-rgb), 0.12) 0%, rgba(var(--cp-config-rgb), 0.02) 56%, rgba(var(--cp-config-rgb), 0) 100%),
        #161f2c;
}

.cp-manual-card {
    border-color: rgba(var(--cp-manual-rgb), 0.24);
    background:
        radial-gradient(360px 96px at 0% -12%, rgba(var(--cp-manual-rgb), 0.12) 0%, rgba(var(--cp-manual-rgb), 0.02) 56%, rgba(var(--cp-manual-rgb), 0) 100%),
        #161f2c;
}

.cp-config-card::before,
.cp-manual-card::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 2px;
}

.cp-config-card::before {
    background: linear-gradient(90deg, rgba(var(--cp-config-rgb), 0.82) 0%, rgba(var(--cp-config-rgb), 0.14) 58%, rgba(var(--cp-config-rgb), 0) 100%);
}

.cp-manual-card::before {
    background: linear-gradient(90deg, rgba(var(--cp-manual-rgb), 0.82) 0%, rgba(var(--cp-manual-rgb), 0.14) 58%, rgba(var(--cp-manual-rgb), 0) 100%);
}

.cp-config-card > *,
.cp-manual-card > * {
    position: relative;
    z-index: 1;
}

.cp-config-card:hover,
.cp-manual-card:hover {
    border-color: rgba(130, 147, 172, 0.36);
    box-shadow: none;
}

.cp-config-card .form-group {
    margin-bottom: 0.84rem;
}

.cp-config-card .form-input {
    font-size: 1rem;
}

.cp-speed-select {
    border-color: rgba(var(--cp-config-rgb), 0.3);
    background:
        linear-gradient(180deg, rgba(var(--cp-config-rgb), 0.1) 0%, rgba(var(--cp-config-rgb), 0.03) 55%, rgba(17, 26, 38, 0.7) 100%),
        #111a26;
    color: #ebf0f8;
}

.cp-speed-select:focus {
    border-color: rgba(var(--cp-config-rgb), 0.56);
    box-shadow: 0 0 0 2px rgba(var(--cp-config-rgb), 0.16);
}

.cp-speed-select option {
    background: #111a26;
    color: #dbe4f2;
}

.cp-section-title {
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #a7b6ca;
    margin-bottom: 0.74rem;
    font-weight: 700;
}

.cp-config-card .cp-section-title {
    color: #c2ae86;
}

.cp-manual-card .cp-section-title {
    color: #99b0ce;
}

.cp-amount-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: var(--space-sm);
    align-items: center;
}

.cp-command-field {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr) 36px;
    align-items: stretch;
    min-height: 42px;
    border: 1px solid rgba(var(--cp-config-rgb), 0.32);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background:
        linear-gradient(180deg, rgba(var(--cp-config-rgb), 0.12) 0%, rgba(var(--cp-config-rgb), 0.04) 50%, rgba(17, 26, 38, 0.72) 100%),
        #111a26;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.cp-command-field:focus-within {
    border-color: rgba(var(--cp-config-rgb), 0.56);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 0 0 2px rgba(var(--cp-config-rgb), 0.18);
}

.cp-command-field-sm {
    min-height: 40px;
}

.cp-step-btn {
    border: 0;
    background: rgba(var(--cp-config-rgb), 0.12);
    color: #dbc79e;
    font-family: var(--font-mono);
    font-size: 1rem;
    font-weight: 700;
    line-height: 1;
    touch-action: manipulation;
    transition: background-color var(--transition-fast), color var(--transition-fast);
}

.cp-step-btn:first-child {
    border-right: 1px solid rgba(var(--cp-config-rgb), 0.24);
}

.cp-step-btn:last-child {
    border-left: 1px solid rgba(var(--cp-config-rgb), 0.24);
}

.cp-step-btn:hover {
    background: rgba(var(--cp-config-rgb), 0.2);
    color: #f2e4c9;
}

.cp-step-btn:active {
    background: rgba(var(--cp-config-rgb), 0.28);
}

.cp-command-input {
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    width: 100%;
    min-height: 100%;
    padding: 0 0.48rem;
    text-align: center;
    color: #edf2fa;
    font-size: 0.95rem;
    font-weight: 650;
    letter-spacing: 0.02em;
    font-variant-numeric: tabular-nums;
}

.cp-command-input:focus {
    box-shadow: none !important;
}

.cp-command-input::-webkit-outer-spin-button,
.cp-command-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.cp-command-input[type="number"] {
    -moz-appearance: textfield;
}

.cp-random-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.79rem;
    color: #9aa8bc;
    padding: 0.4rem 0.56rem;
    border: 1px solid rgba(130, 147, 172, 0.24);
    border-radius: var(--radius-sm);
    min-height: 40px;
}

.cp-random-toggle input {
    margin: 0;
}

.cp-range-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-sm);
    margin-top: var(--space-sm);
}

.cp-config-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-sm);
}

.cp-config-grid .form-group {
    margin-bottom: 0;
}

.cp-manual-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-sm);
}

.cp-manual-grid .btn {
    min-height: 40px;
}

.cp-config-card .btn-secondary {
    background: rgba(var(--cp-config-rgb), 0.12);
    color: #e7dcc6;
    border-color: rgba(var(--cp-config-rgb), 0.32);
}

.cp-config-card .btn-secondary:hover {
    background: rgba(var(--cp-config-rgb), 0.2);
    border-color: rgba(var(--cp-config-rgb), 0.5);
}

.cp-manual-card .btn-outline {
    background: rgba(var(--cp-manual-rgb), 0.08);
    color: #aec1db;
    border-color: rgba(var(--cp-manual-rgb), 0.3);
}

.cp-manual-card .btn-outline:hover {
    background: rgba(var(--cp-manual-rgb), 0.16);
    color: #d8e4f6;
    border-color: rgba(var(--cp-manual-rgb), 0.52);
}

@media (max-width: 1024px) {
    .bot-panel-layout {
        grid-template-columns: 1fr;
    }

    .bot-panel-side {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: var(--space-sm);
    }
}

@media (max-width: 768px) {
    #controlPanelModal {
        padding: 0.35rem;
    }

    .bot-panel-modal {
        width: 100%;
        max-width: none;
        border-radius: var(--radius-lg);
        padding: 0.82rem;
        margin-bottom: 0.6rem;
    }

    .bot-panel-header {
        align-items: flex-start;
        gap: var(--space-sm);
    }

    .bot-panel-header-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .bot-panel-primary-actions {
        flex-direction: column;
    }

    .bot-panel-quick-actions {
        grid-template-columns: 1fr 1fr;
    }

    .bot-panel-stats-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .cp-stat-card:nth-child(1) {
        grid-column: 1 / -1;
    }

    .cp-runtime-window {
        height: 204px;
    }

    .cp-activity-window {
        height: 132px;
    }

    .bot-panel-side {
        grid-template-columns: 1fr;
    }

    .cp-config-grid {
        grid-template-columns: 1fr;
    }

    .cp-amount-row {
        grid-template-columns: 1fr;
    }

    .cp-random-toggle {
        justify-content: center;
    }
}

@media (max-width: 520px) {
    .bot-panel-quick-actions {
        grid-template-columns: 1fr;
    }

    .bot-panel-stats-grid {
        grid-template-columns: 1fr;
    }

    .cp-manual-grid {
        grid-template-columns: 1fr;
    }

    .cp-runtime-window {
        height: 176px;
    }

    .cp-activity-window {
        height: 114px;
    }
}

/* --- Responsive Fit System --- */
@media (max-width: 1024px) {
    .main-content {
        padding: 1.15rem;
    }

    .page-title {
        font-size: 1.32rem;
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: var(--space-md);
    }

    .card {
        padding: 0.95rem;
    }

    .table th,
    .table td {
        padding-left: 0.72rem;
        padding-right: 0.72rem;
    }

    .device-card-body > div {
        grid-template-columns: 1fr !important;
        gap: 0.9rem !important;
    }

    .device-video {
        aspect-ratio: 16 / 9;
    }
}

@media (max-width: 768px) {
    html {
        font-size: 15px;
    }

    body {
        overflow-x: hidden;
    }

    .layout {
        display: block;
    }

    .sidebar {
        width: min(84vw, 320px);
        transform: translateX(calc(-100% - 18px));
        box-shadow: 18px 0 42px rgba(6, 10, 16, 0.45);
        z-index: 900;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 0.9rem 0.72rem 1.15rem;
    }

    .mobile-menu-btn {
        position: fixed;
        top: 0.58rem;
        left: 0.58rem;
        z-index: 950;
        min-height: 36px;
    }

    .page-header {
        margin-top: 2.35rem;
        margin-bottom: 0.85rem;
        gap: 0.6rem;
    }

    .page-title {
        font-size: 1.2rem;
        line-height: 1.2;
    }

    .page-subtitle {
        font-size: 0.82rem;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.58rem;
        margin-bottom: 0.82rem;
    }

    .stat-card {
        padding: 0.72rem;
    }

    .stat-icon {
        font-size: 0.62rem;
        letter-spacing: 0.08em;
    }

    .stat-value {
        font-size: 1.35rem;
    }

    .stat-label {
        font-size: 0.64rem;
    }

    .card {
        padding: 0.8rem;
    }

    .card-header {
        margin-bottom: 0.74rem;
        padding-bottom: 0.55rem;
    }

    .btn {
        min-height: 44px;
        padding: 0.5rem 0.7rem;
        font-size: 0.8rem;
    }

    .btn-sm {
        min-height: 40px;
    }

    .table {
        font-size: 0.78rem;
    }

    .table th {
        font-size: 0.64rem;
        padding: 0.55rem 0.6rem;
        letter-spacing: 0.03em;
    }

    .table td {
        padding: 0.56rem 0.6rem;
    }

    .device-card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.45rem;
    }

    .device-card-body {
        padding: 0.72rem;
    }

    .device-card-body > div {
        grid-template-columns: 1fr !important;
        gap: 0.72rem !important;
    }

    .device-video {
        aspect-ratio: 16 / 9;
    }

    .device-stats {
        grid-template-columns: 1fr 1fr;
        gap: 0.45rem;
        margin-top: 0.7rem;
    }

    .device-stat {
        padding: 0.5rem 0.58rem;
    }

    .device-stat-label {
        font-size: 0.63rem;
    }

    .device-stat-value {
        font-size: 0.88rem;
    }

    .toast-container {
        left: 0.62rem;
        right: 0.62rem;
        top: 0.62rem;
    }

    .toast {
        min-width: 0;
        width: 100%;
        padding: 0.56rem 0.62rem;
    }
}

@media (max-width: 520px) {
    .mobile-menu-btn {
        top: 0.44rem;
        left: 0.44rem;
        padding: 0.4rem 0.56rem;
        font-size: 0.68rem;
    }

    .main-content {
        padding: 0.78rem 0.6rem 1rem;
    }

    .page-header {
        margin-top: 2.15rem;
    }

    .stats-grid,
    .device-stats {
        grid-template-columns: 1fr;
    }

    .card {
        padding: 0.72rem;
    }

    .btn {
        font-size: 0.78rem;
    }

    .bot-panel-modal {
        padding: 0.68rem;
    }

    .bot-panel-title {
        font-size: 0.97rem;
    }

    .bot-panel-subtitle {
        font-size: 0.74rem;
    }

    .bot-panel-stats-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 0.42rem;
    }

    .cp-stat-card {
        min-height: 56px;
        padding: 0.44rem 0.5rem;
    }

    .cp-stat-label {
        font-size: 0.58rem;
        margin-bottom: 0.24rem;
    }

    .cp-stat-value {
        font-size: 0.82rem;
    }

    .cp-stat-note {
        font-size: 0.56rem;
        margin-top: 0.16rem;
    }

    .cp-stat-card:nth-child(1) {
        grid-column: 1 / -1;
        min-height: 60px;
        padding: 0.52rem 0.62rem;
    }

    .cp-stat-card:nth-child(1) .cp-stat-value {
        font-size: 0.8rem;
        line-height: 1.24;
        white-space: normal;
    }

    .cp-stat-card:nth-child(1) .cp-stat-note {
        font-size: 0.54rem;
    }

    .cp-stat-card:nth-child(n+2) {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-align: center;
        min-height: 54px;
        padding: 0.36rem 0.3rem;
    }

    .cp-stat-card:nth-child(n+2) .cp-stat-label {
        font-size: 0.5rem;
        margin-bottom: 0.15rem;
        letter-spacing: 0.08em;
    }

    .cp-stat-card:nth-child(n+2) .cp-stat-value {
        font-size: 0.95rem;
        line-height: 1.03;
    }

    .cp-connection-line {
        font-size: 0.73rem;
        padding: 0.42rem 0.55rem;
    }

    .cp-runtime-window {
        height: 176px;
    }

    .cp-activity-window {
        height: 112px;
        font-size: 0.72rem;
        line-height: 1.4;
    }

    .bot-panel-quick-actions .btn,
    .cp-manual-grid .btn,
    .cp-action-btn {
        min-height: 42px;
    }

    .cp-config-card .form-input {
        font-size: 0.92rem;
    }

    .cp-command-field {
        grid-template-columns: 38px minmax(0, 1fr) 38px;
        min-height: 44px;
    }

    .cp-command-field-sm {
        min-height: 42px;
    }

    .cp-step-btn {
        font-size: 1.04rem;
    }
}

@media (max-width: 390px) {
    html {
        font-size: 14px;
    }

    .page-title {
        font-size: 1.1rem;
    }

    .stat-value {
        font-size: 1.22rem;
    }

    .bot-panel-stats-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 0.38rem;
    }

    .cp-stat-card:nth-child(1) {
        min-height: 56px;
        padding: 0.46rem 0.5rem;
    }

    .cp-stat-card:nth-child(1) .cp-stat-label {
        font-size: 0.54rem;
    }

    .cp-stat-card:nth-child(1) .cp-stat-value {
        font-size: 0.74rem;
    }

    .cp-stat-card:nth-child(1) .cp-stat-note {
        font-size: 0.5rem;
        line-height: 1.2;
    }

    .cp-stat-card:nth-child(n+2) {
        min-height: 50px;
        padding: 0.32rem 0.26rem;
    }

    .cp-stat-card:nth-child(n+2) .cp-stat-label {
        font-size: 0.46rem;
        margin-bottom: 0.14rem;
    }

    .cp-stat-card:nth-child(n+2) .cp-stat-value {
        font-size: 0.87rem;
    }

    .cp-command-field {
        grid-template-columns: 36px minmax(0, 1fr) 36px;
        min-height: 42px;
    }

    .cp-command-field-sm {
        min-height: 40px;
    }

    .cp-step-btn {
        font-size: 0.98rem;
    }

    .cp-runtime-window {
        height: 156px;
    }

    .cp-activity-window {
        height: 98px;
    }
}
