:root {
    --bg-primary: #0f0f0f;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #252525;
    --bg-hover: #2a2a2a;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --text-muted: #666666;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --accent-subtle: rgba(99, 102, 241, 0.1);
    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;
    --border: #2a2a2a;
    --radius: 12px;
    --radius-sm: 8px;
}

html.theme-light,
body.theme-light {
    --bg-primary: #f6f7fb;
    --bg-secondary: #ffffff;
    --bg-tertiary: #eef1f6;
    --bg-hover: #e3e7ef;
    --text-primary: #111827;
    --text-secondary: #4b5563;
    --text-muted: #7b8494;
    --accent: #4f46e5;
    --accent-hover: #4338ca;
    --accent-subtle: rgba(79, 70, 229, 0.1);
    --success: #15803d;
    --warning: #b45309;
    --error: #dc2626;
    --border: #d9dee8;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    color-scheme: dark;
}

html.theme-light,
body.theme-light {
    color-scheme: light;
}

/* Form Elements */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.form-input {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent);
}

/* Buttons */
.btn-small {
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-edit {
    background: var(--accent-subtle);
    border-color: var(--accent);
    color: var(--accent);
}

.btn-edit:hover {
    background: var(--accent);
    color: white;
}

.btn-delete {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--error);
    color: var(--error);
}

.btn-delete:hover {
    background: var(--error);
    color: white;
}

.btn-cancel {
    background: var(--bg-tertiary);
    border-color: var(--border);
    color: var(--text-secondary);
}

