/* FROM TIKTOK TO TINKOFF — strict dark theme */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-dark: #0c0c0c;
    --bg-card: rgba(18, 18, 18, 0.95);
    --border: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.15);
    --text: #e5e7eb;
    --text-muted: #9ca3af;
    --accent: #d1d5db;
    --accent-metallic: linear-gradient(135deg, #e5e7eb 0%, #9ca3af 50%, #e5e7eb 100%);
    --sidebar-width: 240px;
    --sidebar-z: 200;
    --touch-min: 44px;
}

body {
    font-family: 'Inter', sans-serif;
    min-height: 100vh;
    color: var(--text);
    position: relative;
    overflow-x: hidden;
}

/* Animated gradient background — shifting dark */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        135deg,
        #0a0a0a 0%,
        #111 15%,
        #1a1a1a 30%,
        #0f0f0f 45%,
        #141414 60%,
        #0c0c0c 75%,
        #161616 90%,
        #0a0a0a 100%
    );
    background-size: 400% 400%;
    animation: bgShift 12s ease-in-out infinite;
    z-index: 0;
    pointer-events: none;
}

@keyframes bgShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

/* Subtle overlay for depth */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at 30% 20%, rgba(255,255,255,0.02) 0%, transparent 50%),
                radial-gradient(ellipse at 70% 80%, rgba(255,255,255,0.015) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* Layout: sidebar + main */
.app-layout {
    display: flex;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

/* Sidebar toggle (mobile) */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: calc(var(--sidebar-z) + 2);
    width: var(--touch-min);
    height: var(--touch-min);
    min-width: var(--touch-min);
    min-height: var(--touch-min);
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-card);
    color: var(--text);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, border-color 0.2s;
    -webkit-tap-highlight-color: transparent;
}
.sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--border-hover);
}
.sidebar-toggle .menu-icon {
    width: 22px;
    height: 22px;
}

/* Sidebar overlay (mobile drawer) */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: var(--sidebar-z);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}
.sidebar-overlay.is-open {
    opacity: 1;
    visibility: visible;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    padding: 20px 0;
    display: flex;
    flex-direction: column;
    animation: sidebarIn 0.4s ease-out;
}

.sidebar-header {
    padding: 0 16px 16px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.sidebar-close {
    display: none;
    width: var(--touch-min);
    height: var(--touch-min);
    min-width: var(--touch-min);
    min-height: var(--touch-min);
    padding: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
    -webkit-tap-highlight-color: transparent;
}
.sidebar-close:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
}
.sidebar-close svg {
    width: 20px;
    height: 20px;
}

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

.logo-title {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.tiktok-icon {
    font-size: 28px;
    flex-shrink: 0;
    background: linear-gradient(90deg, #ff0050, #ff6b9d, #00f2ea);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: logoPulse 3s ease-in-out infinite;
}

@keyframes logoPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.85; }
}

.sidebar-title {
    font-family: 'Poppins', sans-serif;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: -0.5px;
    background: linear-gradient(90deg, #ff0050, #ff6b9d, #00f2ea);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-tabs {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.tab {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    min-height: var(--touch-min);
    background: transparent;
    border: none;
    border-left: 3px solid transparent;
    border-radius: 0 8px 8px 0;
    cursor: pointer;
    transition: all 0.25s ease;
    color: var(--text-muted);
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    text-align: left;
    -webkit-tap-highlight-color: transparent;
}

.tab .tab-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    opacity: 0.85;
}
.tab .tab-icon svg {
    width: 100%;
    height: 100%;
}
.tab .tab-label {
    flex: 1;
    min-width: 0;
}

.tab:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    border-left-color: rgba(255, 255, 255, 0.2);
}
.tab:hover .tab-icon {
    opacity: 1;
}

.tab.active {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    border-left-color: var(--text-muted);
}
.tab.active .tab-icon {
    opacity: 1;
}

.sidebar-footer {
    margin-top: auto;
    padding: 16px;
    border-top: 1px solid var(--border);
}

.sidebar-footer .current-user {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-logout {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: var(--touch-min);
    justify-content: center;
}
.btn-logout .tab-icon {
    width: 18px;
    height: 18px;
}
.btn-logout .tab-icon svg {
    width: 100%;
    height: 100%;
}

/* Main content */
.main-content {
    flex: 1;
    padding: 24px;
    animation: contentFade 0.35s ease-out;
}

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

.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* Header in main (stats + logout) */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 28px;
}

