:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #f8fbff;
  --line: #dce5f2;
  --text: #122033;
  --muted: #66758a;
  --primary: #167aff;
  --primary-2: #0f66d8;
  --primary-soft: #e8f2ff;
  --green: #12a56f;
  --green-soft: #e8f8f1;
  --red: #e54f62;
  --red-soft: #fff0f2;
  --amber: #b97816;
  --amber-soft: #fff6e6;
  color-scheme: light;
  font-family: Inter, "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  background: #edf3fb;
}

body {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 16px 0;
  background:
    radial-gradient(circle at 50% 0%, rgba(22, 122, 255, 0.18), transparent 34%),
    linear-gradient(180deg, #f7fbff, #e9f0f8);
}

button,
input,
select { font: inherit; }

button { cursor: pointer; }

.phone-shell {
  position: relative;
  width: min(100%, 430px);
  height: min(844px, calc(100dvh - 32px));
  min-height: min(680px, calc(100dvh - 32px));
  max-height: 900px;
  overflow: hidden;
  background: var(--bg);
  border: 1px solid rgba(22, 122, 255, 0.14);
  border-radius: 32px;
  box-shadow: 0 24px 70px rgba(40, 72, 110, 0.22);
}

.statusbar {
  height: 30px;
  padding: 8px 18px 0;
  display: flex;
  justify-content: space-between;
  background: var(--bg);
  color: #26364a;
  border-radius: 32px 32px 0 0;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.03em;
}

.status-icons {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 9px;
}

.status-icons i {
  position: relative;
  width: 17px;
  height: 8px;
  border: 1px solid #26364a;
  border-radius: 2px;
}

.status-icons i::after {
  content: "";
  position: absolute;
  inset: 1px 3px 1px 1px;
  background: var(--primary);
  border-radius: 1px;
}

.app {
  height: calc(100% - 102px);
  overflow-y: auto;
  padding-bottom: 22px;
  scrollbar-width: none;
}

.app::-webkit-scrollbar { display: none; }

.bottom-nav {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  height: 72px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding-bottom: max(5px, env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.94);
  border-top: 1px solid var(--line);
  box-shadow: 0 -12px 28px rgba(56, 82, 112, 0.08);
  backdrop-filter: blur(20px);
  border-radius: 0 0 32px 32px;
}

.bottom-nav button {
  border: 0;
  background: transparent;
  color: #8a98aa;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 10px;
}

.bottom-nav button.active {
  color: var(--primary);
}

svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.top {
  padding: 17px 20px 8px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
}

.overline,
.kicker {
  color: var(--primary);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.14em;
}

.top h1 {
  margin: 4px 0 4px;
  font-size: 25px;
  line-height: 1.08;
  letter-spacing: 0;
}

.top p,
.content-card > p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.65;
}

.avatar {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--primary), #65a7ff);
  color: #fff;
  box-shadow: 0 10px 24px rgba(22, 122, 255, 0.24);
  font-size: 11px;
  font-weight: 900;
}

.session-card,
.content-card,
.audit-summary {
  margin: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 10px 26px rgba(49, 76, 110, 0.08);
}

.session-card {
  padding: 15px;
  background:
    linear-gradient(135deg, rgba(22, 122, 255, 0.09), rgba(255, 255, 255, 0.96)),
    var(--surface);
}

.session-row {
  display: flex;
  align-items: center;
  gap: 11px;
}

.shield {
  width: 40px;
  height: 40px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  color: var(--primary);
  background: var(--primary-soft);
}

.session-row small {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 9px;
}

.session-row strong {
  font-size: 12px;
  color: var(--text);
  overflow-wrap: anywhere;
}

.session-state {
  margin-left: auto;
  padding: 5px 8px;
  border-radius: 10px;
  color: var(--amber);
  background: var(--amber-soft);
  font-size: 9px;
  font-weight: 800;
}

.session-state.ok {
  color: var(--green);
  background: var(--green-soft);
}

.module-map {
  margin-top: 14px;
  padding-top: 13px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 9px;
  border-top: 1px solid var(--line);
  color: #8090a4;
  font-size: 10px;
  font-weight: 800;
}

.module-map span.active { color: var(--primary); }

.module-map i {
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), #69aaff);
}

.content-card {
  padding: 18px;
}

.content-card h2 {
  margin: 7px 0 6px;
  font-size: 19px;
  line-height: 1.22;
}

.agent-pair {
  margin-top: 16px;
  display: grid;
  gap: 9px;
}

.agent-card,
.handoff,
.check {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
}

.agent-card {
  padding: 13px;
  display: grid;
  grid-template-columns: 38px 1fr auto;
  align-items: center;
  gap: 11px;
}

.agent-card > span,
.handoff > span,
.check > span {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: var(--primary);
  background: var(--primary-soft);
}

