:root {
  --bg: #eef2ec;
  --panel: #fff;
  --text: #1a3d1a;
  --muted: #6a7a6a;
  --line: #dde5da;
  --accent: #2f5d2f;
  --accent-soft: #e7f0e7;
  --danger: #b33a3a;
  --danger-soft: #f8eaea;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(26, 61, 26, 0.04), 0 8px 24px rgba(26, 61, 26, 0.06);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background:
    radial-gradient(ellipse 70% 40% at 100% 0%, rgba(47, 93, 47, 0.08), transparent 50%),
    var(--bg);
  color: var(--text);
  line-height: 1.45;
  min-height: 100vh;
}
a { color: var(--accent); }
.boot { padding: 2rem; color: var(--muted); }

.layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  min-height: 100vh;
}
.sidebar {
  background: #163016;
  color: #eef5ee;
  padding: 1.1rem 0.85rem;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar h1 {
  font-size: 0.92rem;
  margin: 0 0.35rem 1.1rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.sidebar nav { display: flex; flex-direction: column; gap: 0.2rem; }
.sidebar button {
  text-align: left;
  background: transparent;
  border: 0;
  color: inherit;
  padding: 0.5rem 0.7rem;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
}
.sidebar button:hover { background: rgba(255,255,255,0.08); }
.sidebar button.is-active { background: rgba(255,255,255,0.14); font-weight: 600; }
.sidebar .meta {
  margin-top: 1.5rem;
  padding: 0 0.35rem;
  font-size: 0.8rem;
  opacity: 0.75;
}
#logout {
  margin-top: 0.45rem;
  padding: 0.35rem 0.55rem;
  border-radius: 6px;
  border: 0;
  cursor: pointer;
  background: rgba(255,255,255,0.1);
  color: #fff;
  font: inherit;
  font-size: 0.8rem;
}
#logout:hover { background: rgba(255,255,255,0.18); }

.main { padding: 1.25rem 1.5rem 2rem; }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.15rem 1.15rem;
  max-width: 960px;
  box-shadow: var(--shadow);
}
.panel--wide { max-width: 1080px; }
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.85rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--line);
}
.panel-head h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 650;
}
.panel-sub {
  margin: 0.2rem 0 0;
  font-size: 0.8rem;
}
h2 { margin: 0 0 1rem; font-size: 1.2rem; }

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}
.login-wrap .panel { width: min(380px, 100%); }

label { display: block; font-size: 0.85rem; margin: 0.7rem 0 0.25rem; color: var(--muted); }
input[type="text"],
input[type="password"],
input[type="number"],
input[type="url"],
textarea,
select {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  background: #fff;
}
input:focus,
textarea:focus,
select:focus {
  outline: 2px solid rgba(47, 93, 47, 0.25);
  border-color: var(--accent);
}
textarea { min-height: 100px; font-family: ui-monospace, monospace; font-size: 0.85rem; }

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.row--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }
.field label { margin: 0; }
.field-hint { margin: 0.25rem 0 0; font-size: 0.75rem; word-break: break-all; }
.field--full { grid-column: 1 / -1; }
.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 1rem; }

button.btn, a.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  border: 0;
  border-radius: 8px;
  padding: 0.48rem 0.85rem;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 560;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
