:root {
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #071112;
  color: #f3f8f7;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100dvh; background: #071112; }
button, input { font: inherit; }
.hidden { display: none !important; }

.login-view {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: calc(24px + env(safe-area-inset-top)) 18px calc(24px + env(safe-area-inset-bottom));
}
.login-card {
  width: min(100%, 430px);
  padding: 24px;
  border: 1px solid #294144;
  border-radius: 22px;
  background: #101d1f;
}
.eyebrow { color: #8fa4a7; font-size: 12px; font-weight: 650; letter-spacing: .08em; }
h1 { margin: 7px 0 10px; font-size: 28px; }
.login-card p { color: #aebec0; font-size: 14px; line-height: 1.6; }
form { display: grid; gap: 9px; margin-top: 18px; }
label { color: #aebec0; font-size: 13px; }
input {
  width: 100%; min-height: 50px; padding: 10px 13px; border: 1px solid #345054;
  border-radius: 13px; background: #091416; color: #f3f8f7;
}
button {
  min-height: 48px; padding: 10px 14px; border: 1px solid #345054; border-radius: 14px;
  color: #edf5f5; background: #132326; font-weight: 700; -webkit-tap-highlight-color: transparent;
}
button:active { transform: translateY(1px); }
button:disabled { opacity: .42; }
.primary-button { margin-top: 6px; border-color: transparent; background: #d7efea; color: #0b2220; }

.app-shell {
  width: min(100%, 520px); margin: 0 auto;
  padding: calc(12px + env(safe-area-inset-top)) 14px calc(26px + env(safe-area-inset-bottom));
}
.compact-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; }
.header-actions { display: flex; align-items: center; gap: 7px; }
.header-button { min-height: 38px; padding: 7px 11px; border-radius: 11px; color: #bcefe0; }
.catalog-status { margin-top: 4px; color: #d6e1e1; font-size: 14px; font-weight: 650; }
.badge { padding: 6px 9px; border-radius: 999px; background: #113e35; color: #69e1bd; font-size: 12px; font-weight: 700; }
.badge.offline { background: #4b3513; color: #ffd16f; }

.camera-card {
  position: relative; overflow: hidden; aspect-ratio: 4 / 3; border: 1px solid #294144;
  border-radius: 20px; background: #020607; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.camera-card:focus-visible { outline: 3px solid #75e8c2; outline-offset: 3px; }
.camera-card.scan-success { border-color: #69efbd; box-shadow: 0 0 0 4px rgba(74,225,172,.25); }
#camera, .product-image { width: 100%; height: 100%; display: block; }
#camera { object-fit: cover; }
.product-image { object-fit: contain; background: #f6f6f2; }
.image-reference {
  position: absolute; right: 10px; top: 10px; z-index: 3; padding: 6px 9px; border-radius: 999px;
  background: rgba(4,13,14,.78); color: #dce6e5; font-size: 11px; backdrop-filter: blur(7px);
}
.camera-empty {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 10px; background: #0d1719; color: #a6b5b7; font-size: 15px;
}
.camera-icon { color: #63d6b3; font-size: 38px; }
.scan-frame {
  position: absolute; left: 7%; right: 7%; top: 35%; height: 30%; border: 2px solid rgba(95,226,183,.9);
  border-radius: 15px; box-shadow: 0 0 0 999px rgba(0,0,0,.18); pointer-events: none;
}
.scan-frame span { position: absolute; left: 8%; right: 8%; top: 50%; height: 2px; background: #5fe2b7; box-shadow: 0 0 10px #5fe2b7; }
.camera-tap-action {
  position: absolute; left: 50%; top: 50%; z-index: 4; width: min(82%,330px); transform: translate(-50%,-50%);
  padding: 16px 18px; border: 1px solid rgba(113,232,194,.8); border-radius: 16px;
  background: rgba(4,20,18,.9); color: #8ff0d0; font-size: 17px; font-weight: 750; text-align: center;
}
.camera-status { position: absolute; left: 11px; bottom: 10px; z-index: 4; padding: 6px 9px; border-radius: 999px; background: rgba(3,11,12,.82); font-size: 12px; }

.result-card, .product-card { margin-top: 10px; padding: 13px 15px; border: 1px solid #294144; border-radius: 16px; background: #101d1f; }
.result-card.success { border-color: #35b88f; background: #0f2c26; }
.result-card.error { border-color: #d45c5c; background: #301919; }
.result-label, .product-row span { color: #8fa4a7; font-size: 11px; font-weight: 600; letter-spacing: .04em; }
.result-code { margin-top: 5px; font: 750 clamp(23px,7vw,32px)/1.15 ui-monospace,"SFMono-Regular",Menlo,monospace; letter-spacing: .06em; overflow-wrap: anywhere; }
.result-hint, .message { color: #9fb0b3; font-size: 12px; line-height: 1.45; }
.result-hint { margin-top: 5px; }
.product-card { display: grid; gap: 8px; }
.product-row { display: grid; grid-template-columns: 76px 1fr; gap: 10px; align-items: baseline; }
.product-row strong { text-align: right; font-size: 14px; overflow-wrap: anywhere; }
.color-row strong { color: #ffd165; font-size: 19px; }
.related-sheet-button { margin-top: 4px; min-height: 44px; border-color: #2d7668; color: #8ff0d0; }

.next-button {
  position: fixed; left: 50%; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 20;
  width: min(calc(100% - 28px),492px); min-height: 60px; transform: translateX(-50%);
  border-color: #8ff0d0; background: #d7efea; color: #0b2220; font-size: 18px;
  box-shadow: 0 10px 34px rgba(0,0,0,.5);
}
.next-button:active { transform: translateX(-50%) translateY(1px); }
body.waiting-next .app-shell { padding-bottom: calc(104px + env(safe-area-inset-bottom)); }
.utility-actions { display: grid; grid-template-columns: 1fr; gap: 9px; margin-top: 10px; }
.message { min-height: 34px; margin-top: 10px; padding: 9px 11px; border-radius: 11px; background: #0c181a; }
.message.error { color: #ffaeae; background: #2c1717; }

.sheet-view { min-height: 70dvh; }
.sheet-toolbar {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 12px 0 14px; border-bottom: 1px solid #294144;
}
.sheet-toolbar h1 { margin: 2px 0 3px; font-size: 23px; }
.sheet-toolbar p { margin: 0; color: #9fb0b3; font-size: 12px; line-height: 1.45; }
.sheet-toolbar > button { min-height: 44px; flex: 0 0 auto; }
.sticky-toolbar { background: #071112; }
.text-button { min-height: 30px !important; padding: 2px 0; border: 0; background: transparent; color: #8ff0d0; }
.sheet-list { display: grid; gap: 10px; padding: 12px 0; }
.sheet-list-item {
  width: 100%; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px;
  min-height: 76px; padding: 13px 14px; text-align: left; border-color: #294144; background: #101d1f;
}
.sheet-list-title { color: #f3f8f7; font-size: 15px; font-weight: 750; overflow-wrap: anywhere; }
.sheet-list-meta { margin-top: 6px; color: #9fb0b3; font-size: 12px; line-height: 1.45; }
.sheet-list-arrow { color: #69e1bd; font-size: 24px; }
.empty-sheet-list { padding: 42px 18px; text-align: center; color: #9fb0b3; border: 1px dashed #345054; border-radius: 16px; }
.sheet-cards { display: grid; gap: 10px; padding: 12px 0 24px; }
.sheet-card { position: relative; scroll-margin-top: 130px; }
.sheet-card img { display: block; width: 100%; height: auto; border: 1px solid #294144; border-radius: 16px; background: #0b0f14; }
.sheet-card.is-target img { border-color: #69efbd; box-shadow: 0 0 0 4px rgba(74,225,172,.25); }
.sheet-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 4px 7px; }
.sheet-card-index { color: #69e1bd; font-size: 12px; font-weight: 750; }
.sheet-card-target {
  padding: 5px 8px; border-radius: 999px;
  background: #d7efea; color: #0b2220; font-size: 12px; font-weight: 750;
}
.sheet-card-error {
  width: 100%; min-height: 170px; display: grid; place-items: center; padding: 18px; border: 1px solid #7b4242;
  border-radius: 16px; color: #ffb4b4; background: #301919; text-align: center;
}

@media (max-height: 700px) {
  .app-shell { padding-top: calc(7px + env(safe-area-inset-top)); }
  .compact-header { margin-bottom: 7px; }
  .camera-card { aspect-ratio: 16 / 10; }
  .result-card, .product-card { margin-top: 7px; padding: 10px 13px; }
  .product-card { gap: 6px; }
}
