/* Buried Treasure — Bandit Power's back office. */

:root {
  --lilac: #D8C5D5;
  --cream: #E0D6CA;
  --ink: #15252E;
  --oxblood: #7A1315;
  --magenta: #A5205F;
  --night: #330a1c;

  --bg: #f6f1ec;
  --panel: #ffffff;
  --line: #e4dcd3;
  --muted: #6b6560;
  --ok: #2f6b4f;
  --ok-bg: #e3f1e8;
  --warn-bg: #fbeee0;
  --warn: #8a4b0b;

  --font-head: "Besley", Georgia, serif;
  --font-body: "auster", "Gill Sans", "Gill Sans MT", "Trebuchet MS", system-ui, sans-serif;
  --radius: 16px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-head); font-weight: 600; line-height: 1.2; margin: 0; letter-spacing: 0.01em; }
p { margin: 0; }
a { color: var(--magenta); }
img { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--magenta); outline-offset: 2px; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.boot { padding: 30vh 0; text-align: center; font-family: var(--font-head); color: var(--muted); }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px;
  border: 2px solid transparent; border-radius: 12px;
  font-weight: 700; font-size: 0.95rem; letter-spacing: 0.02em;
  text-decoration: none; white-space: nowrap;
  background: var(--magenta); color: #fff;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.btn:hover { background: var(--oxblood); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn--ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn--ghost:hover { background: #fff; border-color: var(--ink); }
.btn--danger { background: #b3261e; }
.btn--danger:hover { background: #8c1d18; }
.btn--small { min-height: 34px; padding: 6px 12px; font-size: 0.85rem; border-radius: 10px; }
.btn--block { width: 100%; }
.link-btn { background: none; border: 0; padding: 0; color: var(--magenta); text-decoration: underline; text-underline-offset: 3px; font-weight: 700; }

/* ---------- Fields ---------- */

.field { display: grid; gap: 6px; }
.field > span, .label { font-weight: 700; font-size: 0.9rem; }
.hint { font-size: 0.82rem; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; min-height: 44px; padding: 10px 12px;
  border: 1.5px solid var(--line); border-radius: 10px; background: #fff;
}
textarea.input { min-height: 110px; resize: vertical; line-height: 1.55; }
.input:focus { outline: none; border-color: var(--magenta); box-shadow: 0 0 0 3px rgba(165, 32, 95, 0.18); }
.input-prefix { position: relative; }
.input-prefix > b { position: absolute; left: 12px; top: 50%; translate: 0 -50%; color: var(--muted); font-weight: 400; }
.input-prefix > .input { padding-left: 28px; }

.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--magenta); flex: none; }
.check small { display: block; color: var(--muted); font-size: 0.82rem; }

