:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #64707d;
  --line: #d9dee5;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --warning: #8a4b00;
  --warning-bg: #fff4dd;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 Arial, Helvetica, sans-serif;
}

body.modal-open {
  overflow: hidden;
}

a {
  color: var(--accent-strong);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.35);
  outline-offset: 2px;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.brand {
  color: var(--text);
  font-size: 20px;
  font-weight: 700;
}

.top-nav,
.inline-form,
.inline-controls,
.action-cell {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.top-nav a {
  color: var(--text);
}

.site-footer {
  display: grid;
  gap: 10px;
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 22px 24px 30px;
  color: var(--muted);
}

.site-footer nav {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.site-footer p {
  margin: 0;
}

.affiliate-note:empty {
  display: none;
}

.page {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.flash-wrap {
  width: min(1200px, calc(100% - 32px));
  margin: 16px auto 0;
}

.flash {
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 6px;
}

.flash.error {
  border-color: #f2b8b5;
  color: var(--danger);
}

.flash.success {
  border-color: #a9d8c3;
  color: var(--accent-strong);
}

.feed-layout,
.admin-layout,
.detail-layout {
  display: grid;
  gap: 20px;
}

.feed-layout {
  grid-template-columns: 280px 1fr;
  align-items: start;
}

.admin-layout {
  grid-template-columns: 220px 1fr;
  align-items: start;
}

.detail-layout {
  grid-template-columns: minmax(260px, 420px) 1fr;
}

.detail-page-overlay {
  display: flex;
  justify-content: center;
}

.detail-window {
  position: relative;
  width: min(1120px, 100%);
  max-height: calc(100vh - 112px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 20px 60px rgba(23, 32, 42, 0.22);
}

.content-page {
  display: grid;
  gap: 14px;
  max-width: 900px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.content-page p {
  margin: 0;
}

.content-page h2 {
  margin-top: 12px;
}

.link-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.link-grid a {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.filters-panel,
.feed-panel,
.admin-main,
.admin-nav,
.auth-panel,
.detail-media,
.detail-content,
.empty-state {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.filters-panel,
.admin-nav {
  position: sticky;
  top: 16px;
}

.filters-panel {
  max-height: calc(100vh - 32px);
  overflow-y: auto;
}

.filters-form,
.stack-form {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.filter-actions {
  position: sticky;
  bottom: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 2px -16px -16px;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--line);
  background: var(--panel);
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.checkbox-label {
  display: inline-flex;
  grid-column: 1 / -1;
  align-items: center;
  gap: 8px;
}

.checkbox-label input {
  width: auto;
  min-height: auto;
}

.button,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  text-decoration: none;
}

.button.primary,
button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.button.secondary {
  color: var(--muted);
}

.button.small,
button.small {
  min-height: 32px;
  padding: 5px 9px;
  font-size: 13px;
}

.button.danger,
button.danger {
  border-color: #f2b8b5;
  color: var(--danger);
}

.link-button {
  min-height: auto;
  padding: 0;
  border: 0;
  color: var(--accent-strong);
  background: transparent;
}

.feed-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 26px;
}

h2 {
  font-size: 18px;
}

.feed-header p,
.muted,
.small-note {
  color: var(--muted);
}

.feed-header p {
  margin: 4px 0 0;
}

.deal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  padding: 18px;
}

.deal-card {
  display: grid;
  grid-template-rows: 180px 1fr;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.image-frame,
.detail-media {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #eef1f4;
}

.image-frame img,
.detail-media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.placeholder,
.detail-placeholder {
  color: var(--muted);
  font-weight: 700;
}

.deal-card-body {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.detail-meta,
.badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.detail-meta span,
.badges span {
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
}

.price-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.price-row strong {
  font-size: 20px;
}

.warning {
  margin: 0;
  padding: 8px 10px;
  border: 1px solid #f1d19b;
  border-radius: 6px;
  background: var(--warning-bg);
  color: var(--warning);
}

.card-actions,
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.pagination {
  padding: 18px;
  border-top: 1px solid var(--line);
}

.detail-media {
  min-height: 420px;
  overflow: hidden;
}

.detail-window .detail-layout {
  gap: 0;
}

.detail-window .detail-media,
.detail-window .detail-content {
  border: 0;
  border-radius: 0;
}

.detail-window .detail-media {
  border-right: 1px solid var(--line);
}

.detail-content,
.admin-main,
.auth-panel,
.empty-state {
  padding: 22px;
}

.detail-back-button {
  position: sticky;
  top: 12px;
  left: 12px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  margin: 12px 0 -50px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.95);
  color: var(--text);
  font-size: 22px;
  line-height: 1;
  text-decoration: none;
}

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin: 18px 0;
}

.facts div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.facts dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.facts dd {
  margin: 4px 0 0;
  font-size: 17px;
  font-weight: 700;
}

.detail-section {
  margin-top: 20px;
}

.detail-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.coupon-code {
  display: inline-block;
  margin: 8px 0;
  padding: 10px 12px;
  border: 1px dashed var(--accent);
  border-radius: 6px;
  background: #eaf8f5;
  font: 700 18px/1.2 Consolas, monospace;
}

.coupon-code-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.raw-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafb;
  color: var(--text);
}

.detail-modal[hidden] {
  display: none;
}

.detail-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
}

.detail-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(23, 32, 42, 0.48);
}

.detail-modal-dialog {
  position: relative;
  width: min(1120px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
}

.detail-modal .detail-window {
  width: 100%;
  max-height: none;
}

.detail-loading {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  font-weight: 700;
}

.review-list {
  display: grid;
  gap: 16px;
}

.review-item {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}

.review-media {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 160px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #eef1f4;
}

.review-media img {
  width: 100%;
  max-height: 180px;
  object-fit: contain;
}

.review-body,
.review-form {
  display: grid;
  gap: 12px;
}

.review-form {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.review-raw {
  max-height: 180px;
  overflow: auto;
}

.admin-nav {
  display: grid;
  gap: 4px;
  padding: 12px;
}

.admin-nav a {
  padding: 9px 10px;
  border-radius: 6px;
  color: var(--text);
}

.admin-nav a:hover {
  background: #eef1f4;
  text-decoration: none;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin: 16px 0 24px;
}

.stat-grid div {
  display: grid;
  gap: 4px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.stat-grid strong {
  font-size: 26px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

@media (max-width: 860px) {
  .site-header,
  .feed-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .feed-layout,
  .admin-layout,
  .detail-layout,
  .review-item {
    grid-template-columns: 1fr;
  }

  .detail-modal {
    align-items: start;
    padding: 12px;
  }

  .detail-modal-dialog {
    width: 100%;
    max-height: calc(100vh - 24px);
  }

  .detail-window {
    max-height: calc(100vh - 24px);
  }

  .detail-window .detail-media {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .filters-panel,
  .admin-nav {
    position: static;
  }

  .filters-panel {
    max-height: none;
    overflow: visible;
  }

  .page {
    padding: 14px;
  }
}