.main-title {
    font-family: 'Poppins', sans-serif;
    font-size: 28px;
    font-weight: 700;
    background: linear-gradient(90deg, #ff0050, #ff6b9d, #00f2ea);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Buttons — no pink/cyan gradient, metallic white/gray */
.btn {
    padding: 10px 20px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s ease;
    font-family: 'Inter', sans-serif;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
}

.btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--border-hover);
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.btn-primary:hover {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.3);
}

.btn-secondary {
    background: transparent;
    border-color: var(--border);
    color: var(--text-muted);
}

.btn-secondary:hover {
    color: var(--text);
    border-color: var(--border-hover);
}

.accounts-filter {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.accounts-filter .filter-btn.active {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--border-hover);
    color: var(--text);
}

/* Form blocks */
.form-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
    animation: cardIn 0.3s ease-out;
}

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

.form-container h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 20px;
}

.input-group {
    margin-bottom: 18px;
}

.result-box {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    font-size: 13px;
    color: var(--text-secondary);
    white-space: pre-wrap;
    max-height: 280px;
    overflow: auto;
}

.input-with-clear {
    display: flex;
    gap: 10px;
    align-items: center;
}

.input-with-clear .input-field {
    flex: 1;
    min-width: 0;
}

.input-with-clear .btn-clear {
    flex-shrink: 0;
}

.input-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.input-field {
    width: 100%;
    padding: 10px 14px;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input-field:focus {
    border-color: var(--border-hover);
    outline: none;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.05);
}

.input-field::placeholder {
    color: var(--text-muted);
    opacity: 0.8;
}

/* Status badges */
.status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    border: 1px solid transparent;
}

.status-online {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
    border-color: rgba(34, 197, 94, 0.3);
}

.status-offline {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border-color: rgba(239, 68, 68, 0.3);
}

.status-busy {
    background: rgba(249, 115, 22, 0.15);
    color: #fb923c;
    border-color: rgba(249, 115, 22, 0.3);
}

.status-pending {
    background: rgba(234, 179, 8, 0.15);
    color: #fbbf24;
    border-color: rgba(234, 179, 8, 0.3);
}

.status-completed {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
    border-color: rgba(34, 197, 94, 0.3);
}

.status-running {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border-color: rgba(59, 130, 246, 0.3);
}

.status-failed {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border-color: rgba(239, 68, 68, 0.3);
}

.status-cancelled {
    background: rgba(107, 114, 128, 0.15);
    color: #9ca3af;
    border-color: rgba(107, 114, 128, 0.3);
}

/* List items */
.list-item {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 16px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease;
}

.list-item:hover {
    background: rgba(255, 255, 255, 0.03);
    border-color: var(--border-hover);
}

.list-item-info {
    flex: 1;
}

.list-item-actions {
    display: flex;
    gap: 8px;
}

/* Stats grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
    text-align: center;
    transition: all 0.25s ease;
}

.stat-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Login screen */
#loginScreen {
    max-width: 380px;
    margin: 80px auto;
    padding: 32px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    position: relative;
    z-index: 1;
    animation: cardIn 0.4s ease-out;
}

#loginScreen h2 {
    margin-bottom: 24px;
    color: var(--text);
    text-align: center;
    font-size: 22px;
}

#appPanel {
    display: none;
}

#appPanel.visible {
    display: block;
}

/* Tab content */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Slider */
.slider-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}

.slider-row input[type="range"] {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.1);
    outline: none;
}

.slider-row input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--text-muted);
    cursor: pointer;
    border: 1px solid var(--border);
}

.slider-row input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--text-muted);
    cursor: pointer;
    border: 1px solid var(--border);
}

.slider-row span {
    min-width: 48px;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 14px;
    text-align: right;
}

/* Links */
a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--text);
}

/* Select, checkbox */
select.input-field {
    cursor: pointer;
}

input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--text-muted);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
    animation: overlayIn 0.2s ease-out;
}

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

.modal-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    width: 90%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    animation: cardIn 0.25s ease-out;
}

.modal-box h3 {
    margin-bottom: 16px;
    color: var(--text);
    font-size: 16px;
}

.pagination-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.pagination-wrap button {
    padding: 8px 12px;
    min-width: 36px;
}

.pagination-wrap span {
    color: var(--text-muted);
    font-size: 13px;
}

/* Error text */
.login-error {
    color: #f87171;
    font-size: 13px;
    margin-top: 12px;
    display: none;
}

