:root {
  color-scheme: dark;
  --bg: #07070a;
  --panel: #121217;
  --panel-soft: #191920;
  --panel-strong: #20212a;
  --text: #f8fafc;
  --muted: #a7b0c0;
  --line: #2a2d38;
  --red: #f01f3d;
  --red-dark: #b10018;
  --gold: #ffbf2e;
  --green: #16a36f;
  --blue: #58a6ff;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(240, 31, 61, 0.16), transparent 30%),
    linear-gradient(315deg, rgba(255, 191, 46, 0.12), transparent 28%),
    var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 36px;
  background: rgba(10, 10, 14, 0.95);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand {
  display: grid;
  gap: 6px;
}

.brand img {
  display: block;
  width: min(310px, 72vw);
  height: auto;
}

.brand p,
small,
.status-card p,
.license-status p,
.toolbar-line p {
  color: var(--muted);
}

h1,
h2,
p {
  margin: 0;
}

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

.pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 800;
}

.pill.ok {
  border-color: rgba(22, 163, 111, 0.5);
  color: #79e0b5;
}

.pill.bad {
  border-color: rgba(240, 31, 61, 0.55);
  color: #ff8fa0;
}

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(320px, 1fr);
  gap: 20px;
  padding: 24px 36px 36px;
}

.auth-layout {
  display: grid;
  min-height: calc(100vh - 120px);
  padding: 34px 18px;
  place-items: center;
}

.auth-panel {
  width: min(520px, 100%);
}

.login-help,
.hint-line {
  color: var(--muted);
  line-height: 1.5;
  margin-top: 12px;
}

.admin-layout {
  grid-template-columns: minmax(320px, 1fr);
}

.panel {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent), var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 22px;
}

.promotions-panel,
.license-panel {
  grid-column: 1 / -1;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.panel-title span {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  color: white;
  font-weight: 900;
}

h2 {
  font-size: 20px;
}

.form,
.filters,
.license-status {
  display: grid;
  gap: 14px;
}

.filters {
  grid-template-columns: minmax(260px, 2fr) repeat(4, minmax(140px, 1fr));
  align-items: end;
}

.wide-field {
  grid-column: span 2;
}

label {
  display: grid;
  gap: 6px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #343846;
  border-radius: 6px;
  background: #0c0c11;
  color: var(--text);
  font: inherit;
  min-height: 44px;
  padding: 10px 12px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--gold);
  outline: 2px solid rgba(255, 191, 46, 0.16);
}

textarea {
  resize: vertical;
}

.check-field {
  align-items: center;
  display: flex;
  gap: 9px;
  min-height: 44px;
}

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

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

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

.compact-form {
  margin-bottom: 18px;
}

button {
  border: 0;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  color: white;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 16px;
  font-weight: 900;
}

.admin-link {
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  text-decoration: none;
  font-weight: 900;
}

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

.secondary {
  background: #242732;
  color: var(--text);
}

.secondary:hover {
  background: #303442;
}

.toolbar-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 16px 0;
}

.promo-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(230px, 1fr));
  gap: 14px;
}

.offer-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  overflow: hidden;
  min-height: 100%;
}

.offer-image {
  aspect-ratio: 4 / 3;
  background: #09090d;
  display: grid;
  place-items: center;
  overflow: hidden;
}

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

.offer-image span {
  color: var(--muted);
  font-weight: 800;
}

.offer-body {
  display: grid;
  gap: 9px;
  padding: 13px;
}

.offer-head {
  display: grid;
  gap: 7px;
}

.offer-title {
  font-size: 15px;
  line-height: 1.3;
  min-height: 40px;
}

.source-badge {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  display: inline-flex;
  font-size: 11px;
  font-weight: 900;
  justify-self: start;
  min-height: 24px;
  padding: 5px 9px;
  text-transform: uppercase;
}

.source-badge.auto {
  border-color: rgba(255, 191, 46, 0.55);
  color: var(--gold);
}

.offer-price {
  color: var(--gold);
  font-size: 24px;
  font-weight: 900;
}

.offer-meta {
  color: var(--muted);
  display: grid;
  gap: 3px;
  font-size: 13px;
}

.offer-links {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 3px;
}

.offer-links a {
  border-radius: 6px;
  color: white;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  text-decoration: none;
}

.buy-link {
  background: linear-gradient(135deg, var(--red), var(--red-dark));
}

.message-link {
  background: var(--panel-strong);
}

.catalog-list {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
}

.catalog-item {
  color: var(--muted);
  font-size: 13px;
}

.status-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 16px;
}

.status-card strong {
  display: block;
  margin-bottom: 4px;
  font-size: 18px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.admin-stats {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.stats div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 14px;
}

.stats span {
  color: var(--gold);
  display: block;
  font-size: 27px;
  font-weight: 900;
}

.stats small {
  display: block;
  margin-top: 3px;
}

.table-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  min-width: 920px;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px;
  text-align: left;
  vertical-align: top;
}

th {
  background: #101017;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

td small {
  display: block;
  margin-top: 4px;
}

tr:last-child td {
  border-bottom: 0;
}

.status {
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 900;
  min-height: 26px;
  padding: 5px 9px;
}

.status.active,
.status.paid {
  border-color: rgba(22, 163, 111, 0.5);
  color: #79e0b5;
}

.status.pending {
  border-color: rgba(255, 191, 46, 0.55);
  color: var(--gold);
}

.status.blocked,
.status.expired,
.status.overdue,
.status.canceled,
.status.inactive {
  border-color: rgba(240, 31, 61, 0.55);
  color: #ff8fa0;
}

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

.table-button {
  min-height: 34px;
  padding: 0 10px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: 360px;
  padding: 14px 16px;
  border-radius: 8px;
  background: #f8fafc;
  color: #111827;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  transition: 0.2s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1180px) {
  .filters,
  .promo-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .wide-field {
    grid-column: 1 / -1;
  }
}

@media (max-width: 820px) {
  .topbar,
  .status-card,
  .toolbar-line,
  .actions,
  .top-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar,
  .layout {
    padding-left: 16px;
    padding-right: 16px;
  }

  .layout,
  .filters,
  .grid-2,
  .grid-3,
  .promo-grid,
  .stats {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }
}
