/* ram-web — dense, fast, dark by default (like the station HMI). */
:root {
  --bg: #0f1410; --panel: #161d17; --panel-2: #1c251d; --line: #2a352b;
  --text: #e3e8e3; --muted: #8d998e; --brand: #61b93c; --brand-ink: #0d120c;
  --warn: #f2b33d; --bad: #e5534b; --ok: #57ab5a; --link: #8fd16e;
  --row-hover: #1f2a20; --review: rgba(229, 83, 75, .10);
  --mono: ui-monospace, "JetBrains Mono", "SFMono-Regular", Menlo, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f7f5; --panel: #ffffff; --panel-2: #f0f3f0; --line: #dde3dd;
    --text: #1b221c; --muted: #5f6b60; --link: #2f7d18; --row-hover: #eef4ec;
    --review: rgba(229, 83, 75, .08); color-scheme: light;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.45 var(--sans); }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* top bar */
.top { display: flex; align-items: center; gap: 24px; padding: 10px 20px;
  background: var(--panel); border-bottom: 2px solid var(--brand);
  position: sticky; top: 0; z-index: 10; }
.brand { font-weight: 700; color: var(--text); letter-spacing: .02em;
  display: inline-flex; align-items: center; gap: 8px; }
.brand img { display: block; }
.brand b { color: var(--brand); }
.top nav { display: flex; gap: 4px; }
.top nav a { padding: 6px 12px; border-radius: 6px; color: var(--muted); }
.top nav a.on, .top nav a:hover { background: var(--panel-2); color: var(--text);
  text-decoration: none; }
.who { margin-left: auto; color: var(--muted); font-size: 13px; }
main { padding: 16px 20px 40px; max-width: 1800px; margin: 0 auto; }
h1 { font-size: 20px; margin: 0 0 12px; }
h2 { font-size: 15px; margin: 22px 0 8px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em; }

/* filters */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: end;
  padding: 12px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; margin-bottom: 12px; }
.filters label { display: flex; flex-direction: column; gap: 3px;
  font-size: 11px; color: var(--muted); text-transform: uppercase;
  letter-spacing: .05em; }
input, select, button, .btn { font: inherit; color: var(--text);
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px;
  padding: 6px 9px; }
input[type=search] { min-width: 260px; }
button, .btn { cursor: pointer; display: inline-block; }
.btn.primary, button.primary { background: var(--brand); color: var(--brand-ink);
  border-color: var(--brand); font-weight: 600; }
.btn:hover { text-decoration: none; filter: brightness(1.1); }
.spacer { flex: 1; }
.htmx-request .busy, .busy.htmx-request { opacity: 1; }
.busy { opacity: 0; transition: opacity .2s; color: var(--muted); }

/* summary tiles */
.tiles { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 16px; min-width: 130px; }
.tile .k { font-size: 11px; color: var(--muted); text-transform: uppercase;
  letter-spacing: .05em; }
.tile .v { font: 600 22px var(--mono); }

/* tables */
.tablewrap { overflow-x: auto; background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 6px 10px; border-bottom: 1px solid var(--line);
  text-align: left; vertical-align: middle; white-space: nowrap; }
th { position: sticky; top: 0; background: var(--panel-2); font-size: 11px;
  color: var(--muted); text-transform: uppercase; letter-spacing: .05em;
  z-index: 1; }
tbody tr:hover { background: var(--row-hover); }
tr.review { background: var(--review); }
td.num, th.num { text-align: right; font-family: var(--mono); }
td.wrap { white-space: normal; min-width: 220px; max-width: 420px; }
tr.click { cursor: pointer; }
/* the box has a module's shape (~4:1), so the strip fills it — no
   black bars above and below; a SO-DIMM just sits narrower */
.thumb { width: 152px; height: 38px; object-fit: contain; display: block;
  border-radius: 3px; }
.badge { display: inline-block; padding: 1px 7px; border-radius: 10px;
  font-size: 11px; font-weight: 600; }
.badge.bad { background: rgba(229, 83, 75, .18); color: var(--bad); }
.badge.ok { background: rgba(87, 171, 90, .18); color: var(--ok); }
.badge.warn { background: rgba(242, 179, 61, .18); color: var(--warn); }
.pager { display: flex; gap: 8px; align-items: center; padding: 10px 2px; }

/* tables that scroll in their own box: the header row stays put */
.tablewrap.scroll { max-height: calc(100vh - 250px); min-height: 240px;
  overflow: auto; }

/* side panel */
.drawer { position: fixed; top: 0; right: 0; height: 100vh;
  width: min(1500px, 96vw); max-width: 100vw; background: var(--bg);
  border-left: 2px solid var(--brand); box-shadow: -10px 0 30px rgba(0,0,0,.35);
  transform: translateX(105%); transition: transform .18s ease-out;
  z-index: 50; display: flex; flex-direction: column; }
