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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: #f5f7fa;
    color: #333;
    line-height: 1.6;
}

.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-box {
    background: white;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
}

.auth-box h1 {
    margin-bottom: 24px;
    text-align: center;
    color: #1a73e8;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #1a73e8;
    box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.2);
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-primary {
    background-color: #1a73e8;
    color: white;
    width: 100%;
}

.btn-primary:hover {
    background-color: #1557b0;
}

.btn-secondary {
    background-color: #f1f3f4;
    color: #333;
}

.btn-secondary:hover {
    background-color: #e8eaed;
}

.btn-success {
    background-color: #34a853;
    color: white;
}

.btn-success:hover {
    background-color: #2d8b47;
}

.btn-danger {
    background-color: #ea4335;
    color: white;
}

.btn-danger:hover {
    background-color: #c5221f;
}

.alert {
    padding: 12px 16px;
    border-radius: 4px;
    margin-bottom: 20px;
}

.alert-error {
    background-color: #fce8e6;
    color: #c5221f;
    border: 1px solid #f5c6cb;
}

.alert-success {
    background-color: #e6f4ea;
    color: #137333;
    border: 1px solid #c3e6cb;
}

.auth-link {
    text-align: center;
    margin-top: 20px;
    color: #666;
}

.auth-link a {
    color: #1a73e8;
    text-decoration: none;
}

.auth-link a:hover {
    text-decoration: underline;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.header {
    background: white;
    padding: 16px 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.home-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: #f0f7ff;
    border-radius: 8px;
    color: #4A90A4;
    text-decoration: none;
    transition: background-color 0.2s, color 0.2s;
}

.home-icon:hover {
    background: #4A90A4;
    color: white;
}

.header h1 {
    color: #1a73e8;
    font-size: 24px;
}

.header-nav {
    display: flex;
    gap: 16px;
    align-items: center;
}

.header-nav a {
    color: #666;
    text-decoration: none;
}

.header-nav a:hover {
    color: #1a73e8;
}

.main-content {
    padding: 24px;
}

.query-section {
    background: white;
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-bottom: 24px;
}

.query-section h2 {
    margin-bottom: 16px;
    color: #333;
}

.query-input {
    width: 100%;
    min-height: 100px;
    padding: 16px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    resize: vertical;
    font-family: inherit;
}

.query-input:focus {
    outline: none;
    border-color: #1a73e8;
    box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.2);
}

.query-actions {
    margin-top: 16px;
    display: flex;
    gap: 12px;
}

.results-section {
    background: white;
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.results-section h2 {
    margin-bottom: 16px;
    color: #333;
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 16px;
}

.results-table th,
.results-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.results-table th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: #333;
}

.results-table tr:hover {
    background-color: #f8f9fa;
}

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: #666;
}

.loading::before {
    content: '';
    width: 24px;
    height: 24px;
    border: 3px solid #ddd;
    border-top-color: #1a73e8;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 12px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.saved-queries {
    background: white;
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-top: 24px;
}

.saved-queries h2 {
    margin-bottom: 16px;
    color: #333;
}

.saved-query-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border: 1px solid #eee;
    border-radius: 4px;
    margin-bottom: 8px;
}

.saved-query-item:hover {
    background-color: #f8f9fa;
}

.saved-query-name {
    font-weight: 500;
}

.saved-query-actions {
    display: flex;
    gap: 8px;
}

.btn-small {
    padding: 6px 12px;
    font-size: 14px;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    padding: 24px;
    border-radius: 8px;
    width: 100%;
    max-width: 500px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
}

.sidebar {
    position: fixed;
    left: 0;
    top: 60px;
    width: 280px;
    height: calc(100vh - 60px);
    background: white;
    border-right: 1px solid #eee;
    padding: 20px;
    overflow-y: auto;
}

.main-with-sidebar {
    margin-left: 280px;
    padding: 24px;
}

.thinking-indicator {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 4px;
    padding: 12px 16px;
    margin-bottom: 16px;
    display: none;
}

.thinking-indicator.active {
    display: block;
}

.error-message {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    padding: 12px 16px;
    color: #721c24;
    margin-bottom: 16px;
}

