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

:root {
    --bg: #0d1117;
    --surface: #161b22;
    --border: #30363d;
    --text: #e6edf3;
    --text-dim: #8b949e;
    --accent: #58a6ff;
    --accent-dim: #1f6feb;
    --green: #3fb950;
    --red: #f85149;
    --orange: #d29922;
}

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

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Header */
header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

header h1 {
    font-size: 18px;
    font-weight: 600;
    color: var(--accent);
}

nav { display: flex; gap: 4px; }

.tab {
    background: none;
    border: 1px solid transparent;
    color: var(--text-dim);
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
}

.tab:hover { color: var(--text); background: var(--border); }
.tab.active { color: var(--text); background: var(--accent-dim); border-color: var(--accent); }

.status {
    margin-left: auto;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 12px;
}

.status.connected { background: #0d2818; color: var(--green); }
.status.disconnected { background: #2d1215; color: var(--red); }

/* Screens */
main { flex: 1; overflow: hidden; }
.screen { display: none; height: 100%; }
.screen.active { display: flex; flex-direction: column; }
.hidden { display: none !important; }

/* Auth */
.auth-box {
    margin: auto;
    padding: 32px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    text-align: center;
    min-width: 320px;
}

.auth-box h2 { margin-bottom: 16px; font-size: 16px; }

.auth-box input {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 14px;
    margin-bottom: 12px;
}

.auth-box button {
    width: 100%;
    padding: 10px;
    background: var(--accent-dim);
    color: var(--text);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
}

.auth-box button:hover { background: var(--accent); }
.error { color: var(--red); font-size: 12px; margin-top: 8px; }

/* Chat */
#chat-screen { display: none; }
#chat-screen.active { display: flex; }

#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}

.msg {
    max-width: 70%;
    padding: 10px 14px;
    margin-bottom: 8px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.msg.user {
    margin-left: auto;
    background: var(--accent-dim);
    border-bottom-right-radius: 4px;
}

.msg.otto {
    margin-right: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

.msg .time {
    font-size: 10px;
    color: var(--text-dim);
    margin-top: 4px;
}

.msg.typing {
    color: var(--text-dim);
    font-style: italic;
}

#chat-input-bar {
    display: flex;
    gap: 8px;
    padding: 12px 20px;
    background: var(--surface);
    border-top: 1px solid var(--border);
}

#chat-input {
    flex: 1;
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 120px;
}

#chat-input:focus { outline: none; border-color: var(--accent); }

#send-btn {
    padding: 10px 20px;
    background: var(--accent-dim);
    color: var(--text);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
}

#send-btn:hover { background: var(--accent); }
#send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Dashboard */
#dashboard-screen { overflow-y: auto; padding: 20px; }
#dashboard-screen.active { display: block; }

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
}

.card.wide { grid-column: 1 / -1; }

.card h3 {
    font-size: 13px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.card-content { font-size: 14px; line-height: 1.6; }

.stat { display: flex; justify-content: space-between; padding: 4px 0; }
.stat .label { color: var(--text-dim); }
.stat .value { font-weight: 600; }

.pq-item {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.pq-item:last-child { border-bottom: none; }
.pq-item .intent { font-size: 11px; color: var(--accent); text-transform: uppercase; }
.pq-item .question { font-size: 13px; margin-top: 2px; }

.hb-item {
    padding: 6px 0;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
}

.hb-item:last-child { border-bottom: none; }
.hb-item .time { color: var(--text-dim); font-size: 11px; }

.msg-item {
    display: flex;
    gap: 8px;
    padding: 6px 0;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
}

.msg-item:last-child { border-bottom: none; }
.msg-item .dir { font-size: 11px; min-width: 24px; }
.msg-item .dir.in { color: var(--green); }
.msg-item .dir.out { color: var(--accent); }
.msg-item .ch { color: var(--text-dim); font-size: 11px; min-width: 60px; }
.msg-item .text { flex: 1; }

/* Responsive */
@media (max-width: 600px) {
    .msg { max-width: 90%; }
    .dashboard-grid { grid-template-columns: 1fr; }
    header { flex-wrap: wrap; }
}
