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

:root {
  --bg:          #0f1117;
  --surface:     #181c27;
  --surface2:    #1e2335;
  --border:      #2a2f45;
  --accent:      #4f6ef7;
  --accent-dark: #3a55d4;
  --success:     #22c55e;
  --danger:      #ef4444;
  --warning:     #f59e0b;
  --text:        #e2e8f0;
  --muted:       #64748b;
  --radius:      8px;
  --font:        -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --sidebar-w:   240px;
}

body.light-mode {
  --bg:       #f0f4f8;
  --surface:  #ffffff;
  --surface2: #f1f5f9;
  --border:   #dde3ed;
  --text:     #1e293b;
  --muted:    #64748b;
}

html, body, #root { height: 100%; font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; transition: background 0.2s, color 0.2s; }

/* ── Layout ───────────────────────────────────────────────────────────────── */
.app-shell { display: flex; height: 100vh; overflow: hidden; }

.sidebar { width: var(--sidebar-w); flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; }

.sidebar-logo { display: flex; align-items: center; gap: 10px; padding: 16px; font-size: 16px; font-weight: 700; color: var(--accent); border-bottom: 1px solid var(--border); letter-spacing: -0.3px; flex-shrink: 0; }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; padding: 10px 8px; flex-shrink: 0; }

.nav-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius); font-size: 13px; font-weight: 500; cursor: pointer; border: none; background: transparent; color: var(--muted); width: 100%; text-align: left; transition: background 0.12s, color 0.12s; }
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--accent)18; color: var(--accent); }
.nav-item svg { flex-shrink: 0; }
.nav-badge { margin-left: auto; font-size: 11px; background: var(--surface2); border-radius: 10px; padding: 1px 7px; color: var(--muted); }

.sidebar-section { padding: 10px 8px 4px; }
.sidebar-section-title { display: flex; align-items: center; justify-content: space-between; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; color: var(--muted); padding: 0 4px; margin-bottom: 4px; }
.sidebar-item { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 6px; font-size: 12px; cursor: pointer; color: var(--muted); border: none; background: transparent; width: 100%; text-align: left; transition: background 0.12s, color 0.12s; }
.sidebar-item:hover { background: var(--surface2); color: var(--text); }
.sidebar-item.active { background: var(--accent)18; color: var(--accent); }
.sidebar-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

.sidebar-scroll { overflow-y: auto; flex: 1; }

.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* ── Topbar ────────────────────────────────────────────────────────────────── */
.topbar { display: flex; align-items: center; gap: 12px; padding: 0 20px; height: 52px; background: var(--surface); border-bottom: 1px solid var(--border); flex-shrink: 0; }
.topbar-title { font-size: 16px; font-weight: 700; }
.topbar-spacer { flex: 1; }
.search-wrap { flex: 1; max-width: 380px; display: flex; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 0 12px; }
.search-wrap svg { color: var(--muted); flex-shrink: 0; }
.search-wrap input { background: none; border: none; outline: none; color: var(--text); font-size: 13px; width: 100%; padding: 8px 0; }
.search-wrap input::placeholder { color: var(--muted); }

/* ── Content ───────────────────────────────────────────────────────────────── */
.content { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 16px; }

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: var(--radius); font-size: 13px; font-weight: 500; cursor: pointer; border: none; transition: opacity 0.15s, transform 0.1s; white-space: nowrap; }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-dark); }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--surface2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { opacity: 0.85; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { opacity: 0.85; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { background: transparent; border: 1px solid var(--border); color: var(--muted); border-radius: 6px; padding: 6px; cursor: pointer; display: inline-flex; align-items: center; transition: color 0.15s, background 0.15s; }
.btn-icon:hover { color: var(--text); background: var(--surface2); }
.btn-icon.danger:hover { color: var(--danger); border-color: var(--danger); }

/* ── Toolbar strip ─────────────────────────────────────────────────────────── */
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ── Cards grid ────────────────────────────────────────────────────────────── */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; align-content: start; }

.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 80px 20px; color: var(--muted); text-align: center; grid-column: 1 / -1; }
.empty-state svg { opacity: 0.3; }
.empty-state h3 { font-size: 18px; font-weight: 600; color: var(--text); }
.empty-state p { max-width: 280px; line-height: 1.6; }

/* ── Profile card ──────────────────────────────────────────────────────────── */
.profile-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px; display: flex; flex-direction: column; gap: 10px; transition: border-color 0.2s; position: relative; }
.profile-card:hover { border-color: #3a4060; }
.profile-card.running { border-color: var(--success); }
.profile-card.locked { border-color: var(--warning); }
.card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.card-title { font-weight: 600; font-size: 15px; line-height: 1.3; word-break: break-word; }
.card-actions { display: flex; gap: 4px; flex-shrink: 0; }
.card-meta { display: flex; flex-direction: column; gap: 5px; }
.meta-row { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.meta-row svg { flex-shrink: 0; }
.card-footer { display: flex; gap: 8px; align-items: center; margin-top: auto; }
.card-footer .btn { flex: 1; justify-content: center; }
.card-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.in-use-banner { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600; color: var(--warning); background: var(--warning)18; border: 1px solid var(--warning)44; border-radius: 6px; padding: 4px 8px; }

/* ── Status badges ─────────────────────────────────────────────────────────── */
.status-pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 20px; }
.dot { width: 7px; height: 7px; border-radius: 50%; }
.dot.running { background: var(--success); box-shadow: 0 0 6px var(--success); }
.dot.stopped { background: var(--muted); }

/* ── Modal ─────────────────────────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 20px; backdrop-filter: blur(4px); }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; width: 100%; max-width: 620px; max-height: 92vh; display: flex; flex-direction: column; overflow: hidden; animation: slideIn 0.15s ease-out; }
.modal-wide { max-width: 780px; }
@keyframes slideIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.modal-title { font-size: 16px; font-weight: 700; }
.modal-body { overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 20px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 20px; border-top: 1px solid var(--border); flex-shrink: 0; }

/* ── Forms ─────────────────────────────────────────────────────────────────── */
.form-section { display: flex; flex-direction: column; gap: 12px; }
.form-section-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; color: var(--muted); padding-bottom: 6px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.form-group { display: flex; flex-direction: column; gap: 5px; flex: 1; }
.form-group label { font-size: 12px; font-weight: 500; color: var(--muted); }
.form-row { display: flex; gap: 10px; flex-wrap: wrap; }
.form-row .form-group { min-width: 100px; }
input, textarea, select { background: var(--surface2); border: 1px solid var(--border); border-radius: 6px; color: var(--text); padding: 8px 10px; font-size: 13px; outline: none; width: 100%; font-family: var(--font); }
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 60px; }
select option { background: var(--surface2); }

