/*
 * Admin panel styling.
 *
 * Dark, dense, and deliberately matched to the storefront's palette (#0a0a0a with
 * the #f4c95e gold) so the two halves of the business feel like one system. No
 * frameworks: this is ~600 lines of plain CSS with custom properties, which is
 * less than the utility classes alone would cost and needs no build step.
 */

:root {
  --bg: #0a0a0a;
  --bg-2: #101010;
  --card: #141414;
  --card-2: #171717;
  --line: #242424;
  --line-2: #2e2e2e;
  --text: #e6e6e6;
  --text-2: #b4b4b4;
  --dim: #8a8a8a;
  --faint: #6a6a6a;
  --gold: #f4c95e;
  --gold-deep: #ecb13c;
  --ink: #160f00;
  --ok: #5ee88c;
  --ok-bg: #0f1d15;
  --warn: #f6c454;
  --warn-bg: #1e1808;
  --err: #ff7a6b;
  --err-bg: #24100e;
  --radius: 12px;
  --radius-lg: 16px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Courier New', monospace;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

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

a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Focus is never removed, only restyled: this panel is operated at speed and the
   keyboard path has to stay visible. */
:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 8px;
  background: var(--gold);
  color: var(--ink);
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 700;
  z-index: 100;
}
.skip:focus { left: 8px; }

/* ------------------------------------------------------------------ layout -- */

.app { display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 20px;
  height: 56px;
  background: linear-gradient(180deg, #171410, var(--card));
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; letter-spacing: 2px; font-size: 12px; text-transform: uppercase; white-space: nowrap; }
.brand-mark { color: var(--gold); font-size: 10px; }

.nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; }
.nav-link {
  padding: 8px 14px;
  border-radius: 8px;
  color: var(--text-2);
  font-weight: 600;
  white-space: nowrap;
}
.nav-link:hover { background: var(--card-2); color: var(--text); text-decoration: none; }
.nav-link.is-active { background: rgba(244, 201, 94, 0.12); color: var(--gold); }

.topbar-right { display: flex; align-items: center; gap: 12px; }
.who { color: var(--dim); font-size: 12px; }

.outlet { flex: 1; padding: 20px; max-width: 1500px; width: 100%; margin: 0 auto; }
.screen { display: flex; flex-direction: column; gap: 16px; }
.screen-title { margin: 0; font-size: 22px; font-weight: 700; }

.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 980px) {
  .two-col, .row-2 { grid-template-columns: 1fr; }
}

/* ------------------------------------------------------------------ panels -- */

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}
.panel-title { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: 0.2px; }

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.toolbar .panel-title { margin-right: auto; }

.crumb { display: flex; align-items: center; gap: 8px; color: var(--dim); font-size: 13px; }
.crumb-sep { color: var(--faint); }

.hint { color: var(--dim); font-size: 12px; line-height: 1.6; }
.hint-inline { margin-left: auto; }
.loading { color: var(--dim); padding: 28px 0; text-align: center; }
.loading-boot { padding: 80px 0; }
.empty-state, .ok-state {
  padding: 22px;
  text-align: center;
  color: var(--dim);
  background: var(--bg-2);
  border: 1px dashed var(--line-2);
  border-radius: var(--radius);
}
.ok-state { color: var(--ok); border-style: solid; border-color: var(--ok-bg); background: var(--ok-bg); }
.error-panel { border-color: var(--err-bg); }

/* ------------------------------------------------------------------ inputs -- */

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 12px; font-weight: 600; color: var(--text-2); letter-spacing: 0.2px; }
.field-hint { font-size: 11px; color: var(--dim); line-height: 1.5; }

.input {
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  color: var(--text);
  border-radius: 9px;
  padding: 9px 11px;
  font-family: inherit;
  font-size: 14px;
  width: 100%;
  min-width: 0;
}
.input:focus { border-color: var(--gold); outline: none; box-shadow: 0 0 0 3px rgba(244, 201, 94, 0.15); }
.textarea { resize: vertical; font-family: inherit; line-height: 1.6; }
.input-search { max-width: 320px; }
.input-inline { padding: 6px 8px; font-size: 13px; }
.input-price { max-width: 110px; text-align: right; font-variant-numeric: tabular-nums; }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--dim) 50%), linear-gradient(135deg, var(--dim) 50%, transparent 50%); background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 30px; }

