* { box-sizing: border-box; }
body { font-family: system-ui, -apple-system, sans-serif; margin: 0; background: #f5f5f5; color: #1a1a1a; line-height: 1.5; }
.header { background: #1a1a2e; color: #eee; padding: 0.75rem 1.5rem; display: flex; justify-content: space-between; align-items: center; }
.header a { color: #eee; text-decoration: none; }
.header a:hover { text-decoration: underline; }
.logo { font-weight: 700; font-size: 1.1rem; }
.header nav { display: flex; align-items: center; gap: 1rem; }
.user-email { font-size: 0.9rem; color: #aaa; }
.inline-form { display: inline; margin: 0; }
.header button { background: transparent; color: #eee; border: 1px solid #555; padding: 0.35rem 0.75rem; cursor: pointer; border-radius: 4px; font-size: 0.9rem; }
.header button:hover { background: #333; }
.main { max-width: 900px; margin: 0 auto; padding: 1.5rem; }
.alert { padding: 0.75rem 1rem; border-radius: 6px; margin-bottom: 1rem; }
.alert-success { background: #d4edda; color: #155724; }
.alert-error { background: #f8d7da; color: #721c24; }
.auth-box { max-width: 380px; margin: 2rem auto; background: #fff; padding: 2rem; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.auth-box h1 { margin-top: 0; font-size: 1.5rem; }
.auth-form label { display: block; margin-bottom: 1rem; }
.auth-form input { width: 100%; padding: 0.5rem 0.75rem; border: 1px solid #ccc; border-radius: 4px; font-size: 1rem; }
.auth-form button { width: 100%; padding: 0.6rem; background: #1a1a2e; color: #fff; border: none; border-radius: 4px; font-size: 1rem; cursor: pointer; }
.auth-form button:hover { background: #16213e; }
.auth-box p { margin-top: 1rem; text-align: center; }
.dashboard { display: flex; flex-direction: column; gap: 2rem; }
.connections-section h2, .chat-section h2 { margin-top: 0; font-size: 1.25rem; }
.card { background: #fff; padding: 1.25rem; border-radius: 8px; box-shadow: 0 2px 6px rgba(0,0,0,0.06); }
.connection-form h3 { margin-top: 0; font-size: 1rem; }
.form-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.connection-form label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.9rem; }
.connection-form input { padding: 0.45rem 0.6rem; border: 1px solid #ccc; border-radius: 4px; }
.connection-form select { padding: 0.45rem 0.6rem; border: 1px solid #ccc; border-radius: 4px; }
.connection-form button { padding: 0.5rem 1rem; background: #1a1a2e; color: #fff; border: none; border-radius: 4px; cursor: pointer; }
.connection-list { list-style: none; padding: 0; margin: 0.5rem 0 0; display: flex; flex-direction: column; gap: 0.5rem; }
.connection-item { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.connection-item .conn-detail { color: #666; font-size: 0.9rem; }
.connection-actions { margin-left: auto; display: flex; align-items: center; gap: 0.5rem; }
.btn-chat { display: inline-block; padding: 0.35rem 0.7rem; border-radius: 4px; background: #1a1a2e; color: #fff; text-decoration: none; font-size: 0.85rem; }
.btn-chat:hover { background: #16213e; }
.btn-danger { background: #dc3545; color: #fff; border: none; padding: 0.35rem 0.6rem; border-radius: 4px; cursor: pointer; font-size: 0.85rem; }
.btn-danger:hover { background: #c82333; }
.muted { color: #666; font-size: 0.95rem; }
.chat-card label { display: block; margin-bottom: 0.75rem; }
#connection-select { padding: 0.5rem; border: 1px solid #ccc; border-radius: 4px; min-width: 200px; }
.chat-history { max-height: 320px; overflow-y: auto; padding: 0.5rem 0; border-top: 1px solid #eee; border-bottom: 1px solid #eee; margin: 0.75rem 0 1rem; display: flex; flex-direction: column; gap: 0.5rem; }
.chat-message { display: inline-block; max-width: 80%; padding: 0.45rem 0.6rem; border-radius: 10px; font-size: 0.95rem; line-height: 1.4; }
.chat-message.user { align-self: flex-end; background: #1a1a2e; color: #fff; border-bottom-right-radius: 2px; }
.chat-message.assistant { align-self: flex-start; background: #f1f3f5; color: #1a1a1a; border-bottom-left-radius: 2px; }
.chat-input-row { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
#question-input { flex: 1; padding: 0.6rem 0.75rem; border: 1px solid #ccc; border-radius: 4px; font-size: 1rem; }
#ask-btn { padding: 0.6rem 1.25rem; background: #1a1a2e; color: #fff; border: none; border-radius: 4px; cursor: pointer; font-size: 1rem; }
#ask-btn:hover { background: #16213e; }
#ask-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.answer-area { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid #eee; }
.answer-text { font-size: 1.05rem; margin-bottom: 1rem; white-space: pre-wrap; }
.answer-table { border-collapse: collapse; margin-top: 0.5rem; font-size: 0.9rem; }
.answer-table th, .answer-table td { border: 1px solid #ddd; padding: 0.4rem 0.6rem; text-align: left; }
.answer-table th { background: #f5f5f5; }
.sql-details, .result-details { margin-top: 0.75rem; }
.sql-details summary, .result-details summary { cursor: pointer; font-weight: 500; }
#sql-preview { background: #f8f8f8; padding: 1rem; border-radius: 4px; overflow-x: auto; font-family: ui-monospace, monospace; font-size: 0.9rem; margin: 0.5rem 0 0; }
.table-wrap { overflow-x: auto; margin-top: 0.5rem; }
#result-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
#result-table th, #result-table td { border: 1px solid #ddd; padding: 0.4rem 0.6rem; text-align: left; }
#result-table th { background: #f5f5f5; }
.hidden { display: none !important; }
.loading { color: #666; font-style: italic; margin-top: 0.5rem; }
.settings-page h1 { margin-top: 0; }
.settings-card { max-width: 520px; }
.settings-card h2 { margin-top: 0; font-size: 1.1rem; }
.settings-form label { display: block; margin-bottom: 0.5rem; font-weight: 500; }
.settings-form input[type="password"] { width: 100%; max-width: 400px; padding: 0.5rem 0.75rem; border: 1px solid #ccc; border-radius: 4px; font-size: 1rem; }
.form-hint { font-size: 0.9rem; color: #666; margin: 0.5rem 0 1rem; }
.form-hint a { color: #1a1a2e; }
.form-actions { display: flex; gap: 0.75rem; margin-top: 1rem; }
.form-actions button { padding: 0.5rem 1rem; background: #1a1a2e; color: #fff; border: none; border-radius: 4px; cursor: pointer; font-size: 0.95rem; }
.form-actions button:hover { background: #16213e; }
.btn-secondary { background: #6c757d !important; }
.btn-secondary:hover { background: #5a6268 !important; }
.migration-cmd { background: #f8f8f8; padding: 1rem; border-radius: 4px; overflow-x: auto; font-size: 0.9rem; margin: 0.5rem 0 0; }