.toggle-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.toggle { position: relative; display: inline-block; width: 36px; height: 20px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-slider { position: absolute; inset: 0; background: var(--border); border-radius: 20px; cursor: pointer; transition: background 0.2s; }
.toggle-slider::before { content: ''; position: absolute; width: 14px; height: 14px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform 0.2s; }
.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(16px); }

.divider { height: 1px; background: var(--border); margin: 4px 0; }

/* ── Tag pills ─────────────────────────────────────────────────────────────── */
.tag-pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; cursor: pointer; border: 1px solid transparent; }
.tag-pill.removable::after { content: '×'; margin-left: 2px; opacity: 0.7; }

/* ── Toast ─────────────────────────────────────────────────────────────────── */
.toast-container { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 9999; }
.toast { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 8px; font-size: 13px; font-weight: 500; background: var(--surface); border: 1px solid var(--border); box-shadow: 0 4px 20px rgba(0,0,0,0.3); animation: toastIn 0.2s ease-out; max-width: 360px; }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
.toast.success { border-color: var(--success); color: var(--success); }
.toast.error   { border-color: var(--danger);  color: var(--danger); }
.toast.info    { border-color: var(--accent);   color: var(--accent); }

/* ── Proxy checker result ──────────────────────────────────────────────────── */
.proxy-result { padding: 8px 12px; border-radius: 6px; font-size: 12px; display: flex; align-items: center; gap: 8px; }
.proxy-result.online  { background: var(--success)18; border: 1px solid var(--success)44; color: var(--success); }
.proxy-result.offline { background: var(--danger)18;  border: 1px solid var(--danger)44;  color: var(--danger); }

/* ── Stats bar ─────────────────────────────────────────────────────────────── */
.stats-bar { display: flex; gap: 12px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px 16px; flex: 1; text-align: center; }
.stat-value { font-size: 22px; font-weight: 700; }
.stat-label { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ── User table ────────────────────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { text-align: left; padding: 10px 12px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted); border-bottom: 1px solid var(--border); }
.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--border)80; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--surface2); }

/* ── Proxy list item ───────────────────────────────────────────────────────── */
.proxy-row { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; display: flex; align-items: center; gap: 12px; }

/* ── FP preview ────────────────────────────────────────────────────────────── */
.fp-preview { background: var(--surface2); border: 1px solid var(--border); border-radius: 6px; padding: 10px; font-size: 11px; color: var(--muted); display: flex; flex-direction: column; gap: 3px; font-family: monospace; }

/* ── Folder color swatch ───────────────────────────────────────────────────── */
.folder-swatch { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; display: inline-block; }

/* ── Modal tabs ────────────────────────────────────────────────────────────── */
.modal-tabs { display: flex; gap: 2px; padding: 0 20px; border-bottom: 1px solid var(--border); background: var(--surface2); flex-shrink: 0; overflow-x: auto; }
.modal-tab { flex-shrink: 0; padding: 12px 16px; font-size: 13px; font-weight: 500; cursor: pointer; border: none; background: transparent; color: var(--muted); border-bottom: 2px solid transparent; transition: all 0.2s; white-space: nowrap; }
.modal-tab:hover { color: var(--text); }
.modal-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── Agent badge ───────────────────────────────────────────────────────────── */
.agent-badge { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.agent-badge.online { background: var(--success); box-shadow: 0 0 6px var(--success); }
.agent-badge.offline { background: var(--muted); }

/* ── Activity table ────────────────────────────────────────────────────────── */
.activity-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.activity-table th { text-align: left; padding: 10px 12px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted); border-bottom: 1px solid var(--border); }
.activity-table td { padding: 10px 12px; border-bottom: 1px solid var(--border)80; }
.activity-table tr:last-child td { border-bottom: none; }
.activity-table tr:hover td { background: var(--surface2); }

/* ── Cookie textarea ───────────────────────────────────────────────────────── */
.cookie-textarea { resize: vertical; min-height: 120px; font-family: 'Courier New', monospace; font-size: 12px; }

/* ── TOTP display ──────────────────────────────────────────────────────────── */
.totp-live { background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 16px; text-align: center; margin: 12px 0; }
.totp-countdown { font-size: 12px; color: var(--muted); margin-top: 8px; }

/* ── Bulk action bar ───────────────────────────────────────────────────────── */
.bulk-bar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; margin-bottom: 16px; }
.bulk-bar-info { font-size: 13px; color: var(--muted); flex: 1; }

/* ── Import modal ──────────────────────────────────────────────────────────── */
.import-modal { display: flex; flex-direction: column; gap: 16px; }
