:root {
  --bg: #f5f6f8;
  --card: #fff;
  --text: #1d2430;
  --muted: #6b7380;
  --line: #dde1e7;
  --accent: #2557a7;
  --accent-text: #fff;
  --warn-bg: #fff6db;
  --warn-line: #e8c95b;
  --ok-bg: #e5f5ea;
  --err-bg: #fde8e8;
  --danger: #b42318;
  --radius: 8px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 1rem 0 .5rem; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; white-space: nowrap; }
.num { text-align: right; white-space: nowrap; }
.sub { display: block; color: var(--muted); font-size: .8em; }
.meta { color: var(--muted); margin: 0 0 .75rem; }
.empty { color: var(--muted); font-style: italic; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Top bar */
.topbar {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .6rem 1.25rem; background: #1d2430; color: #fff;
}
.topbar a, .topbar .link { color: #fff; }
.brand { font-weight: 700; letter-spacing: .02em; }
.crumbs { display: flex; gap: .4rem; align-items: center; flex: 1; min-width: 0; }
.crumbs span { opacity: .6; }
.topbar-right { display: flex; gap: 1rem; align-items: center; }
.user { opacity: .8; }
.lang-form select { background: transparent; color: #fff; border: 1px solid #ffffff55; border-radius: 4px; padding: .15rem .3rem; }
.lang-form option { color: var(--text); }

main { padding: 1.25rem; max-width: 1400px; margin: 0 auto; }

/* Buttons and forms */
button, .button {
  display: inline-block; font: inherit; padding: .4rem .8rem; border-radius: 6px;
  border: 1px solid var(--line); background: var(--card); color: var(--text); cursor: pointer;
}
.button:hover { text-decoration: none; background: #eef1f5; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.link { background: none; border: none; padding: 0; color: var(--accent); }
button.link.danger { color: var(--danger); }
form.inline { display: inline; }
input[type=text], input[type=search], input[type=number], input[type=password], select, textarea {
  font: inherit; padding: .4rem .5rem; border: 1px solid var(--line); border-radius: 6px;
  background: #fff; width: 100%;
}
.stacked { display: flex; flex-direction: column; gap: .35rem; }
.stacked label { font-weight: 600; margin-top: .5rem; }
.stacked button { align-self: flex-start; margin-top: .75rem; }
.help { color: var(--muted); }
.errorlist { color: var(--danger); margin: 0; padding-left: 1rem; }
.error { color: var(--danger); }

/* Page layout */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.actions, .pager { display: flex; gap: .5rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.25rem; margin-bottom: 1rem; }
.card.narrow { max-width: 380px; margin: 3rem auto; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; }

.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.messages li { padding: .6rem .9rem; border-radius: 6px; margin-bottom: .4rem; background: var(--ok-bg); }
.messages .msg-warning { background: var(--warn-bg); }
.messages .msg-error { background: var(--err-bg); }
.warning { background: var(--warn-bg); border: 1px solid var(--warn-line); padding: .5rem .8rem; border-radius: 6px; }

/* Filters */
.filters { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; margin-bottom: .75rem; }
.filters > div { display: flex; flex-direction: column; gap: .2rem; min-width: 160px; }
.filters label { font-size: .85em; color: var(--muted); }
.filters .filter-buttons { flex-direction: row; align-items: center; gap: .75rem; min-width: 0; }
.print-bar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 1rem; color: var(--muted); }

/* Tables */
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { padding: .45rem .7rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.list th.num, table.list td.num { text-align: right; }
table.list thead th { background: #f0f2f5; font-size: .85em; color: var(--muted); position: sticky; top: 0; }
table.list tbody tr:hover { background: #f7f9fc; }
tr.missing td { color: var(--muted); text-decoration: line-through; }
tr.non-light td { color: var(--muted); }

/* Fixture detail */
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
ul.plain { list-style: none; padding: 0; margin: 0; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.photo-grid figure { margin: 0; }
.photo-grid img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }
.photo-grid figcaption { font-size: .9em; margin-top: .25rem; }
.upload { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; border-top: 1px solid var(--line); padding-top: 1rem; }
.upload > div { display: flex; flex-direction: column; gap: .2rem; min-width: 220px; flex: 1; }
.upload label { font-weight: 600; }

@media (max-width: 640px) {
  main { padding: .75rem; }
  .topbar { padding: .5rem .75rem; }
  .crumbs { order: 3; flex-basis: 100%; }
  .filters > div { min-width: 45%; flex: 1; }
}

/* Forms in cards */
.form-card { max-width: 640px; }
.field { display: flex; flex-direction: column; gap: .25rem; margin-top: .5rem; }
.field > label { font-weight: 600; }
.field.checkbox > label { font-weight: normal; display: flex; gap: .5rem; align-items: center; }
.field.checkbox input { width: auto; }
.help ul { margin: .25rem 0; padding-left: 1.2rem; }
.roles-help { margin-top: 1rem; }


/* Compact tables and the fixture picker on the truss page */
table.list.compact th, table.list.compact td { padding: .3rem .5rem; }
table.list.compact input[type=text] { width: 5.5rem; padding: .25rem .4rem; }
.add-fixtures { margin-top: 1rem; border-top: 1px solid var(--line); padding-top: .75rem; }
.add-fixtures summary { cursor: pointer; font-weight: 600; margin-bottom: .5rem; }
.pick-tools { display: flex; gap: .75rem; align-items: center; margin-bottom: .5rem; }
.pick-tools input[type=search] { max-width: 18rem; }
.pick-list { max-height: 26rem; overflow-y: auto; border: 1px solid var(--line); border-radius: 6px; }
table.pick { margin: 0; }
table.pick thead th { position: sticky; top: 0; z-index: 1; }
table.pick th.check, table.pick td.check { width: 2rem; text-align: center; }
table.pick input[type=checkbox] { width: 1.1rem; height: 1.1rem; cursor: pointer; }
table.pick td label { display: block; cursor: pointer; }
table.pick tbody tr { cursor: pointer; }
table.pick tbody tr:nth-child(even) { background: #fafbfc; }
table.pick tbody tr:hover { background: #eef3fb; }
table.pick tbody tr.selected { background: #dde8f8; }

[hidden] { display: none !important; }