.btn-cancel:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-save {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.btn-save:hover {
    background: var(--accent-hover);
}

.btn-add {
    background: var(--success);
    border-color: var(--success);
    color: white;
}

.btn-add:hover {
    opacity: 0.9;
}

/* Agent Checkbox */
.agent-checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.agent-checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.agent-checkbox:hover {
    border-color: var(--accent);
}

.agent-checkbox.checked {
    background: var(--accent-subtle);
    border-color: var(--accent);
}

.agent-checkbox input {
    display: none;
}

/* User Agent Tags */
.user-agents {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
}

.user-agent-tag {
    font-size: 11px;
    padding: 2px 8px;
    background: var(--accent-subtle);
    border-radius: 10px;
    color: var(--accent);
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Mobile Optimizations */
@media (max-width: 768px) {
    * {
        -webkit-tap-highlight-color: transparent;
        -webkit-touch-callout: none;
    }
    
    body {
        font-size: 16px;
        -webkit-font-smoothing: antialiased;
    }
    
    /* Buttons - larger touch targets */
    .btn-small, .btn-edit, .btn-delete, .btn-cancel, .btn-save, .btn-add {
        min-height: 44px;
        min-width: 44px;
        padding: 12px 16px;
    }
    
    /* Form inputs */
    .form-input {
        font-size: 16px;
        padding: 14px 16px;
    }
    
    /* Admin page mobile */
    .admin-header {
        padding: 16px;
        flex-wrap: wrap;
        gap: 12px;
    }
    
    .admin-header h1 {
        font-size: 18px;
    }
    
    .admin-back-btn {
        padding: 12px 16px;
        width: 100%;
        justify-content: center;
    }
    
    .admin-content {
        padding: 16px;
        gap: 16px;
    }
    
    .admin-section-header {
        padding: 14px 16px;
    }
    
    .admin-section-body {
        padding: 14px 16px;
        max-height: none;
    }
    
    .admin-card {
        flex-wrap: wrap;
        padding: 12px;
    }
    
    .admin-card-actions {
        width: 100%;
        justify-content: flex-end;
        margin-top: 8px;
        padding-top: 8px;
        border-top: 1px solid var(--border);
    }
    
    .admin-card-actions .btn-small {
        flex: 1;
        text-align: center;
    }
    
    /* Agent checkboxes */
    .agent-checkbox-group {
        gap: 10px;
    }
    
    .agent-checkbox {
        padding: 12px 14px;
        font-size: 14px;
    }
    
    /* Emoji picker mobile */
    .emoji-picker {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-height: 50vh;
        border-radius: var(--radius) var(--radius) 0 0;
        padding: 16px;
    }
    
    .emoji-grid {
        grid-template-columns: repeat(6, 1fr);
        gap: 8px;
    }
    
    .emoji-option {
        width: 44px;
        height: 44px;
        font-size: 24px;
    }
    
    /* Scroll behavior */
    .admin-section-body {
        -webkit-overflow-scrolling: touch;
    }
}

/* Extra small screens */
@media (max-width: 480px) {
    .admin-header h1 {
        font-size: 16px;
    }
    
    .admin-section-title {
        font-size: 14px;
    }
    
    .admin-card-info h4 {
        font-size: 13px;
    }
    
    .admin-card-info p {
        font-size: 11px;
    }
}

/* Landscape orientation */
@media (max-height: 500px) and (orientation: landscape) {
    .admin-header {
        padding: 12px 16px;
    }
    
    .admin-section-body {
        max-height: 200px;
    }
}

/* Form Actions */
.form-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 14px;
}

/* Admin Page */
.admin-page {
    min-height: 100vh;
    background:
        radial-gradient(circle at 20% 0%, rgba(99, 102, 241, 0.12), transparent 28%),
        linear-gradient(180deg, #101115 0%, #0b0c0f 100%);
    padding-bottom: 56px;
}

body.theme-light .admin-page {
    background:
        radial-gradient(circle at 20% 0%, rgba(79, 70, 229, 0.1), transparent 28%),
        linear-gradient(180deg, #f7f8fc 0%, #eef1f6 100%);
}

.admin-header {
    padding: 18px 28px;
    background: rgba(18, 19, 24, 0.86);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: blur(18px);
}

body.theme-light .admin-header {
    background: rgba(255, 255, 255, 0.88);
    border-bottom-color: rgba(17, 24, 39, 0.08);
}

.admin-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.admin-brand-mark {
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

body.theme-light .admin-brand-mark {
    background: rgba(17, 24, 39, 0.04);
    border-color: rgba(17, 24, 39, 0.1);
}

.admin-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.admin-brand-mark img {
    max-width: 28px;
    max-height: 28px;
}

.brand-logo-img {
    opacity: 0;
    transition: opacity 0.16s ease;
}

.brand-logo-img.is-loaded {
    opacity: 1;
}

.admin-logo h1 {
    font-size: 20px;
    font-weight: 600;
}

.admin-logo p {
    margin-top: 3px;
    color: var(--text-secondary);
    font-size: 12px;
}

.admin-header h1 {
    font-size: 20px;
    font-weight: 600;
}

.admin-back-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    font-size: 14px;
}

body.theme-light .admin-back-btn {
    background: rgba(17, 24, 39, 0.04);
    border-color: rgba(17, 24, 39, 0.1);
}

.admin-back-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

body.theme-light .admin-back-btn:hover {
    background: rgba(17, 24, 39, 0.08);
}

.admin-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 28px;
    max-width: 1440px;
    margin: 0 auto;
}

.admin-overview {
    min-height: 148px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 20px;
    align-items: end;
    padding: 26px;
    background: linear-gradient(135deg, rgba(35, 38, 49, 0.92), rgba(20, 22, 29, 0.92));
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 10px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.32);
}

.admin-eyebrow {
    display: inline-flex;
    align-items: center;
    height: 24px;
    padding: 0 9px;
    margin-bottom: 12px;
    color: #c7d2fe;
    background: rgba(99, 102, 241, 0.14);
    border: 1px solid rgba(129, 140, 248, 0.22);
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0;
}

.admin-overview h2 {
    font-size: 30px;
    line-height: 1.14;
    margin-bottom: 8px;
    font-weight: 700;
}

.admin-overview p {
    color: var(--text-secondary);
    font-size: 14px;
}

.admin-metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(110px, 1fr));
    gap: 10px;
}