.drawer.open { transform: none; }
/* drag the left edge to resize (app.js; double-click: default width) */
.drawer-grip { position: absolute; left: -6px; top: 0; bottom: 0; width: 12px;
  cursor: ew-resize; z-index: 2; }
.drawer-grip:hover, .drawer.resizing .drawer-grip {
  background: linear-gradient(90deg, transparent 4px, var(--brand) 4px, var(--brand) 8px, transparent 8px); }
.drawer.resizing { transition: none; user-select: none; }
.drawer-bar { display: flex; gap: 8px; align-items: center; padding: 8px 12px;
  background: var(--panel); border-bottom: 1px solid var(--line); }
.drawer-bar button { min-width: 34px; }
#drawer-body { overflow: auto; padding: 12px 16px 40px; flex: 1; }
#drawer-body .pics { grid-template-columns: 1fr 1fr; }
#drawer-body h1 { font-size: 17px; }
tr.current { outline: 2px solid var(--brand); outline-offset: -2px; }

/* messages + actions */
.flash { background: rgba(87, 171, 90, .15); border: 1px solid var(--ok);
  color: var(--text); padding: 8px 12px; border-radius: 8px; margin-bottom: 12px; }
.flash.bad { background: rgba(229, 83, 75, .12); border-color: var(--bad); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  padding: 10px 12px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; margin: 0 0 12px; }
.actions form { display: flex; gap: 6px; align-items: center; margin: 0; }
.btn.danger, button.danger { border-color: var(--bad); color: var(--bad);
  background: transparent; }
.btn.ok, button.ok { border-color: var(--ok); color: var(--ok); background: transparent; }
td.sel, th.sel { width: 28px; text-align: center; }
.group { margin-bottom: 14px; }
.group h3 { font: 600 14px var(--mono); margin: 0 0 6px; }

/* module page */
.headline { display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 12px; }
.headline .nav { margin-left: auto; display: flex; gap: 6px; }
.pics { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 12px; }
.pic { background: #000; border: 1px solid var(--line); border-radius: 8px;
  overflow: hidden; }
.pic img { width: 100%; height: auto; display: block; }
.pic .cap { background: var(--panel); padding: 5px 10px; font-size: 12px;
  color: var(--muted); display: flex; justify-content: space-between;
  align-items: center; gap: 8px; }
/* zoom / pan / turn (app.js) */
.zoom { position: relative; overflow: hidden; cursor: zoom-in;
  touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.zoom.zoomed { cursor: grab; touch-action: none; }
.zoom.dragging { cursor: grabbing; }
.zoom img { transform-origin: 50% 50%; -webkit-user-drag: none;
  will-change: transform; }
.zoom.anim img { transition: transform .12s ease-out; }
.ztools { display: flex; gap: 4px; align-items: center; }
.ztools button { padding: 0 7px; font-size: 13px; line-height: 20px;
  min-width: 26px; }
.ztools a { margin-left: 6px; }
.pics-wide .pics, .pics-wide #drawer-body .pics { grid-template-columns: 1fr; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 12px; }
.kv { width: 100%; }
.kv th { position: static; width: 38%; background: transparent;
  font-size: 12px; padding: 8px 12px; }
.kv td { white-space: normal; font-family: var(--mono); font-size: 15px;
  padding: 8px 12px; }
.notes li { margin: 2px 0; }

/* purchases */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 12px 14px; }
.panel h3 { margin-bottom: 8px; }
.panel textarea { width: 100%; box-sizing: border-box; margin: 8px 0; font: 13px var(--mono);
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 6px; padding: 6px 8px; }
.panel form.row, form.row { display: flex; gap: 8px; align-items: center;
  justify-content: space-between; margin: 0 0 6px; }
details.group > summary { cursor: pointer; margin-bottom: 6px; }
.signoff input[name=note] { min-width: 14em; }
.signoff button, form.row button, .panel button { white-space: nowrap; }

/* auto review / edit form */
.review-box { margin: 10px 0 14px; }
.review-box table th { position: static; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
  gap: 8px 10px; margin-top: 8px; }
.fields label { display: flex; flex-direction: column; gap: 3px; font-size: 11px;
  color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.fields input, .fields select { text-transform: none; letter-spacing: 0; }
.fields label.proposed input, .fields label.proposed select {
  border-color: var(--warn); box-shadow: 0 0 0 1px var(--warn) inset; }
details.edit > summary { cursor: pointer; }
.edit-record { margin: 12px 0 0; }

/* failed requests (app.js) */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 200%);
  max-width: min(640px, calc(100vw - 32px)); background: var(--panel);
  border: 1px solid var(--bad); border-left-width: 4px; border-radius: 8px;
  padding: 10px 14px; box-shadow: 0 8px 30px rgba(0,0,0,.35); z-index: 100;
  transition: transform .2s ease-out; cursor: pointer; }
