:root {
    --bg-main: #0b0f19;
    --bg-surface: #111827;
    --bg-card: rgba(17, 24, 39, 0.75);
    --bg-card-hover: rgba(31, 41, 55, 0.6);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-glow: rgba(59, 130, 246, 0.3);
    
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --primary-gradient: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    
    --emerald: #10b981;
    --emerald-glow: rgba(16, 185, 129, 0.2);
    --danger: #ef4444;
    --danger-hover: #dc2626;
    
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --text-dim: #6b7280;
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    
    --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

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

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: var(--font-sans);
    min-height: 100vh;
    line-height: 1.5;
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(59, 130, 246, 0.08) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(16, 185, 129, 0.05) 0%, transparent 40%);
    background-attachment: fixed;
}

.app-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    gap: 2rem;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

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

.brand-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 8px 16px rgba(37, 99, 235, 0.3);
}

.brand h1 {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #ffffff;
}

.badge {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    color: #60a5fa;
    background: rgba(59, 130, 246, 0.15);
    padding: 2px 8px;
    border-radius: 999px;
    margin-top: 3px;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.server-status {
    display: flex;
    gap: 1rem;
}

.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.75rem 1.25rem;
    min-width: 160px;
}

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

.stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    margin-top: 2px;
}

.text-emerald {
    color: var(--emerald);
}

.stat-hint {
    font-size: 0.75rem;
    color: var(--text-dim);
}

.progress-bar-bg {
    width: 100%;
    height: 5px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 99px;
    margin-top: 6px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--emerald);
    border-radius: 99px;
    transition: width 0.3s ease;
}

/* Main Cards */
.main-content {
    display: flex;
    flex-direction: column;
    gap: 1.75rem;
}

.card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    transition: border-color 0.2s ease;
}

.card-header h2, .card-header h3 {
    font-size: 1.15rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.88rem;
    margin-top: 0.35rem;
}

/* Auth Card */
.auth-card {
    border-color: rgba(59, 130, 246, 0.2);
    padding: 1.25rem 1.75rem;
}

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

.auth-status-wrap {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.dot-active {
    background-color: var(--emerald);
    box-shadow: 0 0 10px var(--emerald);
}

.dot-inactive {
    background-color: var(--danger);
    box-shadow: 0 0 10px var(--danger);
}

.token-container {
    margin-top: 1.2rem;
    padding-top: 1.2rem;
    border-top: 1px solid var(--border-color);
}

.token-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    line-height: 1.4;
}

.token-hint code {
    background: rgba(255, 255, 255, 0.08);
    padding: 2px 6px;
    border-radius: 4px;
    color: #60a5fa;
    font-family: var(--font-mono);
}

.token-textarea {
    width: 100%;
    background: #080d1a;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: #38bdf8;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    padding: 0.75rem 1rem;
    outline: none;
    resize: vertical;
    transition: border-color 0.2s ease;
}

.token-textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.token-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.85rem;
}

/* Form */
.download-form {
    margin-top: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}

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

.input-icon {
    position: absolute;
    left: 1rem;
    color: var(--text-dim);
    pointer-events: none;
}

.download-form input {
    width: 100%;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: #fff;
    padding: 0.85rem 1rem;
    font-size: 0.95rem;
    font-family: inherit;
    transition: all 0.2s ease;
}

.input-wrapper input {
    padding-left: 2.85rem;
}

.download-form input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
    background: rgba(15, 23, 42, 0.85);
}

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

.flex-1 {
    flex: 1;
}

.form-actions {
    display: flex;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: inherit;
    font-weight: 600;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary-gradient);
    color: #fff;
    padding: 0.85rem 1.6rem;
    font-size: 0.95rem;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
    white-space: nowrap;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35);
    transform: translateY(-1px);
}

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

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.btn-danger-outline {
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.25);
}

.btn-danger-outline:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.btn-sm {
    padding: 0.45rem 0.85rem;
    font-size: 0.82rem;
}

/* Active Task & Terminal */
.task-card {
    border-color: rgba(59, 130, 246, 0.4);
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.1);
}

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

.task-title {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: var(--emerald);
    box-shadow: 0 0 10px var(--emerald);
}

.animate-pulse {
    animation: pulse 1.8s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

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

.task-subtext {
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* Visual Progress Bar Card */
.progress-visual-card {
    background: rgba(15, 23, 42, 0.65);
    border: 1px solid rgba(59, 130, 246, 0.25);
    border-radius: var(--radius-md);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.25rem;
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.05);
}

.progress-top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.progress-headline {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
}

.progress-big-number {
    font-size: 2.5rem;
    font-weight: 800;
    line-height: 1;
    font-family: var(--font-mono);
    background: linear-gradient(135deg, #38bdf8 0%, #10b981 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.progress-sub-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.progress-chips {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.chip {
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid var(--border-color);
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
}

.chip-label {
    color: var(--text-dim);
}

.chip-val {
    color: #38bdf8;
    font-family: var(--font-mono);
    font-weight: 600;
}

.main-progress-bar-bg {
    width: 100%;
    height: 16px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 0.85rem;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.4);
}

.main-progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6 0%, #06b6d4 50%, #10b981 100%);
    border-radius: 999px;
    transition: width 0.4s ease;
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.4);
}

.progress-meta-row {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.85rem;
}

.meta-item {
    display: flex;
    gap: 0.5rem;
}

.meta-label {
    color: var(--text-muted);
}

.meta-value {
    color: #fff;
    font-family: var(--font-mono);
    font-weight: 600;
}

.terminal-container {
    background: #06090e;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.terminal-bar {
    background: #0f172a;
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.terminal-dots {
    display: flex;
    gap: 6px;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}
.dot-red { background: #ef4444; }
.dot-yellow { background: #f59e0b; }
.dot-green { background: #10b981; }

.terminal-title {
    font-size: 0.75rem;
    font-family: var(--font-mono);
    color: var(--text-dim);
}

.terminal-btn {
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 4px;
    cursor: pointer;
}

.terminal-btn.active {
    color: var(--emerald);
    border-color: rgba(16, 185, 129, 0.3);
}

.terminal-body {
    padding: 1.25rem;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: #38bdf8;
    background: #070d18;
    max-height: 280px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
    line-height: 1.45;
}

/* Files Table */
.files-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}

.table-container {
    overflow-x: auto;
}

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

.files-table th {
    padding: 0.75rem 1rem;
    color: var(--text-dim);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-color);
}

.files-table td {
    padding: 0.9rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.files-table tr:hover td {
    background: var(--bg-card-hover);
}

.file-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.file-icon {
    color: #60a5fa;
}

.text-right {
    text-align: right;
}

.text-center {
    text-align: center;
}

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

.py-6 {
    padding-top: 1.5rem;
    padding-bottom: 1.5rem;
}

.hidden {
    display: none !important;
}

/* Footer */
.footer {
    text-align: center;
    color: var(--text-dim);
    font-size: 0.8rem;
    margin-top: auto;
    padding-top: 1.5rem;
}

/* Responsive */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        align-items: flex-start;
    }
    .form-row {
        flex-direction: column;
        align-items: stretch;
    }
    .btn-primary {
        width: 100%;
    }
}
