/* ─── Tokens ─────────────────────────────────────────────────────────────────── */
:root {
    --bg: #0f0f14;
    --surface: #1a1a24;
    --surface-2: #22222f;
    --surface-hover: #2a2a3a;
    --border: rgba(255, 255, 255, 0.06);
    --border-active: rgba(124, 131, 255, 0.4);
    --text: #e8e8f0;
    --text-secondary: #8888a0;
    --text-muted: #555568;
    --accent: #7c83ff;
    --accent-glow: rgba(124, 131, 255, 0.25);
    --accent-surface: rgba(124, 131, 255, 0.08);
    --success: #34d399;
    --success-surface: rgba(52, 211, 153, 0.1);
    --error: #f87171;
    --error-surface: rgba(248, 113, 113, 0.1);
    --warning: #fbbf24;
    --warning-surface: rgba(251, 191, 36, 0.1);
    --radius: 16px;
    --radius-sm: 10px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Reset ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ─── App Container ──────────────────────────────────────────────────────────── */
.app { max-width: 480px; margin: 0 auto; padding: 16px 16px 32px; position: relative; }

/* ─── Header ─────────────────────────────────────────────────────────────────── */
.header { display: flex; align-items: center; gap: 14px; padding: 20px 0 12px; margin-bottom: 8px; }
.header-icon {
    width: 48px; height: 48px; border-radius: 14px;
    background: linear-gradient(135deg, var(--accent), #5b5fff);
    display: flex; align-items: center; justify-content: center;
    color: white; flex-shrink: 0; box-shadow: 0 4px 20px var(--accent-glow);
}
.header h1 { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
.header p { font-size: 0.8rem; color: var(--text-secondary); font-weight: 500; margin-top: 2px; }

/* ─── Mode Tabs ──────────────────────────────────────────────────────────────── */
.mode-tabs {
    display: flex; gap: 6px; padding: 4px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-sm); margin-bottom: 16px;
}
.mode-tab {
    flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 12px; border: none; border-radius: 8px;
    background: transparent; color: var(--text-secondary);
    font-family: var(--font); font-size: 0.85rem; font-weight: 600;
    cursor: pointer; transition: var(--transition);
}
.mode-tab:hover { color: var(--text); background: var(--surface-2); }
.mode-tab.active {
    background: var(--accent-surface); color: var(--accent);
    box-shadow: 0 0 0 1px var(--border-active);
}

/* ─── Mode Content ───────────────────────────────────────────────────────────── */
.mode-content { display: none; }
.mode-content.active { display: block; animation: fadeSlideIn 0.3s ease forwards; }

/* ─── Step Indicator ─────────────────────────────────────────────────────────── */
.steps-indicator { display: flex; align-items: center; justify-content: center; gap: 0; padding: 12px 24px 20px; }
.step-dot {
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--surface-2); border: 2px solid var(--border);
    transition: var(--transition); flex-shrink: 0;
}
.step-dot.active { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 12px var(--accent-glow); }
.step-dot.done { background: var(--success); border-color: var(--success); }
.step-line { flex: 1; height: 2px; background: var(--border); margin: 0 4px; transition: var(--transition); }
.step-line.done { background: var(--success); }

/* ─── Card ───────────────────────────────────────────────────────────────────── */
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 24px 20px;
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
}
.card-header { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.card-header h2 { font-size: 1.1rem; font-weight: 600; letter-spacing: -0.01em; }
.step-badge {
    width: 28px; height: 28px; border-radius: 8px;
    background: var(--accent-surface); color: var(--accent);
    font-weight: 700; font-size: 0.8rem;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.card-desc { font-size: 0.82rem; color: var(--text-secondary); line-height: 1.5; margin-bottom: 18px; }

/* ─── Inputs ─────────────────────────────────────────────────────────────────── */
.input-group { margin-bottom: 16px; }
.input-group input {
    width: 100%; padding: 14px 16px;
    background: var(--surface-2); border: 1.5px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text);
    font-family: var(--font); font-size: 0.95rem; font-weight: 500;
    outline: none; transition: var(--transition);
}
.input-group input::placeholder { color: var(--text-muted); }
.input-group input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.input-hint { font-size: 0.78rem; margin-top: 8px; min-height: 18px; transition: var(--transition); }
.input-hint.error { color: var(--error); }
.input-hint.success { color: var(--success); }
.input-hint.info { color: var(--text-secondary); }

/* ─── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
    width: 100%; padding: 14px 20px; border: none; border-radius: var(--radius-sm);
    font-family: var(--font); font-size: 0.92rem; font-weight: 600;
    cursor: pointer; transition: var(--transition); position: relative; overflow: hidden;
}
.btn-primary {
    background: linear-gradient(135deg, var(--accent), #5b5fff);
    color: white; box-shadow: 0 4px 16px var(--accent-glow);
}
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 6px 24px var(--accent-glow); }
.btn-primary:active:not(:disabled) { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }
.btn.loading .btn-text { opacity: 0; }
.btn.loading .btn-loader { display: block; }
.btn-loader {
    display: none; position: absolute; top: 50%; left: 50%;
    width: 20px; height: 20px; margin: -10px 0 0 -10px;
    border: 2.5px solid rgba(255, 255, 255, 0.2);
    border-top-color: white; border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
.btn-secondary {
    background: var(--surface-2); border: 1.5px solid var(--border-active);
    color: var(--accent); display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-secondary:hover { background: var(--accent-surface); }
.btn-secondary.copied { border-color: var(--success); color: var(--success); background: var(--success-surface); }

/* ─── Squads List ────────────────────────────────────────────────────────────── */
.squads-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.squad-item {
    display: flex; align-items: center; gap: 12px; padding: 14px 16px;
    background: var(--surface-2); border: 1.5px solid var(--border);
    border-radius: var(--radius-sm); cursor: pointer; transition: var(--transition);
    -webkit-tap-highlight-color: transparent; user-select: none;
}
.squad-item:hover { background: var(--surface-hover); }
.squad-item.selected { border-color: var(--accent); background: var(--accent-surface); }
.squad-check {
    width: 22px; height: 22px; border-radius: 6px;
    border: 2px solid var(--text-muted);
    display: flex; align-items: center; justify-content: center;
    transition: var(--transition); flex-shrink: 0;
}
.squad-item.selected .squad-check { background: var(--accent); border-color: var(--accent); }
.squad-check svg { opacity: 0; transition: var(--transition); }
.squad-item.selected .squad-check svg { opacity: 1; }
.squad-name { font-size: 0.92rem; font-weight: 500; }

/* ─── HWID / Duration ────────────────────────────────────────────────────────── */
.hwid-selector { display: flex; gap: 8px; margin-bottom: 4px; }
.hwid-btn {
    flex: 1; padding: 12px 0; background: var(--surface-2);
    border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    color: var(--text); font-family: var(--font); font-size: 0.95rem;
    font-weight: 600; cursor: pointer; transition: var(--transition);
}
.hwid-btn:hover { background: var(--surface-hover); }
.hwid-btn.active { border-color: var(--accent); background: var(--accent-surface); color: var(--accent); }
.duration-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.duration-btn {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 16px 8px; background: var(--surface-2); border: 1.5px solid var(--border);
    border-radius: var(--radius-sm); cursor: pointer; transition: var(--transition);
    color: var(--text); font-family: var(--font);
}
.duration-btn:hover { background: var(--surface-hover); }
.duration-btn.active { border-color: var(--accent); background: var(--accent-surface); }
.duration-value { font-size: 1.4rem; font-weight: 700; line-height: 1; }
.duration-label { font-size: 0.75rem; color: var(--text-secondary); margin-top: 4px; font-weight: 500; }
.duration-btn.active .duration-value { color: var(--accent); }
.divider-text { text-align: center; position: relative; margin: 16px 0; }
.divider-text::before { content: ''; position: absolute; top: 50%; left: 0; right: 0; height: 1px; background: var(--border); }
.divider-text span { position: relative; background: var(--surface); padding: 0 16px; color: var(--text-muted); font-size: 0.8rem; font-weight: 500; }
.auto-resolved {
    display: flex; align-items: center; gap: 8px; padding: 10px 14px;
    background: var(--success-surface); border-radius: var(--radius-sm);
    margin-bottom: 16px; color: var(--success); font-size: 0.82rem; font-weight: 500;
}

/* ─── Summary ────────────────────────────────────────────────────────────────── */
.card-summary { text-align: center; }
.summary-icon { margin: 0 auto 16px; width: 64px; height: 64px; display: flex; align-items: center; justify-content: center; }
.spinner { width: 40px; height: 40px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
.summary-details { text-align: left; margin: 20px 0; }
.summary-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 0.85rem; }
.summary-row:last-child { border-bottom: none; }
.summary-label { color: var(--text-secondary); font-weight: 500; }
.summary-value { font-weight: 600; text-align: right; max-width: 60%; word-break: break-all; }
.summary-link { margin: 16px 0 20px; text-align: left; }
.summary-link label { font-size: 0.8rem; color: var(--text-secondary); font-weight: 500; display: block; margin-bottom: 8px; }
.copy-field { display: flex; gap: 8px; }
.copy-field input {
    flex: 1; padding: 12px 14px; background: var(--surface-2);
    border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    color: var(--text); font-family: var(--font); font-size: 0.82rem; font-weight: 500; outline: none;
}
.btn-copy {
    width: 44px; background: var(--accent-surface); border: 1.5px solid var(--border-active);
    border-radius: var(--radius-sm); color: var(--accent); cursor: pointer;
    display: flex; align-items: center; justify-content: center; transition: var(--transition);
}
.btn-copy:hover { background: var(--accent); color: white; }

/* ─── Client Message Block ───────────────────────────────────────────────────── */
.client-message-block { margin: 20px 0; text-align: left; }
.client-message-header { display: flex; align-items: center; gap: 8px; color: var(--accent); font-size: 0.85rem; font-weight: 600; margin-bottom: 10px; }
.client-message-content {
    background: var(--surface-2); border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    padding: 14px 16px; font-size: 0.82rem; line-height: 1.65; color: var(--text);
    white-space: pre-wrap; word-break: break-word; margin-bottom: 12px; max-height: 320px; overflow-y: auto;
}

/* ─── Manage Mode ────────────────────────────────────────────────────────────── */
.manage-section { margin-bottom: 16px; }
.manage-user-header { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.manage-avatar {
    width: 48px; height: 48px; border-radius: 14px;
    background: var(--accent-surface); color: var(--accent);
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.manage-user-info { flex: 1; min-width: 0; }
.manage-user-info h3 { font-size: 1.05rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.manage-status-badge {
    display: inline-flex; align-items: center; gap: 6px; margin-top: 4px;
    padding: 3px 10px; border-radius: 20px; font-size: 0.72rem; font-weight: 600; text-transform: uppercase;
}
.manage-status-badge.active { background: var(--success-surface); color: var(--success); }
.manage-status-badge.disabled { background: var(--error-surface); color: var(--error); }
.manage-status-badge.expired { background: var(--warning-surface); color: var(--warning); }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.btn-icon {
    width: 40px; height: 40px; border-radius: var(--radius-sm);
    background: var(--surface-2); border: 1px solid var(--border);
    color: var(--text-secondary); cursor: pointer; display: flex;
    align-items: center; justify-content: center; transition: var(--transition); flex-shrink: 0;
}
.btn-icon:hover { background: var(--surface-hover); color: var(--text); }

/* ─── Manage Details ─────────────────────────────────────────────────────────── */
.manage-details { margin-bottom: 20px; }
.detail-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 0.84rem;
}
.detail-row:last-child { border-bottom: none; }
.detail-label { color: var(--text-secondary); font-weight: 500; flex-shrink: 0; margin-right: 12px; }
.detail-value { font-weight: 600; text-align: right; word-break: break-all; max-width: 60%; }

/* ─── Action Buttons ─────────────────────────────────────────────────────────── */
.manage-actions-title { font-size: 0.82rem; color: var(--text-secondary); font-weight: 600; margin-bottom: 12px; text-transform: uppercase; letter-spacing: 0.05em; }
.manage-actions-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.action-btn {
    display: flex; align-items: center; gap: 8px; padding: 12px 14px;
    border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface-2); color: var(--text);
    font-family: var(--font); font-size: 0.82rem; font-weight: 600;
    cursor: pointer; transition: var(--transition);
}
.action-btn:hover { background: var(--surface-hover); }
.action-btn:active { transform: scale(0.97); }
.action-toggle { color: var(--warning); border-color: rgba(251,191,36,0.2); }
.action-toggle:hover { background: var(--warning-surface); }
.action-toggle.is-disabled { color: var(--success); border-color: rgba(52,211,153,0.2); }
.action-toggle.is-disabled:hover { background: var(--success-surface); }
.action-edit { color: var(--accent); border-color: rgba(124,131,255,0.2); }
.action-edit:hover { background: var(--accent-surface); }
.action-revoke { color: var(--text-secondary); }
.action-traffic { color: var(--text-secondary); }
.action-delete { color: var(--error); border-color: rgba(248,113,113,0.2); grid-column: span 2; }
.action-delete:hover { background: var(--error-surface); }

/* ─── Edit Panel ─────────────────────────────────────────────────────────────── */
.edit-field { margin-bottom: 20px; }
.edit-field > label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 10px; text-transform: uppercase; letter-spacing: 0.03em; }
.edit-duration-grid { margin-bottom: 0; }
.edit-buttons { display: flex; gap: 10px; margin-top: 8px; }
.edit-buttons .btn { flex: 1; }

/* ─── Modal ──────────────────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.6);
    backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000; padding: 20px; animation: fadeIn 0.2s ease;
}
.modal-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 28px 24px; width: 100%;
    max-width: 340px; text-align: center; animation: scaleIn 0.25s ease;
}
.modal-icon { margin-bottom: 16px; }
.modal-card h3 { font-size: 1.05rem; font-weight: 700; margin-bottom: 8px; }
.modal-card p { font-size: 0.85rem; color: var(--text-secondary); line-height: 1.5; margin-bottom: 20px; }
.modal-buttons { display: flex; gap: 10px; }
.modal-btn { flex: 1; padding: 12px 16px; font-size: 0.85rem; }
.modal-btn.danger { background: linear-gradient(135deg, var(--error), #e05050); box-shadow: 0 4px 16px rgba(248,113,113,0.25); }

/* ─── Toast ──────────────────────────────────────────────────────────────────── */
.toast {
    position: fixed; bottom: -60px; left: 50%; transform: translateX(-50%);
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 12px 20px;
    font-size: 0.85rem; font-weight: 600; color: var(--text);
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    transition: bottom 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1100; white-space: nowrap;
}
.toast.show { bottom: 32px; }
.toast.success { border-color: var(--success); color: var(--success); }
.toast.error { border-color: var(--error); color: var(--error); }

/* ─── Animations ─────────────────────────────────────────────────────────────── */
.step { display: none; animation: fadeSlideIn 0.35s ease forwards; }
.step.active { display: block; }
@keyframes fadeSlideIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.92); } to { opacity: 1; transform: scale(1); } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Light theme ────────────────────────────────────────────────────────────── */
@media (prefers-color-scheme: light) {
    :root {
        --bg: #f0f0f5; --surface: #ffffff; --surface-2: #f5f5fa;
        --surface-hover: #ebebf2; --border: rgba(0, 0, 0, 0.08);
        --border-active: rgba(124, 131, 255, 0.5);
        --text: #1a1a2e; --text-secondary: #6e6e8a; --text-muted: #9999b0;
    }
}

/* ─── Active feedback ────────────────────────────────────────────────────────── */
.squad-item:active, .hwid-btn:active, .duration-btn:active { transform: scale(0.97); }
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 4px; }
