/* Jax Card admin console — light ops theme.
 *
 * Intentionally decoupled from theme.css: admin pages use this file
 * only (see admin_base.html), so public pages can never regress from
 * console tweaks and vice versa. Dense system UI, neutral grays,
 * tables-first. All admin interactivity is progressive enhancement
 * (static/js/admin.js); every form works with JS disabled.
 */

:root {
  --ad-bg: #f4f5f7;
  --ad-surface: #ffffff;
  --ad-surface-2: #fafbfc;
  --ad-ink: #17202b;
  --ad-muted: #5b6b7c;
  --ad-rule: #e2e7ee;
  --ad-rule-strong: #c9d2de;
  --ad-accent: #1d5fc2;
  --ad-accent-ink: #ffffff;
  --ad-danger: #b42318;
  --ad-warn-bg: #fef3c7;
  --ad-warn-ink: #92400e;
  --ad-ok-bg: #dcfce7;
  --ad-ok-ink: #166534;
  --ad-info-bg: #e0ecff;
  --ad-info-ink: #1e40af;
  --ad-radius: 8px;
  --ad-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --ad-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html { scrollbar-gutter: stable; }

body.ad {
  margin: 0;
  background: var(--ad-bg);
  color: var(--ad-ink);
  font-family: var(--ad-font);
  font-size: 14px;
  line-height: 1.5;
}

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

.ad-topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--ad-surface);
  border-bottom: 1px solid var(--ad-rule-strong);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.25rem;
  min-height: 52px;
}

.ad-brand {
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
  color: var(--ad-ink);
  text-decoration: none;
}

.ad-brand span {
  color: var(--ad-muted);
  font-weight: 400;
}

.ad-tabs {
  display: flex;
  gap: 0.25rem;
  flex: 1;
  overflow-x: auto;
}

.ad-tabs a {
  color: var(--ad-muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.65rem 0.8rem;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}

.ad-tabs a:hover { color: var(--ad-ink); }

.ad-tabs a.active {
  color: var(--ad-accent);
  border-bottom-color: var(--ad-accent);
}

.ad-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
}

.ad-user a { color: var(--ad-muted); font-size: 0.85rem; }

.ad-main {
  max-width: 100rem;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 4rem;
}

.ad-subnav {
  position: sticky;
  top: 52px;
  z-index: 30;
  background: var(--ad-bg);
  padding: 0.6rem 0;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--ad-rule);
  margin-bottom: 1.25rem;
}

.ad-subnav a {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ad-muted);
  text-decoration: none;
  background: var(--ad-surface);
  border: 1px solid var(--ad-rule);
  border-radius: 999px;
  padding: 0.25rem 0.8rem;
}

.ad-subnav a:hover { color: var(--ad-ink); border-color: var(--ad-rule-strong); }

/* ---------- banners ---------- */

.ad-banner {
  border-radius: var(--ad-radius);
  padding: 0.6rem 0.9rem;
  margin: 0 0 1rem;
  font-size: 0.88rem;
}

.ad-banner.ok { background: var(--ad-ok-bg); color: var(--ad-ok-ink); }
.ad-banner.err { background: #fee2e2; color: var(--ad-danger); }
.ad-banner.warn { background: var(--ad-warn-bg); color: var(--ad-warn-ink); }
.ad-banner.info { background: var(--ad-info-bg); color: var(--ad-info-ink); }

/* ---------- sections / cards ---------- */

.ad-section { margin-bottom: 2rem; }

.ad-section > h2 {
  font-size: 1.05rem;
  margin: 0 0 0.15rem;
}

.ad-section .ad-help {
  color: var(--ad-muted);
  font-size: 0.83rem;
  margin: 0 0 0.75rem;
  max-width: 70rem;
}

.ad-card {
  background: var(--ad-surface);
  border: 1px solid var(--ad-rule);
  border-radius: var(--ad-radius);
  padding: 1rem;
  margin-bottom: 1rem;
}

.ad-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 900px) {
  .ad-grid-2 { grid-template-columns: 1fr; }
}

/* ---------- toolbar ---------- */

.ad-toolbar {
  display: flex;
  gap: 0.6rem;
  align-items: flex-end;
  flex-wrap: wrap;
  background: var(--ad-surface);
  border: 1px solid var(--ad-rule);
  border-radius: var(--ad-radius);
  padding: 0.75rem 0.9rem;
  margin-bottom: 0.75rem;
}

.ad-toolbar .ad-field { margin: 0; }

.ad-filter {
  margin-left: auto;
  min-width: 12rem;
}

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

.ad-tablewrap {
  overflow-x: auto;
  background: var(--ad-surface);
  border: 1px solid var(--ad-rule);
  border-radius: var(--ad-radius);
}

table.ad-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.85rem;
}

.ad-table caption {
  text-align: left;
  font-weight: 700;
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--ad-rule);
}

.ad-table th,
.ad-table td {
  padding: 0.5rem 0.7rem;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--ad-rule);
}

.ad-table thead th {
  position: sticky;
  top: 0;
  background: var(--ad-surface-2);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ad-muted);
  white-space: nowrap;
  z-index: 1;
}

.ad-table tbody tr:nth-child(even) { background: var(--ad-surface-2); }
.ad-table tbody tr:hover { background: #eef3fb; }
.ad-table tbody tr:last-child td { border-bottom: none; }

.ad-table td.num,
.ad-table th.num { text-align: right; font-variant-numeric: tabular-nums; }

.ad-table tr.row-off td { color: var(--ad-muted); }
.ad-table tr.row-off td:first-child { text-decoration: line-through; }
.ad-table tr.row-low td.qty { color: var(--ad-danger); font-weight: 700; }
.ad-table tr.row-dirty { box-shadow: inset 3px 0 0 var(--ad-accent); }

/* ---------- badges ---------- */

.ad-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 0.1rem 0.55rem;
  white-space: nowrap;
  background: #e8edf4;
  color: #33415c;
}

