:root {
  --brand-red: #e21820;
  --ink: #121316;
  --panel: #1b1d22;
  --panel-2: #24272e;
  --line: #343842;
  --text: #f2f3f5;
  --muted: #a7adb8;
  --font: "Source Sans 3", "Segoe UI", sans-serif;
}

body.admin-body {
  margin: 0;
  font-family: var(--font);
  background: #0e0f12;
  color: var(--text);
  min-height: 100vh;
}

body.admin-menu-open {
  overflow: hidden;
}

.admin-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.admin-overlay {
  display: none;
}

.admin-sidebar {
  background: linear-gradient(180deg, #17191e, #101115);
  border-right: 1px solid var(--line);
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 100vh;
}

.admin-sidebar-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--line);
}

.admin-brand {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  color: #fff;
  text-decoration: none;
}

.admin-brand img { height: 48px; width: auto; align-self: flex-start; }
.admin-brand span { font-weight: 700; letter-spacing: 0.03em; }

.admin-drawer-close {
  display: none;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: #fff;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.admin-nav { display: flex; flex-direction: column; gap: 0.25rem; flex: 1; }
.admin-nav a {
  color: #fff;
  text-decoration: none;
  padding: 0.55rem 0.7rem;
  border-radius: 6px;
  font-weight: 600;
}
.admin-nav a:hover { background: var(--panel-2); color: #fff; }

.admin-sidebar-profile {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 0.7rem;
  border-top: 1px solid var(--line);
  margin-top: auto;
}

.admin-profile-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.admin-profile-meta strong {
  font-size: 0.92rem;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.admin-profile-meta span {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-profile-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-red), #7a0c12);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.admin-profile-avatar.sm {
  width: 34px;
  height: 34px;
  font-size: 0.75rem;
}

.admin-main { display: flex; flex-direction: column; min-width: 0; }
.admin-top {
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: rgba(27, 29, 34, 0.95);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(8px);
}
.admin-top-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}
.admin-top h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-menu-toggle {
  display: none;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: #fff;
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
}
.admin-menu-box {
  display: grid;
  gap: 5px;
  width: 18px;
  margin: 0 auto;
}
.admin-menu-line {
  display: block;
  height: 2px;
  width: 100%;
  background: currentColor;
  border-radius: 2px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.admin-menu-toggle.is-open .admin-menu-line:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.admin-menu-toggle.is-open .admin-menu-line:nth-child(2) {
  opacity: 0;
}
.admin-menu-toggle.is-open .admin-menu-line:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.admin-profile-wrap {
  position: relative;
  flex-shrink: 0;
}
.admin-profile-btn {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  border: 1px solid var(--line);
  background: var(--panel);
  color: #fff;
  border-radius: 999px;
  padding: 0.3rem 0.7rem 0.3rem 0.35rem;
  cursor: pointer;
}
.admin-profile-btn:hover,
.admin-profile-btn.is-open {
  border-color: #4a5060;
  background: var(--panel-2);
}
.admin-profile-btn-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.15;
  text-align: left;
}
.admin-profile-btn-text strong {
  font-size: 0.85rem;
  font-weight: 700;
}
.admin-profile-btn-text small {
  font-size: 0.72rem;
  color: var(--muted);
}
.admin-profile-caret {
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--muted);
  margin-left: 0.15rem;
}

.admin-profile-menu {
  position: absolute;
  top: calc(100% + 0.45rem);
  right: 0;
  width: min(260px, calc(100vw - 1.5rem));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.35);
  padding: 0.5rem;
  z-index: 50;
}
.admin-profile-menu-head {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.65rem 0.55rem 0.8rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 0.35rem;
}
.admin-profile-menu-head strong {
  display: block;
  font-size: 0.92rem;
}
.admin-profile-menu-head span {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  word-break: break-all;
}
.admin-profile-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--text);
  text-decoration: none;
  padding: 0.65rem 0.7rem;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
}
.admin-profile-item:hover {
  background: var(--panel-2);
  color: #fff;
}
.admin-profile-item.danger {
  color: #ff7b82;
}
.admin-profile-item.danger:hover {
  background: rgba(226, 24, 32, 0.15);
  color: #ffb0b4;
}

.admin-content { padding: 1.5rem; }