.admin-metric {
    min-width: 110px;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.055);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
}

.admin-metric span {
    display: block;
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
}

.admin-metric small {
    display: block;
    margin-top: 4px;
    color: var(--text-secondary);
    font-size: 12px;
}

.admin-grid {
    display: grid;
    gap: 20px;
}

.admin-grid-settings {
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1.15fr) minmax(280px, 0.7fr);
    align-items: stretch;
}

.admin-grid-operations {
    grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
    align-items: start;
}

.admin-section {
    background: rgba(22, 24, 31, 0.92);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    overflow: hidden;
    box-shadow: 0 16px 38px rgba(0, 0, 0, 0.22);
    display: flex;
    flex-direction: column;
}

.admin-section-header {
    min-height: 64px;
    padding: 16px 18px;
    background: rgba(255, 255, 255, 0.035);
    border-bottom: 1px solid rgba(255, 255, 255, 0.075);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.admin-section-title {
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-icon {
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.065);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    font-size: 15px;
}

.count-pill {
    min-width: 26px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 8px;
    background: rgba(99, 102, 241, 0.18);
    border: 1px solid rgba(129, 140, 248, 0.28);
    color: #c7d2fe;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.admin-section-body {
    padding: 16px;
    max-height: 520px;
    overflow-y: auto;
    flex: 1;
}

.admin-grid-settings .admin-section-body {
    display: flex;
}

.admin-grid-settings .admin-form-embedded {
    width: 100%;
    min-height: 100%;
    display: flex;
    flex-direction: column;
}

.admin-grid-settings .form-actions {
    margin-top: auto;
    padding-top: 14px;
}

.admin-card {
    background: rgba(255, 255, 255, 0.045);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 10px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    transition: background 0.2s, border-color 0.2s, transform 0.2s;
}

.admin-card:hover {
    background: rgba(255, 255, 255, 0.065);
    border-color: rgba(129, 140, 248, 0.28);
    transform: translateY(-1px);
}

.admin-card:last-child {
    margin-bottom: 0;
}

.admin-skeleton-card {
    pointer-events: none;
}

.skeleton-block,
.skeleton-line,
.skeleton-tags span {
    position: relative;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.075);
    border-color: rgba(255, 255, 255, 0.075);
}

.skeleton-block::after,
.skeleton-line::after,
.skeleton-tags span::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.12), transparent);
    animation: skeleton-shimmer 1.2s infinite;
}

.skeleton-line {
    height: 12px;
    max-width: 320px;
    margin-bottom: 10px;
    border-radius: 999px;
}

.skeleton-title {
    width: 52%;
    height: 14px;
}

.skeleton-tags {
    display: flex;
    gap: 6px;
    margin-top: 12px;
}

.skeleton-tags span {
    width: 68px;
    height: 20px;
    border-radius: 999px;
}

@keyframes skeleton-shimmer {
    100% {
        transform: translateX(100%);
    }
}

.admin-card-avatar {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(99, 102, 241, 0.13);
    border: 1px solid rgba(129, 140, 248, 0.2);
    border-radius: 8px;
    color: #e0e7ff;
    font-size: 18px;
    font-weight: 700;
}

.admin-card-info {
    flex: 1;
    min-width: 0;
}

.admin-card-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 4px;
}

