:root {
  color-scheme: light;
  --ink: #17201a;
  --muted: #627065;
  --canvas: #f6f5ef;
  --panel: #ffffff;
  --line: #d9ddd2;
  --forest: #1f5a40;
  --forest-strong: #164530;
  --moss: #8aa36f;
  --clay: #c56f42;
  --gold: #d6a842;
  --sky: #5f8ead;
  --danger: #b9473d;
  --warning: #9b6a18;
  --shadow: 0 18px 45px rgba(27, 38, 30, 0.11);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--canvas);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(95, 142, 173, 0.35);
  outline-offset: 2px;
}

.app-shell {
  width: min(1180px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 20px 0 36px;
}

.topbar {
  padding: 12px 0 18px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 5vw, 4.5rem);
  line-height: 0.95;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1.3rem;
  line-height: 1.15;
}

h3 {
  margin-bottom: 4px;
  font-size: 1.02rem;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(92px, 1fr));
  gap: 8px;
  min-width: min(100%, 620px);
}

.status-strip span {
  min-height: 62px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.74);
  color: var(--muted);
  font-size: 0.82rem;
}

.status-strip strong {
  display: block;
  color: var(--ink);
  font-size: 1.6rem;
  line-height: 1;
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(246, 245, 239, 0.92);
  backdrop-filter: blur(14px);
}

.tab {
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.tab.active {
  background: var(--forest);
  color: #fff;
}

main {
  padding-top: 18px;
}

.home-panel {
  display: grid;
  grid-template-columns: minmax(280px, 0.85fr) minmax(360px, 1.15fr);
  gap: 16px;
  align-items: stretch;
  margin-bottom: 16px;
}

.welcome-copy {
  display: grid;
  align-content: start;
  gap: 12px;
  min-height: 232px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.welcome-copy h2 {
  font-size: clamp(1.65rem, 4vw, 3rem);
}

.welcome-copy p {
  max-width: 48rem;
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.4;
}

.current-user-card {
  display: grid;
  gap: 10px;
  align-self: end;
  margin-top: auto;
  padding-top: 4px;
}

.current-user-card .user-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}

.current-user-card strong,
.current-user-card span {
  display: block;
}

.current-user-card span {
  color: var(--muted);
  font-size: 0.88rem;
}

.current-user-card .button-row {
  margin-top: 0;
}

.workflow-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.workflow-card {
  display: grid;
  align-content: space-between;
  gap: 12px;
  min-height: 232px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  text-align: left;
  box-shadow: var(--shadow);
}

.workflow-card:hover {
  border-color: rgba(31, 90, 64, 0.42);
  transform: translateY(-1px);
}

.workflow-card strong {
  display: block;
  font-size: 1.2rem;
  line-height: 1.12;
}

.workflow-card span {
  display: block;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.35;
}

.workflow-card.borrow {
  border-top: 5px solid var(--forest);
}

.workflow-card.return {
  border-top: 5px solid var(--sky);
}

.workflow-card.inspect {
  border-top: 5px solid var(--gold);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.scan-layout,
.work-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(340px, 1.25fr);
  gap: 16px;
  align-items: start;
}

.tool-panel,
.detail-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.tool-panel {
  padding: 16px;
}

.wide-panel {
  grid-column: 1 / -1;
}

.detail-panel {
  min-height: 510px;
  overflow: hidden;
}

.panel-heading {
  display: flex;
  gap: 12px;
  align-items: start;
  justify-content: space-between;
  margin-bottom: 14px;
}

.inventory-heading {
  align-items: end;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.pill.neutral {
  background: #edf0e7;
  color: #465149;
}

.pill.available {
  background: #e6f1e8;
  color: #23623d;
}

.pill.reserved {
  background: #fff2cf;
  color: #82590e;
}

.pill.checked-out {
  background: #e7f0f6;
  color: #315f7b;
}

.pill.maintenance,
.pill.broken {
  background: #f9e2dd;
  color: #94362f;
}

.scanner-frame {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(31, 90, 64, 0.92), rgba(17, 31, 29, 0.94)),
    radial-gradient(circle at 30% 25%, rgba(214, 168, 66, 0.28), transparent 35%);
}

#cameraFeed {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scanner-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.9);
  font-size: 3.5rem;
  font-weight: 900;
}

