:root {
    --adm-bg: #0b0f19;
    --adm-surface: #111827;
    --adm-surface-light: #1f2937;
    --adm-border: #374151;
    --adm-text: #f9fafb;
    --adm-text-muted: #9ca3af;
    --adm-primary: #3b82f6;
    --adm-primary-hover: #2563eb;
    --adm-success: #10b981;
    --adm-warning: #f59e0b;
    --adm-danger: #ef4444;
}

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

body.admin-body {
    background-color: var(--adm-bg);
    color: var(--adm-text);
    font-family: 'Plus Jakarta Sans', sans-serif;
    line-height: 1.5;
}

.admin-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.admin-sidebar {
    width: 260px;
    background-color: var(--adm-surface);
    border-right: 1px solid var(--adm-border);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 24px 16px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--adm-border);
    margin-bottom: 20px;
}

.brand-icon {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    color: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.brand-name {
    font-size: 1rem;
    font-weight: 700;
}

.brand-badge {
    font-size: 0.65rem;
    color: #3b82f6;
    letter-spacing: 1px;
    font-weight: 700;
}

.sidebar-menu {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-grow: 1;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    color: var(--adm-text-muted);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: 8px;
    transition: all 0.2s;
}

.menu-item:hover {
    color: var(--adm-text);
    background-color: var(--adm-surface-light);
}

.menu-item.active {
    color: white;
    background-color: var(--adm-primary);
}

.sidebar-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 16px;
    border-top: 1px solid var(--adm-border);
}

.admin-user-pill {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    background: #4b5563;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
}

.user-info strong {
    display: block;
    font-size: 0.8rem;
}

.user-info span {
    font-size: 0.7rem;
    color: var(--adm-text-muted);
}

.btn-logout {
    color: var(--adm-text-muted);
    padding: 6px;
    border-radius: 6px;
    transition: color 0.2s;
}

.btn-logout:hover {
    color: var(--adm-danger);
}