.api-calls-info {
    background: #e7f3ff;
    border: 1px solid #b8daff;
    border-radius: 4px;
    padding: 12px 16px;
    margin-bottom: 16px;
    font-size: 14px;
}

.export-actions {
    margin-top: 16px;
    display: flex;
    gap: 8px;
}

.console-section {
    background: #1e1e1e;
    border-radius: 8px;
    margin-bottom: 24px;
    overflow: hidden;
}

.console-header {
    background: #333;
    color: #fff;
    padding: 8px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
}

.console-output {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    color: #d4d4d4;
    padding: 12px 16px;
    height: 200px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.console-output .log-time {
    color: #6a9955;
}

.console-output .log-info {
    color: #9cdcfe;
}

.console-output .log-success {
    color: #4ec9b0;
}

.console-output .log-error {
    color: #f14c4c;
}

.console-output .log-warning {
    color: #dcdcaa;
}

.console-output .log-ai {
    color: #ce9178;
}

.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
    margin-left: 8px;
}

.btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.results-header h2 {
    margin: 0;
}

.debug-section {
    background: #2d2d2d;
    border-radius: 8px;
    margin-top: 24px;
    overflow: hidden;
}

.debug-header {
    background: #404040;
    color: #fff;
    padding: 12px 16px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
}

.debug-header:hover {
    background: #4a4a4a;
}

.debug-content {
    padding: 16px;
    color: #d4d4d4;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    max-height: 500px;
    overflow-y: auto;
}

.debug-block {
    margin-bottom: 20px;
}

.debug-block h4 {
    color: #9cdcfe;
    margin: 0 0 10px 0;
    font-size: 14px;
    border-bottom: 1px solid #555;
    padding-bottom: 5px;
}

.debug-block pre {
    background: #1e1e1e;
    padding: 12px;
    border-radius: 4px;
    overflow-x: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    margin: 0;
    max-height: 200px;
    overflow-y: auto;
}

.debug-call {
    background: #1e1e1e;
    border-radius: 4px;
    margin-bottom: 12px;
    overflow: hidden;
}

.debug-call-header {
    padding: 10px 12px;
    font-size: 13px;
}

.debug-call-header.debug-success {
    background: #1e3a1e;
    border-left: 3px solid #4ec9b0;
}

.debug-call-header.debug-error {
    background: #3a1e1e;
    border-left: 3px solid #f14c4c;
}

.debug-details {
    padding: 12px;
    border-top: 1px solid #333;
}

.debug-details > div {
    margin-bottom: 8px;
}

.debug-error-text {
    color: #f14c4c;
}

.debug-response {
    background: #161616 !important;
    font-size: 12px;
    max-height: 150px;
}

.main-content.with-sidebar {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 24px;
    align-items: start;
}

.content-area {
    min-width: 0;
}

.sidebar {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    padding: 16px;
    position: sticky;
    top: 24px;
}

.sidebar-section {
    margin-bottom: 20px;
}

.sidebar-section:last-child {
    margin-bottom: 0;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.sidebar-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin: 0;
}

.view-all-link {
    font-size: 12px;
    color: #4A90A4;
    text-decoration: none;
}

.view-all-link:hover {
    text-decoration: underline;
}

.conversation-list-sidebar {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 400px;
    overflow-y: auto;
}

.sidebar-conv-item {
    padding: 10px 12px;
    background: #f5f5f5;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.sidebar-conv-item:hover {
    background: #e8e8e8;
}

.sidebar-conv-item.active {
    background: #e3f2fd;
    border-left: 3px solid #4A90A4;
}

.conv-title {
    font-size: 13px;
    font-weight: 500;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-meta {
    font-size: 11px;
    color: #888;
    margin-top: 2px;
}

.no-items {
    font-size: 13px;
    color: #888;
    padding: 12px;
    text-align: center;
}

.btn-block {
    width: 100%;
    display: block;
}

.current-conv-info {
    background: #f0f7ff;
    border-radius: 6px;
    padding: 12px;
}

.current-conv-info h4 {
    font-size: 12px;
    color: #666;
    margin-bottom: 6px;
}

#currentConvTitle {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    margin-bottom: 8px;
    word-break: break-word;
}

@media (max-width: 900px) {
    .main-content.with-sidebar {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        position: static;
        order: -1;
    }
}