.scan-reticle {
  position: absolute;
  width: min(66%, 280px);
  aspect-ratio: 1;
  border: 3px solid rgba(255, 255, 255, 0.86);
  border-radius: 8px;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.18);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.button-row.end {
  justify-content: flex-end;
}

.camera-hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.35;
}

.camera-hint.warning {
  padding: 9px 10px;
  border-radius: 7px;
  background: #fff2cf;
  color: #72500f;
}

.primary-action {
  background: var(--forest);
  color: #fff;
  font-weight: 850;
  padding: 0 14px;
}

.primary-action:hover {
  background: var(--forest-strong);
}

.secondary-action {
  border: 1px solid var(--line);
  background: #f7f8f3;
  color: var(--ink);
  font-weight: 750;
  padding: 0 13px;
}

.danger-action {
  background: var(--danger);
  color: #fff;
  font-weight: 850;
  padding: 0 14px;
}

.inline-form,
.stack-form {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

label {
  display: grid;
  gap: 6px;
  color: #344039;
  font-size: 0.85rem;
  font-weight: 800;
}

.form-block {
  display: grid;
  gap: 6px;
}

.field-label {
  color: #344039;
  font-size: 0.85rem;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cfd5c8;
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
}

input,
select {
  min-height: 42px;
  padding: 0 11px;
}

textarea {
  resize: vertical;
  padding: 10px 11px;
}

.input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.input-row button {
  padding: 0 14px;
  background: var(--sky);
  color: #fff;
  font-weight: 850;
}

.choice-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.choice-button {
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: #f7f8f3;
  color: #344039;
  font-size: 0.84rem;
  font-weight: 800;
}

.choice-button.selected {
  border-color: var(--forest);
  background: var(--forest);
  color: #fff;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.empty-state {
  display: grid;
  min-height: 510px;
  place-items: center;
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.item-hero {
  padding: 20px;
  color: #fff;
  background:
    linear-gradient(135deg, rgba(23, 32, 26, 0.72), rgba(23, 32, 26, 0.22)),
    linear-gradient(145deg, #2f7354, #b07742);
}

.item-hero.maintenance,
.item-hero.broken {
  background:
    linear-gradient(135deg, rgba(23, 32, 26, 0.68), rgba(23, 32, 26, 0.22)),
    linear-gradient(145deg, #8d3f38, #d6a842);
}

.item-hero.reserved {
  background:
    linear-gradient(135deg, rgba(23, 32, 26, 0.7), rgba(23, 32, 26, 0.2)),
    linear-gradient(145deg, #9b6a18, #5f8ead);
}

.item-hero.checked-out {
  background:
    linear-gradient(135deg, rgba(23, 32, 26, 0.68), rgba(23, 32, 26, 0.18)),
    linear-gradient(145deg, #315f7b, #8aa36f);
}

.item-hero h2 {
  max-width: 720px;
  margin: 7px 0 8px;
  font-size: clamp(1.7rem, 4vw, 3rem);
  line-height: 1;
}

.item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.item-body {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.info-cell {
  min-height: 82px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafbf8;
}

.info-cell span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 850;
  text-transform: uppercase;
}

.notice {
  padding: 12px;
  border-radius: 8px;
  background: #f5efe0;
  color: #59401a;
}

.notice strong {
  display: block;
  margin-bottom: 3px;
}

.care-list {
  display: grid;
  gap: 7px;
  margin: 0;
  padding-left: 19px;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.action-grid button {
  min-height: 54px;
  padding: 8px 10px;
  line-height: 1.12;
}

.list-stack {
  display: grid;
  gap: 10px;
}

.list-item {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf8;
}

.list-item-header {
  display: flex;
  gap: 8px;
  align-items: start;
  justify-content: space-between;
}

.list-item p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.inventory-controls {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 150px;
  gap: 8px;
  width: min(100%, 560px);
}

.inventory-table {
  display: grid;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.inventory-row {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr 0.8fr 0.7fr auto;
  gap: 12px;
  align-items: center;
  min-height: 58px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.inventory-row:last-child {
  border-bottom: 0;
}

.inventory-row.header {
  min-height: 42px;
  background: #eef1e8;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: uppercase;
}

.inventory-row button {
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: #f8f9f5;
  font-weight: 800;
}

.muted {
  color: var(--muted);
}

.event-log {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.event-log li {
  padding: 9px 10px;
  border-radius: 7px;
  background: #f4f6ef;
  color: #415047;
  font-size: 0.88rem;
}

.loan-session-panel {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf8;
}

.loan-session-panel.active {
  border-color: rgba(31, 90, 64, 0.42);
  background: #eef6ee;
}

.loan-session-panel.returning {
  border-color: rgba(95, 142, 173, 0.45);
  background: #edf5f8;
}

.loan-session-heading {
  display: flex;
  gap: 10px;
  align-items: start;
  justify-content: space-between;
}

.loan-session-heading h3 {
  margin-bottom: 3px;
}

.loan-session-heading p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.loan-session-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.loan-session-list li {
  display: flex;
  gap: 8px;
  justify-content: space-between;
  padding: 8px 9px;
  border-radius: 7px;
  background: #fff;
  color: #405047;
  font-size: 0.88rem;
}

.loan-session-alert {
  padding: 9px 10px;
  border-radius: 7px;
  background: #fff2cf;
  color: #72500f;
  font-weight: 750;
}

.borrower-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.borrower-card {
  min-height: 56px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: #f8f9f5;
  color: var(--ink);
  text-align: left;
}

.borrower-card strong,
.borrower-card span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.borrower-card span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.8rem;
}

.borrower-card.selected {
  border-color: rgba(31, 90, 64, 0.58);
  background: #eef6ee;
}

.check-row {
  display: flex;
  grid-template-columns: none;
  gap: 9px;
  align-items: center;
}

.check-row input {
  width: 18px;
  min-height: 18px;
}

.bottom-metrics {
  margin-top: 18px;
}

.label-list {
  display: grid;
  gap: 12px;
}

.gear-label {
  display: grid;
  grid-template-columns: 54px minmax(110px, 1.25fr) 54px minmax(130px, 1fr) 58px;
  gap: 8px;
  align-items: center;
  min-height: 68px;
  padding: 6px 8px;
  border: 1px solid #2f332c;
  background: #fff100;
  color: #050505;
}

.gear-label-title {
  min-width: 0;
}

.gear-label-title strong {
  display: block;
  overflow: hidden;
  font-size: clamp(1.25rem, 3vw, 2.35rem);
  font-weight: 950;
  line-height: 0.95;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gear-label-title span {
  display: block;
  margin-top: 5px;
  overflow: hidden;
  font-size: 0.95rem;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gear-label-instruction {
  font-size: clamp(0.86rem, 1.65vw, 1.3rem);
  font-weight: 500;
  line-height: 1.22;
}

.qr-box {
  position: relative;
  aspect-ratio: 1;
  border: 2px solid #050505;
  background:
    linear-gradient(90deg, #050505 10px, transparent 10px 14px, #050505 14px 18px, transparent 18px),
    linear-gradient(#050505 8px, transparent 8px 13px, #050505 13px 18px, transparent 18px),
    repeating-linear-gradient(45deg, #050505 0 3px, transparent 3px 7px),
    #fff;
  background-size: 24px 24px, 20px 20px, 13px 13px, auto;
}

.qr-box::before,
.qr-box::after {
  position: absolute;
  width: 18px;
  height: 18px;
  border: 5px solid #050505;
  background: #fff100;
  content: "";
}

.qr-box::before {
  top: 4px;
  left: 4px;
}

.qr-box::after {
  right: 4px;
  bottom: 4px;
}

.label-mark {
  display: grid;
  place-items: center;
}

.label-mark-shape {
  position: relative;
  width: 50px;
  height: 38px;
  border: 6px solid #050505;
  transform: rotate(45deg);
}

.label-mark-shape::before {
  position: absolute;
  inset: 10px 3px 3px 10px;
  border-left: 5px solid #050505;
  border-bottom: 5px solid #050505;
  content: "";
}

.label-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  padding: 8px 0 2px;
}

.label-actions code {
  overflow-wrap: anywhere;
  color: #32423a;
  font-size: 0.82rem;
}

dialog {
  width: min(520px, calc(100vw - 28px));
  padding: 0;
  border: 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

#loanDialog {
  width: min(720px, calc(100vw - 28px));
}

dialog::backdrop {
  background: rgba(23, 32, 26, 0.5);
}

.dialog-card {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.dialog-card p {
  margin-bottom: 0;
  color: var(--muted);
}

@media (max-width: 900px) {
  .home-panel,
  .scan-layout,
  .work-grid {
    grid-template-columns: 1fr;
  }

  .status-strip {
    width: 100%;
  }

  .detail-panel {
    min-height: 0;
  }

  .empty-state {
    min-height: 220px;
  }

  .inventory-heading {
    align-items: start;
    flex-direction: column;
  }

  .inventory-controls {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100vw - 18px, 1180px);
    padding-top: 10px;
  }

  .tabs {
    grid-template-columns: repeat(2, 1fr);
  }

  .status-strip,
  .workflow-grid,
  .info-grid,
  .action-grid,
  .inventory-controls,
  .two-col {
    grid-template-columns: 1fr;
  }

  .welcome-copy,
  .workflow-card {
    min-height: 0;
  }

  .inventory-row,
  .inventory-row.header {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .inventory-row.header {
    display: none;
  }

  .input-row {
    grid-template-columns: 1fr;
  }

  .label-actions {
    grid-template-columns: 1fr;
  }

  .borrower-list {
    grid-template-columns: 1fr;
  }

  .gear-label {
    grid-template-columns: 58px minmax(0, 1fr);
  }

  .gear-label .qr-box:nth-child(3),
  .gear-label-instruction,
  .label-mark {
    display: none;
  }

  .gear-label-title strong {
    font-size: 1.7rem;
  }

  .gear-label-title span {
    font-size: 1rem;
  }
}

@media print {
  body {
    background: #fff;
  }

  .topbar,
  .tabs,
  .home-panel,
  .scan-layout,
  .bottom-metrics,
  .work-grid > .tool-panel:first-child,
  .panel-heading .secondary-action,
  .label-actions,
  #eventDialog {
    display: none !important;
  }

  .app-shell {
    width: 100%;
    padding: 0;
  }

  main,
  .work-grid {
    display: block !important;
    padding: 0;
  }

  .view {
    display: none !important;
  }

  #maintenanceView {
    display: block !important;
  }

  .tool-panel {
    border: 0;
    box-shadow: none;
  }

  .gear-label {
    grid-template-columns: 78px minmax(160px, 1fr) 78px minmax(230px, 1.1fr) 82px;
    gap: 12px;
    min-height: 86px;
    padding: 7px 10px;
    break-inside: avoid;
    margin-bottom: 8px;
    box-shadow: none;
  }

  .gear-label-title strong {
    font-size: 3.6rem;
  }

  .gear-label-title span {
    margin-top: 8px;
    font-size: 1.25rem;
  }

  .gear-label-instruction {
    font-size: 2rem;
  }

  .label-mark-shape {
    width: 76px;
    height: 58px;
    border-width: 8px;
  }

  .label-mark-shape::before {
    inset: 16px 5px 5px 16px;
    border-left-width: 7px;
    border-bottom-width: 7px;
  }
}
