:root {
    --bg: #f4f7f5;
    --bg-card: #ffffff;
    --text: #1e2d24;
    --text-muted: #5a6b5f;
    --border: #d4ddd6;
    --sidebar-bg: #1b2e22;
    --sidebar-text: rgba(255,255,255,.72);
    --sidebar-active: rgba(100,200,120,.12);
    --accent: #3d9960;
    --accent-light: #e8f5ec;
}
.dark-mode {
    --bg: #0f1a14;
    --bg-card: #162119;
    --text: #d8e4dc;
    --text-muted: #7a9985;
    --border: #243a2b;
    --sidebar-bg: #0a140e;
    --sidebar-text: rgba(255,255,255,.6);
    --sidebar-active: rgba(100,200,120,.1);
    --accent: #4db870;
    --accent-light: #1a2e20;
}
body {
    background-color: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-color .3s, color .3s;
}
.card {
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
    background-color: var(--bg-card);
    color: var(--text);
}
.dark-mode .card {
    box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.dark-mode .table {
    color: var(--text);
    --bs-table-bg: transparent;
    --bs-table-hover-bg: rgba(255,255,255,.04);
}
.dark-mode .table-striped > tbody > tr:nth-of-type(odd) > * {
    --bs-table-bg: rgba(255,255,255,.02);
}
.dark-mode .form-control, .dark-mode .form-select {
    background-color: #1a1a2e;
    border-color: var(--border);
    color: var(--text);
}
.dark-mode .form-control:focus {
    background-color: #1a1a2e;
    color: var(--text);
}
.dark-mode .badge {
    opacity: .9;
}
.dark-mode .text-muted { color: var(--text-muted) !important; }
.dark-mode .text-secondary { color: var(--text-muted) !important; }
.dark-mode .text-dark { color: var(--text) !important; }
.dark-mode .bg-light { background-color: var(--bg-card) !important; }
.navbar-brand {
    font-weight: 700;
}
.api-key-display {
    user-select: all;
    font-size: .85em;
}
.model-tag {
    background: var(--accent-light);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: .85em;
    margin-right: 4px;
    color: var(--accent);
}
.dark-mode .model-tag {
    background: rgba(77,184,112,.12);
    color: var(--accent);
}
main { flex: 1; }
.has-sidebar main { flex: 1; }
code {
    color: #d63384;
}
.dark-mode code {
    color: #e689b8;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 56px;
    left: 0;
    bottom: 0;
    width: 220px;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    z-index: 1030;
    transition: transform .3s;
    overflow-y: auto;
}
.sidebar-nav {
    flex: 1;
    padding: .75rem 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: .6rem 1.25rem;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: .9rem;
    transition: background .15s, color .15s;
    border-radius: 0;
}
.sidebar-link:hover {
    background: var(--sidebar-active);
    color: #fff;
}
.sidebar-link.active {
    background: var(--sidebar-active);
    color: #8fe8a8;
    font-weight: 600;
}
.sidebar-link svg {
    flex-shrink: 0;
    opacity: .8;
}
.sidebar-link.active svg,
.sidebar-link:hover svg {
    opacity: 1;
}
.sidebar-footer {
    padding: .75rem 0;
    border-top: 1px solid rgba(255,255,255,.1);
}
.theme-toggle {
    width: 100%;
    border: none;
    background: none;
    cursor: pointer;
    text-align: left;
}

/* Green accent */
.navbar-dark.bg-dark {
    background-color: #162119 !important;
}
.btn-primary {
    background-color: var(--accent);
    border-color: var(--accent);
}
.btn-primary:hover {
    background-color: #2e8a4e;
    border-color: #2e8a4e;
}
.badge.bg-success {
    background-color: var(--accent) !important;
}
a {
    color: var(--accent);
}
a:hover {
    color: #2e8a4e;
}
.dark-mode .navbar-dark.bg-dark {
    background-color: #0a140e !important;
}

/* Main content with sidebar */
.main-with-sidebar {
    margin-left: 220px;
    padding: 1.5rem 2rem;
    max-width: 100%;
}

/* Mobile sidebar */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,.5);
    z-index: 1029;
}
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar-open .sidebar {
        transform: translateX(0);
    }
    .sidebar-open .sidebar-overlay {
        display: block;
    }
    .main-with-sidebar {
        margin-left: 0;
        padding: 1rem;
    }
}
