/* Dark theme — full-site patches (load after kkt.css / analytics.css) */

html.theme-dark body,
html.theme-dark .app-shell,
html.chat-theme-dark.chat-lock,
html.chat-theme-dark body.chat-page {
  background: var(--bg-dark) !important;
  color: var(--text-primary) !important;
}

/* Cards / panels */
html.theme-dark .card,
html.theme-dark .dash-tile,
html.theme-dark .hw-card,
html.theme-dark .settings-card,
html.theme-dark .cmodal-box,
html.theme-dark .nav-dropdown-panel,
html.theme-dark .notif-panel,
html.chat-theme-dark .chat-mention-dd,
html.chat-theme-dark .chat-members-panel {
  background: var(--bg-card) !important;
  color: var(--text-primary) !important;
  border-color: var(--border) !important;
}

html.theme-dark .btn-sec {
  background: rgba(255, 255, 255, 0.06) !important;
  color: var(--accent) !important;
  border-color: rgba(var(--accent-rgb), 0.45) !important;
}
html.theme-dark .btn-sec:hover {
  background: rgba(var(--accent-rgb), 0.14) !important;
  color: var(--accent2) !important;
}

html.theme-dark .btn-prim,
html.theme-dark .btn-primary,
html.theme-dark .btn-success,
html.theme-dark .bg-primary,
html.theme-dark .bg-success {
  background: var(--accent-grad) !important;
  background-color: var(--accent) !important;
  border-color: transparent !important;
  box-shadow: 0 4px 16px rgba(var(--accent-rgb), 0.28) !important;
}
html.theme-dark .btn-prim,
html.theme-dark .btn-primary,
html.theme-dark .btn-success,
html.theme-dark .btn-prim span,
html.theme-dark .btn-prim i,
html.theme-dark .btn-prim .btn-busy,
html.theme-dark .btn-primary span,
html.theme-dark .btn-success span {
  color: #fff !important;
  -webkit-text-fill-color: #fff !important;
}

/* Forms */
html.theme-dark .form-control,
html.theme-dark .form-select,
html.theme-dark input[type="text"],
html.theme-dark input[type="password"],
html.theme-dark input[type="email"],
html.theme-dark input[type="number"],
html.theme-dark input[type="date"],
html.theme-dark input[type="datetime-local"],
html.theme-dark input[type="search"],
html.theme-dark input[type="url"],
html.theme-dark textarea,
html.theme-dark select,
html.theme-dark .card .form-control,
html.theme-dark .card .form-select,
html.theme-dark .la-select,
html.theme-dark .custom-select-trigger,
html.theme-dark .list-search__input,
html.theme-dark .list-search__input:focus {
  background: var(--bg-card2) !important;
  color: var(--text-primary) !important;
  border-color: var(--border) !important;
}
html.theme-dark .form-control::placeholder,
html.theme-dark textarea::placeholder,
html.theme-dark .list-search__input::placeholder {
  color: var(--text-muted) !important;
}
html.theme-dark .form-label,
html.theme-dark label,
html.theme-dark .text-muted,
html.theme-dark .page-header p,
html.theme-dark .page-header small {
  color: var(--text-muted) !important;
}
html.theme-dark h1, html.theme-dark h2, html.theme-dark h3,
html.theme-dark h4, html.theme-dark h5, html.theme-dark h6,
html.theme-dark .page-header h1,
html.theme-dark .page-title {
  color: var(--text-primary) !important;
}

/* Tables */
html.theme-dark table,
html.theme-dark .table,
html.theme-dark .table > :not(caption) > * > * {
  background-color: transparent !important;
  border-color: var(--border) !important;
  box-shadow: none !important;
}
html.theme-dark .table {
  color: var(--text-primary);
}
html.theme-dark .table thead th {
  background-color: var(--bg-card2) !important;
  color: var(--text-muted) !important;
  text-transform: none;
  letter-spacing: 0;
}
html.theme-dark .table-light,
html.theme-dark .table-striped > tbody > tr:nth-of-type(odd) > * {
  background-color: var(--bg-card2) !important;
  color: var(--text-primary) !important;
}
html.theme-dark .table tbody tr:hover > * {
  background-color: var(--bg-card2) !important;
}

