:root {
  color-scheme: dark;
  --bg: #050507;
  --panel: #101116;
  --text: #F3F5FF;
  --muted: #B8BBC4;
  --line: #2A2D34;
  --soft: #161820;
  --accent: #8EDBFF;
  --danger: #F1A7C8;
  --lavender: #9B7CFF;
  --ice: #8EDBFF;
  --pink: #F1A7C8;
  --glow: #F3F5FF;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 18% 0%, rgba(155, 124, 255, .18), transparent 32rem),
    radial-gradient(circle at 86% 8%, rgba(142, 219, 255, .12), transparent 30rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  border: 0;
  border-radius: 8px;
  background: var(--text);
  color: #fff;
  cursor: pointer;
  font-weight: 800;
  min-height: 40px;
  padding: 0 16px;
}

button:hover {
  filter: brightness(1.08);
}

input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  min-height: 42px;
  padding: 0 12px;
  width: 100%;
}

textarea {
  padding: 12px;
  resize: vertical;
}

label {
  color: var(--muted);
  display: grid;
  font-size: 13px;
  font-weight: 800;
  gap: 8px;
}

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

.site-shell,
.admin-shell {
  width: min(1160px, calc(100% - 28px));
  margin: 0 auto;
  padding: 24px 0 56px;
}

.login-screen {
  align-items: center;
  display: grid;
  min-height: 100vh;
  padding: 20px;
}

.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 16px;
  margin: 0 auto;
  padding: 24px;
  width: min(420px, 100%);
}

.login-card h1 {
  font-size: 34px;
}

.login-error {
  color: var(--danger);
  min-height: 20px;
}

.ad-slot {
  align-items: center;
  aspect-ratio: 5 / 1;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  display: flex;
  justify-content: center;
  overflow: hidden;
  text-align: center;
  width: 100%;
}

.ad-slot a {
  color: inherit;
  display: block;
  height: 100%;
  text-decoration: none;
  width: 100%;
}

.ad-slot img {
  display: block;
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.ad-link-fill {
  height: 100%;
}

.info-row {
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr 1fr;
  margin-top: 16px;
}

.info-panel,
.admin-panel,
.insight-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.info-panel {
  min-height: 136px;
  padding: 16px;
}

.panel-head {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
}

.panel-head h2,
.admin-panel-head h2 {
  font-size: 18px;
}

.text-list {
  display: grid;
  gap: 10px;
}

.text-item {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-template-columns: auto 1fr;
}

.text-item img {
  background: var(--soft);
  border-radius: 8px;
  height: 44px;
  object-fit: cover;
  width: 44px;
}

.text-item p,
.muted {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}

.catalog-head,
.admin-top {
  align-items: end;
  display: flex;
  gap: 20px;
  justify-content: space-between;
  margin: 28px 0 16px;
}

.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  margin-bottom: 8px;
  text-transform: uppercase;
}

h1 {
  font-size: clamp(30px, 5vw, 56px);
  letter-spacing: 0;
  line-height: 1.02;
}

.country-select {
  min-width: 160px;
}

.search-row {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr auto 220px;
}

.search-input {
  min-height: 48px;
}

.line-button,
.admin-row button,
.modal-actions button:first-child {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--text);
}

.sort-select {
  min-height: 48px;
}

.filter-panel {
  align-items: end;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr 1fr auto;
  margin-top: 12px;
  padding: 14px;
}

.gift-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  margin-top: 18px;
}

.gift-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: inherit;
  overflow: hidden;
  text-decoration: none;
}

.gift-card:hover {
  border-color: #b7c0d1;
  filter: brightness(0.99);
}

.gift-card img {
  aspect-ratio: 1;
  background: var(--soft);
  display: block;
  object-fit: contain;
  padding: 10px;
  width: 100%;
}

.gift-info {
  display: grid;
  gap: 2px;
  padding: 8px;
  text-align: center;
}

