@import url("https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@600;700&family=Onest:wght@400;500;600;700;800&display=swap");

:root {
  --paper: #fbfaf6;
  --paper-2: #f3f0e8;
  --ink: #171717;
  --ink-2: #2b2b28;
  --muted: #747069;
  --line: #ded8c9;
  --sage: #78866b;
  --sage-2: #e5eadf;
  --brass: #c7a15b;
  --brass-2: #f0e4c9;
  --graphite: #384047;
  --white: #fffefa;
  --danger: #8c2830;
  --shadow: 0 18px 44px rgba(25, 25, 22, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(120, 134, 107, 0.14), transparent 34%),
    linear-gradient(180deg, #f8f6ef 0%, #ede8dd 100%);
  font-family: "Onest", "Segoe UI", sans-serif;
  letter-spacing: 0;
}

body.modal-open {
  overflow: hidden;
}

.bg-glow {
  display: none;
}

.page-shell {
  width: min(1100px, calc(100vw - 24px));
  margin: 16px auto 24px;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 76px;
  margin: 0 0 14px;
  padding: 12px;
  border: 1px solid rgba(222, 216, 201, 0.82);
  border-radius: 8px;
  background: rgba(255, 254, 250, 0.86);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
}

.brand img {
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  object-fit: contain;
}

.brand h1 {
  margin: 0;
  color: var(--ink);
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: clamp(1.32rem, 6vw, 2rem);
  line-height: 0.98;
}

.brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.22;
}

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.toolbar .group {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.btn {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn-solid {
  color: #fff;
  border-color: #151515;
  background: linear-gradient(135deg, #171717, #33342f);
}

.btn-outline {
  color: var(--ink);
  background: rgba(255, 254, 250, 0.86);
}

.card {
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid rgba(222, 216, 201, 0.82);
  border-radius: 8px;
  background: rgba(255, 254, 250, 0.88);
  box-shadow: var(--shadow);
}

.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.course {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  min-height: 136px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
}

.course img {
  width: 100%;
  height: 100%;
  min-height: 136px;
  object-fit: cover;
}

.course-body {
  min-width: 0;
  padding: 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
}

.course-body h3 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.08;
}

.course-body p {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.38;
}

.course-preview {
  display: -webkit-box;
  min-height: 3.55em;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.badge,
.pill {
  display: inline-flex;
  width: fit-content;
  border: 1px solid rgba(199, 161, 91, 0.34);
  border-radius: 999px;
  padding: 5px 9px;
  background: var(--brass-2);
  color: #725c2b;
  font-size: 0.76rem;
  font-weight: 700;
}

.meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.meta strong {
  white-space: nowrap;
}

.input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  color: var(--ink);
  padding: 10px 12px;
  font: inherit;
}

textarea.input {
  min-height: 96px;
  resize: vertical;
}

.table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  overflow: hidden;
  border-radius: 8px;
}

.table th,
.table td {
  border-bottom: 1px solid var(--line);
  text-align: left;
  padding: 10px;
  font-size: 0.86rem;
  vertical-align: top;
}

.table th {
  background: var(--sage-2);
  color: var(--graphite);
  font-weight: 800;
}

.table tbody tr {
  background: rgba(255, 254, 250, 0.88);
}

#coursesTableWrap,
#usersTableWrap {
  overflow-x: auto;
  padding-bottom: 4px;
}

.pager {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  gap: 8px;
}

.hidden {
  display: none !important;
}

.notice {
  border: 1px solid rgba(120, 134, 107, 0.25);
  border-radius: 8px;
  background: rgba(229, 234, 223, 0.68);
  padding: 10px 12px;
  color: var(--graphite);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 40;
  max-width: calc(100vw - 28px);
  transform: translateX(-50%);
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  padding: 10px 14px;
  opacity: 0;
  transition: 0.22s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  pointer-events: auto;
}

.course-detail {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: end center;
  padding: 10px;
}

.course-detail-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(23, 23, 23, 0.46);
  backdrop-filter: blur(10px);
}