.admin-card-info h4 {
    font-size: 14px;
    font-weight: 650;
    margin-bottom: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.muted-inline {
    color: var(--text-muted);
    font-weight: 500;
}

.admin-card-info p {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-card-info small {
    font-size: 11px;
    color: var(--text-muted);
}

.status-chip {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    height: 22px;
    padding: 0 8px;
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.2);
    color: #86efac;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 650;
}

.status-chip-admin {
    background: rgba(99, 102, 241, 0.14);
    border-color: rgba(129, 140, 248, 0.28);
    color: #c7d2fe;
}

.status-chip-external {
    background: rgba(245, 158, 11, 0.12);
    border-color: rgba(245, 158, 11, 0.3);
    color: #fcd34d;
}

.status-chip-limit {
    background: rgba(6, 182, 212, 0.12);
    border-color: rgba(6, 182, 212, 0.3);
    color: #67e8f9;
}

.token-limit-inputs {
    display: flex;
    gap: 8px;
}

.token-limit-inputs .form-input[type="number"] {
    flex: 1;
    min-width: 0;
}

.token-limit-inputs select {
    width: auto;
    flex: 0 0 auto;
}

.user-edit-limit {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    flex-wrap: wrap;
}

.user-edit-limit .token-limit-inputs {
    flex: 0 0 auto;
    min-width: 220px;
}

.external-user-row {
    margin-top: 26px;
}

.form-help {
    font-size: 11.5px;
    color: var(--text-muted);
    line-height: 1.45;
    margin-top: 6px;
}

.user-prompt-preview {
    font-size: 11.5px;
    color: var(--text-muted);
    background: rgba(99, 102, 241, 0.07);
    border: 1px solid rgba(99, 102, 241, 0.14);
    border-radius: 8px;
    padding: 6px 8px;
    line-height: 1.4;
}

.admin-card-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.admin-card-agent {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
}

.admin-card-agent .admin-card-title-row {
    flex-wrap: wrap;
    justify-content: flex-start;
}

.admin-card-agent .admin-card-info h4,
.admin-card-agent .admin-card-info p {
    white-space: normal;
    overflow: visible;
    overflow-wrap: anywhere;
}

.admin-card-agent .admin-card-info small {
    overflow-wrap: anywhere;
}

.admin-card-agent .admin-card-actions {
    grid-column: 1 / -1;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    margin-top: 0;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.075);
}

.admin-card-agent .admin-card-actions .btn-small {
    flex: 0 1 auto;
    white-space: normal;
}

.admin-form {
    padding: 18px;
    background: rgba(255, 255, 255, 0.035);
    border-top: 1px solid rgba(255, 255, 255, 0.075);
}

.admin-form-embedded {
    padding: 0;
    background: transparent;
    border-top: 0;
}

.admin-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

@media (max-width: 600px) {
    .admin-form-grid {
    grid-template-columns: 1fr;
    }

    .provider-diagnostics {
        grid-template-columns: 1fr;
    }
}

.logo-preview {
    min-height: 96px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.045);
    border: 1px dashed rgba(255, 255, 255, 0.14);
    border-radius: 8px;
    text-align: center;
}

.logo-preview img {
    max-height: 62px;
    max-width: 100%;
    display: none;
}

.logo-preview span {
    color: var(--text-secondary);
    font-size: 13px;
}

.provider-status-card {
    padding: 14px;
    margin-bottom: 14px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.045);
}

.provider-status-card.is-ok {
    border-color: rgba(34, 197, 94, 0.28);
    background: rgba(34, 197, 94, 0.08);
}

.provider-status-card.is-error {
    border-color: rgba(245, 158, 11, 0.3);
    background: rgba(245, 158, 11, 0.08);
}

.provider-status-card > div {
    display: flex;
    align-items: center;
    gap: 9px;
}

.provider-status-card strong {
    color: var(--text-primary);
    font-size: 14px;
}

.provider-status-card p {
    margin: 8px 0 0;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.5;
}

.provider-status-dot {
    width: 9px;
    height: 9px;
    border-radius: 999px;
    background: var(--warning);
    box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.12);
    flex: 0 0 auto;
}

.provider-status-dot.is-ok {
    background: var(--success);
    box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.12);
}

.provider-status-dot.is-error {
    background: var(--warning);
}

.provider-toggle {
    margin: 12px 0;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
}

.provider-toggle input {
    width: 17px;
    height: 17px;
    accent-color: var(--accent-primary);
}

