:root {
  color-scheme: light dark;
  --navy: #0b233e;
  --navy-2: #102f52;
  --blue: #1e6bb8;
  --gold: #e8a62c;
  --green: #14865a;
  --red: #b33a3a;
  --ink: #102033;
  --muted: #667789;
  --line: rgba(16, 32, 51, .12);
  --card: rgba(255, 255, 255, .94);
  --surface: #f3f6f9;
  --shadow: 0 16px 40px rgba(5, 25, 45, .12);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--surface); }
body {
  margin: 0;
  min-height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 90% -5%, rgba(30, 107, 184, .17), transparent 28rem),
    linear-gradient(180deg, #eef3f7 0%, #f7f9fb 100%);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.app-shell {
  width: min(100%, 760px);
  min-height: 100svh;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 0 calc(88px + env(safe-area-inset-bottom));
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px 14px;
}
.brand-row { display: flex; align-items: center; gap: 12px; }
.brand-icon { width: 43px; height: 43px; border-radius: 12px; box-shadow: 0 8px 20px rgba(11, 35, 62, .18); }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 24px; line-height: 1.05; margin-bottom: 0; letter-spacing: -.03em; }
h2 { font-size: 30px; line-height: 1.08; letter-spacing: -.035em; margin-bottom: 12px; }
h3 { font-size: 19px; }
.eyebrow { margin-bottom: 4px; font-size: 11px; line-height: 1; letter-spacing: .13em; font-weight: 800; color: var(--muted); }
.status-pill, .live-badge, .section-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-weight: 800;
  letter-spacing: .03em;
  white-space: nowrap;
}
.status-pill { padding: 7px 10px; font-size: 11px; border: 1px solid var(--line); background: rgba(255,255,255,.72); }
.status-checking { color: var(--muted); }
.status-live { color: #0a6b47; background: rgba(20, 134, 90, .1); border-color: rgba(20, 134, 90, .25); }
.status-offline { color: var(--red); background: rgba(179, 58, 58, .09); border-color: rgba(179,58,58,.22); }
.live-badge { padding: 7px 9px; font-size: 10px; color: #0a6b47; background: rgba(20, 134, 90, .1); }
.section-badge { padding: 6px 9px; margin-bottom: 16px; font-size: 10px; color: #82520b; background: rgba(232,166,44,.15); }

main { padding: 0 16px; }
.view { display: none; animation: fade .16s ease-out; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
.center-card, .hero-card, .info-card, .notice-card, .search-form, .result-card, .quick-search-card, .metric-card, .system-list {
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.center-card, .hero-card {
  margin-top: 10vh;
  padding: 28px 24px;
  border-radius: 24px;
  text-align: center;
}
.hero-card p, .center-card p { color: var(--muted); line-height: 1.5; }
.warning-card { border-color: rgba(179,58,58,.25); }
.large-symbol { width: 54px; height: 54px; display: grid; place-items: center; margin: 0 auto 16px; border-radius: 50%; background: rgba(179,58,58,.12); color: var(--red); font-size: 28px; font-weight: 900; }
.spinner { width: 34px; height: 34px; margin: 0 auto 20px; border: 3px solid rgba(30,107,184,.18); border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.field-label { display: block; margin: 18px 0 8px; text-align: left; font-size: 13px; font-weight: 800; color: var(--muted); }
.text-input {
  width: 100%;
  min-height: 50px;
  padding: 13px 14px;
  border: 1px solid rgba(16,32,51,.2);
  border-radius: 13px;
  background: rgba(255,255,255,.94);
  color: var(--ink);
  font-size: 17px;
  outline: none;
}
.text-input:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(30,107,184,.12); }
.code-input { letter-spacing: .02em; font-size: 15px; text-transform: uppercase; }
.primary-button, .secondary-button, .danger-button {
  width: 100%;
  min-height: 50px;
  border-radius: 14px;
  padding: 12px 16px;
  font-weight: 800;
  border: 0;
  cursor: pointer;
}
.primary-button { margin-top: 16px; color: white; background: linear-gradient(135deg, var(--blue), #13518c); box-shadow: 0 10px 24px rgba(30,107,184,.25); }
.primary-button:active { transform: translateY(1px); }
.primary-button[disabled], .secondary-button[disabled], .danger-button[disabled] { opacity: .5; cursor: default; transform: none; }
.primary-button.compact { width: auto; min-width: 104px; margin-top: 0; }
.face-button span { font-size: 20px; margin-right: 6px; }
.secondary-button { margin-top: 18px; background: rgba(30,107,184,.1); color: var(--blue); border: 1px solid rgba(30,107,184,.2); }
.danger-button { margin-top: 10px; background: rgba(179,58,58,.08); color: var(--red); border: 1px solid rgba(179,58,58,.2); }
.fine-print { margin: 12px 2px 0; color: var(--muted); font-size: 12px; line-height: 1.45; }

.welcome-row, .view-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 10px 4px 6px; }
.welcome-row h2, .view-heading h2 { margin-bottom: 0; }
.quick-search-card {
  width: 100%;
  display: grid;
  grid-template-columns: 46px 1fr auto;
  align-items: center;
  gap: 13px;
  margin: 14px 0;
  padding: 18px;
  border-radius: 20px;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.quick-search-card strong, .system-row strong { display: block; font-size: 16px; }
.quick-search-card small, .system-row small, .metric-card small { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; }
.quick-icon { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 14px; color: white; background: var(--navy); font-size: 26px; }
.chevron { color: var(--muted); font-size: 28px; }
.grid-two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.metric-card { padding: 18px; border-radius: 18px; }
.metric-card strong { display: block; margin-top: 7px; font-size: 21px; }
.metric-label { font-size: 11px; font-weight: 800; letter-spacing: .08em; color: var(--muted); text-transform: uppercase; }
.metric-card.muted strong { color: var(--muted); }
.section-title { margin: 25px 4px 10px; }
.system-list { border-radius: 20px; overflow: hidden; }
.system-row {
  width: 100%;
  display: grid;
  grid-template-columns: 12px 1fr auto;
  align-items: center;
  gap: 12px;
  min-height: 66px;
  padding: 12px 16px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  text-align: left;
}
.system-row:last-child { border-bottom: 0; }
.system-row.enabled { cursor: pointer; }
.system-dot { width: 9px; height: 9px; border-radius: 50%; background: #a9b3bc; }
.system-dot.live { background: var(--green); box-shadow: 0 0 0 4px rgba(20,134,90,.12); }

.search-form { margin-top: 12px; padding: 18px; border-radius: 20px; }
.search-form .field-label { margin-top: 0; }
.search-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.result-region { margin-top: 14px; }
.result-card { padding: 19px; border-radius: 20px; }
.result-card h3 { margin-bottom: 5px; }
.result-card .sku-title { color: var(--muted); line-height: 1.4; }
.stock-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin: 17px 0; }
.stock-box { padding: 13px 8px; border-radius: 14px; text-align: center; background: rgba(30,107,184,.07); }
.stock-box strong { display: block; font-size: 24px; line-height: 1.1; }
.stock-box span { display: block; margin-top: 5px; font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.detail-list { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 8px; }
.detail-row, .info-row { display: flex; justify-content: space-between; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.detail-row:last-child, .info-row:last-child { border-bottom: 0; }
.detail-row span, .info-row span { color: var(--muted); }
.detail-row strong, .info-row strong { text-align: right; word-break: break-word; }
.issue-list { margin: 14px 0 0; padding: 0; list-style: none; }
.issue-list li { padding: 8px 10px; margin-top: 6px; border-radius: 10px; background: rgba(232,166,44,.12); color: #704607; font-size: 12px; }
.component-card { margin-top: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.55); }
.result-loading, .result-error, .empty-result { padding: 22px; border-radius: 18px; text-align: center; color: var(--muted); background: rgba(255,255,255,.7); border: 1px solid var(--line); }
.result-error { color: var(--red); border-color: rgba(179,58,58,.2); }

.info-card { padding: 7px 18px; border-radius: 20px; margin-top: 12px; }
.notice-card { padding: 18px; border-radius: 18px; margin-top: 15px; }
.notice-card p { margin: 7px 0 0; color: var(--muted); line-height: 1.45; }
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(92px + env(safe-area-inset-bottom));
  z-index: 20;
  max-width: calc(100% - 34px);
  padding: 11px 15px;
  border-radius: 12px;
  background: rgba(10, 25, 40, .94);
  color: white;
  box-shadow: 0 12px 28px rgba(0,0,0,.2);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition: .18s ease;
  font-size: 13px;
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 10;
  width: min(100%, 760px);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 8px 10px calc(7px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(248,250,252,.9);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  transform: translateX(-50%);
}
.bottom-nav.hidden { display: none; }
.nav-button { min-height: 52px; border: 0; background: transparent; color: var(--muted); border-radius: 12px; }
.nav-button span { display: block; font-size: 21px; line-height: 1; }
.nav-button small { display: block; margin-top: 4px; font-size: 10px; font-weight: 700; }
.nav-button.active { color: var(--blue); background: rgba(30,107,184,.08); }

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #edf4fb;
    --muted: #9eafc0;
    --line: rgba(226, 238, 248, .12);
    --card: rgba(18, 36, 54, .94);
    --surface: #08131e;
    --shadow: 0 16px 40px rgba(0,0,0,.22);
  }
  html, body { background: #08131e; }
  body { background: radial-gradient(circle at 90% -5%, rgba(30,107,184,.25), transparent 28rem), linear-gradient(180deg,#08131e,#0c1926); }
  .status-pill { background: rgba(20,38,56,.8); }
  .text-input { background: rgba(5,16,27,.74); color: var(--ink); border-color: rgba(226,238,248,.18); }
  .bottom-nav { background: rgba(8,19,30,.88); }
  .component-card, .result-loading, .result-error, .empty-result { background: rgba(5,16,27,.35); }
}

@media (max-width: 380px) {
  .topbar { padding-left: 15px; padding-right: 15px; }
  main { padding: 0 12px; }
  h2 { font-size: 27px; }
  .status-pill { font-size: 9px; padding: 6px 8px; }
  .search-row { grid-template-columns: 1fr; }
  .primary-button.compact { width: 100%; }
  .stock-grid { grid-template-columns: 1fr 1fr 1fr; }
}