.gift-info strong {
  color: #59627f;
  font-size: 14px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gift-info span {
  color: #737a94;
  font-size: 14px;
  line-height: 1.1;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  grid-column: 1 / -1;
  padding: 28px;
  text-align: center;
}

.empty.small {
  padding: 18px;
}

.token-box {
  width: min(340px, 100%);
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.tab {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--text);
}

.tab.active {
  background: var(--text);
  color: #fff;
}

.admin-panel {
  display: none;
  padding: 18px;
}

.admin-panel.active {
  display: block;
}

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

.admin-list {
  display: grid;
  gap: 8px;
}

.gift-admin-filters {
  display: grid;
  gap: 12px;
  grid-template-columns: 160px 160px 1fr;
  margin-bottom: 14px;
}

.gift-admin-grid {
  display: grid;
  gap: 10px;
}

.gift-admin-card {
  align-items: start;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: 84px 1fr;
  padding: 10px;
}

.gift-admin-card.expired {
  opacity: 0.72;
}

.gift-admin-card img {
  aspect-ratio: 1;
  background: var(--soft);
  border-radius: 8px;
  object-fit: contain;
  padding: 8px;
  width: 84px;
}

.gift-admin-title {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.badge {
  background: #fff3cd;
  border: 1px solid #f2d37b;
  border-radius: 999px;
  color: #7a5a00;
  font-size: 12px;
  font-weight: 800;
  padding: 3px 8px;
}

.badge.ok {
  background: #e8f7ef;
  border-color: #a5dfbd;
  color: #167344;
}

.badge.expired {
  background: #fdecef;
  border-color: #f3b4bf;
  color: #a33a4c;
}

.gift-admin-card dl {
  display: grid;
  gap: 5px 10px;
  grid-template-columns: 100px 1fr;
  margin: 0;
}

.gift-admin-card dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.gift-admin-card dd {
  font-size: 12px;
  margin: 0;
  overflow-wrap: anywhere;
}

.gift-admin-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

.gift-edit-preview {
  align-items: center;
  display: grid;
  gap: 12px;
  grid-template-columns: 72px 1fr;
}

.gift-edit-preview img {
  aspect-ratio: 1;
  background: var(--soft);
  border-radius: 8px;
  object-fit: contain;
  padding: 8px;
  width: 72px;
}

.admin-row,
.table-head {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr auto;
  min-height: 48px;
  padding: 8px 10px;
}

.admin-row div {
  display: flex;
  gap: 8px;
}

.admin-row button {
  min-height: 34px;
  padding: 0 12px;
}

.pager {
  color: var(--muted);
  margin-top: 14px;
  text-align: right;
}

.ad-table {
  grid-template-columns: 70px 1.2fr 1.4fr 100px 70px 70px;
}

.alias-table {
  grid-template-columns: 56px 90px 1.2fr 1fr 1.2fr 80px;
}

.unknown-table {
  grid-template-columns: 56px 90px 1.3fr 1fr 100px 90px 1.4fr;
}

.inline-form {
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: 90px repeat(4, minmax(0, 1fr)) 120px;
  margin-bottom: 16px;
  padding: 14px;
}

.inline-form button {
  min-height: 44px;
}

.table-head {
  background: var(--soft);
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  margin-bottom: 8px;
}

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

.insight-card {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.insight-card strong {
  font-size: 34px;
}

.traffic-box {
  background: var(--soft);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  padding: 14px;
}

.modal {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  width: min(560px, calc(100% - 24px));
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.38);
}

.modal form {
  display: grid;
  gap: 14px;
  padding: 20px;
}

.date-row {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr 1fr;
}

.check-row {
  align-items: center;
  display: flex;
  gap: 8px;
}

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

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

@media (max-width: 900px) {
  .info-row,
  .catalog-head,
  .admin-top,
  .insight-grid {
    grid-template-columns: 1fr;
  }

  .catalog-head,
  .admin-top {
    align-items: stretch;
    display: grid;
  }

  .search-row,
  .filter-panel,
  .gift-admin-filters {
    grid-template-columns: 1fr;
  }

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

  .ad-table {
    grid-template-columns: 48px 1fr;
  }

  .alias-table,
  .unknown-table,
  .inline-form {
    grid-template-columns: 1fr;
  }

  .table-head {
    display: none;
  }
}

@media (max-width: 520px) {
  .site-shell,
  .admin-shell {
    width: min(100% - 18px, 1160px);
    padding-top: 12px;
  }

  .tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

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

  .date-row {
    grid-template-columns: 1fr;
  }
}

button {
  border: 1px solid rgba(184, 187, 196, .22);
  background: linear-gradient(135deg, rgba(155, 124, 255, .24), rgba(42, 45, 52, .92));
  color: var(--glow);
}

button:hover {
  border-color: var(--ice);
  filter: none;
}

input,
select,
textarea,
.tab,
.line-button,
.admin-row button,
.modal-actions button:first-child {
  background: rgba(5, 5, 7, .78);
  color: var(--glow);
}

.tab.active,
.modal-actions button:last-child {
  background: linear-gradient(135deg, rgba(155, 124, 255, .28), rgba(42, 45, 52, .92));
  color: var(--glow);
}

.gift-card,
.gift-admin-card,
.admin-row,
.modal,
.login-card {
  background: rgba(16, 17, 22, .94);
}

.gift-card:hover {
  border-color: var(--ice);
  filter: none;
}

.gift-info strong {
  color: var(--glow);
}

.gift-info span {
  color: var(--muted);
}

.badge {
  background: rgba(241, 167, 200, .12);
  border-color: rgba(241, 167, 200, .35);
  color: var(--pink);
}

.badge.ok {
  background: rgba(142, 219, 255, .12);
  border-color: rgba(142, 219, 255, .35);
  color: var(--ice);
}

.badge.expired {
  background: rgba(241, 167, 200, .12);
  border-color: rgba(241, 167, 200, .35);
  color: var(--pink);
}

.ad-slot,
.info-panel,
.admin-panel,
.insight-card,
.filter-panel {
  box-shadow: 0 18px 48px rgba(0, 0, 0, .22);
}
