:root {
    --bg: #0a0a0c;
    --bg-soft: #111114;
    --surface: #15151a;
    --surface-2: #1b1b21;
    --border: rgba(255, 255, 255, 0.07);
    --border-strong: rgba(255, 255, 255, 0.12);
    --text: #eeeef1;
    --text-muted: #8b8b96;
    --text-dim: #5f5f6b;
    --accent: #e0303f;
    --accent-soft: rgba(224, 48, 63, 0.14);
    --accent-2: #7a1219;
    --money: #22c55e;
    --white-c: #eab308;
    --bot: #ef4444;
    --real: #3b82f6;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow-lg: 0 24px 48px -12px rgba(0, 0, 0, 0.55);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    background-image: radial-gradient(ellipse 900px 500px at 15% -5%, rgba(224, 48, 63, 0.10) 0%, transparent 60%);
    color: var(--text);
    min-height: 100vh;
    font-feature-settings: 'tnum';
    -webkit-font-smoothing: antialiased;
}

/* ===== LOGIN ===== */
.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px 40px 44px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    position: relative;
}

.login-logo {
    text-align: center;
    margin-bottom: 8px;
    position: relative;
}

.login-logo::before {
    content: '';
    position: absolute;
    left: 50%; top: 50%;
    width: 200px; height: 200px;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle, rgba(224, 48, 63, 0.25) 0%, rgba(224, 48, 63, 0) 70%);
    pointer-events: none;
    z-index: 0;
}

.login-logo img {
    position: relative;
    z-index: 1;
    width: 150px;
    height: auto;
    filter: drop-shadow(0 6px 18px rgba(224, 48, 63, 0.3));
}

.login-box h1 {
    text-align: center;
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 4px;
    letter-spacing: -.01em;
}

.login-box .subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 30px;
}

.field { margin-bottom: 16px; }

.field label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 7px;
}

.field input, .field select {
    width: 100%;
    padding: 11px 13px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 13.5px;
    font-family: inherit;
    transition: border-color .15s, box-shadow .15s;
}

.field select { cursor: pointer; }

.field input:focus, .field select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.field input::placeholder { color: var(--text-dim); }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    width: 100%;
    padding: 11px 18px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 13.5px;
    cursor: pointer;
    transition: filter .15s, transform .1s;
    font-family: inherit;
}

.btn:hover { filter: brightness(1.1); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-secondary {
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
    color: var(--text);
}
.btn-secondary:hover { background: #222229; filter: none; }

.btn-danger { background: transparent; border: 1px solid rgba(239, 68, 68, .3); color: #f87171; }
.btn-danger:hover { background: rgba(239, 68, 68, .1); filter: none; }

.btn-ghost { background: transparent; border: 1px solid var(--border-strong); color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); background: var(--surface-2); filter: none; }

.btn-sm { padding: 7px 12px; font-size: 12.5px; width: auto; }

.login-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.25);
    color: #fca5a5;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 18px;
}

/* ===== APP SHELL ===== */
.app {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: var(--bg-soft);
    border-right: 1px solid var(--border);
    padding: 20px 14px;
    display: flex;
    flex-direction: column;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 8px 18px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 14px;
}

.sidebar-logo img {
    width: 32px;
    height: 32px;
    border-radius: 8px;
}
.sidebar-logo .name { font-weight: 700; font-size: 14.5px; letter-spacing: -.01em; }
.sidebar-logo .name span {
    display: block;
    font-weight: 500;
    font-size: 10px;
    color: var(--text-dim);
    letter-spacing: .02em;
    text-transform: uppercase;
}

.nav-section-label {
    font-size: 10.5px;
    font-weight: 700;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: .06em;
    padding: 6px 10px;
    margin-top: 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    margin-bottom: 2px;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    font-family: inherit;
    transition: background .15s, color .15s;
}

.nav-item .ic { font-size: 15px; width: 18px; text-align: center; }

.nav-item:hover { background: var(--surface); color: var(--text); }

.nav-item.active {
    background: var(--accent-soft);
    color: #fff;
}

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

.user-chip {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
}
.user-chip .avatar {
    width: 28px; height: 28px;
    border-radius: 8px;
    background: var(--accent-soft);
    color: var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 12px;
}
.user-chip .info { line-height: 1.3; }
.user-chip .info b { display: block; font-size: 13px; color: var(--text); }
.user-chip .info span { font-size: 10.5px; color: var(--text-dim); }

