/* RGMZ admin. Shares the brand palette but is its own utilitarian interface —
   dense, fast to scan, no decoration that does not earn its place. */

:root {
  --green: #0f3d35;
  --green-deep: #082a25;
  --green-900: #061f1b;
  --charcoal: #171a19;
  --ivory: #f5f2ea;
  --mist: #e7e9e2;
  --gold: #b89452;
  --gold-dark: #9c7a3f;

  --bg: #f4f5f2;
  --surface: #fff;
  --text: #1b201e;
  --muted: #6b746f;
  --border: #dde1db;
  --border-strong: #c3c9c1;
  --ok: #1f6b45;
  --warn: #8a6414;
  --err: #9b2c2c;

  --sp1: 4px; --sp2: 8px; --sp3: 12px; --sp4: 16px; --sp5: 24px; --sp6: 32px; --sp7: 48px;
  --radius: 5px;
  --side-w: 232px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
}

h1 { font-size: 22px; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 15px; margin: 0 0 var(--sp4); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
a { color: inherit; text-decoration: none; }
code { background: var(--mist); padding: 1px 5px; border-radius: 3px; font-size: 12px; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---------- sidebar ---------- */
.side {
  position: fixed; inset: 0 auto 0 0; width: var(--side-w);
  background: var(--green-900); color: #cfd8d4;
  display: flex; flex-direction: column; padding: var(--sp5) 0;
}
.side__brand { display: block; padding: 0 var(--sp5) var(--sp5); }
.mark { font-family: 'Cormorant Garamond', Georgia, serif; font-size: 26px; letter-spacing: .2em; color: var(--gold); font-weight: 600; display: block; }
.mark--lg { font-size: 36px; text-align: center; }
.side__brand .sub { font-size: 10px; letter-spacing: .24em; text-transform: uppercase; color: #7d8a85; }
.side__nav { display: flex; flex-direction: column; gap: 2px; padding: 0 var(--sp3); flex: 1; }
.side__nav a {
  display: flex; align-items: center; gap: var(--sp3);
  padding: 9px var(--sp3); border-radius: var(--radius);
  font-size: 13.5px; font-weight: 500; color: #b9c4bf;
  transition: background .15s, color .15s;
}
.side__nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.side__nav a.is-active { background: var(--green); color: #fff; }
.side__nav svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.side__foot { padding: var(--sp4) var(--sp5) 0; border-top: 1px solid rgba(255,255,255,.08); margin-top: var(--sp4); }
.side__user { font-size: 12px; margin: 0 0 var(--sp3); color: #cfd8d4; }
.side__user span { color: #7d8a85; }
.side__logout, .side__site { display: block; font-size: 12px; color: #8f9c97; padding: 3px 0; }
.side__logout:hover, .side__site:hover { color: var(--gold); }

/* ---------- main ---------- */
.main { margin-left: var(--side-w); padding: var(--sp6) var(--sp7); max-width: 980px; }
.main--wide { max-width: 1500px; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp5); margin-bottom: var(--sp5); flex-wrap: wrap; }
.page-head .count { font-size: 14px; color: var(--muted); font-weight: 400; margin-left: var(--sp2); }
.back { font-size: 12px; color: var(--muted); display: inline-block; margin-bottom: 2px; }
.back:hover { color: var(--green); }
.muted { color: var(--muted); font-size: 12.5px; }
.strike { text-decoration: line-through; }
.hint { font-size: 12px; color: var(--muted); margin: var(--sp2) 0 0; }
.empty { padding: var(--sp7); text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius); }

/* ---------- flash / notice ---------- */
.flash { padding: var(--sp3) var(--sp4); border-radius: var(--radius); margin-bottom: var(--sp5); font-size: 13px; }
.flash--ok { background: rgba(31,107,69,.1); color: var(--ok); border: 1px solid rgba(31,107,69,.28); }
.flash--error { background: rgba(155,44,44,.08); color: var(--err); border: 1px solid rgba(155,44,44,.28); }
.notice { background: rgba(184,148,82,.1); border: 1px solid rgba(184,148,82,.4); padding: var(--sp4); border-radius: var(--radius); font-size: 13px; margin-bottom: var(--sp5); }

/* ---------- cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--sp4); margin-bottom: var(--sp6); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--sp4) var(--sp5); transition: border-color .15s, transform .15s; }
a.card:hover { border-color: var(--gold); transform: translateY(-1px); }
.card__label { font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); margin: 0 0 var(--sp2); }
.card__value { font-size: 30px; font-weight: 600; margin: 0; line-height: 1; color: var(--green); }
.card__sub { font-size: 12px; color: var(--muted); margin: var(--sp2) 0 0; }

/* ---------- panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--sp5); margin-bottom: var(--sp5); }
.stack { display: grid; gap: var(--sp5); }

/* ---------- tables ---------- */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: var(--sp3) var(--sp4); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: var(--sp3) var(--sp4); border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fafbf9; }
.thumb { width: 42px; height: 42px; object-fit: contain; background: var(--mist); border-radius: 3px; display: block; }
.thumb--empty { display: block; width: 42px; height: 42px; background: var(--mist); border-radius: 3px; }

/* ---------- badges ---------- */
.badge { display: inline-block; font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; padding: 2px 7px; border-radius: 3px; background: var(--mist); color: #47504b; }
.badge--new { background: var(--green); color: #fff; }
.badge--pre { background: var(--mist); color: var(--green); }
.badge--edited { background: rgba(184,148,82,.22); color: var(--gold-dark); }
.badge--ok { background: rgba(31,107,69,.15); color: var(--ok); }
.badge--warn { background: rgba(138,100,20,.15); color: var(--warn); }

/* ---------- forms ---------- */
.field { margin-bottom: var(--sp4); }
.field label { display: block; font-size: 12px; font-weight: 600; margin-bottom: var(--sp2); text-transform: capitalize; }
.field input[type=text], .field input[type=number], .field input[type=email], .field input[type=password], .field select, .field textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius);
  font: inherit; font-size: 13px; background: var(--surface); color: var(--text);
}
.field textarea { resize: vertical; line-height: 1.6; font-family: var(--font); }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--green); outline: 2px solid rgba(184,148,82,.4); outline-offset: 0; }
.field--switch { display: flex; align-items: center; justify-content: space-between; gap: var(--sp4); }
.field--switch label { margin: 0; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch span { display: inline-block; width: 38px; height: 21px; background: var(--border-strong); border-radius: 999px; position: relative; transition: background .18s; cursor: pointer; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 15px; height: 15px; border-radius: 50%; background: #fff; transition: transform .18s; }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(17px); }
.switch input:focus-visible + span { outline: 2px solid var(--gold); outline-offset: 2px; }

.two { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp4); }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: var(--sp4); margin: 0 0 var(--sp4); }
legend { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 0 var(--sp2); }
.specs__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--sp3) var(--sp4); }
.slide { background: #fbfcfa; }
.slide__row { display: grid; grid-template-columns: 160px minmax(0,1fr); gap: var(--sp4); align-items: start; }
.slide-image { aspect-ratio: 16/9; background: var(--mist); border-radius: var(--radius); overflow: hidden; margin-bottom: var(--sp2); display: grid; place-items: center; }
.slide-image img { width: 100%; height: 100%; object-fit: cover; display: block; }
.slide-image__empty { padding: var(--sp2); font-size: 10px; line-height: 1.3; color: var(--muted); text-align: center; }
.slide__actions { display: flex; gap: var(--sp2); flex-wrap: wrap; margin-top: var(--sp3); padding-top: var(--sp3); border-top: 1px solid var(--border); }
@media (max-width: 560px) { .slide__row { grid-template-columns: 1fr; } }

.edit { display: grid; grid-template-columns: minmax(0,1fr) 300px; gap: var(--sp6); align-items: start; }
.edit__side { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--sp4); position: sticky; top: var(--sp5); }
.edit__main { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--sp5); }
.preview { width: 100%; aspect-ratio: 1; object-fit: contain; background: var(--mist); border-radius: var(--radius); margin-bottom: var(--sp3); }
.preview--empty { display: grid; place-items: center; color: var(--muted); font-size: 12px; }

