/* CF Account Manager — Dark Cyber Theme */
:root {
    --bg-primary: #0a0e14;
    --bg-secondary: #0d1117;
    --bg-tertiary: #161b22;
    --bg-card: #12171e;
    --border-color: #21262d;
    --border-glow: #30363d;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --accent-primary: #00d4ff;
    --accent-secondary: #a855f7;
    --accent-hover: #22d3ee;
    --success: #00ff88;
    --error: #ff4757;
    --warning: #ffa502;
    --gradient-primary: linear-gradient(135deg, #00d4ff 0%, #a855f7 100%);
    --shadow-sm: 0 2px 4px rgba(0,0,0,.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,.4);
    --shadow-lg: 0 8px 32px rgba(0,0,0,.5);
    --shadow-glow: 0 0 20px rgba(0,212,255,.15);
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

* { margin:0; padding:0; box-sizing:border-box; }
body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* ── Login ── */
.login-wrap {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh;
    background: radial-gradient(ellipse at 50% 30%, rgba(0,212,255,.06) 0%, transparent 60%);
}
.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 40px;
    width: 380px;
    box-shadow: var(--shadow-lg), var(--shadow-glow);
}
.login-card .logo-area {
    text-align: center; margin-bottom: 32px;
}
.login-card .logo-area img {
    width: 64px; height: 64px; border-radius: 12px; margin-bottom: 12px;
}
.login-card .logo-area h1 {
    font-size: 20px; font-weight: 600;
    background: var(--gradient-primary); -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.login-card .logo-area p { color: var(--text-muted); font-size: 13px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; font-weight: 500; }
.form-input {
    width: 100%; padding: 10px 14px; border-radius: var(--radius-sm);
    border: 1px solid var(--border-color); background: var(--bg-secondary);
    color: var(--text-primary); font-size: 14px; font-family: inherit;
    transition: border-color .2s;
}
.form-input:focus { outline: none; border-color: var(--accent-primary); box-shadow: 0 0 0 3px rgba(0,212,255,.15); }
.btn-primary {
    width: 100%; padding: 11px; border: none; border-radius: var(--radius-sm);
    background: var(--gradient-primary); color: #fff; font-size: 14px; font-weight: 600;
    cursor: pointer; transition: opacity .2s, transform .1s; font-family: inherit;
}
.btn-primary:hover { opacity: .9; }
.btn-primary:active { transform: scale(.98); }
.login-error { color: var(--error); font-size: 13px; text-align: center; margin-bottom: 12px; }

/* ── Dashboard Layout ── */
.dashboard { padding: 0; }
.topbar {
    position: sticky; top: 0; z-index: 100;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 28px; height: 60px;
    background: var(--bg-secondary); border-bottom: 1px solid var(--border-color);
    backdrop-filter: blur(12px);
}
.topbar-left { display: flex; align-items: center; gap: 14px; }
.topbar-left img { width: 32px; height: 32px; border-radius: 8px; }
.topbar-left h1 { font-size: 17px; font-weight: 600; background: var(--gradient-primary); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.btn-sm {
    padding: 6px 14px; border-radius: var(--radius-sm); font-size: 12px;
    font-weight: 500; cursor: pointer; border: 1px solid var(--border-color);
    background: var(--bg-tertiary); color: var(--text-secondary); font-family: inherit;
    transition: all .2s;
}
.btn-sm:hover { border-color: var(--accent-primary); color: var(--text-primary); }
.btn-accent { background: rgba(0,212,255,.1); border-color: rgba(0,212,255,.3); color: var(--accent-primary); }
.btn-accent:hover { background: rgba(0,212,255,.2); }
.btn-danger { border-color: rgba(255,71,87,.3); color: var(--error); }
.btn-danger:hover { background: rgba(255,71,87,.1); }

.main-content { padding: 24px 20px; max-width: 100%; margin: 0 auto; }

/* ── Stats ── */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card {
    background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: var(--radius-md); padding: 20px;
    transition: border-color .2s;
}
.stat-card:hover { border-color: var(--border-glow); }
.stat-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px; }
.stat-value { font-size: 28px; font-weight: 700; font-family: 'JetBrains Mono', monospace; }
.stat-value.cyan { color: var(--accent-primary); }
.stat-value.purple { color: var(--accent-secondary); }
.stat-value.green { color: var(--success); }
.stat-value.orange { color: var(--warning); }
.stat-value.yellow { color: #facc15; }

/* ── Table ── */
.table-card {
    background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: var(--radius-md); overflow: hidden;
}
.table-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid var(--border-color);
}
.table-header h2 { font-size: 15px; font-weight: 600; }
.ns-filter-group { display: flex; gap: 4px; }
.ns-filter-btn { padding: 4px 10px; font-size: 11px; }
.ns-filter-btn.active { background: rgba(0,212,255,.2); border-color: var(--accent-primary); color: var(--accent-primary); }
.table-actions { display: flex; gap: 8px; }

#table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; min-width: 1200px; }
thead th {
    padding: 10px 12px; text-align: left; font-size: 11px; font-weight: 600;
    color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px;
    background: var(--bg-tertiary); border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}
tbody td {
    padding: 10px 12px; border-bottom: 1px solid var(--border-color);
    font-size: 13px; vertical-align: middle;
}
td:nth-child(7) { overflow: hidden; max-width: 0; }
tbody tr { transition: background .15s; }
tbody tr:hover { background: rgba(0,212,255,.03); }
tbody tr.row-selected { background: rgba(0,212,255,.07); }
tbody tr.row-selected:hover { background: rgba(0,212,255,.11); }
tbody tr:last-child td { border-bottom: none; }

th:nth-child(1), td:nth-child(1) { width: 3%; text-align: center; padding-left: 4px; padding-right: 4px; }
th:nth-child(2), td:nth-child(2) { width: 13%; }
th:nth-child(3), td:nth-child(3) { width: 7%; }
th:nth-child(4), td:nth-child(4) { width: 9%; }
th:nth-child(5), td:nth-child(5) { width: 12%; }
th:nth-child(6), td:nth-child(6) { width: 7%; }
th:nth-child(7), td:nth-child(7) { width: 26%; }
th:nth-child(8), td:nth-child(8) { width: 9%; }
th:nth-child(9), td:nth-child(9) { width: 8%; }
th:nth-child(10), td:nth-child(10) { width: 6%; }

#cb-select-all,
.row-select-cb {
    width: 15px;
    height: 15px;
    cursor: pointer;
    accent-color: var(--accent-primary);
    flex-shrink: 0;
}

.cell-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.email-cell { font-weight: 500; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.clickable-cell { cursor: pointer; transition: background .15s, color .15s; }
.clickable-cell:hover { background: rgba(0,212,255,.08); color: var(--accent-primary); }
.clickable-cell:active { transform: scale(.97); }

.mono-cell {
    font-family: 'JetBrains Mono', monospace; font-size: 12px;
    color: var(--text-secondary);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ── TOTP Live Code ── */
.totp-cell { display: flex; align-items: center; gap: 10px; }
.totp-code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 18px; font-weight: 700; letter-spacing: 3px;
    color: var(--success); cursor: pointer; user-select: all;
    transition: color .3s;
    min-width: 100px;
}
.totp-code.warn { color: var(--warning); }
.totp-code.critical { color: var(--error); }
.totp-code:hover { text-shadow: 0 0 8px currentColor; }

.totp-timer {
    position: relative; width: 32px; height: 32px; flex-shrink: 0;
}
.totp-timer svg { transform: rotate(-90deg); }
.totp-timer circle {
    fill: none; stroke-width: 3; cx: 16; cy: 16; r: 13;
}
.totp-timer .track { stroke: var(--border-color); }
.totp-timer .progress { stroke: var(--success); stroke-linecap: round; transition: stroke-dashoffset .3s linear, stroke .3s; }
.totp-timer .progress.warn { stroke: var(--warning); }
.totp-timer .progress.critical { stroke: var(--error); }
.totp-timer .time-text {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    font-size: 10px; font-weight: 600; font-family: 'JetBrains Mono', monospace;
    color: var(--text-secondary);
}

/* Backup codes */
.backup-badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 500;
    background: rgba(168,85,247,.1); color: var(--accent-secondary);
    cursor: pointer; border: 1px solid rgba(168,85,247,.2); transition: all .2s;
    white-space: nowrap;
}
.backup-badge:hover { background: rgba(168,85,247,.2); }

.card-badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 500;
    border: 1px solid rgba(250,204,21,.2); transition: all .2s;
    white-space: nowrap;
}
.card-badge.registered { background: rgba(250,204,21,.1); color: #facc15; }
.card-badge.none { background: transparent; color: var(--text-muted); border-color: transparent; }

/* CF Zone badge */
.cf-zone-badge {
    display: inline-flex; align-items: center; gap: 5px; flex-wrap: wrap;
    padding: 3px 8px; border-radius: 20px; font-size: 11px; font-weight: 500;
    background: rgba(0,212,255,.08); color: var(--text-primary);
    cursor: pointer; border: 1px solid rgba(0,212,255,.2); transition: all .2s;
    white-space: normal; max-width: 100%;
    margin: 2px 0;
}
.cf-zone-badge:hover { background: rgba(0,212,255,.15); }

/* CF Zone wrap — multi-line zone display */
.cf-zone-wrap {
    display: block;
    padding: 4px 8px; border-radius: 8px; font-size: 11px;
    background: rgba(0,212,255,.06); border: 1px solid rgba(0,212,255,.15);
    cursor: pointer; transition: all .2s; margin: 2px 0;
    overflow: hidden;
    max-width: 100%; min-width: 0;
}
.cf-zone-wrap:hover { background: rgba(0,212,255,.12); }
.cf-zone-main {
    display: flex; align-items: center; gap: 5px; flex-wrap: wrap;
    font-weight: 500; color: var(--text-primary);
}
.cf-zone-detail {
    margin-top: 1px;
    display: block !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    line-height: 16px;
    max-width: 100%;
    min-width: 0;
}
.cf-detail-label {
    display: inline;
    font-weight: 700; color: var(--accent-primary); font-size: 9px;
    text-transform: uppercase; letter-spacing: .5px; opacity: .7;
    margin-right: 3px;
}
.cf-detail-value {
    display: inline;
    font-family: 'JetBrains Mono', monospace; font-size: 10px;
    color: var(--text-secondary);
}
.cf-plan-tag {
    font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 8px;
    text-transform: uppercase; letter-spacing: .3px; white-space: nowrap;
}
.plan-free .cf-plan-tag { background: rgba(110,118,129,.2); color: var(--text-muted); }
.plan-pro .cf-plan-tag { background: rgba(251,146,60,.15); color: #fb923c; }
.plan-biz .cf-plan-tag { background: rgba(168,85,247,.15); color: var(--accent-secondary); }
.plan-ent .cf-plan-tag { background: rgba(0,255,136,.15); color: var(--success); }
.cf-badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 500;
    background: rgba(0,212,255,.06); color: var(--text-muted);
    border: 1px solid rgba(0,212,255,.1);
}

/* API Key cell */
.api-key-cell {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all .2s;
}
.api-key-cell:hover {
    color: var(--accent-primary);
    background: rgba(0,212,255,.08);
}

/* Card tooltip */
.card-badge.registered { position: relative; cursor: default; }
.card-badge.registered[title]:hover::after {
    content: attr(title);
    position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
    padding: 5px 10px; border-radius: 6px; font-size: 11px; white-space: nowrap;
    background: var(--bg-tertiary); border: 1px solid var(--border-glow);
    color: var(--text-primary); z-index: 10; box-shadow: var(--shadow-md);
    font-family: 'JetBrains Mono', monospace;
}

.row-actions { display: flex; gap: 4px; flex-shrink: 0; }
.row-actions button {
    background: none; border: 1px solid var(--border-color); border-radius: var(--radius-sm);
    padding: 4px 6px; cursor: pointer; color: var(--text-muted); transition: all .2s;
    display: flex; align-items: center; flex-shrink: 0;
}
.row-actions button:hover { border-color: var(--accent-primary); color: var(--accent-primary); }
.row-actions button.del:hover { border-color: var(--error); color: var(--error); }

/* ── Modal ── */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(4px);
    display: none; align-items: center; justify-content: center; z-index: 1000;
}
.modal-overlay.active { display: flex; }
.modal {
    background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: var(--radius-lg); padding: 28px; width: 480px; max-height: 90vh;
    overflow-y: auto; box-shadow: var(--shadow-lg);
}
.modal h2 { font-size: 17px; margin-bottom: 20px; }
.modal .form-group { margin-bottom: 14px; }
.modal textarea.form-input { min-height: 80px; resize: vertical; }
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* ── Backup codes modal ── */
.backup-list {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px;
    margin-top: 12px;
}
.backup-item {
    font-family: 'JetBrains Mono', monospace; font-size: 14px;
    padding: 8px 14px; background: var(--bg-tertiary); border: 1px solid var(--border-color);
    border-radius: var(--radius-sm); color: var(--accent-secondary); text-align: center;
}

/* ── Toast ── */
.toast {
    position: fixed; bottom: 24px; right: 24px;
    padding: 12px 20px; border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 500; z-index: 2000;
    transform: translateY(80px); opacity: 0; transition: all .3s;
    border: 1px solid;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.ok { background: rgba(0,255,136,.1); border-color: rgba(0,255,136,.3); color: var(--success); }
.toast.err { background: rgba(255,71,87,.1); border-color: rgba(255,71,87,.3); color: var(--error); }

/* Empty */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state svg { margin-bottom: 16px; opacity: .4; }
.empty-state p { font-size: 14px; }

/* ── TOTP Setup Runner ── */
.setup-card {
    background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: var(--radius-md); margin-top: 24px; overflow: hidden;
}
.setup-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid var(--border-color);
}
.setup-title { display: flex; align-items: center; gap: 10px; }
.setup-title svg { color: var(--accent-primary); }
.setup-title h2 { font-size: 15px; font-weight: 600; }
.setup-controls { display: flex; align-items: center; gap: 12px; }
.setup-progress {
    font-family: 'JetBrains Mono', monospace; font-size: 12px;
    color: var(--text-muted);
}
.btn-setup-start {
    padding: 6px 16px; border-radius: var(--radius-sm); font-size: 12px;
    font-weight: 600; cursor: pointer; border: 1px solid rgba(0,255,136,.3);
    background: rgba(0,255,136,.1); color: var(--success); font-family: inherit;
    display: inline-flex; align-items: center; transition: all .2s;
}
.btn-setup-start:hover { background: rgba(0,255,136,.2); }
.btn-setup-start:disabled { opacity: .4; cursor: not-allowed; }
.btn-setup-stop {
    padding: 6px 16px; border-radius: var(--radius-sm); font-size: 12px;
    font-weight: 600; cursor: pointer; border: 1px solid rgba(255,71,87,.3);
    background: rgba(255,71,87,.1); color: var(--error); font-family: inherit;
    display: inline-flex; align-items: center; transition: all .2s;
}
.btn-setup-stop:hover { background: rgba(255,71,87,.2); }

.setup-info-bar {
    padding: 10px 20px;
    font-family: 'JetBrains Mono', monospace; font-size: 12px; font-weight: 600;
    color: var(--accent-primary); background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
}
.setup-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 0;
}
.worker-panel {
    border: 1px solid var(--border-color); border-top: none;
    display: flex; flex-direction: column;
}
.worker-panel:first-child { border-top: none; }
.worker-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 14px; background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}
.worker-email {
    font-family: 'JetBrains Mono', monospace; font-size: 12px;
    font-weight: 600; color: var(--text-primary);
}
.worker-status {
    font-size: 11px; font-weight: 600; padding: 2px 8px;
    border-radius: 10px;
}
.status-running { color: var(--warning); background: rgba(255,165,2,.12); }
.status-success { color: var(--success); background: rgba(0,255,136,.12); }
.status-error { color: var(--error); background: rgba(255,71,87,.12); }
.worker-log {
    padding: 8px 14px; max-height: 260px; overflow-y: auto;
    font-family: 'JetBrains Mono', monospace; font-size: 11px;
    line-height: 1.6; color: var(--text-secondary);
    background: var(--bg-primary);
    scrollbar-width: thin; scrollbar-color: var(--border-glow) transparent;
}
.worker-log .log-line { padding: 1px 0; white-space: pre-wrap; word-break: break-all; }
.worker-log .log-start { color: var(--accent-primary); font-weight: 600; }
.worker-log .log-success { color: var(--success); font-weight: 600; }
.worker-log .log-error { color: var(--error); font-weight: 600; }

.concurrency-label {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 12px; color: var(--text-muted); font-weight: 500;
}
.concurrency-input {
    width: 48px; padding: 4px 6px; text-align: center;
    border: 1px solid var(--border-color); border-radius: var(--radius-sm);
    background: var(--bg-secondary); color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace; font-size: 13px;
}
.concurrency-input:focus { outline: none; border-color: var(--accent-primary); }

/* Copy flash */
.copied { animation: flash .3s; }
@keyframes flash { 50% { opacity: .5; } }

/* Responsive */
@media (max-width: 1024px) { .stats-row { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 768px) {
    .stats-row { grid-template-columns: 1fr; }
    .topbar { padding: 0 16px; }
    .main-content { padding: 16px; }
    table { font-size: 12px; }
    .totp-code { font-size: 15px; letter-spacing: 2px; }
}