.main { padding: 26px 34px 60px; max-width: 1440px; }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 22px;
    flex-wrap: wrap;
    gap: 12px;
}

.topbar h2 { font-size: 20px; font-weight: 700; letter-spacing: -.01em; }
.topbar .subtitle-sm { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }

.live-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: #4ade80;
    font-size: 11.5px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 999px;
}

.live-dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: #4ade80;
    animation: pulse 1.6s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(74, 222, 128, .6); }
    70% { box-shadow: 0 0 0 6px rgba(74, 222, 128, 0); }
    100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); }
}

.tab-panel[hidden] { display: none; }

.toolbar-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

/* range chips */
.range-chips { display: flex; gap: 6px; }
.range-chip {
    padding: 6px 13px;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background .15s, color .15s, border-color .15s;
}
.range-chip:hover { color: var(--text); }
.range-chip.active {
    background: var(--accent);
    color: white;
    border-color: transparent;
}

.campaign-select {
    min-width: 220px;
}

/* stat cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    position: relative;
    opacity: 0;
    transition: border-color .2s;
}

.stat-card .dot-ind {
    width: 7px; height: 7px; border-radius: 50%;
    display: inline-block; margin-right: 6px;
}
.stat-card.money .dot-ind { background: var(--money); }
.stat-card.white .dot-ind { background: var(--white-c); }
.stat-card.real .dot-ind { background: var(--real); }
.stat-card.bot .dot-ind { background: var(--bot); }
.stat-card.conv .dot-ind { background: var(--accent); }

.stat-card .label {
    font-size: 11.5px;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
}

.stat-card .value { font-size: 28px; font-weight: 700; letter-spacing: -.01em; }

/* card */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    margin-bottom: 18px;
}

.card h3 { font-size: 14.5px; font-weight: 700; margin-bottom: 16px; display: flex; align-items: center; gap: 7px; }
.card h4 { font-size: 13.5px; font-weight: 700; }