.agent-card strong,
.handoff strong,
.material strong {
  display: block;
  color: var(--text);
  font-size: 12px;
}

.agent-card small,
.handoff small,
.material small {
  color: var(--muted);
  font-size: 9px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.agent-card em {
  color: var(--green);
  font: 9px ui-monospace, SFMono-Regular, monospace;
  font-style: normal;
  font-weight: 800;
}

.notice,
.empty-state {
  margin-top: 13px;
  padding: 11px;
  border: 1px solid rgba(22, 122, 255, 0.16);
  border-radius: 12px;
  background: var(--primary-soft);
  color: #31557e;
  font-size: 10px;
  line-height: 1.6;
}

.auth-gate {
  margin-top: 15px;
  padding: 13px;
  display: flex;
  align-items: center;
  gap: 11px;
  border: 1px solid rgba(185, 120, 22, 0.2);
  border-radius: 14px;
  background: var(--amber-soft);
}

.auth-gate.passed {
  border-color: rgba(18, 165, 111, 0.22);
  background: var(--green-soft);
}

.auth-gate > span {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: var(--amber);
  background: #fff;
}

.auth-gate.passed > span {
  color: var(--green);
}

.auth-gate strong {
  display: block;
  color: var(--text);
  font-size: 12px;
}

.auth-gate small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.5;
}

.field {
  display: block;
  margin-top: 14px;
}

.field span {
  display: block;
  margin-bottom: 7px;
  color: #4f6178;
  font-size: 10px;
  font-weight: 800;
}

.field input,
.field select {
  width: 100%;
  height: 46px;
  padding: 0 13px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 13px;
  outline: none;
  font-size: 12px;
}

.field input:focus,
.field select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(22, 122, 255, 0.11);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.json {
  margin-top: 15px;
  overflow: hidden;
  background: #f7faff;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.json-head {
  height: 36px;
  padding: 0 11px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 9px;
}

.json-head b {
  color: var(--primary);
  font-family: ui-monospace, SFMono-Regular, monospace;
}

.json pre {
  margin: 0;
  max-height: 250px;
  padding: 12px;
  overflow: auto;
  color: #244263;
  font: 9px/1.65 ui-monospace, SFMono-Regular, monospace;
  white-space: pre-wrap;
}

.handoff {
  margin-top: 15px;
  padding: 13px;
  display: flex;
  align-items: center;
  gap: 11px;
}

.case-tabs {
  margin: 13px 0 0;
  padding-bottom: 3px;
  display: flex;
  gap: 7px;
  overflow-x: auto;
}

.case-tabs button {
  flex: 0 0 auto;
  padding: 8px 11px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: #fff;
  color: #63748a;
  font-size: 9px;
  font-weight: 800;
}

.case-tabs button.active {
  border-color: rgba(22, 122, 255, 0.32);
  color: var(--primary);
  background: var(--primary-soft);
}

.check-list {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}

.check {
  padding: 11px;
  display: grid;
  grid-template-columns: 25px 1fr auto;
  gap: 9px;
  align-items: center;
}

.check > span {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  color: var(--green);
  background: var(--green-soft);
}

.check svg {
  width: 14px;
  height: 14px;
}

.check strong {
  display: block;
  color: var(--text);
  font-size: 11px;
}

.check small {
  color: var(--muted);
  font-size: 8px;
}

.check em {
  color: var(--primary);
  font: 8px ui-monospace, SFMono-Regular, monospace;
  font-style: normal;
  font-weight: 800;
}

.result {
  margin-top: 15px;
  padding: 15px;
  border: 1px solid rgba(18, 165, 111, 0.22);
  border-radius: 15px;
  background: var(--green-soft);
}

.result.fail {
  border-color: rgba(229, 79, 98, 0.26);
  background: var(--red-soft);
}

.result-head {
  display: flex;
  gap: 11px;
  align-items: center;
}

.result-head > span {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--green);
  font-weight: 900;
}

.result.fail .result-head > span {
  color: #fff;
  background: var(--red);
}

.result h3 {
  margin: 0 0 4px;
  color: var(--text);
  font-size: 13px;
}

