/* ==========================================================================
   Fearless — admin. Same monochrome system as the storefront, denser.
   Printful holds the products; this panel edits how they are presented.
   ========================================================================== */

:root {
  color-scheme: light;
  --bg: #ffffff;
  --bg-sunken: #f4f4f5;
  --bg-raised: #ffffff;
  --band: #111114;
  --band-text: #f3f3f4;
  --band-text-2: #9d9da6;
  --text: #101013;
  --text-2: #5b5b64;
  --text-3: #8a8a93;
  --line: #e5e5e8;
  --line-2: #c8c8cf;
  --line-strong: #101013;
  --img-well: #efeff1;
  --logo-filter: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #17181c;
    --bg-sunken: #1d1e23;
    --bg-raised: #212229;
    --band: #101115;
    --text: #f2f2f4;
    --text-2: #a2a2ac;
    --text-3: #74747e;
    --line: #2b2c33;
    --line-2: #3b3c45;
    --line-strong: #f2f2f4;
    --img-well: #23242a;
    --logo-filter: invert(1);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #17181c;
  --bg-sunken: #1d1e23;
  --bg-raised: #212229;
  --band: #101115;
  --text: #f2f2f4;
  --text-2: #a2a2ac;
  --text-3: #74747e;
  --line: #2b2c33;
  --line-2: #3b3c45;
  --line-strong: #f2f2f4;
  --img-well: #23242a;
  --logo-filter: invert(1);
}

:root { --ease: cubic-bezier(0.22, 0.61, 0.36, 1); }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Archivo, "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 0.9375rem;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; display: block; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--line-strong); outline-offset: 2px; }

h1, h2, h3 {
  margin: 0;
  font-weight: 800;
  font-stretch: 92%;
  letter-spacing: -0.022em;
  line-height: 1.15;
}
h1 { font-size: 1.4rem; }
h2 { font-size: 1.0625rem; }
h3 { font-size: 0.9375rem; }

.muted { color: var(--text-2); }
.small { font-size: 0.8125rem; }
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85em;
  background: var(--bg-sunken);
  padding: 0.1em 0.35em;
  border-radius: 2px;
}

/* --- sign in -------------------------------------------------------------- */

.signin { min-height: 100vh; display: grid; place-items: center; padding: 2rem 1.25rem; }
.signin-card { width: min(23rem, 100%); }
.signin img { height: 1.85rem; margin-bottom: 1.85rem; filter: var(--logo-filter); }
.signin h1 { margin-bottom: 0.3rem; }
.signin p { color: var(--text-2); margin: 0 0 1.75rem; }

/* --- shell ---------------------------------------------------------------- */

.app { display: grid; min-height: 100vh; grid-template-columns: 1fr; }
@media (min-width: 60rem) { .app { grid-template-columns: 13.5rem 1fr; } }

.side {
  background: var(--band);
  color: var(--band-text-2);
  padding: 1.4rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}
.side img { height: 1.25rem; filter: invert(1); }

.side nav { display: flex; flex-wrap: wrap; gap: 0.1rem; }
@media (min-width: 60rem) { .side nav { flex-direction: column; } }

.side nav a {
  text-decoration: none;
  padding: 0.45rem 0.6rem;
  border-radius: 2px;
  border-left: 2px solid transparent;
}
.side nav a:hover { color: var(--band-text); background: rgba(255, 255, 255, 0.06); }
.side nav a[aria-current="page"] {
  color: var(--band-text);
  background: rgba(255, 255, 255, 0.1);
  border-left-color: var(--band-text);
  font-weight: 600;
}

.side-foot { margin-top: auto; font-size: 0.8125rem; }
.side-foot button {
  background: none; border: 0; color: inherit; padding: 0;
  cursor: pointer; text-decoration: underline;
}
.side-foot a { color: var(--band-text); }

