.admin-shell {
  min-height: 100vh;
}

body.login-mode .admin-shell {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 100vh;
}

body.login-mode .admin-shell > .container {
  width: 100%;
  max-width: 620px;
}

body.login-mode .admin-header {
  display: none;
}

body:not(.login-mode) .admin-shell > .container {
  width: 100%;
  max-width: none;
  padding-inline: clamp(1rem, 4vw, 4rem);
  margin-inline: auto;
}

.admin-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(12rem, 18%) minmax(0, 1fr);
  align-items: start;
  gap: 1.5rem;
  width: 100%;
  max-width: 110rem;
  margin-inline: auto;
}

.admin-sidebar {
  position: sticky;
  top: 1.5rem;
  display: flex;
  min-height: clamp(28rem, calc(100vh - 12rem), 48rem);
  flex-direction: column;
  padding: 1rem;
  border: 1px solid rgba(233, 108, 255, 0.2);
  border-radius: 20px;
  background: linear-gradient(165deg, rgba(23, 13, 34, 0.96), rgba(8, 10, 15, 0.96));
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.34);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-brand img {
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.sidebar-brand strong,
.sidebar-brand span {
  display: block;
}

.sidebar-brand strong {
  color: #fff;
  font-family: "Orbitron", sans-serif;
  font-size: 0.82rem;
}

.sidebar-brand span {
  margin-top: 0.18rem;
  color: var(--accent-2);
  font-size: 0.6rem;
  letter-spacing: 0.14em;
}

.sidebar-nav {
  display: grid;
  gap: 0.4rem;
  margin-top: 1.25rem;
}

.sidebar-link,
.sidebar-logout {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  padding: 0.78rem 0.75rem;
  text-align: left;
  transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.sidebar-link:hover,
.sidebar-link.is-active {
  border-color: rgba(233, 108, 255, 0.26);
  background: rgba(169, 0, 255, 0.13);
  color: #fff;
  transform: translateX(2px);
}

.sidebar-icon {
  display: inline-grid;
  width: 34px;
  height: 28px;
  place-items: center;
  border: 1px solid rgba(233, 108, 255, 0.28);
  border-radius: 7px;
  color: var(--accent-2);
  font: 0.58rem "Orbitron", sans-serif;
  letter-spacing: 0.02em;
}

.sidebar-footer {
  display: grid;
  gap: 0.65rem;
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-back,
.sidebar-logout {
  color: var(--muted);
  font-size: 0.8rem;
  text-decoration: none;
}

.sidebar-back:hover {
  color: #fff;
}

.sidebar-logout {
  justify-content: center;
  border-color: rgba(255, 120, 140, 0.3);
  color: #ff9bab;
  font-size: 0.76rem;
}

.sidebar-logout:hover {
  background: rgba(255, 120, 140, 0.1);
  color: #ffb0bd;
}

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

.content-heading {
  margin: 0 0 1rem;
  padding: 0.25rem 0.25rem 0;
}

.content-heading h2 {
  margin: 0.35rem 0 0.3rem;
  font-family: "Orbitron", sans-serif;
}

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

.admin-card {
  background: rgba(12, 15, 20, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 20px;
  padding: clamp(1.15rem, 2vw, 1.75rem);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

.login-card {
  max-width: 560px;
  margin: 0 auto;
  padding: 2.25rem;
  background: linear-gradient(145deg, rgba(20, 12, 30, 0.95), rgba(8, 10, 15, 0.94));
  border-color: rgba(233, 108, 255, 0.28);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.48), 0 0 45px rgba(169, 0, 255, 0.12);
  text-align: center;
}

.login-logo {
  width: 92px;
  height: 92px;
  object-fit: contain;
  margin: 0 auto 1rem;
  filter: drop-shadow(0 12px 22px rgba(169, 0, 255, 0.4));
}

.login-card .admin-form {
  margin-top: 1.5rem;
  text-align: left;
}

.login-card .btn-accent {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.82rem 1rem;
  border-radius: 11px;
  font-family: "Orbitron", sans-serif;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.login-card .btn-accent:hover {
  box-shadow: 0 14px 34px rgba(233, 108, 255, 0.42);
  filter: brightness(1.08);
  transform: translateY(-2px);
}

.admin-card h2 {
  margin: 0.35rem 0 1rem;
  font-family: "Orbitron", sans-serif;
  font-size: 1.35rem;
}

.admin-card-heading,
.editor-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.admin-form {
  display: grid;
  gap: 0.65rem;
}

.admin-form label,
.editor-card > label {
  color: #e8e8f3;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.admin-form input,
.admin-form textarea,
.admin-form select,
.editor-card select,
.page-editor,
#page-editor {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  background: rgba(4, 6, 10, 0.82);
  color: #f4f4ff;
  padding: 0.7rem 0.8rem;
}

#page-editor {
  display: block;
  min-height: clamp(24rem, 55vh, 42rem);
  max-height: clamp(30rem, 65vh, 52rem);
  margin-top: 0.65rem;
  resize: vertical;
  font: 0.84rem/1.5 Consolas, "Liberation Mono", monospace;
}

.editor-view-switch {
  display: inline-flex;
  gap: 0.3rem;
  margin-top: 1rem;
  padding: 0.25rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: rgba(4, 6, 10, 0.7);
}

.view-switch {
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  padding: 0.5rem 0.9rem;
  font-size: 0.78rem;
  font-weight: 600;
}

.view-switch:hover,
.view-switch.is-active {
  background: rgba(169, 0, 255, 0.2);
  color: #fff;
}

.code-search {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  width: min(100%, 34rem);
  margin: 0.75rem 0 0.65rem auto;
  padding: 0.3rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 9px;
  background: #15151d;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
}

.code-search[hidden] {
  display: none;
}

.code-search input {
  min-width: 0;
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: #f4f4ff;
  padding: 0.45rem 0.55rem;
  font: 0.82rem Consolas, "Liberation Mono", monospace;
}

.code-search input::placeholder {
  color: #888294;
}

.code-search-count {
  min-width: 4.5rem;
  color: var(--muted);
  font-size: 0.72rem;
  text-align: center;
  white-space: nowrap;
}

.code-search-button {
  display: inline-grid;
  width: 1.8rem;
  height: 1.8rem;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 1rem;
}

.code-search-button:hover {
  background: rgba(169, 0, 255, 0.2);
  color: #fff;
}

.code-search-close {
  font-size: 1.25rem;
}

.page-preview {
  display: none;
  width: 100%;
  min-height: clamp(24rem, 55vh, 42rem);
  max-height: clamp(30rem, 65vh, 52rem);
  margin-top: 0.65rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  background: #0b0b12;
}

.admin-panel[data-admin-section="pages"].preview-mode #page-editor {
  display: none;
}

.admin-panel[data-admin-section="pages"].preview-mode .page-preview {
  display: block;
}

.editor-actions {
  justify-content: flex-start;
  margin-top: 0.85rem;
}

.admin-help {
  margin: 0.85rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.admin-message {
  min-height: 1.3rem;
  color: var(--accent-2);
  font-size: 0.88rem;
}

.admin-message.error {
  margin-top: 1rem;
  color: #ff8d9f;
}

.upload-form {
  margin-bottom: 0.75rem;
}

.upload-form input[type="file"] {
  padding: 0.55rem;
}

.image-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}

.image-item {
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  background: rgba(4, 6, 10, 0.7);
}

.image-item img {
  display: block;
  width: 100%;
  height: 100px;
  object-fit: cover;
  background: #080a0e;
}

.image-item-info {
  display: grid;
  gap: 0.45rem;
  padding: 0.65rem;
}

.image-name {
  overflow: hidden;
  color: #e8e8f3;
  font-size: 0.76rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-list {
  display: grid;
  gap: 0.65rem;
  margin-top: 1rem;
}

.news-admin-card {
  grid-column: 1 / -1;
}

.news-content-input {
  min-height: clamp(20rem, 42vh, 36rem);
  max-height: 70vh;
  resize: vertical;
}

.news-list {
  display: grid;
  gap: 0.7rem;
  margin-top: 1.2rem;
}

.news-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 0.75rem;
}

.news-item-main {
  min-width: 0;
}

.news-item-title {
  overflow: hidden;
  color: #f4f4ff;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.news-item-meta {
  color: var(--muted);
  font-size: 0.76rem;
}

.news-item-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.user-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 0.7rem;
}

.user-item-main {
  min-width: 0;
}

.user-item-name {
  overflow: hidden;
  color: #f4f4ff;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-item-role {
  color: var(--muted);
  font-size: 0.76rem;
}

.delete-image {
  border: 1px solid rgba(255, 120, 140, 0.4);
  border-radius: 7px;
  background: transparent;
  color: #ff9bab;
  font-size: 0.75rem;
  padding: 0.35rem 0.5rem;
}

.delete-image:hover {
  background: rgba(255, 120, 140, 0.12);
}

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

  .admin-sidebar {
    position: static;
    min-height: auto;
  }

  .sidebar-nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .sidebar-link {
    justify-content: center;
    flex-direction: column;
    gap: 0.35rem;
    padding: 0.65rem 0.35rem;
    text-align: center;
  }

  .sidebar-link:hover,
  .sidebar-link.is-active {
    transform: translateY(-1px);
  }
}

@media (max-width: 560px) {
  .admin-header,
  .admin-card-heading,
  .editor-actions,
  .news-item,
  .sidebar-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .sidebar-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .editor-actions .btn {
    width: 100%;
  }
}