html.theme-dark table.sched-table,
html.theme-dark table.sched-table.table {
  --bs-table-bg: var(--bg-card);
  --bs-table-color: var(--text-primary);
  --bs-table-border-color: rgba(244, 248, 241, 0.18);
  --bs-table-striped-bg: var(--bg-card2);
  --bs-table-hover-bg: rgba(76, 175, 69, 0.14);
  color: var(--text-primary) !important;
  background-color: var(--bg-card) !important;
}
html.theme-dark table.sched-table > :not(caption) > * > *,
html.theme-dark table.sched-table.table > :not(caption) > * > * {
  color: var(--text-primary) !important;
  background-color: var(--bg-card) !important;
  border-color: rgba(244, 248, 241, 0.18) !important;
  box-shadow: none !important;
}
html.theme-dark table.sched-table thead th {
  background-color: var(--bg-card2) !important;
  color: var(--text-muted) !important;
}

/* Chat leftovers */
html.chat-theme-dark .tg-sidebar,
html.chat-theme-dark .tg-sidebar-header,
html.chat-theme-dark .tg-main-header,
html.chat-theme-dark .tg-chat-toolbar,
html.chat-theme-dark .chat-input-wrap {
  background: var(--bg-card) !important;
  border-color: var(--border) !important;
  color: var(--text-primary) !important;
}
html.chat-theme-dark .tg-main,
html.chat-theme-dark .tg-messages {
  background-color: #1c231e !important;
  background-image: none !important;
}
html.chat-theme-dark .tg-contact-name,
html.chat-theme-dark .tg-chat-toolbar__text-title,
html.chat-theme-dark .chat-bubble-text,
html.theme-dark .cmodal-title {
  color: var(--text-primary) !important;
}
html.chat-theme-dark .chat-input,
html.chat-theme-dark .chat-input:focus,
html.theme-dark .cmodal-input,
html.theme-dark .cmodal-input:focus {
  background: var(--bg-card2) !important;
  color: var(--text-primary) !important;
  border-color: var(--border) !important;
}
html.chat-theme-dark .chat-action-btn,
html.theme-dark #chatMediaBtn,
html.theme-dark #chatSidebarClose,
html.chat-theme-dark .chat-row {
  background: var(--bg-card2) !important;
  color: var(--text-primary) !important;
  border-color: var(--border) !important;
}
html.chat-theme-dark .chat-msg-other .chat-bubble {
  background: var(--bg-card2) !important;
  color: var(--text-primary) !important;
}
html.chat-theme-dark .chat-members-tag,
html.chat-theme-dark .chat-members-mute {
  background: var(--bg-card2) !important;
  color: var(--accent) !important;
  border-color: var(--border) !important;
}
html.chat-theme-dark .chat-members-mute.is-muted {
  background: rgba(248, 113, 113, 0.15) !important;
  color: #f87171 !important;
}
html.chat-theme-dark .chat-muted-banner {
  background: rgba(248, 113, 113, 0.12) !important;
  color: #fca5a5 !important;
}

/* FAB labels on dock */
html.theme-dark .app-dock__item::after,
html.theme-dark .app-dock__fab-label {
  color: var(--text-primary) !important;
}
html.theme-dark .app-dock {
  background: rgba(26, 30, 36, 0.92) !important;
  border-color: rgba(var(--accent-rgb), 0.28) !important;
}

/* Homework / previews */
html.theme-dark .hw-sub-answer,
html.theme-dark .hw-file-preview,
html.theme-dark .hw-file-preview img {
  background: var(--bg-card2) !important;
  border-color: var(--border) !important;
  color: var(--text-primary) !important;
}

/* Alerts / badges */
html.theme-dark .alert-success,
html.theme-dark .alert-warning,
html.theme-dark .alert-danger,
html.theme-dark .alert-info {
  color: var(--text-primary) !important;
  border-color: var(--border) !important;
}
html.theme-dark .alert-success { background: rgba(45, 212, 191, 0.12) !important; }
html.theme-dark .alert-warning { background: rgba(251, 191, 36, 0.12) !important; }
html.theme-dark .alert-danger { background: rgba(248, 113, 113, 0.12) !important; }
html.theme-dark .alert-info { background: rgba(94, 234, 212, 0.1) !important; }

