:root {
    --bg-main: #0d1117;
    --bg-panel: #161b22;
    --bg-chat: #1c2128;
    --bg-bot-msg: #21262d;
    --bg-user-msg: #1f6feb;
    --bg-log-request: #1a1f2e;
    --bg-log-response: #0d2818;
    --bg-log-error: #3d1111;
    --bg-log-system: #1a1a2e;
    --text-main: #e6edf3;
    --text-dim: #8b949e;
    --text-bot: #e6edf3;
    --text-user: #ffffff;
    --accent: #f7931a;
    --border: #30363d;
    --green: #3fb950;
    --red: #f85149;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --mono: 'SF Mono', Monaco, Consolas, monospace;
}

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

body {
    font-family: var(--font);
    background: var(--bg-main);
    color: var(--text-main);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

.app {
    display: flex;
    height: 100vh;
    height: 100dvh;
}

/* ═══ ЧАТ-ПАНЕЛЬ ═══ */
.chat-panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
    flex: 0 0 35%;
    border-right: 1px solid var(--border);
    background: var(--bg-panel);
}

.chat-header {
    padding: 12px 16px;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.chat-header h2 {
    font-size: 15px;
    font-weight: 600;
    color: var(--accent);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
    scroll-behavior: smooth;
}

.message {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
}

.message.bot {
    align-self: flex-start;
    background: var(--bg-bot-msg);
    color: var(--text-bot);
    border-bottom-left-radius: 2px;
}

.message.user {
    align-self: flex-end;
    background: var(--bg-user-msg);
    color: var(--text-user);
    border-bottom-right-radius: 2px;
}

.message.bot table {
    border-collapse: collapse;
    width: 100%;
    margin: 8px 0;
    font-size: 13px;
}

.message.bot th, .message.bot td {
    border: 1px solid #444;
    padding: 6px 8px;
    text-align: left;
    white-space: nowrap;
}

.message.bot th { background: #2d333b; font-weight: 600; }
.message.bot tr:nth-child(even) { background: #1c2128; }

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 8px 0;
}

.chat-input-area {
    padding: 12px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
    background: var(--bg-panel);
    flex-shrink: 0;
}

#chatInput {
    flex: 1;
    padding: 10px 12px;
    background: var(--bg-chat);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-main);
    font-size: 14px;
    outline: none;
}

#chatInput:focus { border-color: var(--accent); }

#sendBtn {
    padding: 10px 18px;
    background: var(--accent);
    color: #000;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

#sendBtn:hover { opacity: 0.85; }
#sendBtn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ═══ ПАНЕЛЬ ЛОГОВ ═══ */
.logs-panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
    flex: 1;
    background: var(--bg-main);
}

.logs-header {
    padding: 12px 16px;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.logs-header h2 {
    font-size: 15px;
    font-weight: 600;
    color: var(--accent);
}

.logs-container {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 8px;
    min-height: 0;
}

.log-entry {
    margin-bottom: 6px;
    padding: 8px 12px;
    border-radius: 6px;
    font-family: var(--mono);
    font-size: 12px;
    border-left: 3px solid var(--border);
}

.log-entry.request { background: var(--bg-log-request); border-left-color: #58a6ff; }
.log-entry.response { background: var(--bg-log-response); border-left-color: var(--green); }
.log-entry.error { background: var(--bg-log-error); border-left-color: var(--red); }
.log-entry.system { background: var(--bg-log-system); border-left-color: var(--accent); }

.log-time { color: var(--text-dim); margin-right: 8px; }
.log-level { font-weight: 700; margin-right: 8px; text-transform: uppercase; }
.log-level.request { color: #58a6ff; }
.log-level.response { color: var(--green); }
.log-level.error { color: var(--red); }
.log-level.system { color: var(--accent); }
.log-message { color: var(--text-main); }

.log-data {
    margin-top: 4px;
    padding: 6px 8px;
    background: rgba(0,0,0,0.3);
    border-radius: 4px;
    color: var(--text-dim);
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 200px;
    overflow-y: auto;
}

.clear-btn {
    padding: 4px 10px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 12px;
}

.clear-btn:hover { border-color: var(--text-dim); color: var(--text-main); }

/* ═══ МОБИЛЬНАЯ ВЕРСИЯ ═══ */
@media (max-width: 767px) {
    .app {
        flex-direction: column;
        height: 100dvh;
    }

    .chat-panel {
        width: 100%;
        height: 55%;
        min-height: 0;
        flex: none;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .logs-panel {
        width: 100%;
        height: 45%;
        min-height: 0;
        flex: none;
    }

    .message {
        max-width: 95%;
        font-size: 14px;
        padding: 10px 12px;
    }

    .message.bot table { font-size: 11px; }
    .message.bot th, .message.bot td { padding: 4px 6px; }
}