.course-detail-panel {
  position: relative;
  width: min(760px, 100%);
  max-height: min(90vh, 880px);
  overflow: auto;
  border: 1px solid rgba(255, 254, 250, 0.5);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: 0 34px 90px rgba(18, 18, 17, 0.34);
}

.course-detail-image {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
}

.detail-content {
  padding: 16px;
}

.detail-content h2 {
  margin: 8px 0 10px;
  color: var(--ink);
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 1.8rem;
  line-height: 1.02;
}

.detail-content p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.detail-close {
  position: absolute;
  z-index: 2;
  top: 10px;
  right: 10px;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255, 254, 250, 0.68);
  border-radius: 999px;
  background: rgba(23, 23, 23, 0.78);
  color: #fff;
  cursor: pointer;
  font-size: 1.4rem;
  line-height: 1;
}

.pay-options {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 14px;
}

.pay-option {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  color: var(--ink);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  font: inherit;
  transition: 0.16s ease;
}

.pay-option span {
  color: var(--sage);
  font-size: 0.78rem;
  font-weight: 800;
}

.pay-option strong {
  font-size: 0.98rem;
}

.pay-option:hover {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.pay-option:hover span {
  color: #dfe8d7;
}

#adminTabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

#adminTabs button {
  flex: 0 0 auto;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  color: var(--ink-2);
  padding: 9px 12px;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}

#adminTabs button.active {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

label {
  color: var(--ink-2);
  font-weight: 700;
}

input[type="file"] {
  min-width: 0;
}

.file-control {
  min-height: 48px;
  border: 1px dashed rgba(120, 134, 107, 0.5);
  border-radius: 8px;
  background: rgba(229, 234, 223, 0.46);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
}

.file-control span {
  color: var(--graphite);
  font-size: 0.9rem;
}

.file-control input {
  display: none;
}

.stats-area .card-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stats-area .card {
  box-shadow: none;
}

.stats-area .card h3 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.stats-area .card p {
  margin: 0;
  color: var(--ink);
  font-size: 1.45rem;
  font-weight: 800;
}

@media (min-width: 520px) {
  .course {
    grid-template-columns: 132px minmax(0, 1fr);
  }

  .pay-options {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .pay-option {
    min-height: 64px;
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (min-width: 760px) {
  .page-shell {
    margin-top: 24px;
  }

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

  .course-detail {
    place-items: center;
  }

  .course-detail-panel {
    display: grid;
    grid-template-columns: minmax(240px, 0.88fr) 1.12fr;
  }

  .course-detail-image {
    height: 100%;
    min-height: 420px;
    aspect-ratio: auto;
  }

  .detail-content {
    padding: 24px;
  }

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

@media (max-width: 430px) {
  .page-shell {
    width: min(100vw - 18px, 430px);
    margin-top: 10px;
  }

  .header {
    align-items: flex-start;
  }

  .toolbar {
    align-items: stretch;
  }

  .toolbar .group,
  .toolbar .btn {
    flex: 1 1 auto;
  }

  .card {
    padding: 10px;
  }

  .course {
    grid-template-columns: 92px minmax(0, 1fr);
  }

  .course img {
    min-height: 128px;
  }

  .course-body {
    padding: 10px;
  }

  .course-body h3 {
    font-size: 0.96rem;
  }

  .meta .btn {
    min-height: 38px;
    padding: 8px 10px;
  }

  .table {
    min-width: 0;
    border-collapse: separate;
    border-spacing: 0 8px;
  }

  .table thead {
    display: none;
  }

  .table,
  .table tbody,
  .table tr,
  .table td {
    display: block;
    width: 100%;
  }

  .table tr {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--white);
    overflow: hidden;
  }

  .table td {
    border-bottom: 1px solid rgba(222, 216, 201, 0.58);
    padding: 9px 10px;
    display: flex;
    justify-content: space-between;
    gap: 12px;
  }

  .table td:last-child {
    border-bottom: 0;
  }

  .table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 800;
  }

  .table td[data-label="Действия"] {
    display: grid;
    grid-template-columns: 1fr;
  }

  .table td[data-label="Действия"]::before {
    margin-bottom: 2px;
  }
}
