* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: #F3F5F8;
  color: #0E1A2B;
  font-family: Figtree, system-ui, sans-serif;
}
body.mode-scan { background: #0B1220; }
button, input { font-family: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:disabled { opacity: 0.55; }
[hidden] { display: none !important; }
a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 3px solid #1D4ED8;
  outline-offset: 2px;
}

#app { height: 100%; }
.view { display: none; }
.view.is-on {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  height: 100%;
  overflow: auto;
  gap: 16px;
  padding: calc(28px + env(safe-area-inset-top)) 20px 24px;
  background: #F3F5F8;
}
.view.is-parked {
  display: flex;
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
}
.with-tabs.is-on { padding-bottom: calc(108px + env(safe-area-inset-bottom)); }
#view-home.is-on { gap: 20px; }
#view-lot.is-on { padding-top: calc(16px + env(safe-area-inset-top)); }
#view-scan.is-on {
  background: #0B1220;
  color: #F2F5FA;
  padding: calc(12px + env(safe-area-inset-top)) 16px calc(20px + env(safe-area-inset-bottom));
  gap: 12px;
}
.screen-scan button:focus-visible, .screen-scan input:focus-visible {
  outline-color: #7DA2FF;
}

h1 { margin: 0; font-size: 32px; font-weight: 800; line-height: 1.1; }
h1.compact { font-size: 26px; }
.sub { margin: 4px 0 0; font-size: 16px; color: #5B6778; }
.title-block { display: flex; flex-direction: column; gap: 4px; }

.back-row { display: flex; align-items: center; gap: 4px; height: 48px; }
.back {
  width: 48px;
  height: 48px;
  margin-left: -12px;
  border: 0;
  background: transparent;
  color: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.card {
  background: #FFFFFF;
  border: 1px solid #D9DFE7;
  border-radius: 20px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.card.pad { padding: 16px; }
.kicker {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #5B6778;
}
.lot-name { font-size: 24px; font-weight: 800; }
.lot-meta { margin: 0; font-size: 16px; color: #5B6778; }
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  padding: 6px 12px;
  border-radius: 999px;
  background: #E8EDF5;
  font-size: 14px;
  font-weight: 600;
}
.count-row { display: flex; align-items: baseline; gap: 10px; }
.big-count { font-size: 56px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.count-label { font-size: 18px; color: #5B6778; }

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  border-radius: 16px;
  font-weight: 700;
}
.btn-primary {
  height: 64px;
  border: 0;
  background: #1D4ED8;
  color: #FFFFFF;
  font-size: 19px;
}
.btn-outline {
  height: 56px;
  border: 2px solid #1D4ED8;
  background: #FFFFFF;
  color: #1D4ED8;
  font-size: 18px;
}
.btn-line {
  height: 52px;
  border-radius: 14px;
  border: 2px solid #D9DFE7;
  background: #FFFFFF;
  color: #0E1A2B;
  font-size: 17px;
}
.btn-danger {
  height: 52px;
  border: 2px solid #D9DFE7;
  background: #FFFFFF;
  color: #B42318;
  font-size: 17px;
}
.btn-end {
  height: 52px;
  margin-top: auto;
  border-radius: 14px;
  border: 2px solid #2A3750;
  background: transparent;
  color: #F2F5FA;
  font-size: 17px;
}
.btn-undo {
  width: auto;
  flex: none;
  height: 48px;
  padding: 0 16px;
  border-radius: 12px;
  border: 2px solid #FFFFFF;
  background: transparent;
  color: #FFFFFF;
  font-size: 16px;
}
.push { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }

.section-label { font-size: 15px; font-weight: 700; color: #5B6778; }
.list {
  background: #FFFFFF;
  border: 1px solid #D9DFE7;
  border-radius: 16px;
}
.list-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid #E3E8EF;
}
.list-row:last-child { border-bottom: 0; }
.list-name { font-size: 16px; font-weight: 700; }
.list-meta { font-size: 14px; color: #5B6778; }
.list-cost { font-size: 15px; font-weight: 600; flex: none; }
.empty-note { margin: 0; font-size: 15px; color: #5B6778; }

.field { display: flex; flex-direction: column; gap: 8px; }
.field-label, .field label {
  font-size: 14px;
  font-weight: 700;
  color: #5B6778;
}
.field input[type="text"],
.field input[type="url"],
.field input[type="password"],
.field input[type="date"] {
  width: 100%;
  height: 56px;
  border-radius: 14px;
  border: 2px solid #D9DFE7;
  background: #FFFFFF;
  padding: 0 16px;
  font-size: 18px;
  font-weight: 600;
  color: #0E1A2B;
}
#view-settings .field input { height: 52px; }
#sheet-url { font-size: 16px; }
.hint { margin: 0; font-size: 14px; line-height: 1.35; color: #5B6778; }
.form-error { margin: 0; font-size: 15px; font-weight: 700; color: #B42318; }

.money {
  display: flex;
  align-items: center;
  height: 56px;
  border-radius: 14px;
  border: 2px solid #D9DFE7;
  background: #FFFFFF;
  padding: 0 16px;
  gap: 6px;
}
.money span { font-size: 20px; font-weight: 700; color: #5B6778; }
.money .suffix { font-size: 15px; font-weight: 400; }
.field .money input {
  flex: 1;
  width: auto;
  height: auto;
  min-width: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0;
  font-size: 22px;
  font-weight: 700;
  color: #0E1A2B;
}
.field .money input:focus { outline: none; }
.money:focus-within { outline: 3px solid #1D4ED8; outline-offset: 2px; }

.toggle-row { display: flex; gap: 8px; }
.toggle-row button {
  flex: 1;
  height: 56px;
  border-radius: 14px;
  border: 2px solid #D9DFE7;
  background: #FFFFFF;
  color: #0E1A2B;
  font-size: 18px;
  font-weight: 600;
}
.toggle-row button.is-on {
  border-color: #1D4ED8;
  background: #1D4ED8;
  color: #FFFFFF;
  font-weight: 700;
}
.cost-toggle button.is-on {
  border-color: #0E1A2B;
  background: #0E1A2B;
  color: #FFFFFF;
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button {
  flex: 1 1 calc(50% - 4px);
  min-width: 0;
  height: 48px;
  border-radius: 14px;
  border: 2px solid #D9DFE7;
  background: #FFFFFF;
  color: #0E1A2B;
  font-size: 16px;
  font-weight: 600;
}
.chips button.is-on {
  border-color: #1D4ED8;
  background: #1D4ED8;
  color: #FFFFFF;
  font-weight: 700;
}
#view-settings .toggle-row button { height: 52px; font-size: 17px; }

.scan-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  gap: 8px;
}
.scan-id { display: flex; align-items: center; gap: 4px; min-width: 0; }
.scan-titles { min-width: 0; }
.scan-name {
  font-size: 17px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.scan-sub { font-size: 13px; color: #9AA7BA; }
.scan-count { text-align: right; flex: none; }
.scan-count strong {
  display: block;
  font-size: 30px;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.scan-count span { font-size: 12px; color: #9AA7BA; }
.scan-label { font-size: 13px; font-weight: 600; color: #9AA7BA; }

.finder {
  position: relative;
  height: 250px;
  border-radius: 20px;
  background: #05090F;
  overflow: hidden;
  flex: none;
}
#reader, #reader__scan_region {
  position: absolute !important;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  border: 0 !important;
  background: transparent !important;
}
#reader video {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  object-fit: cover;
}
#reader__dashboard, #reader__header_message { display: none !important; }
#reader * { pointer-events: none; }
.finder-hint {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 64px;
  z-index: 2;
  font-size: 14px;
  color: #9AA7BA;
  pointer-events: none;
}
.torch {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 0;
  background: #1B2740;
  color: #F2F5FA;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.torch.is-on { background: #34D399; color: #0B1220; }
.bracket {
  position: absolute;
  z-index: 2;
  width: 30px;
  height: 30px;
  pointer-events: none;
}
.bracket.tl { top: 64px; left: 48px; border-top: 4px solid #34D399; border-left: 4px solid #34D399; border-top-left-radius: 10px; }
.bracket.tr { top: 64px; right: 48px; border-top: 4px solid #34D399; border-right: 4px solid #34D399; border-top-right-radius: 10px; }
.bracket.bl { top: 148px; left: 48px; border-bottom: 4px solid #34D399; border-left: 4px solid #34D399; border-bottom-left-radius: 10px; }
.bracket.br { top: 148px; right: 48px; border-bottom: 4px solid #34D399; border-right: 4px solid #34D399; border-bottom-right-radius: 10px; }
.scan-line {
  position: absolute;
  z-index: 2;
  top: 120px;
  left: 56px;
  right: 56px;
  height: 3px;
  border-radius: 2px;
  background: #34D399;
  pointer-events: none;
}
.finder.is-flash::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  background: #34D399;
  opacity: 0.55;
  pointer-events: none;
}
.camera-error {
  position: absolute;
  z-index: 2;
  left: 16px;
  right: 16px;
  bottom: 64px;
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
  color: #FBBF24;
  text-align: center;
}
.type-btn {
  position: absolute;
  z-index: 2;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  height: 48px;
  padding: 0 18px;
  border-radius: 24px;
  border: 0;
  background: #1B2740;
  color: #F2F5FA;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
}

.banner {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  border-radius: 16px;
  padding: 12px 14px;
  color: #FFFFFF;
}
.banner-ok { background: #0F7B55; }
.banner-bad { background: #B42318; }
.banner-icon {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #FFFFFF;
  color: #0F7B55;
  display: flex;
  align-items: center;
  justify-content: center;
}
.banner-bad .banner-icon { color: #B42318; }
.banner-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.banner-label { font-size: 13px; font-weight: 700; }
.banner-title {
  font-size: 17px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wake-tip {
  background: #141D2E;
  color: #F2F5FA;
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.35;
}
.screen-scan .toggle-row button {
  border-color: #2A3750;
  background: #141D2E;
  color: #F2F5FA;
}
.screen-scan .toggle-row button.is-on {
  border-color: #F2F5FA;
  background: #F2F5FA;
  color: #0B1220;
  font-weight: 800;
}
.scan-list { display: flex; flex-direction: column; gap: 8px; }
.scan-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  height: 60px;
  padding: 0 12px;
  border: 0;
  border-radius: 14px;
  background: #141D2E;
  color: #F2F5FA;
  text-align: left;
}
.cover { flex: none; width: 32px; height: 44px; border-radius: 4px; }
.scan-copy { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.scan-title {
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.scan-meta { font-size: 13px; color: #9AA7BA; }
.scan-meta.warn { color: #FBBF24; font-weight: 600; }
.chevron { flex: none; color: #9AA7BA; }

.book-id {
  display: flex;
  gap: 16px;
  align-items: center;
  background: #FFFFFF;
  border: 1px solid #D9DFE7;
  border-radius: 20px;
  padding: 16px;
}
.book-cover { width: 64px; height: 92px; border-radius: 6px; flex: none; }
.book-title { font-size: 20px; font-weight: 800; line-height: 1.2; }
.book-author, .book-isbn { font-size: 16px; color: #5B6778; }
.book-isbn { font-size: 14px; font-variant-numeric: tabular-nums; }
.where-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: #E8EDF5;
  border-radius: 14px;
  padding: 12px 16px;
}
.where-kicker { font-size: 13px; font-weight: 700; color: #5B6778; }
.where-name { font-size: 16px; font-weight: 600; }
.where-note { font-size: 13px; color: #5B6778; flex: none; }

.setup-note {
  background: #E8EDF5;
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
}
.card-title { font-size: 20px; font-weight: 800; }
.card-copy { margin: 0; font-size: 14px; line-height: 1.4; color: #5B6778; }
.pair { display: flex; gap: 8px; }
.pair button { flex: 1; height: 52px; border-radius: 14px; font-size: 17px; font-weight: 700; }
.btn-test { border: 2px solid #1D4ED8; background: #FFFFFF; color: #1D4ED8; }
.btn-open { border: 2px solid #D9DFE7; background: #FFFFFF; color: #0E1A2B; }
.status {
  display: flex;
  align-items: center;
  gap: 12px;
  border-radius: 14px;
  padding: 12px 14px;
}
.status.ok { background: #E3F4EC; color: #0B5A3E; }
.status.bad { background: #FDECEC; color: #B42318; }
.status.idle { background: #E8EDF5; color: #0E1A2B; }
.status .dot { width: 12px; height: 12px; border-radius: 50%; flex: none; background: #8A94A3; }
.status.ok .dot { background: #0F7B55; }
.status.bad .dot { background: #B42318; }
.status strong { display: block; font-size: 16px; font-weight: 700; }
.status p { margin: 2px 0 0; font-size: 14px; }
.sound-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sound-name { font-size: 17px; font-weight: 700; }
.switch {
  flex: none;
  width: 64px;
  height: 40px;
  border: 0;
  border-radius: 20px;
  background: #8A94A3;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
}
.switch.is-on { background: #0F7B55; justify-content: flex-end; }
.switch i { width: 32px; height: 32px; border-radius: 50%; background: #FFFFFF; display: block; }
.volume-row { display: flex; align-items: center; gap: 12px; }
.volume-row span { font-size: 14px; font-weight: 700; color: #5B6778; }
.volume-row input { flex: 1; height: 32px; accent-color: #1D4ED8; }

.stat-grid { display: flex; gap: 12px; }
.stat {
  flex: 1;
  min-width: 0;
  background: #FFFFFF;
  border: 1px solid #D9DFE7;
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-label { font-size: 13px; font-weight: 700; color: #5B6778; }
.stat-value { font-size: 32px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-value.warn { color: #92400E; }
.chart-title { font-size: 18px; font-weight: 800; }
.chart-sub { font-size: 14px; color: #5B6778; }
.bars {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 170px;
  border-bottom: 1px solid #C5CDD8;
}
.bar-col {
  flex: 1;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}
.bar-value { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.bar {
  width: 100%;
  max-width: 34px;
  background: #1D4ED8;
  border-radius: 4px 4px 0 0;
}
.month-row { display: flex; gap: 10px; font-size: 13px; color: #5B6778; text-align: center; }
.month-row span { flex: 1; }
.month-row .now { font-weight: 700; color: #0E1A2B; }
.fmt { display: flex; flex-direction: column; gap: 6px; }
.fmt-top { display: flex; justify-content: space-between; font-size: 15px; gap: 8px; }
.fmt-top b { font-weight: 700; }
.fmt-top span { color: #5B6778; font-variant-numeric: tabular-nums; }
.track { height: 12px; border-radius: 6px; background: #E8EDF5; }
.track i { display: block; height: 12px; border-radius: 6px; background: #1D4ED8; }
.metrics-error { margin: 0; font-size: 14px; font-weight: 700; color: #B42318; }
#metrics-body { display: flex; flex-direction: column; gap: 16px; }

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  background: #FFFFFF;
  border-top: 1px solid #D9DFE7;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 0;
  border: 0;
  background: transparent;
  color: #5B6778;
  font-size: 12px;
  font-weight: 700;
}
.tab[aria-current="page"] { color: #1D4ED8; font-weight: 800; }
.tab svg { stroke-width: 2; }
.tab[aria-current="page"] svg { stroke-width: 2.4; }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  overflow: auto;
  background: #F3F5F8;
  color: #0E1A2B;
  padding: calc(16px + env(safe-area-inset-top)) 20px calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
}
