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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    font-size: 13px;
    color: #1a1a1a;
    background: #f5f5f5;
    height: 100vh;
    overflow: hidden;
}

.layout {
    display: flex;
    height: 100vh;
}

.sidebar {
    width: 280px;
    min-width: 280px;
    background: #fff;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar h2 {
    padding: 12px 14px 8px;
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

#table-search {
    margin: 0 10px 8px;
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
    outline: none;
}

#table-search:focus {
    border-color: #4a90d9;
    box-shadow: 0 0 0 2px rgba(74, 144, 217, 0.15);
}

#table-list {
    overflow-y: auto;
    flex: 1;
    padding-bottom: 20px;
}

.group-header {
    padding: 7px 14px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: #666;
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 6px;
    background: #fafafa;
    border-top: 1px solid #eee;
}

.group-header:hover { background: #f0f0f0; }

.arrow { font-size: 8px; color: #999; }

.badge {
    background: #e8e8e8;
    color: #666;
    padding: 1px 6px;
    border-radius: 8px;
    font-size: 10px;
    margin-left: auto;
}

.group-body { display: block; }

.table-item {
    padding: 6px 14px 6px 24px;
    cursor: pointer;
    border-bottom: 1px solid #f5f5f5;
}

.table-item:hover { background: #f0f7ff; }

.table-name {
    font-size: 12px;
    font-weight: 500;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.table-meta {
    font-size: 11px;
    color: #999;
    margin-top: 1px;
}

.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 12px 16px;
    gap: 10px;
}

.query-section h3, .results-section h3 {
    font-size: 13px;
    font-weight: 600;
    color: #444;
    margin-bottom: 6px;
}

#sql-editor {
    width: 100%;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 13px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    resize: vertical;
    outline: none;
    background: #fafafa;
    line-height: 1.5;
    tab-size: 2;
}

#sql-editor:focus {
    border-color: #4a90d9;
    box-shadow: 0 0 0 2px rgba(74, 144, 217, 0.15);
}

.query-actions {
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 12px;
}

button {
    padding: 6px 16px;
    background: #4a90d9;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
}

button:hover { background: #3a7bc8; }

#query-status {
    font-size: 12px;
}

#query-status.running { color: #999; }
#query-status.success { color: #2d8a4e; }
#query-status.error { color: #c0392b; }

.results-section {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.table-wrapper {
    flex: 1;
    overflow: auto;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
}

table {
    border-collapse: collapse;
    width: 100%;
    font-size: 12px;
}

th {
    position: sticky;
    top: 0;
    background: #f7f7f7;
    border-bottom: 2px solid #ddd;
    padding: 6px 10px;
    text-align: left;
    font-weight: 600;
    color: #555;
    white-space: nowrap;
}

td {
    padding: 4px 10px;
    border-bottom: 1px solid #f0f0f0;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

tr:hover td { background: #f8f9fa; }

.null { color: #ccc; font-style: italic; }

.dir-views-header {
    background: #e8f0fe;
    color: #1a73e8;
    border-top: 2px solid #c5d9f5;
}

.dir-view {
    background: #f8fbff;
    border-left: 3px solid #4a90d9;
}

.dir-view .table-name {
    font-weight: 600;
    color: #1a73e8;
}
