* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #0f0f0f;
    color: #e0e0e0;
    min-height: 100vh;
}

/* ── Header + Tabs ─────────────────────────────────────────────────── */

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: #1a1a1a;
    border-bottom: 1px solid #2a2a2a;
}

header h1 {
    font-size: 20px;
    color: #00b4d8;
}

.tabs { display: flex; gap: 8px; }

.tab {
    padding: 8px 18px;
    border-radius: 6px;
    border: 1px solid #333;
    background: #222;
    color: #ccc;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
}

.tab:hover { background: #2a2a2a; }
.tab.active { background: #00b4d8; color: #000; border-color: #00b4d8; }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Stats Bar ─────────────────────────────────────────────────────── */

.stats-bar {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 12px 24px;
    background: #141414;
    border-bottom: 1px solid #2a2a2a;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 60px;
}

.stat-value {
    font-size: 22px;
    font-weight: 700;
    color: #e0e0e0;
}

.stat-label {
    font-size: 11px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

.stat-live { color: #4caf50; }
.stat-offline { color: #888; }
.stat-bomb { color: #e74c3c; }
.stat-convos { color: #00b4d8; }
.stat-replied { color: #ff9800; }
.stat-telegrams { color: #4caf50; }

.stat-sep {
    width: 1px;
    height: 36px;
    background: #333;
}

/* ── Create Panel ──────────────────────────────────────────────────── */

.create-panel {
    padding: 20px 24px;
    background: #141414;
    border-bottom: 1px solid #2a2a2a;
}

.create-panel h2 {
    font-size: 16px;
    color: #00b4d8;
    margin-bottom: 12px;
}

.create-form {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}

.create-form label {
    display: block;
    font-size: 13px;
    color: #999;
}

.create-form input, .create-form select {
    display: block;
    margin-top: 4px;
    padding: 7px 10px;
    background: #111;
    border: 1px solid #333;
    border-radius: 6px;
    color: #e0e0e0;
    font-size: 14px;
    width: 140px;
}

.create-form input:focus, .create-form select:focus {
    outline: none;
    border-color: #00b4d8;
}

.create-form button {
    padding: 8px 20px;
    border-radius: 6px;
    border: none;
    background: #00b4d8;
    color: #000;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
}

.create-form button:hover { background: #0096b7; }
.btn-clear { background: #c0392b; color: #fff; border: none; padding: 6px 14px; border-radius: 6px; cursor: pointer; font-size: .85rem; }
.btn-clear:hover { background: #e74c3c; }
.checkbox-label { flex-direction: row; align-items: center; gap: 8px; }
.checkbox-label input[type="checkbox"] { width: auto; margin: 0; }

/* ── Account Cards ─────────────────────────────────────────────────── */

main {
    padding: 24px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 16px;
}

.card {
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 10px;
    padding: 16px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.card-header h3 {
    font-size: 16px;
    color: #fff;
}

.card-header h3 span {
    color: #888;
    font-weight: 400;
    font-size: 13px;
    margin-left: 6px;
}

.badge {
    font-size: 12px;
    padding: 3px 10px;
    border-radius: 12px;
    font-weight: 600;
}

.badge.live { background: #1a3a1a; color: #4caf50; }
.badge.offline { background: #2a2020; color: #888; }

.status-line {
    font-size: 13px;
    color: #aaa;
    margin-bottom: 8px;
    min-height: 18px;
}

.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.controls button {
    padding: 6px 14px;
    border-radius: 6px;
    border: 1px solid #333;
    background: #222;
    color: #ccc;
    cursor: pointer;
    font-size: 13px;
}

.controls button:hover { background: #2a2a2a; border-color: #444; }
.controls button.active { background: #00b4d8; color: #000; border-color: #00b4d8; }

.info-row {
    font-size: 12px;
    color: #777;
    margin-bottom: 8px;
}

.log-toggle {
    font-size: 12px;
    color: #666;
    cursor: pointer;
    user-select: none;
    margin-top: 8px;
}

.log-toggle:hover { color: #999; }

.log {
    margin-top: 6px;
    max-height: 160px;
    overflow-y: auto;
    font-size: 12px;
    font-family: "Cascadia Code", "Fira Code", monospace;
    color: #888;
    background: #111;
    border-radius: 6px;
    padding: 8px;
    display: none;
}

.log.open { display: block; }
.log div { padding: 1px 0; }

/* ── Conversations Tab ─────────────────────────────────────────────── */

.convo-layout {
    display: flex;
    height: calc(100vh - 120px);
}

.convo-sidebar {
    width: 300px;
    border-right: 1px solid #2a2a2a;
    background: #141414;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 12px;
    border-bottom: 1px solid #2a2a2a;
}

.sidebar-header label {
    font-size: 13px;
    color: #999;
    display: block;
}

.sidebar-header select {
    width: 100%;
    margin-top: 4px;
    padding: 7px 10px;
    background: #111;
    border: 1px solid #333;
    border-radius: 6px;
    color: #e0e0e0;
    font-size: 14px;
}

.sidebar-header select:focus {
    outline: none;
    border-color: #00b4d8;
}

.convo-list {
    flex: 1;
    overflow-y: auto;
}

.convo-item {
    padding: 10px 12px;
    border-bottom: 1px solid #1e1e1e;
    cursor: pointer;
    font-size: 13px;
}

.convo-item:hover { background: #1a1a1a; }
.convo-item.active { background: #1a2a3a; border-left: 3px solid #00b4d8; }

.convo-item .convo-name {
    color: #fff;
    font-weight: 600;
    margin-bottom: 2px;
}

.convo-item .convo-preview {
    color: #777;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.convo-item .convo-meta {
    font-size: 11px;
    color: #555;
    margin-top: 2px;
}

.convo-item .telegram-badge {
    display: inline-block;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 8px;
    background: #1a3a1a;
    color: #4caf50;
    margin-left: 6px;
}

/* ── Chat View ─────────────────────────────────────────────────────── */

.convo-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #0f0f0f;
}

.chat-header {
    padding: 12px 16px;
    border-bottom: 1px solid #2a2a2a;
    font-size: 15px;
    color: #ccc;
    background: #1a1a1a;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.msg-bubble {
    max-width: 65%;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

.msg-bubble.them {
    align-self: flex-start;
    background: #1e1e1e;
    color: #e0e0e0;
    border-bottom-left-radius: 4px;
}

.msg-bubble.me {
    align-self: flex-end;
    background: #00b4d8;
    color: #000;
    border-bottom-right-radius: 4px;
}

.msg-time {
    font-size: 10px;
    color: #555;
    margin-top: 2px;
}

.msg-bubble.me .msg-time { color: rgba(0,0,0,0.5); }

.chat-input {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid #2a2a2a;
    background: #1a1a1a;
}

.chat-input input {
    flex: 1;
    padding: 8px 12px;
    background: #111;
    border: 1px solid #333;
    border-radius: 6px;
    color: #e0e0e0;
    font-size: 14px;
}

.chat-input input:focus {
    outline: none;
    border-color: #00b4d8;
}

.chat-input button {
    padding: 8px 18px;
    border-radius: 6px;
    border: none;
    background: #00b4d8;
    color: #000;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
}

.chat-input button:hover { background: #0096b7; }

/* ── Modals ────────────────────────────────────────────────────────── */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 100;
    justify-content: center;
    align-items: center;
}

.modal-overlay.open { display: flex; }

.modal {
    background: #1e1e1e;
    border: 1px solid #333;
    border-radius: 12px;
    padding: 24px;
    width: 380px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal.modal-wide { width: 520px; }

.modal h2 {
    font-size: 18px;
    margin-bottom: 16px;
    color: #00b4d8;
}

.modal h3 {
    font-size: 14px;
    margin-bottom: 8px;
    color: #ccc;
}

.modal label {
    display: block;
    font-size: 13px;
    color: #999;
    margin-bottom: 12px;
}

.modal input, .modal select, .modal textarea {
    display: block;
    width: 100%;
    margin-top: 4px;
    padding: 8px 10px;
    background: #111;
    border: 1px solid #333;
    border-radius: 6px;
    color: #e0e0e0;
    font-size: 14px;
}

.modal input:focus, .modal select:focus, .modal textarea:focus {
    outline: none;
    border-color: #00b4d8;
}

.modal textarea {
    font-family: inherit;
    resize: vertical;
}

.modal hr {
    border: none;
    border-top: 1px solid #333;
    margin: 16px 0;
}

.modal-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.modal-actions button {
    padding: 8px 16px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    background: #00b4d8;
    color: #000;
}

.modal-actions button:hover { background: #0096b7; }
.modal-actions button.secondary { background: #333; color: #ccc; }
.modal-actions button.secondary:hover { background: #444; }
.modal-actions button.danger { background: #8b0000; color: #fff; }
.modal-actions button.danger:hover { background: #a00; }

.funnel-item {
    padding: 8px;
    margin-bottom: 6px;
    background: #151515;
    border-radius: 6px;
    font-size: 13px;
}

.funnel-item strong { color: #00b4d8; }

/* ── Footer ────────────────────────────────────────────────────────── */

footer {
    padding: 16px 24px;
    text-align: center;
    display: flex;
    justify-content: center;
    gap: 12px;
}

footer button {
    padding: 6px 14px;
    border-radius: 6px;
    border: 1px solid #333;
    background: #222;
    color: #ccc;
    cursor: pointer;
    font-size: 13px;
}

footer button:hover { background: #2a2a2a; }

/* ── Empty state ───────────────────────────────────────────────────── */

.empty {
    text-align: center;
    color: #555;
    padding: 60px 20px;
    font-size: 15px;
    grid-column: 1 / -1;
}