.provider-diagnostics {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.provider-diagnostics div {
    min-width: 0;
    padding: 10px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.075);
}

.provider-diagnostics span,
.provider-diagnostics strong {
    display: block;
}

.provider-diagnostics span {
    color: var(--text-muted);
    font-size: 11px;
    margin-bottom: 5px;
}

.provider-diagnostics strong {
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.sidebar-btn {
    min-height: 38px;
    padding: 9px 13px;
    background: rgba(255, 255, 255, 0.055);
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
}

.sidebar-btn:hover {
    background: rgba(255, 255, 255, 0.09);
    color: var(--text-primary);
}

.reset-password-row {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    color: var(--warning);
    font-size: 13px;
}

.reset-password-row input {
    width: 18px;
    height: 18px;
}

.sidebar-btn.admin-btn {
    background: var(--accent-subtle);
    border-color: var(--accent);
    color: var(--accent);
}

.sidebar-btn.admin-btn:hover {
    background: var(--accent);
    color: white;
}

.admin-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    min-height: 40px;
    padding: 8px 16px;
    background: rgba(18, 19, 24, 0.92);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 12px;
    color: #888;
    z-index: 50;
    backdrop-filter: blur(14px);
}

.admin-footer a {
    color: #c7d2fe;
    text-decoration: none;
}

.admin-footer-divider {
    color: var(--accent);
}

body.theme-light .admin-overview {
    background: #ffffff;
    border-color: #dfe4ee;
    box-shadow: 0 16px 36px rgba(15, 23, 42, 0.07);
}

body.theme-light .admin-eyebrow {
    background: rgba(79, 70, 229, 0.08);
    border-color: rgba(79, 70, 229, 0.16);
    color: #4338ca;
}

body.theme-light .admin-metric,
body.theme-light .admin-section,
body.theme-light .admin-card,
body.theme-light .logo-preview,
body.theme-light .provider-status-card,
body.theme-light .provider-diagnostics div,
body.theme-light .admin-form {
    background: #ffffff;
    border-color: #dfe4ee;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.05);
}

body.theme-light .admin-section-header {
    background: #f8fafc;
    border-bottom-color: #dfe4ee;
}

body.theme-light .section-icon {
    background: #eef2ff;
    border-color: #dfe4ff;
}

body.theme-light .count-pill,
body.theme-light .status-chip-admin {
    background: rgba(79, 70, 229, 0.08);
    border-color: rgba(79, 70, 229, 0.16);
    color: #4338ca;
}

body.theme-light .status-chip-external {
    background: rgba(217, 119, 6, 0.1);
    border-color: rgba(217, 119, 6, 0.22);
    color: #a16207;
}

body.theme-light .status-chip-limit {
    background: rgba(8, 145, 178, 0.1);
    border-color: rgba(8, 145, 178, 0.22);
    color: #0e7490;
}

body.theme-light .user-prompt-preview {
    background: rgba(79, 70, 229, 0.06);
    border-color: rgba(79, 70, 229, 0.14);
    color: #475569;
}

body.theme-light .form-help {
    color: #64748b;
}

body.theme-light .admin-card:hover {
    background: #f8fafc;
    border-color: #cfd8e6;
}

body.theme-light .admin-card-avatar {
    background: #eef2ff;
    border-color: #dfe4ff;
    color: #4338ca;
}

body.theme-light .skeleton-block,
body.theme-light .skeleton-line,
body.theme-light .skeleton-tags span {
    background: #e9eef6;
    border-color: #e2e8f0;
}

body.theme-light .skeleton-block::after,
body.theme-light .skeleton-line::after,
body.theme-light .skeleton-tags span::after {
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.72), transparent);
}

body.theme-light .provider-status-card.is-ok {
    background: rgba(21, 128, 61, 0.08);
    border-color: rgba(21, 128, 61, 0.22);
}

