:root {
  --bg: #f6f7f9;
  --text: #172126;
  --muted: #637078;
  --line: #d9e0e4;
  --panel: #ffffff;
  --green: #0f766e;
  --green-dark: #0b5f59;
  --blue: #1d4ed8;
  --amber: #b45309;
  --red: #b42318;
  --shadow: 0 8px 24px rgba(20, 30, 40, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input { font: inherit; }

.app-shell {
  min-height: 100vh;
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: rgba(246, 247, 249, 0.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(217, 224, 228, 0.8);
}

h1, h2, p { margin: 0; }
h1 { font-size: 22px; line-height: 1.25; }
h2 { font-size: 20px; line-height: 1.25; }

main { flex: 1; padding: 14px 14px 80px; }

.screen { display: none; }
.screen.active { display: block; }
.hidden { display: none !important; }

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
}

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

.panel.compact { padding: 14px; margin-top: 14px; }
.panel-title-row,
.home-summary,
.scan-header,
.button-row,
.status-strip,
.scan-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.muted { color: var(--muted); margin-top: 8px; line-height: 1.55; }
.message { margin-top: 12px; line-height: 1.55; color: var(--muted); }
.message.error { color: var(--red); font-weight: 700; }
.message.ok { color: var(--green-dark); font-weight: 700; }

.field { display: block; margin-top: 16px; }
.field span { display: block; font-weight: 700; margin-bottom: 6px; }
input {
  width: 100%;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: white;
}

button {
  border: 0;
  border-radius: 8px;
  min-height: 44px;
  padding: 0 14px;
  font-weight: 800;
}

.primary { background: var(--green); color: white; }
.primary:active { background: var(--green-dark); }
.secondary { background: #e7f0ee; color: var(--green-dark); }
.ghost, .small { background: #edf1f3; color: #27343a; }
.danger-text { color: var(--red); }
.wide { width: 100%; margin-top: 18px; }
.small { min-height: 38px; font-size: 14px; padding: 0 10px; }

.home-summary { margin-bottom: 14px; }
.current-user { font-size: 20px; font-weight: 900; margin-top: 2px; }
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: #e8eef1;
  color: #324047;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}
.badge.online { background: #d9f2e9; color: #065f46; }
.badge.offline { background: #ffe7e0; color: var(--red); }

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

.action {
  height: 86px;
  color: white;
  font-size: 18px;
}
.action.checkout { background: var(--green); }
.action.return { background: var(--blue); }
.action.confirm { background: var(--amber); }

.status-strip { margin: 12px 0; flex-wrap: wrap; justify-content: flex-start; }
.status-lines { display: grid; gap: 8px; color: var(--muted); }

.camera-card {
  position: relative;
  width: min(100%, calc(100svh - 260px), 560px);
  aspect-ratio: 1 / 1;
  margin: 12px auto 10px;
  overflow: hidden;
  border-radius: 8px;
  background: #111;
  box-shadow: var(--shadow);
}

#scanVideo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.scan-guide {
  position: absolute;
  inset: 9%;
  border: 3px solid rgba(255, 255, 255, 0.88);
  border-radius: 8px;
  pointer-events: none;
}

.scan-guide::after {
  content: "";
  position: absolute;
  left: 12%;
  right: 12%;
  top: 50%;
  border-top: 2px solid rgba(16, 185, 129, 0.9);
}

.scan-feedback {
  min-height: 28px;
  text-align: center;
  font-weight: 900;
  color: var(--green-dark);
}
.scan-feedback.warn { color: var(--amber); }
.scan-feedback.error { color: var(--red); }

.item-list { display: grid; gap: 8px; margin-top: 10px; }
.item-card {
  display: grid;
  gap: 4px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.item-card.row {
  grid-template-columns: 1fr auto;
  align-items: center;
}
.tool-name { font-weight: 900; font-size: 17px; }
.tool-id, .tool-meta { color: var(--muted); font-size: 13px; }
.remove-item {
  width: 36px;
  min-height: 36px;
  padding: 0;
  background: #ffe7e0;
  color: var(--red);
}

.review { margin: 16px 0; }
.button-row { margin-top: 12px; }
.button-row > button { flex: 1; }

.confirm-panel { text-align: center; }
.confirm-name {
  font-size: 22px;
  font-weight: 900;
  margin: 14px 0 10px;
}
.qr-box {
  width: min(78vw, 360px);
  height: min(78vw, 360px);
  margin: 0 auto;
  padding: 12px;
  display: grid;
  place-items: center;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.qr-box img, .qr-box svg {
  width: 100%;
  height: 100%;
}
.ttl {
  margin-top: 12px;
  font-size: 18px;
  font-weight: 900;
  color: var(--green-dark);
}

.footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 14px calc(9px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 380px) {
  main { padding-left: 10px; padding-right: 10px; }
  .action { height: 78px; font-size: 16px; }
  h1 { font-size: 20px; }
}