.ad-badge.st-new { background: var(--ad-info-bg); color: var(--ad-info-ink); }
.ad-badge.st-paid { background: var(--ad-ok-bg); color: var(--ad-ok-ink); }
.ad-badge.st-shipped { background: #e9d5ff; color: #6b21a8; }
.ad-badge.st-cancelled,
.ad-badge.st-failed { background: #fee2e2; color: var(--ad-danger); }
.ad-badge.preset-brushed { background: #e8edf4; color: #33415c; }
.ad-badge.preset-smooth { background: var(--ad-ok-bg); color: var(--ad-ok-ink); }
.ad-badge.preset-polished { background: var(--ad-info-bg); color: var(--ad-info-ink); }
.ad-badge.unused { background: var(--ad-warn-bg); color: var(--ad-warn-ink); }
.ad-badge.off { background: #fee2e2; color: var(--ad-danger); }
.ad-badge.on { background: var(--ad-ok-bg); color: var(--ad-ok-ink); }

/* ---------- forms ---------- */

.ad-field { margin: 0 0 0.6rem; }

.ad-field > label,
.ad-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ad-muted);
  margin-bottom: 0.2rem;
}

.ad-table input,
.ad-table select,
.ad-toolbar input,
.ad-toolbar select,
.ad-card input,
.ad-card select,
.ad-formgrid input,
.ad-formgrid select {
  font: inherit;
  font-size: 0.85rem;
  padding: 0.35rem 0.45rem;
  border: 1px solid var(--ad-rule-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--ad-ink);
  max-width: 100%;
}

.ad-table input[type="number"] { width: 5rem; }
.ad-table input.num-sm { width: 4rem; }

input:focus-visible,
select:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--ad-accent);
  outline-offset: 1px;
}

button.ad-btn,
a.ad-btn {
  font: inherit;
  font-size: 0.83rem;
  font-weight: 600;
  padding: 0.38rem 0.9rem;
  border: 1px solid var(--ad-rule-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--ad-ink);
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  white-space: nowrap;
}

button.ad-btn:hover,
a.ad-btn:hover { border-color: var(--ad-accent); color: var(--ad-accent); }

button.ad-btn.primary {
  background: var(--ad-accent);
  border-color: var(--ad-accent);
  color: var(--ad-accent-ink);
}

button.ad-btn.primary:hover { filter: brightness(1.08); color: #fff; }
button.ad-btn.danger { color: var(--ad-danger); border-color: #f0b4ae; }
button.ad-btn:disabled { opacity: 0.45; cursor: default; }

.ad-formgrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 0.6rem 0.9rem;
  align-items: end;
}

.ad-checkline {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  padding-bottom: 0.35rem;
}

.ad-mono { font-family: var(--ad-mono); font-size: 0.8rem; }
.ad-muted { color: var(--ad-muted); }
.ad-pre { white-space: pre-wrap; word-break: break-word; }

/* ---------- login ---------- */

.ad-loginwrap {
  min-height: 70vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ad-logincard {
  background: var(--ad-surface);
  border: 1px solid var(--ad-rule);
  border-radius: 12px;
  padding: 2rem;
  width: 100%;
  max-width: 24rem;
}

.ad-logincard h1 { margin: 0 0 1rem; font-size: 1.2rem; }
.ad-logincard .ad-field input { width: 100%; }

/* ---------- order sheet extras ---------- */

.ad-kv {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.ad-kv .ad-card { margin: 0; }
.ad-kv h3 { margin: 0 0 0.4rem; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ad-muted); }
.ad-kv p { margin: 0.15rem 0; }

.ad-thumb { max-width: 220px; max-height: 140px; border: 1px solid var(--ad-rule-strong); border-radius: 6px; }

/* ---------- tint swatches ----------
 * Approximates the designer preview: the wash hex over a neutral
 * metal gradient with the same multiply composite the canvas uses. */

.tint-swatch {
  display: inline-block;
  width: 3rem;
  height: 1.6rem;
  border: 1px solid var(--ad-rule-strong);
  border-radius: 6px;
  background: linear-gradient(135deg, #e8eaed 0%, #a9aeb5 100%);
  overflow: hidden;
  vertical-align: middle;
}

.tint-swatch i {
  display: block;
  width: 100%;
  height: 100%;
  mix-blend-mode: multiply;
}

.tint-swatch.bare {
  background: repeating-linear-gradient(135deg, #fff 0 4px, #e8edf4 4px 8px);
}

.ad-timeline { list-style: none; margin: 0; padding: 0; }
.ad-timeline li { padding: 0.4rem 0; border-bottom: 1px solid var(--ad-rule); font-size: 0.85rem; }
.ad-timeline li:last-child { border-bottom: none; }

/* ---------- gallery ---------- */

.ad-galgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(19rem, 1fr));
  gap: 1rem;
}

.ad-galgrid .ad-card h3 { margin: 0 0 0.5rem; }
.ad-galgrid label { display: block; font-size: 0.75rem; font-weight: 700; color: var(--ad-muted); margin: 0.5rem 0 0.15rem; }
.ad-galgrid input[type="text"] { width: 100%; }

/* ---------- print (order workbench sheet) ---------- */

@media print {
  .ad-topbar, .ad-subnav, .no-print { display: none !important; }
  body.ad { background: #fff; font-size: 11pt; }
  .ad-main { max-width: none; padding: 0; }
  .ad-card, .ad-tablewrap { border-color: #999; break-inside: avoid; }
  .ad-tablewrap { overflow: visible; }
  a { text-decoration: none; color: inherit; }
}
