/* Red White Mobile admin.
   Answering "too old design i feel": quiet surfaces, one accent, data that
   reads like data. Same red / white / matte black as the storefront. */

:root {
  --red: #e11d2e;
  --red-deep: #a2101d;
  --red-wash: #fff1f2;
  --ink: #16171a;
  --ink-2: #2a2c31;
  --muted: #6b6f76;
  --line: #e4e6ea;
  --paper: #f6f7f9;
  --good: #0f8a5f;
  --good-wash: #e9f7f1;
  --warn: #b45309;
  --warn-wash: #fdf3e6;
  --bad: #b3261e;
  --bad-wash: #fdecea;
  --rail: 232px;
  --ease: cubic-bezier(.22, .61, .36, 1);
}

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

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px; color: var(--ink); background: var(--paper);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, .brand { font-family: Outfit, Inter, sans-serif; letter-spacing: -.02em; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
:focus-visible { outline: 3px solid var(--red); outline-offset: 2px; border-radius: 4px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- rail ---------- */
.rail {
  position: fixed; inset: 0 auto 0 0; width: var(--rail);
  background: var(--ink); color: rgba(255,255,255,.72);
  display: flex; flex-direction: column; padding: 22px 14px;
}
.brand {
  display: block; padding: 0 10px 22px; font-size: 17px; font-weight: 800;
  letter-spacing: -.03em; color: #fff; text-decoration: none;
}
.brand span { color: var(--red); }
.brand em { font-style: normal; color: rgba(255,255,255,.55); }
.brand small { display: block; font-family: Inter, sans-serif; font-size: 10px; font-weight: 600;
  letter-spacing: .2em; text-transform: uppercase; color: rgba(255,255,255,.4); margin-top: 5px; }

.rail nav { display: grid; gap: 2px; }
.rail nav a {
  padding: 10px 12px; border-radius: 8px; text-decoration: none;
  font-size: 13.5px; font-weight: 500;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.rail nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.rail nav a.on { background: var(--red); color: #fff; font-weight: 600; }

.rail-foot { margin-top: auto; padding: 16px 12px 0; border-top: 1px solid rgba(255,255,255,.12); display: grid; gap: 6px; }
.rail-foot .who { color: #fff; font-weight: 600; font-size: 13px; }
.rail-foot .mode { font-size: 11px; color: rgba(255,255,255,.45); }
.rail-foot .out { font-size: 12.5px; text-decoration: none; color: rgba(255,255,255,.6); }
.rail-foot .out:hover { color: var(--red); }

main { margin-left: var(--rail); padding: 26px 30px 60px; }
@media (max-width: 860px) {
  .rail { position: static; width: auto; }
  .rail nav { grid-auto-flow: column; overflow-x: auto; }
  main { margin-left: 0; padding: 20px; }
}

.top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.top h1 { font-size: 25px; margin: 0; }

.flash {
  border-radius: 10px; padding: 12px 16px; margin-bottom: 18px;
  font-size: 13.5px; font-weight: 500;
  background: var(--good-wash); color: #0b6647; border: 1px solid #bde5d5;
}
.flash.warn { background: var(--warn-wash); color: #8a4a08; border-color: #f0dcbe; }
.flash.bad { background: var(--bad-wash); color: var(--bad); border-color: #f3c9c5; }

/* ---------- tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 20px; }
@media (max-width: 1180px) { .tiles { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 620px) { .tiles { grid-template-columns: repeat(2, 1fr); } }
.tile {
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 18px; text-decoration: none; display: grid; gap: 4px;
  transition: border-color .15s var(--ease), transform .15s var(--ease);
}
.tile:hover { border-color: var(--ink); transform: translateY(-2px); }
.tile .v { font-family: Outfit, sans-serif; font-size: 30px; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.tile .l { font-size: 12px; color: var(--muted); line-height: 1.4; }
.tile.warn .v { color: var(--warn); }
.tile.bad .v { color: var(--bad); }

/* ---------- cards ---------- */
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1080px) { .cols { grid-template-columns: 1fr; } }
.card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 20px 22px; margin-bottom: 16px; }
.card h2 { font-size: 16px; margin: 0 0 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.hint { font-size: 12.5px; color: var(--muted); }
.note { font-size: 13px; color: var(--muted); line-height: 1.6; margin: 0 0 16px; max-width: 84ch; }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 10.5px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted); padding: 0 10px 10px; border-bottom: 1px solid var(--line);
}
th.num { text-align: right; }
td { padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fafbfc; }
td .sub { display: block; font-size: 11.5px; color: var(--muted); margin-top: 2px; }
td.msg { font-size: 12.5px; color: var(--muted); max-width: 40ch; }
.empty { color: var(--muted); text-align: center; padding: 26px 0; font-size: 13.5px; }

.grid input[type="number"] {
  width: 92px; border: 1px solid var(--line); border-radius: 7px;
  padding: 7px 9px; text-align: right; font-variant-numeric: tabular-nums;
  transition: border-color .14s var(--ease), box-shadow .14s var(--ease);
}
.grid input[type="number"]:focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 3px rgba(22,23,26,.06); }
.prefix { color: var(--muted); margin-right: 3px; font-size: 12.5px; }
tr.dirty td { background: var(--warn-wash); }
tr.dirty:hover td { background: #fbeed9; }

.swatch { display: inline-block; width: 13px; height: 13px; border-radius: 50%; border: 1px solid rgba(0,0,0,.15); margin-left: 8px; vertical-align: -2px; }
td.neg { color: var(--red); }

/* ---------- badges ---------- */
.badge {
  display: inline-block; border-radius: 999px; padding: 3px 10px;
  font-size: 11px; font-weight: 700; letter-spacing: .03em;
  background: var(--paper); color: var(--muted); border: 1px solid var(--line);
}
.badge.ok, .badge.sent, .badge.published, .badge.live { background: var(--good-wash); color: #0b6647; border-color: #bde5d5; }
.badge.low, .badge.warn, .badge.pending, .badge.disabled, .badge.approved, .badge.received { background: var(--warn-wash); color: #8a4a08; border-color: #f0dcbe; }
.badge.out, .badge.bad, .badge.failed, .badge.rejected { background: var(--bad-wash); color: var(--bad); border-color: #f3c9c5; }

/* ---------- buttons ---------- */
button.primary {
  background: var(--red); color: #fff; border-radius: 999px;
  padding: 10px 22px; font-weight: 700; font-size: 13.5px;
  transition: background .15s var(--ease), transform .15s var(--ease);
}
button.primary:hover { background: var(--red-deep); transform: translateY(-1px); }
.mini {
  display: inline-block; border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 14px; font-size: 12.5px; font-weight: 600; text-decoration: none; background: #fff;
  transition: border-color .14s var(--ease), color .14s var(--ease);
}
.mini:hover { border-color: var(--ink); }
.mini.danger:hover { border-color: var(--bad); color: var(--bad); }
td.actions { display: flex; gap: 6px; flex-wrap: wrap; }
td.actions form { display: inline; }

/* ---------- push bar ---------- */
.push {
  background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--red);
  border-radius: 12px; padding: 20px 22px; margin-bottom: 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap;
}
.push.quiet { border-left-color: var(--good); color: var(--muted); font-size: 13.5px; }
.push h3 { margin: 0 0 8px; font-size: 15px; }
.diff { margin: 0; padding-left: 18px; font-size: 12.5px; color: var(--muted); line-height: 1.7; }
.diff b { color: var(--ink); }

/* ---------- variants ---------- */
.picker { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.picker label { font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.picker select { border: 1px solid var(--line); border-radius: 999px; padding: 9px 16px; background: #fff; min-width: 260px; }
.addrow { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.addrow input { border: 1px solid var(--line); border-radius: 8px; padding: 8px 11px; font-size: 13px; }
.addrow input[name="name"] { flex: 1; min-width: 130px; }
.addrow input[name="delta"] { width: 96px; text-align: right; }
.addrow input[name="meta"] { width: 106px; }
.addrow button { border: 1px solid var(--ink); background: var(--ink); color: #fff; border-radius: 8px; padding: 8px 18px; font-size: 13px; font-weight: 600; }
.addrow button:hover { background: #000; }

/* A tile whose number just changed under the operator, briefly marked. */
@keyframes tile-bump {
  0%   { background: var(--red-wash, #fff1f2); transform: translateY(-2px); }
  100% { background: #fff; transform: none; }
}
.tile.bumped { animation: tile-bump .9s var(--ease, ease-out); }
@media (prefers-reduced-motion: reduce) { .tile.bumped { animation: none; } }

/* ---------- add-a-row and stacked forms ----------
   The rate tables can only be edited until something can be added to them, so
   both rate screens carry one of these under the grid. */
.addform { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; }
.addform .field { flex: 1 1 190px; margin: 0; }
.addform .addrow { margin-top: 0; flex: 0 0 auto; }
.stack { display: grid; gap: 14px; max-width: 420px; }
.stack .field { margin: 0; }
.actions form { display: inline-block; }
button.danger, .mini.danger {
  border: 1px solid var(--line); background: #fff; color: var(--red);
  border-radius: 8px; padding: 6px 12px; font-size: 12px; font-weight: 600;
}
button.danger:hover, .mini.danger:hover { border-color: var(--red); background: #fff5f6; }

/* ---------- posts ---------- */
.post { display: flex; gap: 20px; justify-content: space-between; align-items: flex-start; padding: 18px 0; border-bottom: 1px solid var(--line); }
.post:last-child { border-bottom: 0; }
.post h3 { font-size: 16px; margin: 8px 0 6px; line-height: 1.3; }
.post p { font-size: 13.5px; color: var(--muted); margin: 0 0 6px; line-height: 1.6; max-width: 74ch; }
.post .sub { font-size: 12px; color: var(--muted); }
.post-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- login ---------- */
.login-page { display: grid; place-items: center; min-height: 100vh; background: var(--ink); padding: 24px; }
.login { background: #fff; border-radius: 18px; padding: 34px 34px 30px; width: min(390px, 100%); display: grid; gap: 8px; }
.login .brand { color: var(--ink); font-size: 18px; font-weight: 800; letter-spacing: -.03em; margin-bottom: 12px; }
.login .brand span { color: var(--red); }
.login .brand em { font-style: normal; color: var(--muted); }
.login h1 { font-size: 26px; margin: 0; }
.login .sub { font-size: 13.5px; color: var(--muted); margin: 0 0 12px; }
.login label { font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-top: 8px; }
.login input { border: 1px solid var(--line); border-radius: 9px; padding: 11px 13px; font-size: 14.5px; }
.login input:focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 3px rgba(22,23,26,.06); }
.login button { margin-top: 18px; background: var(--red); color: #fff; border-radius: 999px; padding: 12px; font-weight: 700; font-size: 14.5px; }
.login button:hover { background: var(--red-deep); }
.login .err { background: var(--bad-wash); color: var(--bad); border: 1px solid #f3c9c5; border-radius: 9px; padding: 10px 13px; font-size: 13px; margin: 0; }

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* Keep the $ on the same line as its field — narrow rate columns wrapped it. */
.grid td.num { white-space: nowrap; }

/* Catalogue search and paging. The shop has 4,019 products, so the stock screen
   is paged rather than one enormous table. */
.searchrow { display: flex; gap: 8px; margin: 0 0 18px; }
.searchrow input {
  flex: 1; border: 1.5px solid var(--line); border-radius: 999px;
  padding: 10px 16px; font: inherit; background: #fff;
}
.searchrow input:focus { outline: none; border-color: var(--red); }

.pager {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 16px 4px 2px; font-size: 13.5px; color: var(--muted);
}

.push .sub { font-size: 13.5px; color: var(--muted); margin: 6px 0 0; line-height: 1.55; }
.grid select {
  border: 1.5px solid var(--line); border-radius: 999px;
  padding: 7px 12px; font: inherit; background: #fff;
}

/* ---------- clean-up tabs ---------- */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin: 0 0 18px; border-bottom: 1px solid var(--line); }
.tab {
  display: inline-flex; align-items: center; gap: 7px; padding: 9px 15px;
  font-size: 13px; font-weight: 600; color: var(--muted); text-decoration: none;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--ink); }
.tab.on { color: var(--red); border-bottom-color: var(--red); }
.pill {
  display: inline-block; background: var(--paper); border: 1px solid var(--line);
  border-radius: 999px; padding: 1px 8px; font-size: 11px; font-weight: 700; color: var(--muted);
}
.tab.on .pill { background: var(--red); color: #fff; border-color: var(--red); }

/* ---------- repair matrix: section picker + dense price grid ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 16px; }
.chip {
  font-size: 12px; font-weight: 600; text-decoration: none; color: var(--muted);
  background: var(--paper); border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px;
}
.chip:hover { color: var(--ink); }
.chip.on { background: var(--red); border-color: var(--red); color: #fff; }

/* Six hundred cells want to be scannable, not roomy. */
.grid input[size="7"] { width: 74px; text-align: right; }
.grid input.wide { width: 100%; min-width: 130px; }
.grid td { padding-top: 4px; padding-bottom: 4px; }

/* ---------- intake form ---------- */
.jobform { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.jobform input, .jobform select {
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 11px; font: inherit; font-size: 13px; background: #fff;
}
.jobform input[name="customer"], .jobform input[name="device"] { flex: 1; min-width: 150px; }
.jobform input[name="quote"] { width: 90px; text-align: right; }

/* extra state badges (order + job workflows) */
.badge.ready, .badge.accepted, .badge.quoted { background: var(--warn-wash); color: #8a4a08; border-color: #f0dcbe; }
.badge.collected, .badge.paid, .badge.done, .badge.back_in_stock { background: var(--good-wash); color: #0b6647; border-color: #bde5d5; }
.badge.price_drop { background: var(--warn-wash); color: #8a4a08; border-color: #f0dcbe; }

/* ---------- product edit form ---------- */
.field { margin: 14px 0; }
.field > label { display: block; font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.field > input, .field > textarea, .field > select {
  width: 100%; box-sizing: border-box; border: 1px solid var(--line); border-radius: 9px;
  padding: 10px 12px; font: inherit; font-size: 14px; background: #fff;
}
.field > input:focus, .field > textarea:focus, .field > select:focus { outline: none; border-color: var(--red); }
.field > textarea { resize: vertical; line-height: 1.5; }
.chks { display: flex; flex-wrap: wrap; gap: 8px 14px; }
.chk { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; color: var(--ink); }
.cols .field { margin: 0; }

/* ---------------- image uploader (product form) ---------------- */
.uploader { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.uploader input[type=url] { flex: 1; min-width: 220px; }
.up-btn {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  border: 1.5px dashed #c9ccd2; border-radius: 8px; padding: 8px 14px;
  font-size: 13px; font-weight: 600; color: #444; background: #fafafa; white-space: nowrap;
}
.up-btn:hover { border-color: #111; color: #111; }
.uploader.over .up-btn { border-color: #e11d2e; color: #e11d2e; background: #fff1f2; }
.uploader.busy { opacity: .7; }
.up-status { font-size: 12.5px; color: #6b6f76; }