/* Toasts — in-page notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 360px;
    width: calc(100% - 40px);
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    padding: 14px 18px;
    border-radius: 10px;
    border: 1px solid;
    font-size: 14px;
    line-height: 1.4;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    animation: toastIn 0.35s ease-out;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

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

.toast-icon svg {
    width: 100%;
    height: 100%;
}

.toast-message {
    flex: 1;
    min-width: 0;
}

.toast-close {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    background: transparent;
    color: inherit;
    cursor: pointer;
    opacity: 0.7;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
}

.toast-close:hover {
    opacity: 1;
}

.toast-close svg {
    width: 16px;
    height: 16px;
}

.toast--success {
    background: rgba(22, 30, 24, 0.95);
    border-color: rgba(34, 197, 94, 0.4);
    color: #bbf7d0;
}

.toast--error {
    background: rgba(30, 22, 22, 0.95);
    border-color: rgba(239, 68, 68, 0.4);
    color: #fecaca;
}

.toast--warning {
    background: rgba(30, 28, 22, 0.95);
    border-color: rgba(234, 179, 8, 0.4);
    color: #fef08a;
}

.toast--info {
    background: rgba(18, 22, 28, 0.95);
    border-color: rgba(148, 163, 184, 0.35);
    color: #e2e8f0;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toast.is-leaving {
    animation: toastOut 0.25s ease-in forwards;
}

@keyframes toastOut {
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

/* Confirm dialog */
.confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.confirm-overlay.is-open {
    opacity: 1;
    visibility: visible;
}

.confirm-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 24px;
    max-width: 400px;
    width: 90%;
    margin: 16px;
    animation: cardIn 0.25s ease-out;
}

.confirm-message {
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    margin-bottom: 20px;
}

.confirm-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.confirm-actions .btn {
    min-width: 100px;
}

.confirm-danger {
    border-color: rgba(239, 68, 68, 0.5);
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
}

.confirm-danger:hover {
    background: rgba(239, 68, 68, 0.25);
    border-color: rgba(239, 68, 68, 0.6);
}

/* Responsive — mobile first breakpoints */
@media (max-width: 900px) {
    .sidebar-toggle {
        display: flex;
    }

    .sidebar-overlay {
        display: block;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: calc(var(--sidebar-z) + 1);
        transform: translateX(-100%);
        transition: transform 0.3s ease, box-shadow 0.3s ease;
        box-shadow: none;
        max-width: 85vw;
        width: 280px;
        min-width: 0;
    }

    .sidebar.is-open {
        transform: translateX(0);
        box-shadow: 8px 0 24px rgba(0, 0, 0, 0.4);
    }

    .sidebar-close {
        display: flex;
    }

    .main-content {
        padding-top: 56px; /* space for fixed toggle */
        padding-left: 12px;
        padding-right: 12px;
        padding-bottom: 20px;
    }

    .page-header {
        margin-bottom: 20px;
    }

    .main-title {
        font-size: 20px;
        padding-right: 50px; /* avoid overlap with toggle */
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
        margin-bottom: 20px;
    }

    .stat-card {
        padding: 16px;
    }

    .stat-value {
        font-size: 24px;
    }

    .form-container {
        padding: 18px;
        margin-bottom: 18px;
    }

    .form-container h2 {
        font-size: 16px;
        margin-bottom: 16px;
    }

    .list-item {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
        padding: 12px;
    }

    .list-item-actions {
        width: 100%;
        flex-wrap: wrap;
    }

    .list-item-actions .btn {
        flex: 1;
        min-width: 120px;
        min-height: var(--touch-min);
    }

    .input-field {
        padding: 12px 14px;
        min-height: 44px;
    }

    .btn {
        min-height: var(--touch-min);
        padding: 12px 18px;
    }

    #loginScreen {
        margin: 40px 16px;
        padding: 24px 20px;
        width: calc(100% - 32px);
        max-width: none;
    }
}

@media (max-width: 480px) {
    .main-content {
        padding-left: 10px;
        padding-right: 10px;
    }

    .sidebar {
        width: 100%;
        max-width: 100%;
    }

    .main-title {
        font-size: 18px;
    }

    .pagination-wrap {
        flex-direction: column;
        align-items: stretch;
    }

    .pagination-wrap button {
        flex: 1;
    }

    .toast-container {
        top: 12px;
        right: 12px;
        left: 12px;
        max-width: none;
        width: auto;
    }
}
