:root {
  /* Viakeys brand: black wordmark, red accent (taken from the Viakeys logo and favicon) */
  --brand-black: #0b0b0c; --brand-red: #c81e28; --brand-red-dark: #a30406;
  --ink: #16181c; --muted: #6b6f76; --line: #e4e5e8; --bg: #f5f5f6; --card: #fff;
  --navy: var(--brand-black); --accent: var(--brand-black); --accent-ink: #fff; --link: var(--brand-red-dark);
  --warn: #fff7e6; --warn-line: #f5c26b;
  --ok: #e7f6ec; --ok-ink: #17663a; --err: #fdecec; --err-ink: #a4262c;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
.top { display: flex; align-items: center; gap: 24px; padding: 12px 20px; background: var(--brand-black); color: #fff; flex-wrap: wrap; border-bottom: 3px solid var(--brand-red); }
.top a { color: #d6d7da; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; color: #fff !important; text-decoration: none !important; }
.brand .logo { height: 20px; width: auto; display: block; }
.brand .app { padding-left: 10px; border-left: 1px solid #3a3b40; letter-spacing: .3px; }
.brand small { font-weight: 400; color: #9a9ca3; font-size: 12px; }

.top nav { display: flex; gap: 4px; }
.top nav a { padding: 6px 12px; border-radius: 6px; }
.top nav a:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.top nav a.on { color: #fff; text-decoration: none; box-shadow: inset 0 -2px 0 var(--brand-red); border-radius: 6px 6px 0 0; }
.who { margin-left: auto; display: flex; gap: 14px; align-items: center; color: #9a9ca3; font-size: 13px; }
.who form { margin: 0; }
main { max-width: 1280px; margin: 0 auto; padding: 20px 16px 60px; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 15px; margin: 0 0 12px; }
.head { display: flex; align-items: center; gap: 12px; margin: 4px 0 16px; flex-wrap: wrap; }
.head .button { margin-left: auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; margin-bottom: 16px; }
.card.narrow { max-width: 420px; margin: 40px auto; }
.card.warn { background: var(--warn); border-color: var(--warn-line); }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(360px, 100%), 1fr)); gap: 16px; }
.cols .card { margin: 0; }
.cols + * { margin-top: 16px; }
dl { display: grid; grid-template-columns: minmax(140px, 40%) 1fr; gap: 6px 14px; margin: 0; }
dt { color: var(--muted); }
dd { margin: 0; overflow-wrap: anywhere; }
label { display: block; margin: 12px 0; color: var(--muted); }
input, select, button, .button { font: inherit; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=number], input[type=date], input[type=url], input:not([type]), select {
  display: block; width: 100%; padding: 8px 10px; border: 1px solid #cfd6e0; border-radius: 6px; background: #fff; color: var(--ink); margin-top: 4px; }
button, .button { display: inline-block; padding: 8px 14px; border-radius: 6px; border: 1px solid #cfd6e0; background: #fff; color: var(--ink); cursor: pointer; }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.small { padding: 4px 10px; font-size: 13px; }
button.link { background: none; border: 0; padding: 0; color: inherit; text-decoration: underline; cursor: pointer; }
.searchbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.searchbar input[type=search] { flex: 1 1 320px; width: auto; margin: 0; }
.searchbar select { width: auto; margin: 0; }
.grid { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.grid th { text-align: left; font-weight: 600; color: var(--muted); background: #fafbfc; }
.grid th, .grid td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.grid tbody tr:hover { background: #f7f7f8; cursor: pointer; }
.grid.issues tbody tr:hover { cursor: default; }
.grid.small td { font-size: 13px; }
.num { text-align: right; }
.mono, code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 13px; }
code.ws { white-space: pre-wrap; background: #f1f3f6; padding: 1px 4px; border-radius: 4px; }
.muted { color: var(--muted); }
.pill { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; background: #eef1f5; color: #3b4658; }
.pill.live { background: var(--ok); color: var(--ok-ink); }
.pill.draft, .pill.ready { background: #eaf2ff; color: #1b4fa8; }
.pill.on_hold { background: var(--warn); color: #7a4d00; }
.pill.discontinued { background: var(--err); color: var(--err-ink); }
.msg { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; background: #eaf2ff; }
.msg.success { background: var(--ok); color: var(--ok-ink); }
.msg.error { background: var(--err); color: var(--err-ink); }
.pager { display: flex; gap: 16px; justify-content: center; margin: 16px 0; }
.crumbs { margin: 0 0 6px; color: var(--muted); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs a { padding: 6px 12px; border: 1px solid var(--line); border-radius: 99px; background: #fff; color: var(--ink); }
.tabs a.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.tabs a b { margin-left: 4px; }
.actions { white-space: nowrap; }
.actions form { display: inline-flex; gap: 4px; margin: 0 0 4px; }
.actions .dismiss input { width: 170px; padding: 4px 6px; margin: 0; font-size: 13px; }
.bulkbar { margin: 12px 0; display: flex; gap: 12px; align-items: center; }
.note { border-left: 3px solid var(--line); padding: 4px 0 4px 12px; margin-bottom: 12px; overflow-wrap: anywhere; }
.note .meta { color: var(--muted); font-size: 12px; margin-bottom: 2px; }
.qr { display: flex; justify-content: center; margin: 12px 0; }
.qr svg { width: 200px; height: 200px; }
body.no-copy .grid, body.no-copy dl { user-select: none; -webkit-user-select: none; }
@media (max-width: 700px) {
  .who { margin-left: 0; }
  dl { grid-template-columns: 1fr; }
  dt { margin-top: 6px; }
  .grid { display: block; overflow-x: auto; }
}
.headactions { margin-left: auto; display: flex; gap: 8px; }
.actionsbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.actionsbar form, form.inline { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
.actionsbar input, form.inline input, form.inline select { width: auto; margin: 0; }
button.danger { border-color: var(--err-ink); color: var(--err-ink); }
.formgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)); gap: 4px 18px; }
.ff label { margin: 8px 0; }
.ff textarea, .noteform textarea, textarea { display: block; width: 100%; padding: 8px 10px; border: 1px solid #cfd6e0; border-radius: 6px; font: inherit; margin-top: 4px; }
.ff.bad input, .ff.bad select, .ff.bad textarea { border-color: var(--err-ink); }
.err { color: var(--err-ink); font-size: 13px; }
label.check { display: flex; gap: 8px; align-items: center; color: var(--ink); }
label.check input { width: auto; display: inline; margin: 0; }
.noteform { display: flex; gap: 8px; align-items: flex-end; margin-bottom: 12px; }
.noteform button { white-space: nowrap; }
.scrollx { overflow-x: auto; }
.rowbad { background: var(--err); }
.rowwarn { background: var(--warn); }
.result { min-width: 260px; }
.result input:not([type=checkbox]) { padding: 4px 6px; margin: 4px 0; }
.okline { color: var(--ok-ink); font-weight: 600; }
.warnline { color: #7a4d00; }
.small { font-size: 12px; }
pre.payload { white-space: pre-wrap; font-size: 12px; max-width: 520px; }
.cols-list { columns: 2; font-size: 13px; }
.stockline { display: flex; gap: 10px; align-items: center; margin-top: 12px; }
.notedel { display: inline; margin-left: 8px; }

button.primary:hover, .button.primary:hover { background: #26272b; border-color: #26272b; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--brand-red); outline-offset: 1px; }
.tabs a.on { background: var(--brand-black); border-color: var(--brand-black); }
.pill.draft, .pill.ready { background: #f0f0f2; color: #34363b; }
.login { text-align: center; }
.login form { text-align: left; }
.loginlogo { height: 28px; width: auto; margin: 6px auto 4px; display: block; }
.msg { background: #f0f0f2; }
.grid td a { color: var(--ink); font-weight: 500; }
.grid td a:hover { color: var(--brand-red-dark); }
.homesearch input { width: 340px; margin: 0; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 16px; margin-bottom: 16px; }
.kpi { display: block; color: var(--ink) !important; text-decoration: none !important; margin: 0; }
.kpi:hover { border-color: #c9cacf; }
.kpi-label { color: var(--muted); font-size: 13px; }
.kpi-row { display: flex; align-items: baseline; gap: 14px; margin: 4px 0 12px; }
.kpi-num { font-size: 40px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.kpi-delta { font-size: 13px; color: var(--muted); }
.kpi-delta.up { color: var(--ok-ink); } .kpi-delta.down { color: var(--brand-red-dark); }
.kpi-delta span { color: var(--muted); margin-left: 4px; }
.spark { display: flex; align-items: flex-end; gap: 6px; height: 60px; border-bottom: 1px solid var(--line); }
.bar-wrap { flex: 1; display: flex; align-items: flex-end; justify-content: center; height: 100%; position: relative; }
.bar { width: 100%; max-width: 28px; background: #c9cacf; border-radius: 4px 4px 0 0; }
.bar.now { background: var(--brand-red); }
.bar-wrap:hover .bar { background: #8e9097; } .bar-wrap:hover .bar.now { background: var(--brand-red-dark); }
.bar-wrap .tip { display: none; position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); white-space: nowrap;
  background: var(--brand-black); color: #fff; font-size: 12px; padding: 3px 7px; border-radius: 4px; margin-bottom: 4px; }
.bar-wrap:hover .tip { display: block; }
.spark-axis { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; margin-top: 4px; }
table.todo { width: 100%; border-collapse: collapse; }
table.todo td { padding: 7px 0; border-bottom: 1px solid var(--line); }
table.todo tr:last-child td { border-bottom: 0; }
.count { display: inline-block; min-width: 28px; text-align: center; padding: 1px 8px; border-radius: 99px; background: #f0f0f2; color: var(--muted); }
.count.has { background: var(--brand-black); color: #fff; }
@media (max-width: 700px) { .homesearch input { width: 100%; } }
table.todo a { color: var(--ink); } table.todo a:hover { color: var(--brand-red-dark); }
.calc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr)); gap: 16px; }
.calc { margin: 0; }
.calc .row3, .calc .row2 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.calc .row2 { grid-template-columns: repeat(2, 1fr); }
.calc label { margin: 6px 0; }
.calc .custom-ar { display: none; }
table.out { width: 100%; border-collapse: collapse; margin-top: 10px; }
table.out th { text-align: left; font-weight: 500; color: var(--muted); padding: 6px 10px 6px 0; width: 38%; border-top: 1px solid var(--line); }
table.out td { padding: 6px 0; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
@media (max-width: 700px) { .calc .row3 { grid-template-columns: 1fr 1fr; } }
.calc label { min-width: 0; }
.calc input, .calc select { display: block; width: 100%; min-width: 0; margin-top: 4px; padding: 8px 10px; border: 1px solid #cfd6e0; border-radius: 6px; background: #fff; font: inherit; color: var(--ink); }
.top { gap: 18px; }
.top nav a { padding: 6px 10px; }
.who { gap: 12px; }
h2.section { font-size: 15px; margin: 8px 0 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); gap: 16px; }
.stat { display: block; margin: 0; color: var(--ink) !important; text-decoration: none !important; }
a.stat:hover { border-color: #c9cacf; }
.stat .kpi-num { margin-top: 6px; }
.stats-note { margin: 8px 0 16px; }
table.brandbars { width: 100%; border-collapse: collapse; }
table.brandbars td { padding: 4px 0; }
table.brandbars .bname { width: 32%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 140px; padding-right: 10px; }
table.brandbars .bname a { color: var(--ink); }
table.brandbars .btrack { width: 55%; }
table.brandbars .btrack a { display: block; height: 14px; background: #f0f0f2; border-radius: 3px; }
table.brandbars .bfill { display: block; height: 100%; background: #8e9097; border-radius: 3px; }
table.brandbars tr:hover .bfill { background: var(--brand-red); }
table.brandbars .num { padding-left: 10px; font-variant-numeric: tabular-nums; }
.cols { align-items: start; }
table.todo td.num { white-space: nowrap; padding-left: 10px; }
.vgroup { padding-bottom: 12px; }
.vhead { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.vactions { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
input.vname { width: 340px; max-width: 100%; margin: 0; }
.pill.warnpill { background: var(--warn); color: #7a4d00; border: 1px solid var(--warn-line); }
.vgroup table { table-layout: fixed; }
.vgroup th:first-child { width: 36px; } .vgroup th:nth-child(2) { width: 100px; } .vgroup th:nth-child(3) { width: 38%; }
.ztask { border-top: 1px solid var(--line); padding: 12px 0; }
.ztask:first-of-type { border-top: 0; padding-top: 0; }
.zhead { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.ztimes { display: flex; gap: 18px; flex-wrap: wrap; color: var(--muted); margin-bottom: 8px; }
.ztimes b { color: var(--ink); font-weight: 600; }
.filehead { display: flex; justify-content: space-between; align-items: center; }
.filecols h3 { font-size: 14px; margin: 4px 0 8px; }
.uploadform { display: flex; gap: 8px; align-items: center; margin: 10px 0 6px; flex-wrap: wrap; }
.uploadform input[type=file] { width: auto; margin: 0; flex: 1; min-width: 200px; }
p.wrap { word-break: break-all; }
.pill.familypill { background: #eef0ff; color: #33338a; border: 1px solid #c9cdf5; text-decoration: none; }
a.pill.familypill:hover { background: #e1e4ff; text-decoration: none; }
.pill.small { font-size: 11px; padding: 0 6px; }
tr.thisrow td { background: #f6f7ff; font-weight: 600; }
.nowrap { white-space: nowrap; }
.famactions { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; justify-content: space-between; margin-top: 12px; }
.famactions form.inline { display: flex; gap: 8px; align-items: center; }
form.inline input.devpicker { width: 380px; max-width: 100%; }
.srcstrip { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 12px; }
.src { font-size: 12px; padding: 3px 10px; border-radius: 99px; background: #f0f0f2; color: var(--muted); }
.src a { color: inherit; }
.src.ok { background: var(--ok); color: var(--ok-ink); }
.src.bad { background: var(--err); color: var(--err-ink); }
.newsitem { display: flex; gap: 14px; margin-bottom: 10px; padding: 14px; }
.newsitem.lead { border-left: 3px solid var(--brand-red); }
.newsitem .thumb { width: 120px; height: 80px; object-fit: cover; border-radius: 6px; flex: none; background: #f0f0f2; }
.nbody { flex: 1; min-width: 0; }
.nmeta { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.ntitle { font-size: 15px; font-weight: 600; color: var(--ink) !important; }
.ntitle:hover { color: var(--brand-red-dark) !important; }
.nsum { margin: 4px 0 8px; color: #44464c; font-size: 13px; }
.nfoot { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.nfoot input.nname { width: 260px; margin: 0; padding: 4px 8px; }
@media (max-width: 700px) { .newsitem .thumb { display: none; } }

/* messages shown inside the block they belong to */
.msg.warning { background: #fff4d6; color: #6b4a00; }
.blockmsg { margin: 0 0 12px; }
[id] { scroll-margin-top: 16px; }
td .blockmsg { margin: 0 0 6px; font-size: 13px; padding: 6px 10px; }

/* file delete: Admin only, opened then confirmed by typing the SKU */
.filedel summary { cursor: pointer; color: var(--muted); list-style: none; }
.filedel summary::-webkit-details-marker { display: none; }
.filedel[open] summary { margin-bottom: 6px; }
.filedel form { display: flex; gap: 6px; justify-content: flex-end; }
.filedel input { width: 150px; margin: 0; }

/* ---- tidy pass, 29 Sep 2026 ---- */
/* header: one line; the signed-in user folds into a small menu */
.top { flex-wrap: nowrap; gap: 16px; }
.top nav { flex: 1 1 auto; flex-wrap: wrap; gap: 2px; min-width: 0; }
.top nav a { padding: 6px 9px; white-space: nowrap; }
details.who { margin-left: auto; position: relative; flex: 0 0 auto; }
details.who summary { list-style: none; cursor: pointer; padding: 6px 10px; border: 1px solid #3a3b40; border-radius: 6px; color: #d6d7da; white-space: nowrap; }
details.who summary::-webkit-details-marker { display: none; }
details.who summary::after { content: " \25BE"; color: #9a9ca3; }
details.who[open] summary { background: rgba(255,255,255,.08); }
details.who .menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 190px; background: #fff; color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.18); padding: 6px; }
details.who .menu .role { padding: 6px 10px; color: var(--muted); font-size: 12px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
details.who .menu a, details.who .menu button { display: block; width: 100%; text-align: left; padding: 7px 10px; border: 0; background: none;
  color: var(--ink) !important; border-radius: 6px; text-decoration: none; font-size: 14px; cursor: pointer; }
details.who .menu a:hover, details.who .menu button:hover { background: var(--bg); }
details.who .menu form { margin: 0; }
@media (max-width: 1100px) { .top { flex-wrap: wrap; } .top nav { order: 3; flex-basis: 100%; } }

/* add / edit form: titled sections, labels above inputs, every input full width */
.formsec h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin: 0 0 4px; }
.formsec .formgrid { grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr)); gap: 0 18px; }
.formsec .ff { min-width: 0; margin: 10px 0 0; }
.formsec .ff.wide { grid-column: span 2; }
.formsec .ff > label { margin: 0 0 4px; font-size: 13px; }
.formsec .ff input, .formsec .ff select, .formsec .ff textarea { margin-top: 0; }
.formsec .ff textarea { min-height: 40px; resize: vertical; }
.formsec .ff small { display: block; margin-top: 3px; font-size: 12px; }
.formsec .req { color: var(--brand-red); }
.dimrow { display: flex; gap: 8px; }
.dimrow input { flex: 1 1 0; min-width: 0; width: auto !important; margin: 0 !important; }
.checkrow { display: flex; flex-wrap: wrap; gap: 10px 28px; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.checkrow label.check { margin: 0; }
.formsave { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0; margin: 0; border-top: 1px solid var(--line); z-index: 5; }
@media (max-width: 640px) { .formsec .ff.wide { grid-column: auto; } }
/* inline forms never push the page sideways on a phone */
form.inline { flex-wrap: wrap; max-width: 100%; }
form.inline input.devpicker { flex: 1 1 220px; min-width: 0; }
.actionsbar form.inline input { min-width: 0; flex: 1 1 160px; }
main { overflow-x: hidden; }
@media (max-width: 700px) {
  .head h1 { font-size: 19px; }
  .homesearch, .homesearch input { width: 100%; }
  .noteform { flex-direction: column; align-items: stretch; }
}
/* device details: Catalogue on the left (two columns of fields on wide screens), Design and System on the right */
.detailgrid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; align-items: start; margin-bottom: 16px; }
.detailgrid .card { margin: 0 0 16px; }
.detailgrid .side-col .card:last-child, .detailgrid .main-col .card:last-child { margin-bottom: 0; }
.detailgrid dl { grid-template-columns: minmax(130px, 42%) 1fr; }
@media (min-width: 1150px) { .detailgrid .main-col dl { grid-template-columns: max-content minmax(0, 1fr) max-content minmax(0, 1fr); column-gap: 18px; } }
@media (max-width: 900px) { .detailgrid { grid-template-columns: 1fr; } }
@media (max-width: 700px) { .detailgrid dl { grid-template-columns: 1fr; } }

/* every box on the add / edit form is the same height and fixed in place (29 Sep 2026) */
.formsec .formgrid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.formsec .ff.full { grid-column: 1 / -1; }
.formsec .ff input, .formsec .ff select, .formsec .ff textarea { height: 40px; }
.formsec .ff textarea { resize: none; min-height: 0; line-height: 22px; padding: 8px 10px; overflow-y: auto; white-space: pre-wrap; }
@media (max-width: 1000px) { .formsec .formgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .formsec .formgrid { grid-template-columns: 1fr; } .formsec .ff.wide { grid-column: auto; } }
.checkitem { display: flex; flex-direction: column; gap: 2px; }
.checkitem small { font-size: 12px; }
.checkitem.locked label.check { color: var(--muted); cursor: not-allowed; }
.formsec input:disabled, .formsec select:disabled, .formsec textarea:disabled { background: #f3f4f6; color: #4b4f56; border-color: #e1e3e8; cursor: not-allowed; }
