:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #eef6f4;
  --text: #151922;
  --muted: #637083;
  --line: #d9e0ea;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --amber: #b7791f;
  --red: #b42318;
  --green: #157347;
  --shadow: 0 16px 40px rgba(23, 31, 45, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

img,
video {
  display: block;
  max-width: 100%;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 68px;
  padding: 12px clamp(16px, 4vw, 40px);
  border-bottom: 1px solid rgba(217, 224, 234, 0.88);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(16px);
}

.brand,
.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand {
  font-weight: 760;
}

.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  letter-spacing: 0;
}

.brand-mark.has-image {
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.page-shell {
  width: min(430px, calc(100% - 24px));
  margin: 0 auto;
  padding: 20px 0 48px;
}

.admin-page .page-shell {
  width: min(1180px, calc(100% - 32px));
  padding: 32px 0 56px;
}

.toolbar,
.admin-title-row {
  display: grid;
  align-items: start;
  gap: 20px;
  margin-bottom: 20px;
}

.admin-page .admin-title-row {
  display: flex;
  align-items: end;
  justify-content: space-between;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 760;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 34px;
  line-height: 1.04;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 22px;
}

h3 {
  margin-bottom: 6px;
  font-size: 17px;
}

.muted,
.section-head p,
.empty-state p {
  color: var(--muted);
}

.search-box {
  display: grid;
  gap: 6px;
  width: min(360px, 100%);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  outline: none;
}

input,
select {
  min-height: 42px;
  padding: 0 12px;
}

input[type="file"] {
  padding: 8px 10px;
}

textarea {
  min-height: 96px;
  resize: vertical;
  padding: 10px 12px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.filter-row,
.tabs {
  display: flex;
  flex-wrap: nowrap;
  gap: 10px;
  overflow-x: auto;
  margin: 20px 0 28px;
  padding-bottom: 2px;
}

.admin-page .tabs {
  flex-wrap: wrap;
  overflow-x: visible;
}

.chip,
.tab,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-weight: 750;
  transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.chip,
.tab {
  padding: 0 14px;
}

.button {
  gap: 8px;
  padding: 0 14px;
}

.chip:hover,
.tab:hover,
.button:hover {
  transform: translateY(-1px);
}

.chip.active,
.tab.active,
.button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.button.ghost {
  background: transparent;
}

.icon-button {
  display: inline-grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.icon-button:hover {
  transform: translateY(-1px);
}

.icon-button svg {
  width: 21px;
  height: 21px;
  fill: currentColor;
}

.telegram-button {
  border-color: rgba(42, 171, 238, 0.24);
  background: #eff8ff;
  color: #229ed9;
}

.button.danger {
  border-color: rgba(180, 35, 24, 0.2);
  background: #fff5f4;
  color: var(--red);
}

.button.warning {
  border-color: rgba(183, 121, 31, 0.22);
  background: #fff7e8;
  color: #8a540f;
}

.button.success {
  border-color: rgba(21, 115, 71, 0.18);
  background: #edf8f1;
  color: var(--green);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.video-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}

.video-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.video-card a {
  display: grid;
  min-height: 100%;
}

.poster {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: linear-gradient(135deg, #e4f0ec, #f7efe0);
}

.poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.poster-placeholder {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  color: var(--accent-strong);
  font-size: 42px;
  font-weight: 800;
}

.badge-row {
  position: absolute;
  right: 10px;
  bottom: 10px;
  left: 10px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 8px;
  background: rgba(21, 25, 34, 0.78);
  color: #fff;
  font-size: 12px;
  font-weight: 760;
}

.video-body {
  display: grid;
  gap: 8px;
  padding: 14px;
}

.video-body p {
  display: -webkit-box;
  min-height: 44px;
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.video-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.empty-state,
.auth-panel,
.admin-panel,
.payment-panel,
.watch-player {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.empty-state {
  padding: 28px;
  text-align: center;
}

.hidden {
  display: none !important;
}

.watch-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 22px;
  align-items: start;
}

.watch-player {
  overflow: hidden;
}

.watch-player video {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
}

.watch-copy {
  padding: 18px;
}

.watch-copy .badge {
  position: static;
  width: fit-content;
  margin-bottom: 10px;
  background: var(--surface-2);
  color: var(--accent-strong);
}

.payment-panel {
  display: grid;
  gap: 18px;
  padding: 18px;
}

.pay-price {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}

.pay-price strong {
  font-size: 34px;
  line-height: 1;
}

.address-box {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px dashed rgba(15, 118, 110, 0.4);
  border-radius: 8px;
  background: var(--surface-2);
}

.address-box code {
  overflow-wrap: anywhere;
  color: var(--accent-strong);
  font-size: 14px;
}

.stack-form {
  display: grid;
  gap: 14px;
}

.stack-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 740;
}

.stack-form .check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 2px;
}

.check-row input {
  width: 18px;
  min-height: 18px;
}

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

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

.span-2 {
  grid-column: 1 / -1;
}

.file-summary {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.admin-page .file-summary {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.file-summary div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.file-summary span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.file-summary strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.brand-settings-preview {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.brand-settings-preview p {
  margin: 4px 0 0;
}

.preview-mark {
  width: 46px;
  height: 46px;
}

.auth-panel {
  display: grid;
  grid-template-columns: 1fr;
  gap: 28px;
  align-items: center;
  padding: 28px;
}

.admin-page .auth-panel {
  grid-template-columns: 1fr minmax(280px, 420px);
}

.admin-shell {
  display: grid;
  gap: 18px;
}

.admin-panel {
  padding: 18px;
}

.admin-panel + .admin-panel {
  margin-top: 18px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  min-width: 120px;
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 800;
}

.status-pending {
  background: #fff7e8;
  color: #8a540f;
}

.status-approved {
  background: #edf8f1;
  color: var(--green);
}

.status-rejected {
  background: #fff5f4;
  color: var(--red);
}

.notice {
  padding: 10px 12px;
  border: 1px solid rgba(15, 118, 110, 0.24);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--accent-strong);
  font-size: 14px;
}

.error {
  border-color: rgba(180, 35, 24, 0.24);
  background: #fff5f4;
  color: var(--red);
}

@media (max-width: 900px) {
  .toolbar,
  .admin-title-row,
  .auth-panel,
  .watch-layout {
    grid-template-columns: 1fr;
  }

  .toolbar,
  .admin-title-row {
    display: grid;
    align-items: start;
  }

  .admin-page .form-grid,
  .admin-page .file-summary,
  .admin-page .auth-panel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .topbar {
    min-height: 60px;
    padding: 10px 12px;
  }

  .top-actions {
    margin-left: auto;
  }

  .top-actions .button {
    flex: none;
  }

  .page-shell {
    width: min(430px, calc(100% - 24px));
    padding-top: 24px;
  }

  h1 {
    font-size: 34px;
  }

  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }
}