body.theme-light .provider-status-card.is-error {
    background: rgba(180, 83, 9, 0.08);
    border-color: rgba(180, 83, 9, 0.24);
}

body.theme-light .sidebar-btn {
    background: #ffffff;
    border-color: #d9e0ea;
    color: #475569;
}

body.theme-light .sidebar-btn:hover {
    background: #f3f6fb;
    color: #111827;
}

body.theme-light .sidebar-btn.admin-btn {
    background: rgba(79, 70, 229, 0.08);
    border-color: rgba(79, 70, 229, 0.18);
    color: #4338ca;
}

body.theme-light .admin-footer {
    background: rgba(255, 255, 255, 0.92);
    border-top-color: #dfe4ee;
    color: #64748b;
}

body.theme-light .admin-footer a {
    color: #4338ca;
}

/* Admin: kullanıcı bölümü buton grubu */
.admin-section-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

/* Admin: şifre sıfırlama maili ön yazı modalı */
.preface-modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.preface-modal-content {
    width: 100%;
    max-width: 680px;
    max-height: 90vh;
    overflow-y: auto;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
    display: flex;
    flex-direction: column;
}

.preface-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
}

.preface-modal-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.preface-modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
}

.preface-modal-close:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.08);
}

.preface-modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.preface-textarea {
    min-height: 200px;
    resize: vertical;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 13px;
    line-height: 1.6;
}

.user-prompt-textarea {
    min-height: 90px;
    resize: vertical;
    font-size: 13px;
    line-height: 1.5;
}

/* Admin: kullanıcı düzenleme modalı (premium) */
.user-edit-modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.62);
    backdrop-filter: blur(6px);
}

.user-edit-modal-content {
    width: 100%;
    max-width: 620px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, rgba(99, 102, 241, 0.05), transparent 120px), var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 32px 80px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(99, 102, 241, 0.08);
    overflow: hidden;
}

.user-edit-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
}

.user-edit-modal-title {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.user-edit-avatar {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.28), rgba(99, 102, 241, 0.12));
    border: 1px solid rgba(99, 102, 241, 0.32);
    color: var(--text-primary);
    font-weight: 600;
    font-size: 17px;
}

.user-edit-modal-heading {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.user-edit-modal-heading h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-edit-modal-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-edit-modal-body {
    padding: 16px 22px 18px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.user-edit-section {
    padding: 14px 16px 16px;
    background: rgba(255, 255, 255, 0.028);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 12px;
}

.user-edit-section-title {
    display: block;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.user-edit-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.user-edit-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.user-edit-field-label {
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-secondary);
}

.user-edit-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.user-edit-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.user-edit-row:hover {
    border-color: rgba(99, 102, 241, 0.45);
}

.user-edit-row:has(input:checked) {
    border-color: rgba(99, 102, 241, 0.55);
    background: rgba(99, 102, 241, 0.07);
}

.user-edit-row input[type="checkbox"] {
    width: 17px;
    height: 17px;
    margin-top: 1px;
    accent-color: var(--accent);
    cursor: pointer;
    flex: 0 0 auto;
}

.user-edit-row-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.user-edit-row-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

.user-edit-row-hint {
    font-size: 11.5px;
    color: var(--text-muted);
    line-height: 1.45;
}

.user-edit-agents {
    margin-top: 0;
}

.user-edit-agents .agent-checkbox {
    padding: 7px 11px;
    background: var(--bg-secondary);
    border-color: var(--border);
}

.user-edit-modal-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 12px;
    padding: 14px 22px;
    border-top: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.02);
}

body.theme-light .user-edit-modal-content {
    background: linear-gradient(180deg, rgba(79, 70, 229, 0.04), transparent 120px), #ffffff;
    border-color: #dfe4ee;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.14);
}

body.theme-light .user-edit-avatar {
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.16), rgba(79, 70, 229, 0.06));
    border-color: rgba(79, 70, 229, 0.28);
    color: #4338ca;
}