/* ---------- image gallery ---------- */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: var(--sp2); margin-bottom: var(--sp3); }
.gallery__item { position: relative; aspect-ratio: 1; background: var(--mist); border-radius: var(--radius); overflow: hidden; }
.gallery__item img { width: 100%; height: 100%; object-fit: contain; display: block; }
.gallery__missing { display: grid; place-items: center; height: 100%; padding: 4px; font-size: 9.5px; line-height: 1.3; color: var(--muted); text-align: center; }
.gallery__remove { position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; padding: 0; border: none; border-radius: 50%; background: rgba(20,22,20,.62); color: #fff; font-size: 14px; line-height: 1; cursor: pointer; display: grid; place-items: center; }
.gallery__remove:hover { background: var(--err); }
.upload-btn { display: block; text-align: center; cursor: pointer; }
.empty--sm { padding: var(--sp5); font-size: 12px; }

.filters-bar { display: flex; gap: var(--sp2); flex-wrap: wrap; }
.filters-bar input, .filters-bar select { padding: 7px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius); font: inherit; font-size: 13px; }
.filters-bar input[type=search] { min-width: 260px; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--sp2); padding: 8px 15px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; transition: background .15s, border-color .15s, color .15s; }
.btn:hover { background: var(--mist); }
.btn--primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn--primary:hover { background: var(--green-deep); color: #fff; }
.btn--ghost { border-color: transparent; color: var(--muted); }
.btn--ghost:hover { color: var(--err); background: rgba(155,44,44,.06); }
.btn--sm { padding: 5px 11px; font-size: 12px; }
.btn--block { width: 100%; margin-top: var(--sp2); }

.pager { display: flex; align-items: center; justify-content: space-between; margin-top: var(--sp5); }
.tabs { display: flex; gap: var(--sp2); }
.tabs a { padding: 5px 11px; border-radius: 999px; font-size: 12px; text-transform: capitalize; color: var(--muted); border: 1px solid transparent; }
.tabs a:hover { background: var(--surface); }
.tabs a.is-active { background: var(--green); color: #fff; }

/* ---------- review moderation modal ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(10,20,16,.5); display: flex; align-items: flex-start; justify-content: center; padding: var(--sp6) var(--sp4); overflow-y: auto; z-index: 100; }
.modal { background: #fff; border-radius: var(--radius); padding: var(--sp5); width: 100%; max-width: 520px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal h2 { margin-top: 0; }
.modal__actions { display: flex; justify-content: flex-end; gap: var(--sp3); margin-top: var(--sp4); }

/* ---------- leads ---------- */
.lead { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--sp4) var(--sp5); margin-bottom: var(--sp3); }
.lead__head { display: flex; justify-content: space-between; gap: var(--sp4); align-items: flex-start; flex-wrap: wrap; }
.lead__body { background: #fafbf9; border-left: 2px solid var(--gold); padding: var(--sp3) var(--sp4); margin: var(--sp3) 0 0; white-space: pre-wrap; font-size: 13px; }
.inline { display: flex; gap: var(--sp2); align-items: center; }
.inline select { padding: 5px 8px; border: 1px solid var(--border-strong); border-radius: var(--radius); font: inherit; font-size: 12px; }
.order-items { margin: var(--sp3) 0; padding: 0; list-style: none; font-size: 13px; }
.order-items li { padding: 3px 0; border-bottom: 1px dashed var(--border); }

.log { background: var(--charcoal); color: #d7ded9; padding: var(--sp4); border-radius: var(--radius); font-size: 12px; line-height: 1.5; overflow-x: auto; max-height: 420px; white-space: pre-wrap; }

/* ---------- login ---------- */
.login-body { display: grid; place-items: center; min-height: 100vh; background: var(--green-900); }
.login { background: var(--surface); padding: var(--sp7); border-radius: 8px; width: min(380px, 92vw); box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.login__sub { text-align: center; font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); margin: 0 0 var(--sp6); }
.login label { display: block; font-size: 12px; font-weight: 600; margin-bottom: var(--sp2); }
.login input { width: 100%; padding: 9px 11px; border: 1px solid var(--border-strong); border-radius: var(--radius); font: inherit; margin-bottom: var(--sp4); }
.login .btn { width: 100%; margin-top: var(--sp2); }

@media (max-width: 900px) {
  .side {
    position: static; width: auto; padding: var(--sp3) var(--sp4);
    display: grid; grid-template-columns: minmax(0, 1fr) auto;
    align-items: center; gap: var(--sp3) var(--sp4);
  }
  .side__brand { padding: 0; }
  .side__nav {
    grid-column: 1 / -1; grid-row: 2;
    flex-direction: row; flex-wrap: nowrap; gap: var(--sp1); padding: 0;
    overflow-x: auto; overscroll-behavior-inline: contain; scrollbar-width: none;
  }
  .side__nav::-webkit-scrollbar { display: none; }
  .side__nav a { flex: 0 0 auto; justify-content: center; padding: 9px 12px; font-size: 12.5px; white-space: nowrap; }
  .side__foot {
    grid-column: 2; grid-row: 1;
    border: 0; margin: 0; padding: 0; display: flex; gap: var(--sp3);
  }
  .side__user { display: none; }
  .main { margin-left: 0; padding: var(--sp4); }
  .edit { grid-template-columns: 1fr; }
  .edit__side { position: static; }
  /* 16px prevents iOS Safari from auto-zooming the page on focus. */
  .field input[type=text], .field input[type=number], .field input[type=email],
  .field input[type=password], .field select, .field textarea { font-size: 16px; }
}

/* Table columns need room; scroll horizontally rather than crushing the title. */
.table { min-width: 860px; }
.table td:nth-child(2) { min-width: 300px; }
.table td:nth-child(2) strong { display: block; line-height: 1.35; }
.table th:first-child, .table td:first-child { width: 58px; }
.table td:last-child, .table th:last-child { width: 70px; text-align: right; }
.main--wide { max-width: none; }

.side__nav a { min-height: 42px; }
.side__logout { background: none; border: 0; padding: 0; color: inherit; cursor: pointer; font: inherit; }
.page-head input[type="search"] { width: min(360px, 100%); }
.badge--ok { background: #ddf5e6; color: #176238; }
.badge--warn { background: #fff0df; color: #8a4700; }
.badge--edited { background: #e9e5ff; color: #48349b; }
@media (max-width: 760px) {
  .side__nav { display: flex; overflow-x: auto; gap: 4px; padding-bottom: 8px; }
  .page-head { align-items: flex-start; }
}

/* ---------- mobile catalogue: rows become cards ---------- */
@media (max-width: 640px) {
  .table-wrap { overflow-x: visible; border: none; background: transparent; }
  .table { min-width: 0; width: 100%; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: var(--sp3); padding: var(--sp3); }
  .table td { border-bottom: 0; padding: 5px 0; display: flex; justify-content: space-between; align-items: center; gap: var(--sp3); }
  .table td[data-label]:not([data-label=""])::before { content: attr(data-label); flex: none; font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
  .table td:first-child, .table td:last-child { width: 100%; text-align: left; }
  .table td:first-child { justify-content: flex-start; }
  .table td:last-child { justify-content: flex-end; padding-top: var(--sp2); }
  .thumb, .thumb--empty { width: 34px; height: 34px; }
  .page-head input[type="search"] { width: 100%; }
  .gallery { grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); }
}