.side .theme-toggle {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--band-text-2);
  border-radius: 999px;
  padding: 0.3rem 0.7rem;
  cursor: pointer;
  font-size: 0.75rem;
  margin-bottom: 0.6rem;
}
.side .theme-toggle:hover { color: var(--band-text); border-color: rgba(255, 255, 255, 0.4); }

.main { padding: clamp(1.15rem, 3vw, 2.25rem); max-width: 78rem; }

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.6rem;
}

/* --- stats ---------------------------------------------------------------- */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  margin-bottom: 1.75rem;
}
.stat { background: var(--bg); padding: 0.95rem 1rem; }
.stat b { display: block; font-size: 1.4rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
.stat span { color: var(--text-2); font-size: 0.78125rem; }

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

.panel {
  border: 1px solid var(--line);
  background: var(--bg-sunken);
  padding: clamp(0.95rem, 2.5vw, 1.4rem);
  margin-bottom: 1.4rem;
}
.panel-head {
  display: flex; flex-wrap: wrap; align-items: baseline;
  justify-content: space-between; gap: 1rem; margin-bottom: 0.9rem;
}

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

.table-wrap { overflow-x: auto; border: 1px solid var(--line); background: var(--bg-sunken); }

table { border-collapse: collapse; width: 100%; font-size: 0.875rem; }
th, td { text-align: left; padding: 0.65rem 0.85rem; border-bottom: 1px solid var(--line); }
th {
  font-weight: 700; font-size: 0.6875rem; color: var(--text-3);
  letter-spacing: 0.05em; text-transform: uppercase; white-space: nowrap;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--bg-raised); }
td.num, th.num { text-align: right; }

.row-link { cursor: pointer; }

.thumb { width: 2.6rem; height: 3.25rem; object-fit: cover; background: var(--img-well); }

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

.pill {
  display: inline-block;
  padding: 0.12rem 0.5rem;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 700;
  white-space: nowrap;
  color: var(--text-2);
}
.pill-strong { border-color: var(--text); color: var(--text); }
.pill-solid { background: var(--text); border-color: var(--text); color: var(--bg); }
.pill-quiet { color: var(--text-3); border-color: var(--line); }

/* --- controls ------------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  background: var(--text); color: var(--bg); border: 1px solid var(--text);
  padding: 0.55rem 1rem; font-weight: 600; font-size: 0.875rem;
  border-radius: 2px; cursor: pointer;
  transition: opacity 0.15s var(--ease);
}
.btn:hover { opacity: 0.82; }
.btn[disabled] { background: var(--bg-sunken); border-color: var(--line); color: var(--text-3); cursor: not-allowed; opacity: 1; }
.btn-wide { width: 100%; }
.btn-quiet { background: none; color: var(--text); border-color: var(--line-2); }
.btn-quiet:hover { background: var(--text); color: var(--bg); opacity: 1; }
.btn-small { padding: 0.32rem 0.65rem; font-size: 0.8125rem; }

.field { margin-bottom: 0.9rem; }
.field label {
  display: block; font-size: 0.6875rem; font-weight: 700;
  letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--text-3); margin-bottom: 0.28rem;
}
.field input, .field select, .field textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--line-2);
  background: var(--bg-raised);
  color: var(--text);
  border-radius: 2px;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--text); }
.field textarea { resize: vertical; min-height: 6rem; line-height: 1.5; }
.field .hint { color: var(--text-3); font-size: 0.78125rem; margin: 0.28rem 0 0; }

.toolbar { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-bottom: 1rem; }
.toolbar input[type="search"] {
  padding: 0.45rem 0.7rem; border: 1px solid var(--line-2);
  background: var(--bg-raised); color: var(--text); border-radius: 2px; min-width: 12rem;
}

.tabs { display: flex; gap: 1rem; font-size: 0.875rem; }
.tabs button {
  background: none; border: 0; border-bottom: 1.5px solid transparent;
  padding: 0.22rem 0; cursor: pointer; color: var(--text-3);
}
.tabs button[aria-pressed="true"] { color: var(--text); border-bottom-color: var(--text); font-weight: 600; }

.switch {
  position: relative; width: 2.3rem; height: 1.3rem;
  border: 1px solid var(--line-2); border-radius: 999px;
  background: var(--bg-sunken); cursor: pointer; padding: 0;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease);
}
.switch::after {
  content: ""; position: absolute; top: 0.13rem; left: 0.16rem;
  width: 0.9rem; height: 0.9rem; border-radius: 50%;
  background: var(--text-3);
  transition: transform 0.15s var(--ease), background 0.15s var(--ease);
}
.switch[aria-checked="true"] { background: var(--text); border-color: var(--text); }
.switch[aria-checked="true"]::after { transform: translateX(0.98rem); background: var(--bg); }

/* --- messages ------------------------------------------------------------- */

