:root,
body.theme-light {
    --admin-bg-start: #f6f9fd;
    --admin-bg-end: #eef4fb;
    --admin-border: rgba(15, 23, 42, 0.1);
    --admin-border-soft: rgba(15, 23, 42, 0.08);
    --admin-text: #0f172a;
    --admin-muted: #64748b;
    --admin-surface: rgba(255, 255, 255, 0.9);
    --admin-surface-strong: rgba(255, 255, 255, 0.97);
    --admin-input-bg: #ffffff;
    --admin-input-border: rgba(15, 23, 42, 0.14);
    --admin-input-text: #0f172a;
    --admin-active-bg: rgba(37, 99, 235, 0.12);
    --admin-active-border: rgba(37, 99, 235, 0.4);
    --admin-soft-card: rgba(248, 250, 252, 0.8);
}

body.theme-dark {
    --admin-bg-start: #0b1220;
    --admin-bg-end: #101a2f;
    --admin-border: rgba(148, 163, 184, 0.25);
    --admin-border-soft: rgba(148, 163, 184, 0.2);
    --admin-text: #e2e8f0;
    --admin-muted: #b8c5d8;
    --admin-surface: rgba(15, 23, 42, 0.82);
    --admin-surface-strong: rgba(15, 23, 42, 0.9);
    --admin-input-bg: #0f172a;
    --admin-input-border: rgba(148, 163, 184, 0.35);
    --admin-input-text: #e2e8f0;
    --admin-active-bg: rgba(59, 130, 246, 0.26);
    --admin-active-border: rgba(125, 211, 252, 0.52);
    --admin-soft-card: rgba(30, 41, 59, 0.75);
}

body {
    background: linear-gradient(180deg, var(--admin-bg-start) 0%, var(--admin-bg-end) 100%);
    color: var(--admin-text);
    min-height: 100vh;
}

.admin-topbar {
    background: var(--admin-surface);
    backdrop-filter: blur(8px);
    border-color: var(--admin-border) !important;
}

.admin-card {
    background: var(--admin-surface-strong);
    border: 1px solid var(--admin-border);
    border-radius: 14px;
    color: var(--admin-text);
    --bs-card-color: var(--admin-text);
    --bs-card-bg: var(--admin-surface-strong);
    --bs-card-border-color: var(--admin-border);
}

body.theme-dark .admin-card {
    border-color: rgba(148, 163, 184, 0.34);
    box-shadow: 0 10px 26px rgba(2, 6, 23, 0.3);
}

body.theme-dark .admin-card h1,
body.theme-dark .admin-card h2,
body.theme-dark .admin-card h3,
body.theme-dark .admin-card h4,
body.theme-dark .admin-card h5,
body.theme-dark .admin-card h6,
body.theme-dark .admin-card .h1,
body.theme-dark .admin-card .h2,
body.theme-dark .admin-card .h3,
body.theme-dark .admin-card .h4,
body.theme-dark .admin-card .h5,
body.theme-dark .admin-card .h6 {
    color: #e8eef8;
}

body.theme-dark .admin-card .border,
body.theme-dark .admin-card .border-top,
body.theme-dark .admin-card .border-end,
body.theme-dark .admin-card .border-bottom,
body.theme-dark .admin-card .border-start {
    border-color: rgba(148, 163, 184, 0.34) !important;
}

.admin-menu .list-group-item {
    border-radius: 10px !important;
    border: 1px solid var(--admin-border);
    margin-bottom: 0.4rem;
    background: transparent;
    color: var(--admin-text);
}

.admin-menu .list-group-item:hover {
    color: var(--admin-text);
    background: var(--admin-soft-card);
}

.admin-menu .list-group-item.active {
    border-color: var(--admin-active-border);
    background: var(--admin-active-bg);
    color: var(--admin-text);
}

.table td,
.table th {
    vertical-align: middle;
    color: var(--admin-text);
    border-color: var(--admin-border-soft);
}

body.theme-dark .table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--admin-text);
    --bs-table-border-color: var(--admin-border-soft);
    --bs-table-striped-bg: rgba(51, 65, 85, 0.44);
    --bs-table-striped-color: var(--admin-text);
    --bs-table-hover-bg: rgba(59, 130, 246, 0.16);
    --bs-table-hover-color: #f8fafc;
}

body.theme-dark a {
    color: #93c5fd;
}

body.theme-dark a:hover {
    color: #dbeafe;
}

body.theme-dark .table > :not(caption) > * > * {
    background-color: transparent !important;
}

body.theme-dark .table > thead > tr > th {
    color: #cbd5e1;
    background-color: rgba(30, 41, 59, 0.9) !important;
    border-bottom-color: rgba(148, 163, 184, 0.36);
}

body.theme-dark .table .text-secondary,
body.theme-dark .table .small.text-secondary {
    color: #c7d4e6 !important;
}

body.theme-dark .table > tbody > tr > * {
    background-color: rgba(15, 23, 42, 0.82) !important;
}

body.theme-dark .table-striped > tbody > tr:nth-of-type(odd) > * {
    color: var(--admin-text);
    background-color: rgba(30, 41, 59, 0.58) !important;
}

body.theme-dark .table-striped > tbody > tr:nth-of-type(even) > * {
    color: var(--admin-text);
    background-color: rgba(15, 23, 42, 0.82) !important;
}

body.theme-dark .table-striped > tbody > tr:hover > * {
    color: #f8fafc;
    background-color: rgba(37, 99, 235, 0.2) !important;
}

body.theme-light .table-striped > tbody > tr:nth-of-type(odd) > * {
    color: var(--admin-text);
    background-color: rgba(241, 245, 249, 0.68);
}

