/* Product DB — one stylesheet, no build step, no external fonts.
   Dark by default because this is a tool that gets used at night as often as
   not; light mode follows the OS preference. */

:root {
  color-scheme: dark light;
  --bg: #11131a;
  --surface: #191c26;
  --surface-2: #212534;
  --border: #2d3244;
  --text: #e6e8ef;
  --text-muted: #9aa1b5;
  --accent: #6ea8fe;
  --ok: #3fb950;
  --warn: #d29922;
  --danger: #f85149;
  --radius: 10px;
  --gap: 1rem;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-2: #f0f2f6;
    --border: #d9dee8;
    --text: #1b1f2a;
    --text-muted: #5d6478;
    --accent: #1f6feb;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }

.container { max-width: 1200px; margin: 0 auto; padding: 1.25rem 1rem 4rem; }

/* header */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--gap); padding: .6rem 1rem;
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.nav { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.nav a { color: var(--text-muted); padding: .25rem 0; }
.nav a.active { color: var(--text); border-bottom: 2px solid var(--accent); }
.brand { font-weight: 700; color: var(--text) !important; }
.link-button {
  background: none; border: 0; color: var(--text-muted);
  cursor: pointer; font: inherit; padding: .25rem;
}
.link-button:hover { color: var(--text); text-decoration: underline; }

/* cards, layout */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem; margin-bottom: var(--gap);
}
.split { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: var(--gap); flex-wrap: wrap; }
.crumb { color: var(--text-muted); margin: 0 0 .5rem; }
.count { color: var(--text-muted); font-weight: 400; font-size: 1rem; }

/* dashboard tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--gap); margin-bottom: var(--gap); }
.tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem; display: flex; flex-direction: column; gap: .25rem; color: inherit;
}
a.tile:hover { border-color: var(--accent); text-decoration: none; }
.tile-value { font-size: 1.6rem; font-weight: 650; letter-spacing: -.02em; }
.tile-of { font-size: 1rem; color: var(--text-muted); font-weight: 400; }
.tile-label { color: var(--text-muted); font-size: .85rem; }
.tile-warn .tile-value { color: var(--warn); }

/* tables */
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { color: var(--text-muted); font-weight: 600; font-size: .85rem; white-space: nowrap; }
.table.compact th, .table.compact td { padding: .35rem .5rem; font-size: .9rem; }
.table tbody tr:hover { background: var(--surface-2); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.clip { max-width: 34ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-muted { opacity: .55; }

/* definition lists */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .35rem .9rem; margin: 0; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; }

/* badges, status */
.badge {
  display: inline-block; padding: .05rem .4rem; margin-left: .3rem;
  border: 1px solid var(--border); border-radius: 999px;
  font-size: .72rem; color: var(--text-muted); background: var(--surface-2);
  vertical-align: middle;
}
.badge-ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, var(--border)); }
.badge-warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, var(--border)); }
.status { font-weight: 600; }
.status-ok, .status-completed { color: var(--ok); }
.status-partial, .status-completed_with_errors { color: var(--warn); }
.status-failed, .status-error { color: var(--danger); }
.muted { color: var(--text-muted); }
.warn { color: var(--warn); }
.alert {
  background: color-mix(in srgb, var(--danger) 15%, var(--surface));
  border: 1px solid var(--danger); border-radius: var(--radius);
  padding: .6rem .8rem;
}

/* buttons, chips */
button, .button {
  display: inline-block; font: inherit; cursor: pointer;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; padding: .45rem .8rem;
}
button:hover, .button:hover { border-color: var(--accent); text-decoration: none; }
.primary { background: var(--accent); border-color: var(--accent); color: #0b0e14; font-weight: 600; }
.ghost { background: none; }
.chip { padding: .25rem .7rem; border: 1px solid var(--border); border-radius: 999px; color: var(--text-muted); }
.chip-on { background: var(--surface-2); color: var(--text); border-color: var(--accent); }
.toggles { display: flex; gap: .5rem; }

/* filters */
.filters { display: flex; flex-direction: column; gap: .75rem; }
.filter-row { display: flex; gap: .5rem; align-items: center; }
.filter-row.wrap { flex-wrap: wrap; }
.filters label { display: flex; align-items: center; gap: .35rem; color: var(--text-muted); font-size: .9rem; }
.filters label.check { gap: .3rem; }
input, select {
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px; padding: .4rem .55rem;
}
input[type="search"] { flex: 1; min-width: 0; }
input:focus, select:focus, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}