button.btn:hover { filter: brightness(1.05); }
button.btn.secondary {
  background: var(--accent-soft);
  color: var(--accent);
}
button.btn.secondary:hover { background: #d9e8d9; }
button.btn.danger {
  background: var(--danger-soft);
  color: var(--danger);
}
button.btn.danger:hover { background: #f0d6d6; }
button.btn.btn-sm {
  padding: 0.32rem 0.6rem;
  font-size: 0.8rem;
  border-radius: 6px;
}
button.btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* Edit product */
.panel--edit {
  padding-bottom: 0.75rem;
}
.edit-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}
.edit-head__thumb {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  overflow: hidden;
  background: #e5ebe3;
  flex-shrink: 0;
}
.edit-head__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.edit-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.edit-section {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fafbf9;
  overflow: hidden;
}
.edit-section__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0.85rem;
  background: #f3f6f2;
  border-bottom: 1px solid var(--line);
}
.edit-section__head h3 {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 650;
  letter-spacing: 0.01em;
}
.edit-section__body {
  padding: 0.85rem;
}
.stack-sm {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.edit-item {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 0.65rem;
  align-items: start;
  padding: 0.55rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.edit-item--variant {
  grid-template-columns: 36px minmax(0, 1fr);
}
.edit-item__badge {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  font-weight: 700;
}
.edit-item__fields {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 0.5rem 0.65rem;
}
.edit-item__fields--grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.field-preview {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  overflow: hidden;
  background: #e5ebe3;
}
.field-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.field-preview--empty {
  background:
    linear-gradient(135deg, #e5ebe3 25%, #d5ddd3 25% 50%, #e5ebe3 50% 75%, #d5ddd3 75%);
  background-size: 10px 10px;
}
.empty-inline {
  margin: 0.25rem 0;
  font-size: 0.85rem;
}
.edit-footer {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.75rem 0 0.25rem;
  margin-top: 0.25rem;
  background: linear-gradient(to top, var(--panel) 70%, transparent);
}
.edit-section .row { margin: 0; }
.edit-section .field + .field,
.edit-section .row + .row,
.edit-section .row + .field,
.edit-section .field + .row {
  margin-top: 0.65rem;
}
.edit-section__body > .row + .row { margin-top: 0.65rem; }
.edit-section__body > .field + .field { margin-top: 0.65rem; }

@media (max-width: 900px) {
  .row--3 { grid-template-columns: 1fr; }
  .edit-item__fields,
  .edit-item__fields--grid {
    grid-template-columns: 1fr;
  }
  .edit-item,
  .edit-item--variant {
    grid-template-columns: 1fr;
  }
}


/* Product list */
.product-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.product-row {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.45rem 0.55rem;
  border: 1px solid transparent;
  border-radius: 10px;
  background: #fafbf9;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.product-row:hover {
  background: #fff;
  border-color: var(--line);
  box-shadow: 0 2px 10px rgba(26, 61, 26, 0.06);
}
.product-row__thumb {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  overflow: hidden;
  background: #e5ebe3;
  flex-shrink: 0;
}
.product-row__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.product-row__thumb--empty {
  background:
    linear-gradient(135deg, #e5ebe3 25%, #d5ddd3 25% 50%, #e5ebe3 50% 75%, #d5ddd3 75%);
  background-size: 12px 12px;
}
.product-row__body { min-width: 0; }
.product-row__title {
  font-size: 0.92rem;
  font-weight: 620;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.product-row__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.35rem;
  margin-top: 0.15rem;
  font-size: 0.75rem;
  color: var(--muted);
}
.product-row__meta .slug {
  font-size: 0.72rem;
  background: #eef2ec;
  color: #3d533d;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.product-row__meta .dot { opacity: 0.5; }
.product-row__meta .price {
  font-weight: 650;
  color: #4a3821;
}
.product-row__status { justify-self: end; }
.product-row__actions {
  display: flex;
  gap: 0.35rem;
  justify-content: flex-end;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 650;
  letter-spacing: 0.02em;
}
.badge--ok {
  background: var(--accent-soft);
  color: var(--accent);
}
.badge--draft {
  background: #f1efe8;
  color: #7a6f55;
}

.review-row .product-row__meta .slug {
  max-width: min(420px, 50vw);
}

table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
th, td { text-align: left; padding: 0.55rem 0.4rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.muted { color: var(--muted); font-size: 0.9rem; }
.error { color: var(--danger); margin: 0.5rem 0; font-size: 0.9rem; }
.ok { color: var(--accent); margin: 0.5rem 0; font-size: 0.9rem; }
.stack { display: flex; flex-direction: column; gap: 0.75rem; }
.card-block {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 0.75rem;
  background: #fafbf9;
}
.help {
  background: var(--accent-soft);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  font-size: 0.9rem;
}

@media (max-width: 900px) {
  .product-row {
    grid-template-columns: 44px minmax(0, 1fr);
    grid-template-areas:
      "thumb body"
      "status actions";
  }
  .product-row__thumb { grid-area: thumb; width: 44px; height: 44px; }
  .product-row__body { grid-area: body; }
  .product-row__status { grid-area: status; justify-self: start; padding-left: calc(44px + 0.75rem); }
  .product-row__actions { grid-area: actions; }
}

@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: relative;
    height: auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1rem;
  }
  .sidebar h1 { margin: 0; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar .meta { margin: 0; margin-left: auto; display: flex; align-items: center; gap: 0.5rem; }
  #logout { margin-top: 0; }
  .row { grid-template-columns: 1fr; }
  .main { padding: 1rem; }
}

/* Dashboard */
.dash-kpis {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 1rem 0 1.25rem;
}
.dash-kpi {
  background: var(--accent-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.85rem 1rem;
}
.dash-kpi__label { font-size: 0.8rem; color: var(--muted); }
.dash-kpi__value { font-size: 1.6rem; font-weight: 700; margin-top: 0.2rem; }
.dash-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 1rem;
}
.dash-chart {
  display: flex;
  align-items: flex-end;
  gap: 0.55rem;
  min-height: 140px;
  padding: 0.5rem 0.25rem 0;
}
.dash-bar {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 0.25rem;
  min-width: 0;
}
.dash-bar__fill {
  width: 100%;
  max-width: 36px;
  border-radius: 8px 8px 4px 4px;
  background: linear-gradient(180deg, #3f7a3f, #2f5d2f);
}
.dash-bar__label { font-size: 0.72rem; color: var(--muted); }
.dash-bar__val { font-size: 0.75rem; font-weight: 600; }
.dash-top { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.55rem; }
.dash-top__item {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 0.65rem;
  align-items: center;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.dash-top__rank {
  width: 28px; height: 28px; border-radius: 999px;
  display: grid; place-items: center;
  background: var(--accent-soft); font-weight: 700; font-size: 0.85rem;
}
.dash-top__title { font-weight: 600; font-size: 0.92rem; }
.dash-top__views { color: var(--accent); }
.dash-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.dash-table th, .dash-table td {
  text-align: left;
  padding: 0.55rem 0.45rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.dash-table th { color: var(--muted); font-weight: 600; font-size: 0.78rem; }
.dash-url-cell { max-width: 280px; }
.dash-url {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  color: var(--accent);
  text-decoration: none;
}
.dash-url:hover { text-decoration: underline; }
@media (max-width: 1000px) {
  .dash-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-grid { grid-template-columns: 1fr; }
}