.alert {
  border: 1px solid var(--line-2);
  background: var(--bg-sunken);
  padding: 0.7rem 0.85rem;
  font-size: 0.875rem;
  margin-bottom: 0.9rem;
}
.alert-bad { border-color: var(--text); border-inline-start-width: 3px; }
.alert-good { border-color: var(--text); border-inline-start-width: 3px; }
.alert[hidden] { display: none; }

.empty { padding: 2.75rem 1rem; text-align: center; color: var(--text-2); }
.empty strong { display: block; color: var(--text); font-size: 1.0625rem; margin-bottom: 0.3rem; }

.loading { padding: 2rem 0; color: var(--text-3); }

/* --- detail (orders and products) ----------------------------------------- */

.detail { display: grid; gap: 1.4rem; }
@media (min-width: 56rem) { .detail { grid-template-columns: minmax(0, 1.4fr) minmax(16rem, 1fr); } }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 0.3rem 1rem; font-size: 0.875rem; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; }

.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.9rem; }

.back {
  background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--text-3); text-decoration: underline;
  font-size: 0.875rem; margin-bottom: 0.9rem;
}
.back:hover { color: var(--text); }

/* --- product editor ------------------------------------------------------- */

/* Printful's own value, shown under a field that has been overridden. */
.from-printful {
  font-size: 0.78125rem;
  color: var(--text-3);
  margin: 0.3rem 0 0;
  display: flex;
  gap: 0.5rem;
  align-items: baseline;
}
.from-printful button {
  background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--text-2); text-decoration: underline; font-size: inherit;
}
.from-printful button:hover { color: var(--text); }

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(7rem, 1fr));
  gap: 0.7rem;
}

.image-card {
  border: 1px solid var(--line);
  background: var(--bg-raised);
  display: flex;
  flex-direction: column;
}
.image-card .frame {
  aspect-ratio: 4 / 5;
  background: var(--img-well);
  overflow: hidden;
  position: relative;
}
.image-card img { width: 100%; height: 100%; object-fit: cover; }
.image-card[data-hidden="true"] .frame { opacity: 0.32; }

.image-card .bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem;
  padding: 0.3rem 0.4rem;
  border-top: 1px solid var(--line);
  font-size: 0.6875rem;
  color: var(--text-3);
}
.image-card .bar button {
  background: none; border: 0; cursor: pointer;
  color: var(--text-2); padding: 0.15rem 0.25rem; line-height: 1;
  border-radius: 2px;
}
.image-card .bar button:hover { color: var(--text); background: var(--bg-sunken); }
.image-card .bar button[disabled] { color: var(--line-2); cursor: not-allowed; }

.kind-tag { font-size: 0.625rem; letter-spacing: 0.04em; text-transform: uppercase; }

.variant-table input[type="number"] {
  width: 6.5rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--line-2);
  background: var(--bg-raised);
  color: var(--text);
  border-radius: 2px;
}
.variant-table td { padding-block: 0.45rem; }

.sticky-save {
  position: sticky;
  bottom: 0;
  background: var(--bg);
  border-top: 1px solid var(--line);
  padding: 0.85rem 0;
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 1.4rem;
}
.sticky-save .spacer { margin-inline-start: auto; }