.admin-channel-picon-wrap {
    width: 38px;
    height: 38px;
    border: 1px solid var(--admin-border-soft);
    border-radius: 8px;
    background: rgba(241, 245, 249, 0.7);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.admin-channel-picon {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.admin-channel-picon-fallback {
    color: var(--admin-muted);
    font-size: 0.9rem;
}

.admin-channel-toggle .btn {
    min-width: 86px;
}

body.theme-dark .admin-channel-picon-wrap {
    background: rgba(30, 41, 59, 0.72);
    border-color: rgba(148, 163, 184, 0.32);
}

.code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.9em;
}

.form-hint,
.text-secondary,
.small.text-secondary {
    color: var(--admin-muted) !important;
}

body.theme-dark .text-muted,
body.theme-dark .form-text {
    color: #b8c5d8 !important;
}

.sticky-top {
    top: 1rem;
}

.admin-toast-wrap {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1090;
    width: min(460px, calc(100vw - 1.5rem));
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    pointer-events: none;
}

.admin-toast {
    pointer-events: auto;
    border: 1px solid rgba(15, 23, 42, 0.15);
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.2);
}

.admin-toast .toast-body {
    font-size: 0.93rem;
}

.admin-toast-title {
    font-weight: 700;
    margin-right: 0.35rem;
}

body.theme-dark .admin-toast {
    border-color: rgba(148, 163, 184, 0.4);
    box-shadow: 0 10px 30px rgba(2, 6, 23, 0.45);
}

body.theme-dark .admin-toast.text-bg-success {
    background: rgba(21, 128, 61, 0.9) !important;
    color: #f0fdf4 !important;
}

body.theme-dark .admin-toast.text-bg-danger {
    background: rgba(185, 28, 28, 0.9) !important;
    color: #fef2f2 !important;
}

body.theme-dark .admin-toast.text-bg-warning {
    background: rgba(161, 98, 7, 0.92) !important;
    color: #fffbeb !important;
}

body.theme-dark .admin-toast.text-bg-info {
    background: rgba(3, 105, 161, 0.9) !important;
    color: #f0f9ff !important;
}

.admin-toolbar-form {
    margin: 0;
}

.admin-toolbar-form .form-select {
    min-width: 116px;
}

.form-control,
.form-select,
.form-check-input {
    background-color: var(--admin-input-bg);
    border-color: var(--admin-input-border);
    color: var(--admin-input-text);
}

body.theme-dark .form-label,
body.theme-dark label,
body.theme-dark .form-check-label {
    color: #dbe6f5;
}

body.theme-dark .form-control::placeholder {
    color: #9fb1c9;
    opacity: 1;
}

body.theme-dark .form-select option {
    color: #e2e8f0;
    background: #0f172a;
}

.form-control:focus,
.form-select:focus {
    color: var(--admin-input-text);
    background-color: var(--admin-input-bg);
    border-color: rgba(59, 130, 246, 0.65);
    box-shadow: 0 0 0 0.2rem rgba(59, 130, 246, 0.18);
}

.form-check-input:checked {
    background-color: #2563eb;
    border-color: #2563eb;
}

body.theme-dark .alert-light,
body.theme-dark .bg-light-subtle {
    background: var(--admin-soft-card) !important;
    color: var(--admin-text) !important;
    border-color: var(--admin-border) !important;
}

body.theme-dark .btn-outline-secondary,
body.theme-dark .btn-outline-primary,
body.theme-dark .btn-outline-danger {
    border-color: var(--admin-input-border);
    color: var(--admin-text);
}

body.theme-dark .btn-outline-secondary:hover,
body.theme-dark .btn-outline-primary:hover,
body.theme-dark .btn-outline-danger:hover {
    background: rgba(71, 85, 105, 0.5);
    color: #ffffff;
}

body.theme-dark .btn-outline-warning {
    border-color: rgba(250, 204, 21, 0.75);
    color: #fde68a;
}

body.theme-dark .btn-outline-warning:hover {
    background: rgba(234, 179, 8, 0.28);
    color: #fff8db;
}

body.theme-dark .badge.text-bg-secondary {
    background-color: rgba(71, 85, 105, 0.92) !important;
    color: #e6edf8 !important;
}

.admin-recaptcha-card {
    display: flex;
    gap: 0.85rem;
    align-items: flex-start;
    border: 1px solid var(--admin-border);
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.08), rgba(16, 185, 129, 0.08));
    padding: 0.9rem 1rem;
}

.admin-recaptcha-icon {
    width: 34px;
    height: 34px;
    border-radius: 999px;
    border: 1px solid var(--admin-border-soft);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #22c55e;
    font-size: 1rem;
    flex: 0 0 auto;
}

.admin-recaptcha-content {
    min-width: 0;
}

.admin-recaptcha-title {
    font-weight: 700;
    color: var(--admin-text);
    margin-bottom: 0.2rem;
}

.admin-recaptcha-text {
    color: var(--admin-muted);
    font-size: 0.92rem;
    line-height: 1.35;
}

.admin-recaptcha-links {
    margin-top: 0.35rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.85rem;
}

.admin-recaptcha-links a {
    color: #60a5fa;
    text-decoration: none;
}

.admin-recaptcha-links a:hover {
    text-decoration: underline;
}

body.theme-dark .admin-recaptcha-card {
    border-color: rgba(148, 163, 184, 0.35);
    background: linear-gradient(135deg, rgba(30, 64, 175, 0.22), rgba(6, 95, 70, 0.2));
}

body.theme-dark .admin-recaptcha-title {
    color: #f8fafc;
}

body.theme-dark .admin-recaptcha-text {
    color: #d6e2f2;
}
