:root {
  --bg: #ebe6dc;
  --paper: #fffdf8;
  --ink: #1c1915;
  --muted: #6f675d;
  --line: #e3d9cb;
  --green: #0f6e56;
  --green-dark: #0c5846;
  --copper: #a24e2c;
  --navy: #1c2824;
  --danger: #8d2d2d;
  --shadow: 0 1px 2px rgba(40, 30, 20, 0.05), 0 10px 28px rgba(40, 30, 20, 0.05);
  --radius: 14px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }
body { overflow-x: hidden; }
body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 Ubuntu, "Segoe UI", "Noto Sans", sans-serif;
}

a { color: var(--green-dark); }
a:hover { color: var(--copper); }
img { max-width: 100%; }

.skip {
  position: absolute;
  left: -999px;
  top: 8px;
  background: white;
  padding: 8px 12px;
  z-index: 5;
}
.skip:focus { left: 8px; }

.top {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: var(--navy);
  color: #f4f0e6;
  position: sticky;
  top: 0;
  z-index: 4;
}
.brand {
  color: #f4f0e6;
  text-decoration: none;
  font-weight: 700;
  letter-spacing: -0.03em;
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}
.brand:hover { color: white; }
.mark {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background:
    linear-gradient(#f4f0e6, #f4f0e6) 5px 5px / 8px 8px no-repeat,
    linear-gradient(#f4f0e6, #f4f0e6) 16px 5px / 7px 3px no-repeat,
    linear-gradient(#f4f0e6, #f4f0e6) 16px 10px / 3px 3px no-repeat,
    #c46a3a;
}
.top nav { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.top form { margin: 0; }
.top nav a, .linkish {
  color: #f4f0e6;
  text-decoration: none;
  padding: 8px 10px;
  border-radius: 8px;
}
.top nav a:hover { background: rgba(255, 255, 255, 0.08); color: white; }
.search { flex: 1; max-width: 420px; }
.search input {
  width: 100%;
  background: rgba(255, 255, 255, 0.08);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.search input::placeholder { color: rgba(244, 240, 230, 0.62); }

.wrap { width: min(1120px, calc(100% - 32px)); margin: 24px auto 48px; }
h1, h2, h3 { line-height: 1.2; letter-spacing: -0.03em; margin: 0 0 8px; }
h1 { font-size: 32px; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }
.lead, .muted { color: var(--muted); }
.lead { margin-top: 0; }

.panel, .room, .card, .passport, .sheet {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel, .card { padding: 16px; }
.stack { display: grid; gap: 16px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; }
.field input, .field select, .field textarea, .search input, .inline input, .inline select {
  font: inherit;
  font-weight: 500;
  color: var(--ink);
  background: white;
  border: 1px solid #d9d0c3;
  border-radius: 10px;
  padding: 10px 12px;
}
textarea { min-height: 84px; resize: vertical; }
.inline { display: flex; flex-wrap: wrap; gap: 8px; }
.inline input, .inline select { min-width: 0; }

.btn, button.btn {
  appearance: none;
  border: 0;
  background: var(--green);
  color: white;
  font: inherit;
  font-weight: 700;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn:hover { background: var(--green-dark); color: white; }
.btn.secondary, .btn.ghost, .btn.danger { background: transparent; }
.btn.secondary { color: var(--ink); border: 1px solid #d3c9ba; }
.btn.secondary:hover { background: #f3eee6; color: var(--ink); }
.btn.ghost { color: var(--muted); padding-inline: 8px; }
.btn.ghost:hover { color: var(--danger); background: transparent; }
.btn.danger { color: var(--danger); border: 1px solid #efd0d0; }
.btn.danger:hover { background: #fdf3f3; color: var(--danger); }
.linkish {
  background: transparent;
  border: 0;
  color: #f4f0e6;
  font: inherit;
  cursor: pointer;
}

.flash { padding: 12px 14px; border-radius: 10px; margin: 0 0 14px; }
.flash-ok { background: #e5f5ee; color: #0d513c; }
.flash-error { background: #fdecec; color: #7d2424; }
.hint { color: var(--muted); font-size: 14px; margin: 6px 0 0; }
.banner {
  background: #f8f1e4;
  border: 1px solid #eadcbf;
  padding: 12px 14px;
  border-radius: 10px;
}

.stats { display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 14px 0; list-style: none; }
.stats li {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  min-width: 120px;
  padding: 10px 12px;
}
.stats b { display: block; font-size: 22px; }
.stats span { color: var(--muted); font-size: 13px; }

.org-list, .result-list { display: grid; gap: 10px; }
.org-link, .result {
  display: block;
  padding: 16px;
  text-decoration: none;
  color: inherit;
}
.org-link:hover, .result:hover { border-color: #c9bba6; }
.org-link strong, .result strong { font-size: 18px; }
.meta { color: var(--muted); font-size: 14px; margin: 4px 0 0; }

.room { padding: 16px; }
.room-head, .arm-head, .section-head, .prow-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  flex-wrap: wrap;
}
.arm {
  margin-top: 12px;
  padding: 12px;
  background: #f7f3eb;
  border-radius: 12px;
}
.device {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.thumb, .photo-empty {
  width: 72px;
  height: 72px;
  border-radius: 10px;
  object-fit: cover;
  background: #e7e1d6;
}
.photo-empty {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}
.photo-empty.large, .passport .photo {
  width: 100%;
  height: auto;
  min-height: 180px;
  max-height: 360px;
  border-radius: 12px;
}
.passport .photo { object-fit: cover; }
.pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  background: #ece7dc;
}
.pill-printer { background: #d9e8f6; color: #18486e; }
.pill-mfp { background: #d7efe6; color: #0d5a45; }
.pill-monitor { background: #f6ead2; color: #6d4c12; }
.pill-desktop, .pill-laptop { background: #e4e2ef; color: #35315c; }
.pill-ups { background: #f6e0d6; color: #7a3918; }
.pill-scanner { background: #e3eef0; color: #1d4e57; }

.passport {
  display: grid;
  grid-template-columns: minmax(0, 280px) minmax(0, 1fr) 220px;
  gap: 22px;
  padding: 18px;
  align-items: start;
}
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px 16px; margin: 16px 0; }
.facts div { margin: 0; }
.facts dt { color: var(--muted); font-size: 13px; }
.facts dd { margin: 2px 0 0; font-weight: 700; }
.sheet { padding: 14px; text-align: center; }
.sheet img { width: 180px; height: 180px; }
.site-qr {
  display: flex;
  align-items: center;
  gap: 16px;
  width: fit-content;
  max-width: 100%;
  margin: 0 0 16px;
  text-align: left;
}
.site-qr img { width: 132px; height: 132px; }
.sheet p { margin: 6px 0; }
.sheet .btn { margin-top: 8px; }
.sheets { display: flex; flex-wrap: wrap; gap: 12px; }
.timeline { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.timeline li { padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.person { padding: 10px 0; border-top: 1px solid var(--line); }
.steps { margin: 0 0 12px; padding-left: 18px; color: var(--muted); }
.type-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.prow { margin-top: 12px; }
.login-card { width: min(440px, 100%); margin: 8vh auto; padding: 28px; }
.scan-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.reader { max-width: 480px; border-radius: 12px; overflow: hidden; background: #111; }
.reader[hidden] { display: none; }
.reader video { width: 100%; }
.empty { padding: 8px 0 16px; }

@media (max-width: 860px) {
  .layout, .passport, .split { grid-template-columns: 1fr; }
  .facts { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .top { display: block; padding: 10px 12px; }
  .top nav { display: flex; width: auto; margin: 6px 0 0; justify-content: flex-start; }
  .top nav a, .linkish { padding: 6px 8px; }
  .search { max-width: none; margin-top: 8px; }
  h1 { font-size: 26px; }
  .wrap { width: min(1120px, calc(100% - 20px)); }
}

@media print {
  body { background: white; }
  .top, .no-print, .flash { display: none !important; }
  .wrap { width: auto; margin: 0; }
  .sheet, .passport { box-shadow: none; break-inside: avoid; page-break-inside: avoid; }
  .sheets { display: block; }
  .sheet { border: 1px dashed #bbb; margin: 0 0 12px; }
}