.check { display: flex; align-items: center; gap: 9px; cursor: pointer; padding: 4px 0; }
.check input { accent-color: var(--gold); width: 16px; height: 16px; }
.check-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 2px 14px; }

/* ----------------------------------------------------------------- buttons -- */

.btn {
  background: var(--card-2);
  border: 1px solid var(--line-2);
  color: var(--text);
  border-radius: 9px;
  padding: 9px 15px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.btn:hover:not(:disabled) { border-color: var(--gold); color: var(--gold); text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: linear-gradient(180deg, #f8d27a, var(--gold) 55%, var(--gold-deep)); color: var(--ink); border-color: transparent; }
.btn-primary:hover:not(:disabled) { color: var(--ink); filter: brightness(1.06); }
.btn-quiet { background: transparent; }
.btn-danger { color: var(--err); border-color: #3a1d1a; }
.btn-danger:hover:not(:disabled) { border-color: var(--err); color: var(--err); background: var(--err-bg); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; padding: 12px; }
.icon-btn { background: none; border: none; color: var(--dim); cursor: pointer; font-size: 15px; padding: 4px 8px; border-radius: 6px; }
.icon-btn:hover { color: var(--text); background: var(--card-2); }

.segmented { display: inline-flex; background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 9px; padding: 2px; gap: 2px; }
.seg { background: none; border: none; color: var(--text-2); padding: 6px 12px; border-radius: 7px; font-size: 12px; font-weight: 600; cursor: pointer; font-family: inherit; white-space: nowrap; }
.seg:hover { color: var(--text); }
.seg.is-active { background: rgba(244, 201, 94, 0.14); color: var(--gold); }

.inline { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ------------------------------------------------------------------ tables -- */

.table-wrap { overflow-x: auto; margin: 0 -4px; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left;
  padding: 8px 10px;
  color: var(--dim);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:hover { background: rgba(255, 255, 255, 0.018); }
.table tbody tr:last-child td { border-bottom: none; }
.table td.empty { text-align: center; color: var(--dim); padding: 26px; }

.cell-stack { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cell-sub { color: var(--dim); font-size: 11.5px; }
.cell-ok { color: var(--ok); }
.cell-warn { color: var(--warn); }
.cell-err { color: var(--err); word-break: break-word; }
.link-strong { font-weight: 700; }
.code-inline { font-family: var(--mono); font-size: 12px; background: var(--bg-2); padding: 2px 6px; border-radius: 5px; color: var(--text-2); word-break: break-all; }

.row-thumb { width: 40px; height: 40px; object-fit: cover; border-radius: 7px; background: var(--bg-2); display: block; }
.row-thumb-empty { display: grid; place-items: center; color: var(--faint); border: 1px dashed var(--line-2); }

/* ------------------------------------------------------------------- pills -- */

.pill {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  border: 1px solid var(--line-2);
  color: var(--text-2);
  background: var(--bg-2);
  white-space: nowrap;
}
.pill-completed, .pill-sent, .pill-available { color: var(--ok); background: var(--ok-bg); border-color: #1e3a28; }
.pill-processing, .pill-queued, .pill-sold { color: var(--gold); background: var(--warn-bg); border-color: #4a3c1c; }
.pill-pending { color: var(--dim); }
.pill-failed, .pill-refunded, .pill-revoked { color: var(--err); background: var(--err-bg); border-color: #3a1d1a; }
.pill-draft { color: var(--dim); }
.pill-trash { color: var(--err); }

/* ------------------------------------------------------------------ alerts -- */

.alert-strip { display: flex; flex-direction: column; gap: 8px; }
.alert {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 15px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--card);
  font-size: 13px;
}
.alert-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.alert-text { flex: 1; }
.alert-action { font-weight: 700; font-size: 12px; }
.alert-ok { border-color: #1e3a28; background: var(--ok-bg); }
.alert-ok .alert-dot { background: var(--ok); }
.alert-warn { border-color: #4a3c1c; background: var(--warn-bg); }
.alert-warn .alert-dot { background: var(--warn); }
.alert-error { border-color: #3a1d1a; background: var(--err-bg); }
.alert-error .alert-dot { background: var(--err); }

/* --------------------------------------------------------------------- KPI -- */

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px; display: flex; flex-direction: column; gap: 5px; }
.kpi-label { font-size: 11px; font-weight: 700; letter-spacing: 1.4px; text-transform: uppercase; color: var(--dim); }
.kpi-value { font-size: 27px; font-weight: 700; letter-spacing: -0.5px; font-variant-numeric: tabular-nums; }
.kpi-meta { display: flex; gap: 7px; color: var(--text-2); font-size: 12px; }
.kpi-sep { color: var(--faint); }
.kpi-delta { font-size: 12px; font-weight: 600; margin-top: 2px; }
.kpi-delta.up { color: var(--ok); }
.kpi-delta.down { color: var(--err); }
.kpi-delta-none { color: var(--faint); font-weight: 500; }

/* ------------------------------------------------------------------- chart -- */

.chart-wrap { position: relative; }
.chart { width: 100%; height: auto; display: block; }
.chart-bar { fill: var(--gold); opacity: 0.85; transition: opacity 0.12s; }
.chart-bar:hover { opacity: 1; }
.chart-axis { stroke: var(--line-2); stroke-width: 1; }
/* 11 user units: the chart's viewBox is 1000 wide and renders around 1,400 CSS
   px, so this lands near 15 px on screen. 20 rendered at nearly 28 px. */
.chart-label { fill: var(--faint); font-size: 11px; font-family: var(--font); }
.chart-max { position: absolute; top: 0; right: 4px; color: var(--faint); font-size: 11px; }
.chart-empty { padding: 40px; text-align: center; color: var(--dim); }
.chart-foot { color: var(--dim); font-size: 12px; }

/* ------------------------------------------------------------------ orders -- */

.order-head { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.order-total { margin: 0; font-size: 30px; font-weight: 700; letter-spacing: -0.6px; font-variant-numeric: tabular-nums; }
.order-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; color: var(--dim); font-size: 12.5px; margin-top: 6px; }
.order-actions { margin-left: auto; display: flex; gap: 9px; flex-wrap: wrap; }

/* The key gets the storefront's vault treatment: it is the thing the customer paid
   for, and the thing the owner is usually here to read out loud. */
.key-vault {
  background: #000;
  background-image: radial-gradient(130% 90% at 50% 0%, rgba(244, 201, 94, 0.12) 0%, rgba(244, 201, 94, 0) 62%);
  border: 1px solid #2b2415;
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.key-vault.is-empty { align-items: center; color: var(--dim); border-style: dashed; border-color: var(--line-2); background: var(--bg-2); }
.key-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.key-value {
  font-family: var(--mono);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 1.6px;
  color: #fff;
  background: #101010;
  border: 1px solid #4a3c1c;
  border-radius: 9px;
  padding: 12px 16px;
  user-select: all;
  word-break: break-all;
  flex: 1;
  min-width: 220px;
}
.key-value.is-revoked { text-decoration: line-through; color: var(--dim); border-color: #3a1d1a; }
.key-mono { font-family: var(--mono); font-size: 12.5px; user-select: all; }

.kv { display: flex; flex-direction: column; gap: 1px; }
.kv-row { display: flex; gap: 14px; padding: 7px 0; border-bottom: 1px solid var(--line); align-items: baseline; }
.kv-row:last-child { border-bottom: none; }
.kv-label { color: var(--dim); font-size: 12px; min-width: 150px; flex: none; }
.kv-value { min-width: 0; word-break: break-word; }

/* ------------------------------------------------------------------- media -- */

.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.media-grid-picker { max-height: 52vh; overflow-y: auto; padding: 2px; }
.media-tile { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; cursor: pointer; }
.media-tile:hover { border-color: var(--gold); }
.media-tile.is-picked { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(244, 201, 94, 0.35); }
.media-thumb { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: #000; }
.media-thumb-file { display: grid; place-items: center; color: var(--dim); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }
.media-meta { padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; }
.media-name { font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-sub { font-size: 11px; color: var(--dim); }
.media-preview { width: 100%; max-height: 300px; object-fit: contain; background: #000; border-radius: var(--radius); margin-bottom: 12px; }

.image-slot { display: flex; flex-direction: column; gap: 10px; }
.image-preview { width: 100%; max-height: 220px; object-fit: contain; background: #000; border-radius: var(--radius); border: 1px solid var(--line); }
.image-empty { height: 120px; display: grid; place-items: center; color: var(--faint); background: var(--bg-2); border: 1px dashed var(--line-2); border-radius: var(--radius); }

.gallery-strip { display: flex; gap: 9px; flex-wrap: wrap; }
.gallery-item { position: relative; width: 78px; height: 78px; }
.gallery-item img { width: 100%; height: 100%; object-fit: cover; border-radius: 9px; border: 1px solid var(--line); background: #000; }
.gallery-remove { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; background: var(--card); border: 1px solid var(--line-2); color: var(--err); cursor: pointer; font-size: 11px; line-height: 1; display: grid; place-items: center; }
.gallery-add { width: 78px; height: 78px; border: 1px dashed var(--line-2); border-radius: 9px; background: var(--bg-2); color: var(--dim); cursor: pointer; font-family: inherit; font-size: 12px; }
.gallery-add:hover { border-color: var(--gold); color: var(--gold); }

.attr-list { display: flex; flex-direction: column; gap: 12px; }
.attr-row { display: grid; grid-template-columns: 1fr 2fr auto; gap: 10px; align-items: end; }
@media (max-width: 700px) { .attr-row { grid-template-columns: 1fr; } }

/* ------------------------------------------------------------------ checks -- */

.checks { display: flex; flex-direction: column; }
.check-row { display: flex; gap: 12px; align-items: flex-start; padding: 11px 0; border-bottom: 1px solid var(--line); }
.check-row:last-child { border-bottom: none; }
.check-dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 5px; flex: none; }
.check-ok .check-dot { background: var(--ok); }
.check-warn .check-dot { background: var(--warn); }
.check-error .check-dot { background: var(--err); }
.check-label { font-weight: 600; }
.details summary { cursor: pointer; color: var(--dim); font-size: 12px; padding: 6px 0; }

/* ------------------------------------------------------------------ modals -- */

.backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.72); display: grid; place-items: center; padding: 20px; z-index: 60; }
.modal { background: var(--card); border: 1px solid var(--line-2); border-radius: var(--radius-lg); width: min(680px, 100%); max-height: 88vh; display: flex; flex-direction: column; }
.modal-head { display: flex; align-items: center; padding: 15px 18px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 15px; flex: 1; }
.modal-body { padding: 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.modal-actions { padding: 14px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 9px; }
.modal-lead { margin: 0 0 4px; color: var(--text-2); font-size: 13px; line-height: 1.6; }

/* ------------------------------------------------------------------ toasts -- */

.toasts { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 9px; z-index: 80; max-width: min(440px, calc(100vw - 36px)); }
.toast {
  background: var(--card);
  border: 1px solid var(--line-2);
  border-left: 3px solid var(--dim);
  border-radius: 10px;
  padding: 12px 15px;
  font-size: 13px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
  animation: toast-in 0.18s ease-out;
}
.toast-ok { border-left-color: var(--ok); }
.toast-err { border-left-color: var(--err); }
.toast-info { border-left-color: var(--gold); }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: 0.22s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Honours a reduced-motion preference: the only animations here are decorative. */
@media (prefers-reduced-motion: reduce) {
  .toast { animation: none; }
  * { transition-duration: 0.01ms !important; }
}

/* -------------------------------------------------------------------- auth -- */

.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(420px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 30px; display: flex; flex-direction: column; gap: 14px; }
.auth-brand { display: flex; align-items: center; gap: 9px; font-weight: 700; letter-spacing: 3px; font-size: 12px; text-transform: uppercase; color: var(--text-2); }
.auth-mark { color: var(--gold); }
.auth-title { margin: 6px 0 0; font-size: 24px; font-weight: 700; }
.auth-lead { margin: 0; color: var(--text-2); font-size: 13px; line-height: 1.65; }
.auth-status { min-height: 18px; font-size: 12.5px; color: var(--text-2); }
.auth-note { font-size: 12px; color: var(--warn); }
.auth-divider { display: flex; align-items: center; gap: 12px; color: var(--faint); font-size: 11px; text-transform: uppercase; letter-spacing: 1px; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.auth-recover { font-size: 12px; color: var(--dim); display: flex; flex-direction: column; gap: 9px; }
.auth-recover summary { cursor: pointer; }
.auth-recover p { margin: 0; line-height: 1.6; }

/* Used for the file inputs behind the upload buttons. A class rather than an
   inline style because this page's CSP forbids inline styles - a style attribute
   is silently dropped and the element stays visible. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