/* device bars */
.device-bar { margin-bottom: 13px; }
.device-bar-head { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 6px; color: var(--text-muted); font-weight: 500; }
.device-bar-track { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.device-bar-fill { height: 100%; width: 0%; border-radius: 999px; background: var(--accent); }

/* table */
.table-wrap { overflow-x: auto; max-height: 440px; overflow-y: auto; border-radius: var(--radius-sm); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
thead th {
    position: sticky; top: 0;
    background: var(--surface-2);
    text-align: left;
    padding: 10px 14px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 10.5px;
    letter-spacing: .04em;
    border-bottom: 1px solid var(--border);
    z-index: 1;
}
tbody td { padding: 10px 14px; border-bottom: 1px solid var(--border); color: var(--text); }
tbody tr:hover { background: var(--surface-2); }
tbody tr.row-money { box-shadow: inset 2px 0 0 var(--money); }
tbody tr.row-white { box-shadow: inset 2px 0 0 var(--white-c); }

.mono { font-family: 'SF Mono', 'Courier New', monospace; font-size: 11.5px; color: var(--text-muted); }
.muted { color: var(--text-muted); }

.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .01em;
}
.badge-money { background: rgba(34,197,94,.12); color: #4ade80; }
.badge-white { background: rgba(234,179,8,.12); color: #facc15; }
.badge-bot { background: rgba(239,68,68,.12); color: #f87171; }
.badge-human { background: rgba(59,130,246,.12); color: #60a5fa; }
.badge-origin { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }

.empty-state { text-align: center; padding: 46px 20px; color: var(--text-muted); }
.empty-state .icon { font-size: 34px; margin-bottom: 10px; opacity: .6; }
.empty-state p { font-size: 13px; max-width: 340px; margin: 0 auto; }

/* settings */
.settings-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 900px) { .settings-grid { grid-template-columns: 1fr; } }

.url-preview {
    background: var(--surface-2);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 11px 13px;
    font-family: 'SF Mono', 'Courier New', monospace;
    font-size: 12px;
    word-break: break-all;
    color: #f0a8ad;
    margin-bottom: 12px;
}

.hint { font-size: 12px; color: var(--text-dim); margin-top: 6px; line-height: 1.5; }

.actions-row { display: flex; gap: 10px; flex-wrap: wrap; }
.actions-row .btn { width: auto; flex: 1; min-width: 150px; }

/* toast */
#toastContainer {
    position: fixed; bottom: 22px; right: 22px;
    display: flex; flex-direction: column; gap: 8px;
    z-index: 999;
}
.toast {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    max-width: 320px;
    opacity: 0;
}
.toast-success { background: #12281c; border: 1px solid rgba(34,197,94,.4); color: #bbf7d0; }
.toast-error { background: #2a1215; border: 1px solid rgba(239,68,68,.4); color: #fecaca; }

/* current config strip */
.config-strip {
    display: flex; gap: 14px; flex-wrap: wrap;
    font-size: 12px; color: var(--text-dim);
    margin-bottom: 18px;
}
.config-strip b { color: var(--text-muted); font-weight: 600; }
.config-strip .dot { opacity: .4; }

/* ===== CAMPANHAS ===== */
.campaign-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 22px;
    margin-bottom: 14px;
    opacity: 0;
}

.campaign-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
}

.campaign-card-title { display: flex; align-items: center; gap: 10px; }
.campaign-card-title .ic {
    width: 34px; height: 34px; border-radius: 9px;
    background: var(--accent-soft); color: var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-size: 15px; flex-shrink: 0;
}
.campaign-card-title h4 { font-size: 15px; font-weight: 700; }
.campaign-card-title .meta { font-size: 11.5px; color: var(--text-dim); margin-top: 2px; }

.campaign-actions { display: flex; gap: 6px; flex-shrink: 0; }
.icon-btn {
    width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
}
.icon-btn:hover { color: var(--text); background: #222229; }
.icon-btn.danger:hover { color: #f87171; border-color: rgba(239,68,68,.3); }

.campaign-urls { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
@media (max-width: 700px) { .campaign-urls { grid-template-columns: 1fr; } }
.campaign-url-item {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
}
.campaign-url-item .k { font-size: 10.5px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .04em; font-weight: 700; margin-bottom: 3px; }
.campaign-url-item .v { font-size: 12.5px; color: var(--text); word-break: break-all; }

.campaign-toggle {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: none;
    border: none;
    font-family: inherit;
    padding: 0;
}

.campaign-body { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.campaign-body[hidden] { display: none; }

.script-block { margin-bottom: 16px; }
.script-block:last-child { margin-bottom: 0; }
.script-block-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 8px;
}
.script-block-head h5 { font-size: 12.5px; font-weight: 700; display: flex; align-items: center; gap: 7px; }
.script-tag {
    font-size: 9.5px; font-weight: 800; letter-spacing: .04em;
    padding: 3px 8px; border-radius: 999px; text-transform: uppercase;
}
.script-tag.white { background: rgba(234,179,8,.12); color: #facc15; }
.script-tag.money { background: rgba(34,197,94,.12); color: #4ade80; }

pre.code-block {
    background: #060607;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    font-family: 'SF Mono', 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.6;
    color: #d4a5a5;
    overflow-x: auto;
    white-space: pre;
}

.copy-btn {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 5px 11px;
    border-radius: 8px;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}
.copy-btn:hover { background: #222229; }

.steps-list { list-style: none; counter-reset: step; }
.steps-list li {
    counter-increment: step;
    padding: 9px 0 9px 32px;
    position: relative;
    font-size: 12.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}
.steps-list li:last-child { border-bottom: none; }
.steps-list li::before {
    content: counter(step);
    position: absolute; left: 0; top: 7px;
    width: 19px; height: 19px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent); font-weight: 700; font-size: 10px;
    display: flex; align-items: center; justify-content: center;
}
.steps-list b { color: var(--text); }

/* modal */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.6);
    display: flex; align-items: center; justify-content: center;
    z-index: 998;
    padding: 20px;
}
.modal-overlay[hidden] { display: none; }
.modal-box {
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    padding: 26px;
    width: 100%;
    max-width: 440px;
    box-shadow: var(--shadow-lg);
}
.modal-box h3 { font-size: 16px; margin-bottom: 18px; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.modal-actions .btn { width: auto; flex: 1; }

@media (max-width: 800px) {
    .app { grid-template-columns: 64px 1fr; }
    .sidebar-logo .name, .nav-item .label, .user-chip .info { display: none; }
    .sidebar-logo { justify-content: center; padding: 4px 0 18px; }
    .nav-item { justify-content: center; }
    .nav-section-label { display: none; }
    .user-chip { justify-content: center; }
    .main { padding: 18px 14px; }
}