body.theme-light .user-edit-section {
    background: #f8fafc;
    border-color: #e2e8f0;
}

body.theme-light .user-edit-row {
    background: #ffffff;
    border-color: #dfe4ee;
}

body.theme-light .user-edit-row:hover {
    border-color: rgba(79, 70, 229, 0.45);
    background: #fafaff;
}

body.theme-light .user-edit-row:has(input:checked) {
    border-color: rgba(79, 70, 229, 0.5);
    background: rgba(79, 70, 229, 0.06);
}

body.theme-light .user-edit-modal-footer {
    background: #f8fafc;
}

.preface-modal-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

@media (max-width: 640px) {
    .admin-section-actions .sidebar-btn {
        flex: 1 1 auto;
    }

    .preface-modal {
        padding: 12px;
        align-items: stretch;
    }

    .user-edit-modal {
        padding: 12px;
        align-items: stretch;
    }

    .user-edit-modal-content {
        max-height: calc(100vh - 24px);
    }

    .user-edit-grid {
        grid-template-columns: 1fr;
    }

    .user-edit-modal-footer .btn-small {
        flex: 1 1 auto;
    }

    .preface-modal-content {
        max-height: calc(100vh - 24px);
    }

    .preface-modal-footer .btn-small {
        flex: 1 1 auto;
    }
}

@media (max-width: 1180px) {
    .admin-grid-settings {
        grid-template-columns: 1fr 1fr;
    }

    .admin-section-provider {
        grid-column: 1 / -1;
    }
}

@media (max-width: 980px) {
    .admin-overview {
        grid-template-columns: 1fr;
        align-items: start;
    }

    .admin-metrics,
    .admin-grid-settings,
    .admin-grid-operations {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .admin-content {
        padding: 16px;
    }

    .admin-overview {
        padding: 20px;
    }

    .admin-overview h2 {
        font-size: 24px;
    }

    .admin-metrics {
        grid-template-columns: 1fr;
    }

    .admin-section-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .admin-section-header .sidebar-btn {
        width: 100%;
    }

    .admin-card-title-row {
        align-items: flex-start;
        flex-direction: column;
    }
}

/* Emoji Picker */
.emoji-picker-container {
    position: relative;
    display: inline-block;
}

.emoji-input {
    width: 64px;
    text-align: center;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.2s;
}

.emoji-input:hover {
    border-color: var(--accent);
}

.emoji-picker {
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    width: 280px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
}

.emoji-option {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.2s;
}

.emoji-option:hover {
    background: var(--bg-hover);
}

/* Prompt Editor */
.prompt-editor-form {
    border-top: 1px solid var(--border);
    margin-top: 14px;
}

.prompt-editor-toolbar {
    align-items: end;
    display: grid;
    gap: 12px;
    grid-template-columns: minmax(180px, 280px) 1fr auto;
}

.prompt-editor-meta {
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.4;
    min-height: 18px;
}

.prompt-editor-textarea {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 13px;
    line-height: 1.55;
    min-height: 420px;
    resize: vertical;
    white-space: pre;
}

.prompt-editor-status {
    color: var(--text-secondary);
    font-size: 12px;
    min-height: 18px;
}

.prompt-page-content {
    max-width: 1180px;
}

.prompt-page-overview {
    align-items: center;
}

.prompt-page-actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}

.prompt-page-section {
    overflow: hidden;
}

.prompt-page-toolbar {
    align-items: end;
    grid-template-columns: minmax(220px, 320px) minmax(180px, 260px) 1fr;
    margin-bottom: 14px;
}

.prompt-page-textarea {
    min-height: calc(100vh - 420px);
}

@media (max-width: 760px) {
    .prompt-editor-toolbar {
        grid-template-columns: 1fr;
    }

    .prompt-page-overview {
        align-items: stretch;
    }

    .prompt-page-actions {
        justify-content: flex-start;
    }
}
