:root {
  --bg: #fafaf9;
  --surface: #ffffff;
  --border: #e5e3df;
  --text: #1c1b1a;
  --text-muted: #8a8580;
  --accent: #2f6f4f;
  --accent-soft: #e7f2ec;
  --warn: #b3691d;
  --warn-soft: #fbeee0;
  --danger: #b3392f;
  --radius: 10px;
  --max-width: 480px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: var(--max-width);
  margin: 0 auto;
  min-height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  padding-bottom: 100px;
  position: relative;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 16px 10px;
  gap: 8px;
}

.topbar h1 {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
  flex: 1;
  letter-spacing: -0.01em;
}

.detail-label {
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text);
  flex-shrink: 0;
}

.icon-btn svg { fill: currentColor; }
.icon-btn.danger { color: var(--danger); }
.icon-btn:active { background: var(--bg); }

.summary-row {
  display: flex;
  padding: 4px 16px 14px;
  gap: 24px;
  border-bottom: 1px solid var(--border);
}

.summary { display: flex; flex-direction: column; }
.summary-num { font-size: 20px; font-weight: 700; line-height: 1.2; }
.summary-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }

.sign-list {
  display: flex;
  flex-direction: column;
}

.sign-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 14px 16px;
  text-align: left;
  cursor: pointer;
  gap: 10px;
  font-family: inherit;
}

.sign-row:active { background: var(--bg); }

.sign-row-main { min-width: 0; }
.sign-row-label { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sign-row-sub { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.status-pill {
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}

.status-pill.in { background: var(--accent-soft); color: var(--accent); }
.status-pill.out { background: var(--warn-soft); color: var(--warn); }

.empty-state {
  padding: 60px 24px;
  text-align: center;
  color: var(--text-muted);
}
.empty-state p { margin: 4px 0; }
.empty-state .muted { font-size: 13px; }
.hidden { display: none !important; }

.fab {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  width: calc(min(100%, var(--max-width)) - 32px);
  background: var(--text);
  color: var(--surface);
  border: none;
  border-radius: var(--radius);
  padding: 15px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.fab:active { opacity: 0.85; }

.detail-body { padding: 4px 16px 20px; }

.qr-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 8px;
}

#qr-canvas { image-rendering: pixelated; background: #fff; border-radius: 4px; }

.qr-id {
  margin-top: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.qr-actions { display: flex; gap: 18px; margin-top: 10px; }

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px;
  font-family: inherit;
}

.status-block {
  margin-top: 16px;
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: 14px;
}

.status-block .status-title { font-weight: 700; font-size: 15px; margin-bottom: 2px; }
.status-block.in { background: var(--accent-soft); border-color: transparent; }
.status-block.out { background: var(--warn-soft); border-color: transparent; }

.primary-btn {
  width: 100%;
  margin-top: 14px;
  padding: 14px;
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
  background: var(--accent);
}
.primary-btn.out { background: var(--warn); }
.primary-btn:active { opacity: 0.88; }

.secondary-btn {
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
}

.section-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 26px 0 8px;
}

.history-list { display: flex; flex-direction: column; }

.history-row {
  display: flex;
  gap: 12px;
  padding: 10px 2px;
  border-bottom: 1px solid var(--border);
}
.history-row:last-child { border-bottom: none; }

.history-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  margin-top: 6px;
  flex-shrink: 0;
}
.history-row.checkout .history-dot { background: var(--warn); }
.history-row.checkin .history-dot { background: var(--accent); }

.history-line { font-size: 14px; }
.history-line b { font-weight: 600; }
.history-time { font-size: 12px; color: var(--text-muted); margin-top: 1px; }

.history-empty { color: var(--text-muted); font-size: 13px; padding: 8px 2px; }

.scan-body { padding: 10px 16px 24px; }

.video-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
}

.video-wrap video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scan-frame {
  position: absolute;
  inset: 14%;
  border: 2px solid rgba(255,255,255,0.85);
  border-radius: 12px;
  pointer-events: none;
}

.center { text-align: center; }
.muted { color: var(--text-muted); font-size: 13px; }

.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 22px 0 14px;
  color: var(--text-muted);
  font-size: 12px;
}
.divider::before, .divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.manual-form { display: flex; gap: 8px; }
.manual-form input {
  flex: 1;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: 15px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  text-transform: uppercase;
}
.manual-form input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 20;
}

.sheet {
  width: 100%;
  max-width: var(--max-width);
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  padding: 20px;
  animation: slide-up 0.15s ease-out;
}

@keyframes slide-up {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.sheet h2 { margin: 0 0 4px; font-size: 17px; }
.sheet .muted { margin-bottom: 14px; }

.sheet input {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: 15px;
  font-family: inherit;
  margin-bottom: 12px;
}
.sheet input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.sheet-actions { display: flex; gap: 10px; margin-top: 4px; }
.sheet-actions button { flex: 1; }

.ghost-btn {
  padding: 13px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
}

.login-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  text-align: center;
}

.login-title { font-size: 22px; font-weight: 700; margin: 0 0 6px; }

.login-form {
  width: 100%;
  max-width: 280px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}

.login-form input {
  padding: 13px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: 16px;
  font-family: inherit;
  text-align: center;
}
.login-form input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.login-error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 14px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--surface);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 30;
  animation: fade-in 0.15s ease-out;
}

@keyframes fade-in {
  from { opacity: 0; transform: translate(-50%, 6px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