/* Auth / landing shells */
html.theme-dark .kkt-shell {
  background: var(--bg-dark) !important;
  animation: none !important;
  color: var(--text-primary) !important;
}
html.theme-dark.auth-lite-html body.auth-lite.kkt-shell,
html.theme-dark.auth-lite-html body.auth-lite {
  background:
    radial-gradient(52rem 28rem at 10% -12%, rgba(76, 175, 69, 0.22), transparent 55%),
    radial-gradient(40rem 24rem at 100% 0%, rgba(109, 204, 99, 0.14), transparent 50%),
    linear-gradient(165deg, #141c12, #1a2318 48%, #121910) !important;
  animation: none !important;
}
html.theme-dark .kkt-bg { display: none !important; }
html.theme-dark.auth-lite-html .kkt-bg { display: block !important; opacity: 0.35; }
html.theme-dark .kkt-panel h1,
html.theme-dark .kkt-logo,
html.theme-dark .auth-split__brand-title {
  color: var(--text-primary) !important;
}
html.theme-dark .kkt-btn-outline,
html.theme-dark .kkt-top-link--ghost {
  background: rgba(255, 255, 255, 0.06) !important;
  color: var(--accent) !important;
  border-color: rgba(var(--accent-rgb), 0.45) !important;
}
html.theme-dark .kkt-bottom {
  background: rgba(0, 0, 0, 0.25) !important;
  color: var(--text-muted) !important;
  border-color: var(--border) !important;
}

html.theme-dark .la-page {
  background: transparent !important;
  color: var(--text-primary) !important;
}
html.theme-dark .la-head h1,
html.theme-dark .la-kpi__value,
html.theme-dark .la-strip__value,
html.theme-dark .la-subj__name {
  color: var(--text-primary) !important;
}
html.theme-dark .la-select,
html.theme-dark .la-btn,
html.theme-dark .la-filters,
html.theme-dark .la-empty-filter,
html.theme-dark .la-card,
html.theme-dark .la-strip__item,
html.theme-dark .la-kpi {
  background: var(--bg-card) !important;
  color: var(--text-primary) !important;
  border-color: var(--border) !important;
}
html.theme-dark .la-select,
html.theme-dark .la-btn {
  color: var(--text-primary) !important;
}
html.theme-dark .la-btn--primary {
  background: var(--accent) !important;
  border-color: var(--accent) !important;
  color: #fff !important;
}
html.theme-dark .la-tab:hover {
  background: rgba(255,255,255,.06) !important;
  color: var(--text-primary) !important;
}
html.theme-dark .la-tab.is-active {
  background: rgba(109, 204, 99, 0.16) !important;
  color: #8be08a !important;
}
html.theme-dark .la-bar {
  background: rgba(255, 255, 255, 0.08) !important;
}

/* Zavuch / manage leftovers */
html.theme-dark .zavuch-home,
html.theme-dark .manage-home {
  color: var(--text-primary) !important;
}

/* Modals / dropdowns / steppers */
html.theme-dark .modal-content,
html.theme-dark .dropdown-menu,
html.theme-dark .num-stepper,
html.theme-dark .qb-panel,
html.theme-dark .toast-item {
  background: var(--bg-card) !important;
  color: var(--text-primary) !important;
  border-color: var(--border) !important;
}
html.theme-dark .num-stepper-btn {
  background: var(--bg-card2) !important;
  color: var(--text-muted) !important;
}
html.theme-dark .num-stepper input {
  color: var(--text-primary) !important;
}

/* Links that were forced dark green */
html.theme-dark a.text-success,
html.theme-dark .text-success,
html.theme-dark .pct-green,
html.theme-dark .sd-green {
  color: var(--accent) !important;
}

/* Empty states / white boxes */
html.theme-dark .empty-state,
html.theme-dark .placeholder-glow,
html.theme-dark .list-empty {
  background: transparent !important;
  color: var(--text-muted) !important;
}

/* Inline white flashes from templates */
html.theme-dark [style*="background:#fff"],
html.theme-dark [style*="background: #fff"],
html.theme-dark [style*="background:#ffffff"],
html.theme-dark [style*="background: #ffffff"],
html.theme-dark [style*="background:white"],
html.theme-dark [style*="background: white"] {
  background: var(--bg-card) !important;
}
html.theme-dark [style*="color:#15261c"],
html.theme-dark [style*="color: #15261c"],
html.theme-dark [style*="color:#1c1917"],
html.theme-dark [style*="color: #1c1917"],
html.theme-dark [style*="color:#24362b"],
html.theme-dark [style*="color: #24362b"] {
  color: var(--text-primary) !important;
}

/* Exam pages */
html.theme-dark .ex-card,
html.theme-dark .ex-list-item,
html.theme-dark .ex-answer,
html.theme-dark .ex-proctor,
html.theme-dark .ex-alert {
  background: var(--bg-card) !important;
  border-color: var(--border) !important;
  color: var(--text-primary) !important;
}
html.theme-dark .ex-answer,
html.theme-dark .ex-proctor,
html.theme-dark .ex-badge {
  background: var(--bg-card2) !important;
}
html.theme-dark .ex-head h1,
html.theme-dark .ex-card__q,
html.theme-dark .ex-score,
html.theme-dark .ex-list-item h3 {
  color: var(--text-primary) !important;
}
html.theme-dark .ex-grade-row input,
html.theme-dark .ex-grade-row textarea,
html.theme-dark .ex-retake__row input {
  background: var(--bg-card2) !important;
  border-color: var(--border) !important;
  color: var(--text-primary) !important;
}

/* Contrast: muted/gray text must stay readable on dark surfaces */
html.theme-dark,
html.theme-dark body {
  color: var(--text-primary);
}
html.theme-dark .text-muted,
html.theme-dark .text-secondary,
html.theme-dark .text-body-secondary,
html.theme-dark .text-black-50,
html.theme-dark .form-text,
html.theme-dark .form-label,
html.theme-dark small,
html.theme-dark .empty-title,
html.theme-dark .page-header p,
html.theme-dark .page-header small,
html.theme-dark footer,
html.theme-dark .auth-split__hint,
html.theme-dark .auth-foot,
html.chat-theme-dark .chat-row-last,
html.chat-theme-dark .chat-header-status,
html.theme-dark .qb-num,
html.theme-dark .builder-stat-label {
  color: var(--text-muted) !important;
}
html.theme-dark [style*="color:#6b7368"],
html.theme-dark [style*="color: #6b7368"],
html.theme-dark [style*="color:#8a9286"],
html.theme-dark [style*="color: #8a9286"],
html.theme-dark [style*="color:#7a8899"],
html.theme-dark [style*="color: #7a8899"],
html.theme-dark [style*="color:#64748b"],
html.theme-dark [style*="color: #64748b"],
html.theme-dark [style*="color:#6c757d"],
html.theme-dark [style*="color: #6c757d"],
html.theme-dark [style*="color:#94a3b8"],
html.theme-dark [style*="color: #94a3b8"],
html.theme-dark [style*="color:#9ca3af"],
html.theme-dark [style*="color: #9ca3af"],
html.theme-dark [style*="color:#a8a29e"],
html.theme-dark [style*="color: #a8a29e"] {
  color: var(--text-muted) !important;
}
html.theme-dark [style*="color:#1c1917"],
html.theme-dark [style*="color: #1c1917"],
html.theme-dark [style*="color:#15261c"],
html.theme-dark [style*="color: #15261c"],
html.theme-dark [style*="color:#1a202c"],
html.theme-dark [style*="color: #1a202c"] {
  color: var(--text-primary) !important;
}

html.theme-dark .pcard,
html.theme-dark .pcard:hover {
  color: #fff !important;
}
html.theme-dark .pcard-title,
html.theme-dark .entity-card .pcard-title,
html.theme-dark .group-card .pcard-title {
  color: #fff !important;
}
html.theme-dark .pcard-desc,
html.theme-dark .pcard-meta,
html.theme-dark .pcard-meta span,
html.theme-dark .group-card .pcard-desc,
html.theme-dark .group-card .pcard-meta {
  color: #fff !important;
  -webkit-text-fill-color: #fff !important;
  opacity: 1 !important;
}

html[class*="chat-wall-"] .tg-main,
html[class*="chat-wall-"] .tg-messages {
  background-color: var(--chat-wall-color) !important;
  background-image: var(--chat-wall-image) !important;
  background-size: var(--chat-wall-size, cover) !important;
  background-repeat: var(--chat-wall-repeat, no-repeat) !important;
  background-position: center !important;
}
html[class*="chat-wall-"] .chat-msg-mine .chat-bubble {
  background: var(--chat-mine, #4caf45) !important;
  color: var(--chat-mine-text, #fff) !important;
}
html[class*="chat-wall-"] .chat-msg-mine .chat-bubble-text {
  color: var(--chat-mine-text, #fff) !important;
}
html[class*="chat-wall-"] .chat-msg-other .chat-bubble {
  background: var(--chat-other, #fff) !important;
  color: var(--chat-other-text, #1c1917) !important;
  border-color: var(--chat-other-border, transparent) !important;
}
html[class*="chat-wall-"] .chat-msg-other .chat-bubble-text {
  color: var(--chat-other-text, #1c1917) !important;
}
html.theme-dark .profile-panel__cta,
html.theme-dark .profile-panel__cta:hover,
html.theme-dark .profile-panel__cta span,
html.theme-dark .profile-panel__cta .btn-busy,
html.theme-dark button.profile-panel__cta,
html.theme-dark label.profile-panel__cta {
  color: #fff !important;
  -webkit-text-fill-color: #fff !important;
}