/* product grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: var(--gap); }
.product-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column;
}
.product-card:hover { border-color: var(--accent); }
.product-card.inactive { opacity: .6; }
.thumb { display: block; aspect-ratio: 1; background: var(--surface-2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-empty { display: grid; place-items: center; height: 100%; color: var(--text-muted); font-size: .8rem; }
.product-body { padding: .6rem .7rem .8rem; display: flex; flex-direction: column; gap: .2rem; }
.product-title { font-weight: 600; color: var(--text); line-height: 1.3; }
.product-meta { margin: 0; font-size: .85rem; color: var(--text-muted); }
.product-price { margin: .3rem 0 0; font-variant-numeric: tabular-nums; }
.empty { grid-column: 1 / -1; }
.load-more { grid-column: 1 / -1; display: flex; justify-content: center; padding: .5rem 0 1.5rem; }
.htmx-request button { opacity: .6; }

/* product detail */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: var(--gap); margin-bottom: var(--gap); }
.gallery figure { margin: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.gallery img { width: 100%; display: block; aspect-ratio: 1; object-fit: contain; background: var(--surface-2); }
.gallery figcaption { padding: .3rem .5rem; font-size: .75rem; }
.tags { display: flex; flex-wrap: wrap; gap: .3rem; margin: .5rem 0 1rem; }
.tag { background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: .1rem .55rem; font-size: .78rem; color: var(--text-muted); }
.body-html { overflow-wrap: anywhere; }
.body-html img { max-width: 100%; height: auto; }
.body-html table { width: 100%; border-collapse: collapse; }
.body-html td, .body-html th { border: 1px solid var(--border); padding: .3rem .5rem; }
.history summary { cursor: pointer; padding: .35rem 0; }

/* login */
.login-wrap { max-width: 360px; margin: 12vh auto 0; }
.login-form { display: flex; flex-direction: column; gap: .4rem; }
.login-form label { color: var(--text-muted); font-size: .9rem; }
.login-form button { margin-top: .8rem; }

@media (max-width: 760px) {
  .split { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: .15rem; }
  .kv dd { margin-bottom: .5rem; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .topbar { flex-wrap: wrap; }
}

/* store admin */
.domains {
  width: 100%; font: 14px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px; padding: .5rem .6rem;
  resize: vertical;
}
.domains:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
form.card label { display: block; color: var(--text-muted); margin-bottom: .35rem; }
form.card label.check { display: flex; align-items: center; gap: .4rem; margin: .6rem 0; }
form.card button { margin-top: .4rem; }
code { background: var(--surface-2); padding: .05rem .3rem; border-radius: 4px; font-size: .9em; }

/* photo search */
.search-form input[type="file"] {
  width: 100%; padding: .6rem; background: var(--surface-2);
  border: 1px dashed var(--border); border-radius: 8px;
}
.score { display: flex; align-items: center; gap: .5rem; margin: .35rem 0 0; }
.score-bar {
  flex: 1; height: 6px; background: var(--surface-2);
  border-radius: 999px; overflow: hidden;
}
.score-fill { display: block; height: 100%; background: var(--accent); }
/* Widths as classes in 5% steps. The CSP forbids inline styles, and a score
   bar is not worth an 'unsafe-inline' exception. */
.score-fill.w0 { width: 0%; }
.score-fill.w5 { width: 5%; }
.score-fill.w10 { width: 10%; }
.score-fill.w15 { width: 15%; }
.score-fill.w20 { width: 20%; }
.score-fill.w25 { width: 25%; }
.score-fill.w30 { width: 30%; }
.score-fill.w35 { width: 35%; }
.score-fill.w40 { width: 40%; }
.score-fill.w45 { width: 45%; }
.score-fill.w50 { width: 50%; }
.score-fill.w55 { width: 55%; }
.score-fill.w60 { width: 60%; }
.score-fill.w65 { width: 65%; }
.score-fill.w70 { width: 70%; }
.score-fill.w75 { width: 75%; }
.score-fill.w80 { width: 80%; }
.score-fill.w85 { width: 85%; }
.score-fill.w90 { width: 90%; }
.score-fill.w95 { width: 95%; }
.score-fill.w100 { width: 100%; }
.score-value { font-size: .8rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.verdicts { display: flex; gap: .35rem; margin-top: .5rem; }
.verdicts form { flex: 1; }
.tiny { width: 100%; padding: .2rem .4rem; font-size: .78rem; }
