/* autowiper admin — one stylesheet, no framework, no JS.
   Deliberately unrelated to public/assets/site.css: the admin is a different app
   and must never inherit a public-site style change. */

:root {
  --ink: #1b1f23;
  --muted: #6a737d;
  --line: #d8dee4;
  --bg: #f6f8fa;
  --card: #fff;
  --accent: #0b63ce;
  --ok: #1a7f37;
  --warn: #9a6700;
  --bad: #cf222e;
  --warn-bg: #fff8c5;
  --bad-bg: #ffebe9;
  --ok-bg: #dafbe1;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
code { background: rgba(0,0,0,.05); padding: .1em .35em; border-radius: 3px; }
pre { background: #fff; border: 1px solid var(--line); border-radius: 5px; padding: .6rem .8rem; overflow-x: auto; }
pre.tight { margin: 0; max-height: 9rem; }

a { color: var(--accent); }

/* --- chrome ------------------------------------------------------------- */

.top {
  display: flex; align-items: center; gap: 1.5rem;
  padding: .7rem 1.25rem;
  background: #24292f; color: #fff;
}
.top a { color: #d6dde5; text-decoration: none; }
.top nav { display: flex; gap: 1.1rem; flex: 1; flex-wrap: wrap; }
.top nav a.on, .top nav a:hover { color: #fff; text-decoration: underline; }
.brand { font-weight: 700; }
.brand span { font-weight: 400; opacity: .7; }
.logout { display: flex; align-items: center; gap: .6rem; margin: 0; }
.who { color: #d6dde5; font-size: 12.5px; }

main { max-width: 76rem; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }
main.centered { max-width: 26rem; padding-top: 4rem; }

h1 { font-size: 1.5rem; margin: 0 0 .8rem; }
h2 { font-size: 1.1rem; margin: 1.5rem 0 .6rem; }
.muted { color: var(--muted); }
.ok { color: var(--ok); }
.bad { color: var(--bad); }

.crumbs { color: var(--muted); margin: -.4rem 0 1rem; }

/* --- cards, tiles ------------------------------------------------------- */

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 6px;
  padding: 1rem 1.25rem; margin: 0 0 1.25rem;
}
.card--narrow { max-width: 26rem; }
.card--danger { border-color: var(--bad); }
.card--danger h2 { color: var(--bad); margin-top: 0; }

.split { display: grid; grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); gap: 1.25rem; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr)); gap: .75rem; margin-bottom: 1.5rem; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: .75rem; text-align: center; }
.tile__n { display: block; font-size: 1.4rem; font-weight: 700; }
.tile__l { display: block; color: var(--muted); font-size: 12px; }

.feed { list-style: none; padding: 0; margin: 0; }
.feed li { padding: .3rem 0; border-bottom: 1px solid var(--line); font-size: 13px; }

/* --- flashes ------------------------------------------------------------ */

.flash { border: 1px solid var(--line); border-radius: 6px; padding: .75rem 1rem; margin: 0 0 1rem; }
.flash p { margin: 0 0 .4rem; }
.flash p:last-child, .flash ul:last-child { margin-bottom: 0; }
.flash--ok { background: var(--ok-bg); border-color: #a2d8ad; }
.flash--warn { background: var(--warn-bg); border-color: #e0c445; }
.flash--error { background: var(--bad-bg); border-color: #f3b0ab; }
.flash pre { max-height: 18rem; }

/* --- the regeneration panel: the thing spec §8 says must not surprise ---- */

.plan { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 6px; padding: 1rem 1.25rem; margin: 0 0 1.25rem; }
.plan__head { margin: 0 0 .6rem; font-weight: 700; }
.plan--full { border-left-color: var(--bad); }
.plan tr.plan--full td { background: var(--bad-bg); }
.plan ul { margin: 0; padding-left: 1.1rem; }
.plan details summary { cursor: pointer; }

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

table.grid { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 6px; }
table.grid th, table.grid td { text-align: left; padding: .45rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.grid thead th { background: #f0f3f6; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
table.grid tr:last-child td { border-bottom: 0; }
table.grid tr.off td { color: var(--muted); background: #fafbfc; }
table.grid .num { text-align: right; }
.url { white-space: nowrap; }

table.kv { border-collapse: collapse; }
table.kv th { text-align: left; padding: .2rem 1rem .2rem 0; color: var(--muted); font-weight: 400; }

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

.toolbar { display: flex; gap: 1rem; align-items: center; justify-content: space-between; margin: 0 0 .75rem; flex-wrap: wrap; }
form.inline { display: flex; gap: .5rem; align-items: center; margin: 0; }

fieldset { background: var(--card); border: 1px solid var(--line); border-radius: 6px; margin: 0 0 1.25rem; padding: .5rem 1.25rem 1rem; }
legend { font-weight: 700; padding: 0 .4rem; }

form p { margin: .9rem 0; }
label { display: block; font-weight: 600; margin-bottom: .2rem; }
label.check { font-weight: 400; display: inline-flex; align-items: center; gap: .4rem; margin-right: 1.25rem; }
label.check input { margin: 0; }

input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; max-width: 44rem; padding: .4rem .55rem;
  border: 1px solid var(--line); border-radius: 5px; font: inherit; background: #fff;
}
input.pos { width: 4.5rem; }
input[type=search] { width: 16rem; }
textarea { max-width: 60rem; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }

.hint { display: block; color: var(--muted); font-size: 12.5px; margin-top: .25rem; }
.warnbox { background: var(--warn-bg); border: 1px solid #e0c445; border-radius: 5px; padding: .6rem .8rem; }

button, .button {
  font: inherit; padding: .4rem .9rem; border-radius: 5px; border: 1px solid var(--line);
  background: #fff; cursor: pointer; text-decoration: none; color: var(--ink); display: inline-block;
}
button:hover, .button:hover { background: #f0f3f6; }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.warn { background: var(--warn-bg); border-color: #e0c445; }
button.danger { background: var(--bad); border-color: var(--bad); color: #fff; }

.actions { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.danger-form { margin-top: 1rem; }
.danger-form button { margin-top: .6rem; }

/* --- screens added with products / editorial / ops ----------------------- */

/* The filter bar on the product list and the fitment picker: several controls
   on one line, wrapping rather than overflowing on a narrow window. */
.filters { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin: 0 0 1rem; }
.filters select, .filters input[type=search] { width: auto; min-width: 9rem; }
.filters .check { margin-right: 0; }
.inline-label { display: inline; font-weight: 600; }

.pager { display: flex; gap: 1rem; align-items: center; }

/* A multi-select is the bulk fitment control — it has to be tall enough that a
   make with 60 generations is pickable without scrolling a 4-row box. */
select[multiple] { width: 100%; max-width: 30rem; padding: .2rem; }

h3 { font-size: 1rem; margin: .2rem 0 .6rem; }
.card h3:first-child { margin-top: 0; }

/* The rebuild progress panel. `hidden` must win over the display the panel
   would otherwise get. */
#rebuild-progress[hidden] { display: none; }
#rebuild-progress { margin-top: 1rem; }
#rebuild-log { white-space: pre-wrap; }

input[type=file] { font: inherit; }

/* ---------------------------------------------------------------------------
   The image library.

   A checkerboard behind every thumbnail, because 2764 of these images are
   cut-outs with ~55 % of their pixels fully transparent: on a white card a
   PNG with a blown alpha channel and a correct one look identical, and the
   whole point of the library is being able to see which you have.
   --------------------------------------------------------------------------- */

.imggrid {
  list-style: none; margin: 0 0 1.25rem; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); gap: .75rem;
}
.imgcard {
  background: var(--card); border: 1px solid var(--line); border-radius: 6px;
  padding: .5rem; font-size: 12px; overflow: hidden;
}
.imgcard--unused { border-style: dashed; }
.imgcard a { display: block; text-decoration: none; color: inherit; }
.imgcard__frame {
  display: flex; align-items: center; justify-content: center;
  height: 7.5rem; margin-bottom: .4rem; border-radius: 4px;
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #eceff2 25%, transparent 25%, transparent 75%, #eceff2 75%),
    linear-gradient(45deg, #eceff2 25%, transparent 25%, transparent 75%, #eceff2 75%);
  background-size: 14px 14px;
  background-position: 0 0, 7px 7px;
}
.imgcard__frame img { max-width: 100%; max-height: 7.5rem; }
.imgcard__path {
  display: block; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px; word-break: break-all; color: var(--accent);
}
.imgcard__meta { display: block; color: var(--muted); margin-top: .25rem; }

.imgpreview {
  display: flex; align-items: center; justify-content: center; min-height: 12rem;
  border: 1px solid var(--line); border-radius: 5px; padding: .75rem;
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #eceff2 25%, transparent 25%, transparent 75%, #eceff2 75%),
    linear-gradient(45deg, #eceff2 25%, transparent 25%, transparent 75%, #eceff2 75%);
  background-size: 18px 18px;
  background-position: 0 0, 9px 9px;
}
.imgpreview img { max-width: 100%; height: auto; }

/* ---------------------------------------------------------------------------
   The picker, as used by every form that carries an image_id.
   --------------------------------------------------------------------------- */

.imgpick { display: flex; gap: .75rem; align-items: flex-start; }
.imgpick__thumb {
  flex: 0 0 auto; width: 6rem; height: 6rem; border: 1px solid var(--line); border-radius: 5px;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #eceff2 25%, transparent 25%, transparent 75%, #eceff2 75%),
    linear-gradient(45deg, #eceff2 25%, transparent 25%, transparent 75%, #eceff2 75%);
  background-size: 12px 12px; background-position: 0 0, 6px 6px;
}
.imgpick__thumb img { max-width: 100%; max-height: 100%; }
.imgpick__thumb span { color: var(--muted); font-size: 11px; text-align: center; padding: .3rem; }
.imgpick__body { flex: 1 1 auto; min-width: 0; }
.imgpick input[type=number] { width: 7rem; }
.imgpick__row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }

dialog.picker {
  width: min(56rem, 92vw); max-height: 86vh; border: 1px solid var(--line);
  border-radius: 8px; padding: 0; background: var(--card); color: inherit;
}
dialog.picker::backdrop { background: rgba(20, 28, 38, .55); }
dialog.picker header {
  display: flex; gap: .6rem; align-items: center; flex-wrap: wrap;
  padding: .8rem 1rem; border-bottom: 1px solid var(--line); position: sticky; top: 0;
  background: var(--card);
}
dialog.picker header h2 { margin: 0; flex: 1 1 auto; font-size: 1rem; }
dialog.picker .picker__body { padding: 1rem; overflow-y: auto; max-height: 66vh; }
dialog.picker .imgcard { cursor: pointer; }
dialog.picker .imgcard:hover, dialog.picker .imgcard:focus-visible { border-color: var(--accent); }
dialog.picker footer {
  display: flex; gap: .8rem; align-items: center; justify-content: space-between;
  padding: .7rem 1rem; border-top: 1px solid var(--line);
}