/* Main Area */
.admin-main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.admin-topbar {
    height: 64px;
    background-color: var(--adm-surface);
    border-bottom: 1px solid var(--adm-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
}

.topbar-title {
    font-size: 1.15rem;
    font-weight: 700;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.api-status-tag {
    font-size: 0.8rem;
    color: var(--adm-success);
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.25);
    padding: 6px 12px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.pulse-dot {
    width: 6px;
    height: 6px;
    background: var(--adm-success);
    border-radius: 50%;
}

.btn-view-app {
    color: var(--adm-primary);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
}

.admin-content {
    padding: 32px;
}

/* KPI Cards */
.admin-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

@media (max-width: 1024px) {
    .admin-kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.kpi-card {
    background: var(--adm-surface);
    border: 1px solid var(--adm-border);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.kpi-icon-wrap {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-blue { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }
.icon-purple { background: rgba(139, 92, 246, 0.15); color: #8b5cf6; }
.icon-amber { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.icon-emerald { background: rgba(16, 185, 129, 0.15); color: #10b981; }

.kpi-label {
    display: block;
    font-size: 0.75rem;
    color: var(--adm-text-muted);
    font-weight: 600;
    text-transform: uppercase;
}

.kpi-val {
    display: block;
    font-size: 1.5rem;
    font-weight: 800;
    margin: 2px 0;
}

.kpi-meta {
    font-size: 0.75rem;
    color: var(--adm-text-muted);
}

.text-success { color: var(--adm-success) !important; }
.text-danger { color: var(--adm-danger) !important; }
.text-primary { color: var(--adm-primary) !important; }
.text-warning { color: var(--adm-warning) !important; }

/* Panels & Tables */
.admin-panel {
    background: var(--adm-surface);
    border: 1px solid var(--adm-border);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
}

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

.panel-title {
    font-size: 1.1rem;
    font-weight: 700;
}

.panel-desc {
    font-size: 0.8rem;
    color: var(--adm-text-muted);
    margin-top: 2px;
}

.panel-link {
    color: var(--adm-primary);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
}

.table-responsive {
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    text-align: left;
}

.admin-table th {
    padding: 12px 14px;
    color: var(--adm-text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--adm-border);
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.5px;
}

.admin-table td {
    padding: 14px;
    border-bottom: 1px solid rgba(55, 65, 81, 0.5);
    vertical-align: middle;
}

.admin-table tr:hover td {
    background: rgba(31, 41, 55, 0.4);
}

.table-thumb {
    width: 44px;
    height: 44px;
    border-radius: 6px;
    object-fit: cover;
    background: #1f2937;
    display: block;
}

.table-prompt, .table-prompt-full {
    max-width: 280px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.table-prompt-full {
    max-width: 380px;
}

.keycode-tag {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    background: var(--adm-surface-light);
    padding: 2px 6px;
    border-radius: 4px;
    color: #60a5fa;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 700;
}

.badge-success { background: rgba(16, 185, 129, 0.15); color: var(--adm-success); }
.badge-danger { background: rgba(239, 68, 68, 0.15); color: var(--adm-danger); }
.badge-neutral { background: var(--adm-surface-light); color: var(--adm-text-muted); }

.credits-badge {
    font-weight: 700;
    color: #38bdf8;
}

.btn-table-action {
    color: var(--adm-primary);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 4px;
    background: rgba(59, 130, 246, 0.1);
}

.btn-table-action:hover {
    background: rgba(59, 130, 246, 0.2);
}

.action-buttons-cell {
    display: flex;
    gap: 6px;
}

/* Forms & Inputs */
.admin-input {
    background: var(--adm-surface-light);
    border: 1px solid var(--adm-border);
    color: var(--adm-text);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-family: inherit;
}

.admin-input:focus {
    outline: none;
    border-color: var(--adm-primary);
}

.admin-pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 20px;
}

.admin-pagination .page-link {
    padding: 6px 12px;
    background: var(--adm-surface-light);
    color: var(--adm-text);
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.8rem;
}

.admin-pagination .page-link.active {
    background: var(--adm-primary);
    color: white;
}

/* Diagnostics */
.diag-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.diag-item {
    display: flex;
    justify-content: space-between;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(55, 65, 81, 0.5);
    font-size: 0.85rem;
}

.diag-label {
    color: var(--adm-text-muted);
}

.config-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.config-box {
    background: var(--adm-surface-light);
    padding: 16px;
    border-radius: 8px;
}

.config-label {
    display: block;
    font-size: 0.75rem;
    color: var(--adm-text-muted);
    margin-bottom: 8px;
    font-weight: 600;
}

.config-box input {
    width: 100%;
}

/* Login Page */
.login-body {
    background-color: var(--adm-bg);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Plus Jakarta Sans', sans-serif;
    color: var(--adm-text);
}

.login-card-container {
    width: 100%;
    max-width: 420px;
    padding: 20px;
}

.login-card {
    background: var(--adm-surface);
    border: 1px solid var(--adm-border);
    border-radius: 16px;
    padding: 32px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
}

.login-header {
    text-align: center;
    margin-bottom: 24px;
}

.login-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    color: white;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}

.login-header h2 {
    font-size: 1.3rem;
    font-weight: 800;
}

.login-header p {
    font-size: 0.8rem;
    color: var(--adm-text-muted);
    margin-top: 4px;
}

.login-form .form-group {
    margin-bottom: 16px;
}

.login-form label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--adm-text-muted);
}

.login-form input {
    width: 100%;
}

.login-hint {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    color: #93c5fd;
    margin-bottom: 20px;
}

.btn-admin-submit {
    width: 100%;
    background: var(--adm-primary);
    color: white;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-admin-submit:hover {
    background: var(--adm-primary-hover);
}

.login-error-alert {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
    padding: 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    margin-bottom: 16px;
    text-align: center;
}
