/* Armory - shared dark / OLED theme. Tile and halo sizes come from config.php. */
:root {
  --bg: #000;
  --panel: #0b0c0e;
  --panel2: #131519;
  --line: #24272d;
  --text: #e7e9ec;
  --dim: #8d939d;
  --accent: #7fb2ff;
  --warn: #f2b84b;
  --err: #ff6b6b;
  --ok: #58c98b;
  --tile: 96px;
  --tile-lg: 320px;
  --halo-size: 1;
  --halo-opacity: .75;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 14px/1.4 system-ui, "Segoe UI", Roboto, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
button {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 6px;
  padding: 5px 11px; cursor: pointer;
}
button:hover { border-color: #3a3f48; }
button.primary, button.on { background: #17304f; border-color: #2b5a94; }
button.danger:hover { border-color: var(--err); color: var(--err); }
button:disabled { opacity: .4; cursor: default; }
input, select, textarea {
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; min-width: 0;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- header ---------- */
.top {
  display: flex; align-items: center; gap: 16px; padding: 12px 16px;
  border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg); z-index: 5;
}
.top h1 { font-size: 18px; margin: 0; flex: 1; font-weight: 600; }
.units { display: inline-flex; }
.units button { border-radius: 0; }
.units button:first-child { border-radius: 6px 0 0 6px; }
.units button:last-child { border-radius: 0 6px 6px 0; border-left: 0; }

/* ---------- tiles ---------- */
.tile {
  position: relative; width: var(--tile); height: var(--tile); flex: none;
  display: grid; place-items: center; overflow: hidden; border-radius: 6px;
}
.tile.big { width: var(--tile-lg); height: var(--tile-lg); max-width: 100%; }
.tile.photo::before {
  content: ""; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: calc(100% * var(--halo-size)); height: calc(100% * var(--halo-size)); border-radius: 50%;
  background: radial-gradient(closest-side,
    rgba(255, 255, 255, var(--halo-opacity)) 0%,
    rgba(255, 255, 255, calc(var(--halo-opacity) * .6)) 40%,
    rgba(255, 255, 255, calc(var(--halo-opacity) * .18)) 75%,
    transparent 100%);
  pointer-events: none;
}
.tile.photo img { position: relative; max-width: 90%; max-height: 90%; object-fit: contain; display: block; }
.tile canvas { width: 100%; height: 100%; display: block; cursor: grab; }
.tile canvas:active { cursor: grabbing; }
.nophoto { position: relative; color: var(--dim); font-size: 11px; }

/* ---------- technical drawing ---------- */
svg.drawing { width: 100%; height: 100%; display: block; }
svg.drawing path { fill: none; vector-effect: non-scaling-stroke; }
svg.drawing .shape { stroke: var(--text); stroke-width: 1.3; fill: rgba(255, 255, 255, .05); stroke-linejoin: round; }
svg.drawing .hole { stroke: var(--dim); stroke-width: 1; stroke-dasharray: 5 3; }
svg.drawing .axis { stroke: var(--accent); stroke-width: .8; stroke-dasharray: 9 3 2 3; opacity: .7; }
svg.drawing .dim { stroke: var(--dim); stroke-width: .7; }
svg.drawing .dim.mk { stroke: var(--accent); }
svg.drawing .dimtxt { fill: var(--text); font-family: inherit; }
svg.drawing .dimtxt.mk { fill: var(--accent); }

/* ---------- filters ---------- */
.filters { padding: 10px 16px; border-bottom: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: end; }
.filters .f { display: grid; gap: 3px; font-size: 12px; color: var(--dim); }
.filters .f > div { display: flex; gap: 4px; align-items: center; }
.filters input { width: 74px; }
.filters input.txt { width: 170px; }
.filters .count { margin-left: auto; color: var(--dim); align-self: center; }

.similar-bar {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 10px 16px;
  background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 53px; z-index: 4;
}
.similar-bar .lead { margin-right: 6px; }
.similar-bar .grow { flex: 1; }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; }
table.parts { border-collapse: collapse; width: 100%; }
table.parts th, table.parts td { padding: 6px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.parts th { font-weight: 600; font-size: 12px; color: var(--dim); white-space: nowrap; user-select: none; background: var(--bg); }
table.parts th.sortable { cursor: pointer; }
table.parts th.sortable:hover { color: var(--text); }
table.parts th[aria-sort] { color: var(--accent); }
table.parts th button { all: unset; cursor: pointer; }
table.parts td.num, table.parts th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.parts td.media { width: 1%; }
.media-row { display: flex; gap: 6px; }
table.parts tbody tr.row { cursor: pointer; }
table.parts tbody tr.row:hover { background: var(--panel); }
table.parts tbody tr.row.selected { background: var(--panel2); }
table.parts tbody tr.row.selected td { border-bottom-color: transparent; }
table.parts td.id { font-weight: 600; white-space: nowrap; }
table.parts td.desc { color: var(--dim); min-width: 160px; max-width: 320px; }
tr.detail td { background: var(--panel2); padding: 4px 10px 18px; }
.detail-media { display: flex; flex-wrap: wrap; gap: 14px; }
.detail-media figure { margin: 0; }
.detail-media figcaption { font-size: 11px; color: var(--dim); text-align: center; padding-top: 4px; }
.detail-text { margin: 12px 0 0; max-width: 80ch; white-space: pre-wrap; }
.empty-msg { padding: 40px 16px; color: var(--dim); text-align: center; }

@media (max-width: 700px) {
  :root { --tile-lg: min(320px, calc(100vw - 40px)); }
  .similar-bar { position: static; }
}