.toast.on { transform: translate(-50%, 0); }

/* duplicates: the modules one under the other, big */
.dup { margin: 0 0 26px; }
.dup-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: baseline;
  margin: 0 0 8px; }
.dup-serial { font-size: 20px; letter-spacing: .02em; }
.dup-card { background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 12px 12px; margin: 0 0 10px; }
.dup-card.review { border-left: 4px solid var(--bad); }
.dup-info { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center;
  margin: 0 0 8px; }
.dup-id { font-size: 17px; font-weight: 700; }
.dup .pics { grid-template-columns: 1fr 1fr; }
.dup-new { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center;
  margin: 0 0 8px; }
.dup-diff { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center;
  margin: 0 0 10px; padding: 10px 12px; background: var(--panel-2);
  border: 1px dashed var(--line); border-radius: 8px; }
/* …the station operator's NOT A DUPLICATE pairs: the two side by side,
   each with its front and back stacked; one column at phone width */
.dup-filter { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 0 0 16px; }
.dup-filter a.on { font-weight: 700; text-decoration: underline; }
.dup.op { border-left: 4px solid var(--warn); padding-left: 10px; }
.dup-op { font-size: 14px; margin: 0 0 8px; }
.dup .warn { color: var(--warn); }
.dup.op .dup-mods { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dup.op .dup-mods .pics { grid-template-columns: 1fr; }
@media (max-width: 900px) { .dup.op .dup-mods { grid-template-columns: 1fr; } }

/* sortable tables (app.js) */
table.sortable thead th { cursor: pointer; user-select: none; }
table.sortable thead th:hover { color: var(--text); }
table.sortable thead th.asc::after { content: " ▲"; font-size: 9px; }
table.sortable thead th.desc::after { content: " ▼"; font-size: 9px; }

/* decoder check */
a.mid { font-family: var(--mono); white-space: nowrap; }
details.more { display: inline; }
details.more > summary { display: inline; cursor: pointer; color: var(--muted); }
details.more[open] > summary { display: none; }

/* login / error */
.center { max-width: 420px; margin: 12vh auto; background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px; padding: 28px; text-align: center; }
.center h1 { margin-bottom: 6px; }
#gbtn { display: flex; justify-content: center; margin: 22px 0 8px; }
.err { color: var(--bad); min-height: 1.4em; }

@media (max-width: 700px) {
  main { padding: 12px 16px 30px; }
  .top { flex-wrap: wrap; gap: 10px; padding: 10px 16px; }
  .top nav { max-width: 100%; overflow-x: auto; }
  .top nav a { white-space: nowrap; }
  input[type=search] { min-width: 0; width: 100%; }
  .pics { grid-template-columns: 1fr; }
  .pager { flex-wrap: wrap; }
  details.pdfx { display: block; width: 100%; }
  .pdfx-form { position: static; width: auto; margin-top: 6px; }
}

/* stock PDF options: a drop-down form in the export bar */
details.pdfx { position: relative; display: inline-block; }
details.pdfx > summary { list-style: none; }
details.pdfx > summary::-webkit-details-marker { display: none; }
.pdfx-form { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20;
  width: 360px; display: flex; flex-direction: column; gap: 6px;
  padding: 12px 14px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); }
.pdfx-form label { display: flex; gap: 6px; align-items: center; }
.pdfx-form label.indent { padding-left: 22px; }
.pdfx-form input[name=title], .pdfx-form input[name=name] { flex: 1; }
.pdfx-form b { margin-top: 4px; font-size: 12px; text-transform: uppercase;
  letter-spacing: .06em; color: var(--muted); }
.tile .v.small { font-size: 14px; font-weight: 500; }

/* Mark sold (stock_sell.html), the Sales page (sales.html) */
.sell-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin: 0 0 12px; }
.sell-form label { display: flex; flex-direction: column; gap: 3px; font-size: 11px;
  color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.sell-form input { text-transform: none; letter-spacing: 0; }
tr:target { outline: 2px solid var(--brand); outline-offset: -2px; }
/* the Sales page's reference, filters and note wrap narrower than
   td.wrap's 220px, and Export / Undo stay side by side: the table fits a
   laptop screen */
td.wrap.sale-text { min-width: 140px; max-width: 320px; }
/* the preview's sell ticket box: a line of its own under the fields */
.sell-hint, .sell-ticket { flex-basis: 100%; }
.sell-ticket { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.sell-ticket .kv { width: auto; min-width: min(420px, 100%); max-width: 720px; }
.sell-ticket label.check { flex-direction: row; align-items: center; gap: 6px;
  text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--text); }
.actions.sale-actions { flex-wrap: nowrap; }
tfoot th { position: static; }
/* the sale-reference filter belongs to the sold view only */
.filters:not(:has(select[name=show] option[value=sold]:checked)) .only-sold { display: none; }