.result p {
  margin: 0;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.digest-chain {
  margin-top: 13px;
  display: grid;
  gap: 7px;
}

.digest {
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.digest span {
  color: var(--muted);
  font-size: 8px;
}

.digest b {
  display: block;
  margin-top: 3px;
  color: #174e91;
  font: 9px ui-monospace, SFMono-Regular, monospace;
  overflow-wrap: anywhere;
}

.button-row {
  margin-top: 17px;
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  gap: 9px;
}

.button-row:has(> :only-child) {
  grid-template-columns: 1fr;
}

.primary,
.secondary {
  width: 100%;
  min-height: 44px;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 900;
}

.primary {
  border: 0;
  color: #fff;
  background: var(--primary);
  box-shadow: 0 12px 24px rgba(22, 122, 255, 0.24);
}

.primary:active { background: var(--primary-2); }

.secondary {
  color: #31557e;
  background: #fff;
  border: 1px solid var(--line);
}

.audit-summary {
  padding: 14px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 7px 12px;
}

.audit-summary span {
  color: var(--muted);
  font-size: 10px;
}

.audit-summary strong {
  color: var(--text);
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, monospace;
}

.audit-list {
  padding: 0 16px;
}

.audit-item {
  position: relative;
  margin-left: 5px;
  padding: 0 0 15px 24px;
  border-left: 1px solid var(--line);
}

.audit-item::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 2px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 3px var(--bg);
}

.audit-item.fail::before { background: var(--red); }

.audit-item time {
  color: #718198;
  font: 8px ui-monospace, SFMono-Regular, monospace;
}

.audit-item strong {
  display: block;
  margin: 4px 0;
  color: var(--text);
  font-size: 11px;
}

.audit-item p {
  margin: 0;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

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

.sheet-mask[hidden] { display: none; }

.sheet {
  position: relative;
  width: min(100%, 430px);
  max-height: 82dvh;
  overflow: auto;
  padding: 8px 18px 28px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -20px 60px rgba(25, 47, 76, 0.18);
}

.sheet-handle {
  width: 40px;
  height: 4px;
  margin: 0 auto 18px;
  border-radius: 4px;
  background: #c9d5e4;
}

.sheet h2 {
  margin: 0;
  color: var(--text);
  font-size: 18px;
}

.sheet-sub {
  margin: 5px 0 14px;
  color: var(--primary);
  font-size: 9px;
}

.auth-summary {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
}

.auth-summary strong {
  display: block;
  color: var(--text);
  font-size: 13px;
}

.auth-summary small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
}

.auth-methods {
  margin: 14px 0;
  padding: 4px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  border-radius: 15px;
  background: #eef4fc;
}

.auth-methods button {
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: #68798e;
  background: transparent;
  font-size: 12px;
  font-weight: 900;
}

.auth-methods button.active {
  color: var(--primary);
  background: #fff;
  box-shadow: 0 8px 18px rgba(45, 75, 111, 0.1);
}

.auth-methods svg {
  width: 18px;
  height: 18px;
}

.fingerprint-panel {
  padding: 20px 14px 14px;
  display: grid;
  justify-items: center;
  text-align: center;
  border: 1px solid rgba(22, 122, 255, 0.14);
  border-radius: 18px;
  background: linear-gradient(180deg, #f4f9ff, #fff);
}

.fingerprint-panel > span {
  width: 72px;
  height: 72px;
  border-radius: 24px;
  display: grid;
  place-items: center;
  color: var(--primary);
  background: var(--primary-soft);
  box-shadow: inset 0 0 0 1px rgba(22, 122, 255, 0.12);
}

.fingerprint-panel svg {
  width: 38px;
  height: 38px;
}

.fingerprint-panel strong {
  margin-top: 14px;
  color: var(--text);
  font-size: 15px;
}

.fingerprint-panel small {
  margin: 7px 6px 16px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.6;
}

.pin-panel {
  padding: 16px 14px 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
}

.pin-dots {
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
}

.pin-dots i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid #b8c6d8;
  background: #fff;
}

.pin-dots i.filled {
  border-color: var(--primary);
  background: var(--primary);
}

.pin-pad {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
}

.pin-pad button {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--text);
  background: var(--surface-2);
  font-size: 14px;
  font-weight: 900;
}

.pin-panel p {
  margin: 10px 0 0;
  color: var(--muted);
  text-align: center;
  font-size: 9px;
}

.close-sheet {
  position: absolute;
  right: 20px;
  border: 0;
  color: var(--muted);
  background: transparent;
  font-size: 20px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 90px;
  z-index: 30;
  transform: translate(-50%, 15px);
  padding: 9px 15px;
  border: 1px solid rgba(22, 122, 255, 0.18);
  border-radius: 20px;
  color: #fff;
  background: #1d3558;
  opacity: 0;
  pointer-events: none;
  transition: 0.2s;
  white-space: nowrap;
  font-size: 10px;
  box-shadow: 0 10px 24px rgba(36, 63, 96, 0.18);
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(22, 122, 255, 0.28);
  outline-offset: 2px;
}

@media (min-width: 431px) {
  .phone-shell {
    height: min(900px, 94vh);
  }
}

@media (max-width: 430px) {
  .phone-shell {
    width: calc(100% - 24px);
  }
}

@media (max-width: 360px) {
  .field-row,
  .button-row {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