.admin-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1.25rem;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem 1.1rem;
}
.stat-card .label { color: var(--muted); font-size: 0.85rem; }
.stat-card .value { font-size: 1.8rem; font-weight: 700; margin-top: 0.2rem; color: #fff; }

.table { color: var(--text); }
.table > :not(caption) > * > * { background: transparent; color: var(--text); border-color: var(--line); }
.table thead th { color: var(--muted); font-weight: 600; }

.form-control, .form-select, .form-check-input {
  background: #12141a;
  border-color: var(--line);
  color: var(--text);
}
.form-control:focus, .form-select:focus {
  background: #12141a;
  color: var(--text);
  border-color: var(--brand-red);
  box-shadow: 0 0 0 0.2rem rgba(226, 24, 32, 0.2);
}
.form-label { color: var(--muted); font-weight: 600; }

.btn-brand {
  background: var(--brand-red);
  border: none;
  color: #fff;
  font-weight: 700;
}
.btn-brand:hover { background: #b81218; color: #fff; }

.thumb-sm { width: 96px; height: 54px; object-fit: cover; border-radius: 4px; }

.admin-login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(circle at 20% 20%, rgba(226, 24, 32, 0.25), transparent 45%),
    #0e0f12;
}

.login-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1.75rem;
}
.login-card img { height: 56px; margin-bottom: 1rem; }
.login-card h1 { font-size: 1.4rem; margin-bottom: 0.25rem; }
.login-card .hint { color: var(--muted); font-size: 0.9rem; margin-bottom: 1.25rem; }

.badge-latest { background: var(--brand-red); }

/* Classic CKEditor 4 (CKEditor.NET style) */
.cke_chrome {
  border-color: #d1d5db !important;
  border-radius: 6px;
  overflow: hidden;
  width: 100% !important;
}
.cke_inner {
  background: #fff !important;
}
.cke_top {
  background: #f3f4f6 !important;
  border-bottom-color: #d1d5db !important;
}
.cke_bottom {
  background: #f3f4f6 !important;
  border-top-color: #d1d5db !important;
}
.cke_contents {
  background: #fff !important;
}
.admin-card .cke {
  max-width: 100%;
}

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

  .admin-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 90;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }
  .admin-overlay.is-visible {
    opacity: 1;
    pointer-events: auto;
  }

  .admin-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(300px, 86vw);
    z-index: 100;
    transform: translateX(-105%);
    transition: transform 0.25s ease;
    border-right: 1px solid var(--line);
    box-shadow: 12px 0 32px rgba(0, 0, 0, 0.35);
    min-height: 100vh;
  }
  .admin-sidebar.is-open {
    transform: translateX(0);
  }

  .admin-drawer-close {
    display: grid;
    place-items: center;
  }

  .admin-menu-toggle {
    display: inline-grid;
    place-items: center;
  }

  .admin-top {
    padding: 0.75rem 0.9rem;
  }

  .admin-profile-btn-text {
    display: none;
  }

  .admin-profile-btn {
    padding: 0.25rem;
    border-radius: 50%;
  }

  .admin-profile-caret {
    display: none;
  }

  .stat-grid { grid-template-columns: 1fr 1fr; }
  .admin-content { padding: 1rem; }
  .admin-card { overflow-x: auto; }
  .table { min-width: 640px; }
}

@media (max-width: 576px) {
  .stat-grid { grid-template-columns: 1fr; }
  .admin-top h1 { font-size: 1.05rem; }
  .login-card { padding: 1.25rem; }
  .thumb-sm { width: 72px; height: 40px; }
  .admin-content { padding: 0.85rem; }
}

.mtv-toast-host {
  z-index: 2100;
}
.mtv-toast-host .toast {
  min-width: min(320px, calc(100vw - 1.5rem));
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
}

body.admin-confirm-open {
  overflow: hidden;
}

.admin-confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 2200;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(3px);
}

.admin-confirm-overlay[hidden] {
  display: none !important;
}

.admin-confirm-dialog {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.35rem 1.35rem 1.15rem;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.45);
  text-align: center;
}

.admin-confirm-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 0.85rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, var(--brand-red), #7a0c12);
}

.admin-confirm-dialog h2 {
  margin: 0 0 0.45rem;
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
}

.admin-confirm-dialog p {
  margin: 0 0 1.15rem;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.admin-confirm-actions {
  display: flex;
  gap: 0.65rem;
  justify-content: center;
  flex-wrap: wrap;
}

.admin-confirm-actions .btn {
  min-width: 110px;
  font-weight: 700;
}