.segmented { display: inline-flex; border: 1.5px solid var(--line); border-radius: 12px; padding: 3px; background: #fff; gap: 3px; flex-wrap: wrap; }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.segmented span { display: block; padding: 7px 14px; border-radius: 9px; font-weight: 700; font-size: 0.9rem; }
.segmented input:checked + span { background: var(--ink); color: #fff; }
.segmented input:focus-visible + span { outline: 3px solid var(--magenta); outline-offset: 1px; }

.error-box { background: #fde8e7; color: #8c1d18; border-radius: 10px; padding: 10px 12px; font-weight: 700; font-size: 0.92rem; }
.error-box:empty { display: none; }
.info-box { background: var(--warn-bg); color: var(--warn); border-radius: 12px; padding: 14px 16px; line-height: 1.55; }
.info-box strong { display: block; margin-bottom: 2px; }

/* ---------- Login ---------- */

.login {
  min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background:
    radial-gradient(ellipse 55% 35% at 12% 18%, rgba(165, 32, 95, 0.42), transparent 70%),
    radial-gradient(ellipse 45% 40% at 88% 60%, rgba(122, 19, 21, 0.6), transparent 70%),
    var(--night);
}
.login__card { width: min(100%, 400px); background: var(--bg); border-radius: 24px; padding: 32px 28px; box-shadow: 0 30px 60px rgba(0, 0, 0, 0.4); }
.login__card img { height: 64px; width: auto; margin: 0 auto 10px; }
.login__card h1 { text-align: center; font-size: 1.6rem; }
.login__card > p { text-align: center; color: var(--muted); margin: 4px 0 22px; font-size: 0.95rem; }
.login form { display: grid; gap: 14px; }
.code-input { letter-spacing: 0.4em; font-size: 1.3rem; text-align: center; font-variant-numeric: tabular-nums; }

/* ---------- Shell ---------- */

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--night); color: #fff;
}
.topbar__brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; margin-right: auto; }
.topbar__brand img { height: 36px; width: auto; }
.topbar__brand span { font-family: var(--font-head); font-size: 1.1rem; }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a { color: #f1e7ee; text-decoration: none; padding: 8px 12px; border-radius: 10px; font-weight: 700; font-size: 0.95rem; }
.topbar nav a:hover { background: rgba(255, 255, 255, 0.1); }
.topbar nav a[aria-current="page"] { background: var(--magenta); color: #fff; }
.topbar__me { display: flex; align-items: center; gap: 10px; font-size: 0.85rem; color: var(--lilac); }
.topbar__me .link-btn { color: #fff; }
.topbar .site-link { color: var(--lilac); font-size: 0.85rem; }
@media (max-width: 640px) {
  .topbar nav { order: 3; width: 100%; justify-content: space-between; }
  .topbar nav a { flex: 1; text-align: center; }
  .topbar__brand span { display: none; }
}

.page { max-width: 1040px; margin: 0 auto; padding: 24px 16px 96px; }
.page__head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page__head h1 { font-size: 1.7rem; margin-right: auto; }
.back { display: inline-flex; gap: 6px; align-items: center; font-weight: 700; text-decoration: none; color: var(--muted); margin-bottom: 10px; }
.back:hover { color: var(--ink); }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.panel + .panel { margin-top: 16px; }
.panel h2 { font-size: 1.15rem; margin-bottom: 14px; }
.stack { display: grid; gap: 16px; }
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.02em; white-space: nowrap; background: #eee8e2; color: var(--muted); }
.pill--live { background: var(--ok-bg); color: var(--ok); }
.pill--sold { background: #f3e1ea; color: var(--magenta); }
.pill--paid { background: var(--warn-bg); color: var(--warn); }
.pill--shipped { background: var(--ok-bg); color: var(--ok); }
.pill--bad { background: #fde8e7; color: #8c1d18; }

/* ---------- Toolbar + lists ---------- */

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar .input { max-width: 280px; }

.list { list-style: none; margin: 0; padding: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.row {
  display: grid; grid-template-columns: auto 64px 1fr auto; gap: 14px; align-items: center;
  padding: 10px 14px; border-top: 1px solid var(--line); background: var(--panel);
}
.row:first-child { border-top: 0; }
.row:hover { background: #fcfaf8; }
.row.dragging { opacity: 0.4; }
.row.drop-before { box-shadow: inset 0 3px 0 var(--magenta); }
.row__thumb { width: 64px; height: 64px; border-radius: 12px; background: var(--cream); display: grid; place-items: center; padding: 6px; overflow: hidden; }
.row__thumb img { width: 100%; height: 100%; object-fit: contain; }
.row__main { min-width: 0; text-decoration: none; color: inherit; display: grid; gap: 2px; }
.row__title { font-family: var(--font-head); font-size: 1.05rem; }
.row__sub { color: var(--muted); font-size: 0.88rem; }
.row__meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 2px; }
.row__price { font-weight: 700; font-variant-numeric: tabular-nums; }
.row__actions { display: flex; gap: 6px; align-items: center; }
.order-btns { display: grid; gap: 2px; }
.order-btns button { width: 30px; height: 26px; border: 1px solid var(--line); background: #fff; border-radius: 8px; font-size: 0.8rem; line-height: 1; }
.order-btns button:hover:not([disabled]) { border-color: var(--ink); }
.order-btns button[disabled] { opacity: 0.3; cursor: default; }
.drag-handle { cursor: grab; color: var(--muted); padding: 4px; user-select: none; }
@media (max-width: 560px) {
  .row { grid-template-columns: auto 52px 1fr; }
  .row__thumb { width: 52px; height: 52px; }
  .row__actions { grid-column: 2 / -1; }
  .drag-handle { display: none; }
}
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }

/* ---------- Product editor ---------- */

.editor { display: grid; gap: 16px; }
@media (min-width: 900px) {
  .editor { grid-template-columns: 1.15fr 1fr; align-items: start; }
  .editor__side { position: sticky; top: 76px; }
}

.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.photo {
  position: relative; aspect-ratio: 1; border-radius: 14px; background: var(--cream);
  border: 2px solid transparent; display: grid; place-items: center; padding: 10px; overflow: hidden;
}
.photo:first-child { border-color: var(--magenta); }
.photo img { width: 100%; height: 100%; object-fit: contain; }
.photo__badge { position: absolute; top: 6px; left: 6px; background: var(--magenta); color: #fff; font-size: 0.7rem; font-weight: 700; padding: 1px 8px; border-radius: 999px; }
.photo__tools { position: absolute; inset: auto 6px 6px 6px; display: flex; justify-content: space-between; gap: 4px; opacity: 0; transition: opacity 0.15s ease; }
.photo:hover .photo__tools, .photo:focus-within .photo__tools { opacity: 1; }
@media (hover: none) { .photo__tools { opacity: 1; } }
.photo__tools button { width: 30px; height: 30px; border: 0; border-radius: 8px; background: rgba(21, 37, 46, 0.85); color: #fff; font-size: 0.9rem; line-height: 1; }
.photo__tools button:hover { background: var(--ink); }
.photo__tools .remove { margin-left: auto; background: rgba(179, 38, 30, 0.9); }
.photo--busy::after { content: "Uploading…"; position: absolute; inset: 0; display: grid; place-items: center; background: rgba(246, 241, 236, 0.75); font-weight: 700; font-size: 0.85rem; }
.photo--failed { border-color: #b3261e; }
.photo--failed::after { content: "Upload failed"; position: absolute; inset: auto 0 0; padding: 4px; background: #b3261e; color: #fff; font-size: 0.75rem; text-align: center; }

.dropzone {
  aspect-ratio: 1; border: 2px dashed #cdbfb2; border-radius: 14px; display: grid; place-items: center; text-align: center;
  color: var(--muted); font-weight: 700; font-size: 0.9rem; padding: 10px; cursor: pointer; background: #fff;
}
.dropzone:hover, .dropzone.over { border-color: var(--magenta); color: var(--magenta); }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dropzone b { font-size: 1.8rem; display: block; line-height: 1; margin-bottom: 4px; }

.preview-card { background: var(--night); border-radius: var(--radius); padding: 18px; color: #f4f1ee; }
.preview-card .label { color: var(--lilac); margin-bottom: 10px; display: block; }
.preview-card__inner { border: 2px solid var(--magenta); border-radius: 22px; padding: 18px 16px; max-width: 230px; margin: 0 auto; }
.preview-card__img { aspect-ratio: 3 / 4; display: grid; place-items: center; margin-bottom: 10px; }
.preview-card__img.wide { aspect-ratio: 16 / 9; }
.preview-card__img img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 10px 12px rgba(0, 0, 0, 0.45)); }
.preview-card h3 { font-size: 1rem; }
.preview-card p { color: var(--lilac); font-size: 0.85rem; }
.preview-card .price { color: #f4f1ee; font-family: var(--font-head); font-weight: 600; margin-top: 4px; }
.preview-card__dots { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.preview-card__dots:empty { display: none; }
.preview-card__dots span { width: 12px; height: 12px; border-radius: 50%; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.25); }

.swatch-editor { border: 0; padding: 0; margin: 0; min-width: 0; }
.swatch-editor legend { padding: 0; margin-bottom: 6px; }
.swatch-editor__rows { display: grid; gap: 8px; justify-items: start; }
.swatch-row { display: grid; grid-template-columns: 44px 1fr auto; gap: 8px; align-items: center; width: 100%; }
.swatch-row input[type="color"] { width: 44px; height: 40px; padding: 3px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; }

.savebar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; gap: 10px; align-items: center; justify-content: flex-end; flex-wrap: wrap;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.96); border-top: 1px solid var(--line);
  box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.06);
}
.savebar__status { margin-right: auto; color: var(--muted); font-size: 0.9rem; }
.savebar__status.dirty { color: var(--warn); font-weight: 700; }

/* ---------- Orders ---------- */

.order-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 14px; padding: 14px 16px; border-top: 1px solid var(--line); text-decoration: none; color: inherit; }
.order-row:first-child { border-top: 0; }
.order-row:hover { background: #fcfaf8; }
.order-row__num { font-family: var(--font-head); font-size: 1.05rem; }
.order-row__total { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.order-row__sub { color: var(--muted); font-size: 0.88rem; }

.items { width: 100%; border-collapse: collapse; }
.items td, .items th { padding: 8px 0; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.items th { font-size: 0.82rem; color: var(--muted); font-weight: 700; }
.items .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.items tfoot td { border: 0; padding: 4px 0; }
.items tfoot tr:last-child td { font-weight: 700; font-size: 1.05rem; padding-top: 8px; }
.address { white-space: pre-line; line-height: 1.6; background: #faf7f4; border-radius: 10px; padding: 12px 14px; font-size: 0.95rem; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: 0.95rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- Settings ---------- */

.switch { display: flex; align-items: center; gap: 14px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch__track { width: 54px; height: 32px; border-radius: 999px; background: #d7cdc3; position: relative; flex: none; transition: background-color 0.15s; }
.switch__track::after { content: ""; position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform 0.15s; }
.switch input:checked + .switch__track { background: var(--ok); }
.switch input:checked + .switch__track::after { transform: translateX(22px); }
.switch input:focus-visible + .switch__track { outline: 3px solid var(--magenta); outline-offset: 2px; }
.switch input:disabled + .switch__track { opacity: 0.5; }
.switch strong { display: block; }

.ship-row { display: grid; grid-template-columns: 1fr 130px auto; gap: 8px; align-items: center; }

/* ---------- Toasts + confirm ---------- */

.toasts { position: fixed; z-index: 50; left: 50%; top: 16px; translate: -50% 0; display: grid; gap: 8px; pointer-events: none; width: min(92vw, 420px); }
.toast { background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 12px; font-weight: 700; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25); animation: toast-in 0.2s ease; text-align: center; }
.toast--error { background: #b3261e; }
@keyframes toast-in { from { transform: translateY(-10px); opacity: 0; } }

.confirm { border: 0; border-radius: 20px; padding: 24px; width: min(92vw, 420px); box-shadow: 0 30px 60px rgba(0, 0, 0, 0.3); }
.confirm::backdrop { background: rgba(21, 37, 46, 0.55); }
.confirm h2 { font-size: 1.25rem; margin-bottom: 8px; }
.confirm p { color: var(--muted); margin-bottom: 20px; }
.confirm__actions { display: flex; gap: 10px; justify-content: flex-end; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
