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

:root {
    --bg: #0f1117;
    --surface: #1a1d27;
    --surface2: #22263a;
    --border: #2e3248;
    --accent: #6c63ff;
    --accent-hover: #5a52e8;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --text: #e2e8f0;
    --text-muted: #8892a4;
    --radius: 10px;
    --radius-sm: 6px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* TOPBAR */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    height: 60px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-brand {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.brand-icon { font-size: 1.3rem; }

.topbar-nav { display: flex; gap: 0.5rem; }

.tab-btn {
    background: none;
    border: 1px solid transparent;
    color: var(--text-muted);
    padding: 0.4rem 1rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.15s;
}

.tab-btn:hover { color: var(--text); background: var(--surface2); }
.tab-btn.active { color: var(--accent); border-color: var(--accent); background: rgba(108,99,255,0.1); }

/* TABS */
.tab-content { display: none; padding: 2rem; max-width: 1200px; margin: 0 auto; }
.tab-content.active { display: block; }

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

.page-header h1 { font-size: 1.4rem; font-weight: 600; }

/* BUTTONS */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1.2rem;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.15s;
    text-decoration: none;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn-danger:hover { background: rgba(239,68,68,0.1); }
.btn-sm { padding: 0.3rem 0.75rem; font-size: 0.8rem; }
.btn-icon { padding: 0.35rem 0.6rem; }

/* ACCOUNTS GRID */
.accounts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
}

.account-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    transition: border-color 0.15s;
}

.account-card:hover { border-color: var(--accent); }
.account-card--inactive { opacity: 0.6; }

.account-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.account-card-info { display: flex; align-items: center; gap: 0.75rem; }

.platform-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.platform-instagram { background: rgba(225,48,108,0.15); color: #e1306c; }
.platform-facebook { background: rgba(24,119,242,0.15); color: #1877f2; }
.platform-youtube { background: rgba(255,0,0,0.15); color: #ff0000; }

.account-name { font-weight: 600; font-size: 0.95rem; }
.account-id { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.15rem; }

.account-card-actions { display: flex; gap: 0.35rem; }

.account-stats-row {
    display: flex;
    gap: 1rem;
    margin: 0.75rem 0;
    padding: 0.75rem;
    background: var(--bg);
    border-radius: var(--radius-sm);
}

.account-stat { text-align: center; flex: 1; }
.account-stat-num { font-size: 1.1rem; font-weight: 700; color: var(--accent); }
.account-stat-lbl { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; }

.account-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 0.75rem;
}

.automation-count { font-size: 0.82rem; color: var(--text-muted); }

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 0.3rem;
}

.status-dot--active { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot--inactive { background: var(--text-muted); }

/* STATS */
.stats-overview {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: center;
}

.stat-card--failed { border-color: rgba(239,68,68,0.3); }
.stat-card--skipped { border-color: rgba(245,158,11,0.3); }

.stat-number { font-size: 2.5rem; font-weight: 700; color: var(--accent); }
.stat-card--failed .stat-number { color: var(--danger); }
.stat-card--skipped .stat-number { color: var(--warning); }
.stat-label { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.25rem; }

.stats-by-platform {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.platform-stat-pill {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 1.25rem;
    font-size: 0.9rem;
}

/* ACCOUNT STATS */
.account-stats-section { margin-bottom: 1.5rem; }

.log-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
    margin-top: 0.5rem;
}

.log-table th, .log-table td {
    padding: 0.5rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.log-table th { color: var(--text-muted); font-weight: 500; background: var(--bg); }
.log-table td { color: var(--text); }

.status-pill {
    padding: 0.15rem 0.5rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-sent { background: rgba(34,197,94,0.15); color: var(--success); }
.status-failed { background: rgba(239,68,68,0.15); color: var(--danger); }
.status-skipped { background: rgba(245,158,11,0.15); color: var(--warning); }
.status-limit_reached { background: rgba(245,158,11,0.15); color: var(--warning); }

/* FORM */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 500; margin-bottom: 0.35rem; color: var(--text); }
.help-text { color: var(--text-muted); font-weight: 400; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

input[type="text"], input[type="password"], input[type="url"], input[type="number"],
select, textarea {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    padding: 0.55rem 0.8rem;
    font-size: 0.875rem;
    transition: border-color 0.15s;
    font-family: inherit;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
}

textarea { resize: vertical; }
.field-hint { font-size: 0.76rem; color: var(--text-muted); margin-top: 0.3rem; display: block; }

.form-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1.5rem; }

/* TOGGLE */
.toggle {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    flex-shrink: 0;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--border);
    border-radius: 20px;
    transition: 0.2s;
}

.toggle-slider:before {
    content: '';
    position: absolute;
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.2s;
}

input:checked + .toggle-slider { background: var(--accent); }
input:checked + .toggle-slider:before { transform: translateX(18px); }

/* MODAL */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
    backdrop-filter: blur(4px);
}

.modal-overlay.hidden { display: none; }

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal--wide { max-width: 720px; }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.modal-header h2 { font-size: 1.1rem; font-weight: 600; }
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 1.1rem; cursor: pointer; padding: 0.25rem; }
.modal-close:hover { color: var(--text); }

.modal form { padding: 1.5rem; overflow-y: auto; }
.modal-body { padding: 1.5rem; overflow-y: auto; }

/* AUTOMATIONS LIST */
.automation-add { margin-bottom: 2rem; padding-bottom: 2rem; border-bottom: 1px solid var(--border); }
.automation-add h3, .modal-body h3 { font-size: 0.9rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 1rem; }

.automation-item {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.85rem 1rem;
    margin-bottom: 0.6rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.automation-item--inactive { opacity: 0.5; }

.auto-keyword-badge {
    background: rgba(108,99,255,0.2);
    color: var(--accent);
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    font-family: monospace;
}

.auto-details { flex: 1; min-width: 0; }
.auto-msg { font-size: 0.82rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 0.2rem; }
.auto-limit { font-size: 0.75rem; color: var(--text-muted); }

.auto-actions { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }

/* TOAST */
.toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1.25rem;
    font-size: 0.875rem;
    z-index: 9999;
    transition: opacity 0.3s;
}

.toast.hidden { opacity: 0; pointer-events: none; }
.toast--success { border-color: var(--success); color: var(--success); }
.toast--error { border-color: var(--danger); color: var(--danger); }

/* VARIANTS */
.variants-generate-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    background: rgba(108,99,255,0.08);
    border: 1px solid rgba(108,99,255,0.3);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
}

.variant-add-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.variant-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
}

.variant-num {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    background: var(--surface2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
}

.variant-text {
    flex: 1;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--text);
}

.variant-actions {
    display: flex;
    gap: 0.35rem;
    flex-shrink: 0;
}

/* UTIL */
.loading { color: var(--text-muted); padding: 2rem; text-align: center; }
.empty-state { color: var(--text-muted); padding: 2rem; text-align: center; font-size: 0.9rem; }

@media (max-width: 600px) {
    .tab-content { padding: 1rem; }
    .stats-overview { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .accounts-grid { grid-template-columns: 1fr; }
    .topbar { padding: 0 1rem; }
}
