:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #667085;
  --line: #d9e0ea;
  --page: #f4f6f8;
  --panel: #ffffff;
  --accent: #0f766e;
  --accent-2: #f4c95d;
  --accent-soft: #dcf2ee;
  --danger: #b42318;
  --danger-soft: #ffe5df;
  --warn: #a65700;
  --warn-soft: #fff1dc;
  --info: #2754a6;
  --info-soft: #e4ecff;
  --good: #1f7a45;
  --good-soft: #dff3e7;
  --shadow: 0 18px 42px rgba(20, 28, 38, .13);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #dce4eb;
  color: var(--ink);
  font-family: "Segoe UI", "Noto Sans TC", Arial, sans-serif;
  display: grid;
  place-items: center;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: progress;
  opacity: .72;
}

.shell {
  width: min(440px, 100%);
  min-height: 100vh;
  background: var(--page);
  display: grid;
  grid-template-rows: auto 1fr auto;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.app-header {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: calc(14px + env(safe-area-inset-top)) 16px 14px;
}

.header-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
}

h1 {
  margin: 0;
  font-size: 23px;
  line-height: 1.18;
  letter-spacing: 0;
}

.icon-button {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #eef2f6;
  color: var(--ink);
  display: grid;
  place-items: center;
  font-weight: 800;
  flex: 0 0 auto;
}

.icon-button.busy {
  color: var(--accent);
  animation: pulseBusy 1s ease-in-out infinite;
}

.score-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.score-strip article {
  border: 1px solid var(--line);
  background: #fbfcfe;
  border-radius: 8px;
  padding: 10px 9px;
  min-width: 0;
}

.score-strip strong {
  display: block;
  font-size: 20px;
  line-height: 1.08;
}

.score-strip span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.content {
  min-height: 0;
  overflow: auto;
  padding: 14px 14px 92px;
}

.search-card {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
}

.search-card input {
  width: 100%;
  min-height: 42px;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.quick-actions button,
.mini-button,
.secondary-button {
  min-height: 36px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  padding: 7px 9px;
  white-space: nowrap;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 14px 2px 8px;
}

.section-title h2 {
  margin: 0;
  font-size: 15px;
}

.section-title span {
  color: var(--muted);
  font-size: 12px;
}

.event-list {
  display: grid;
  gap: 10px;
}

.event-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 10px;
  cursor: pointer;
}

.event-card:focus-within,
.event-card:hover {
  border-color: #b9c5d4;
}

.event-top {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: start;
  gap: 10px;
}

.badge {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-weight: 800;
}

.tone-danger { color: var(--danger); background: var(--danger-soft); }
.tone-warn { color: var(--warn); background: var(--warn-soft); }
.tone-info { color: var(--info); background: var(--info-soft); }
.tone-good { color: var(--good); background: var(--good-soft); }

.event-card h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.event-meta {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.amount {
  font-weight: 800;
  white-space: nowrap;
  font-size: 14px;
}

.source {
  color: #475467;
  font-size: 12px;
  border-top: 1px solid #edf0f4;
  padding-top: 9px;
}

.event-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.primary-button,
.small-primary {
  min-height: 38px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  padding: 7px 10px;
  white-space: nowrap;
}

.small-secondary {
  min-height: 38px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #f8fafc;
  color: var(--ink);
  padding: 7px 10px;
  white-space: nowrap;
}

.small-primary:disabled,
.small-secondary:disabled {
  box-shadow: inset 0 0 0 1px rgba(15, 118, 110, .08);
}

@keyframes pulseBusy {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(.94); }
}

.privacy-card,
.danger-zone {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  margin-bottom: 10px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.privacy-card h3,
.danger-zone h3 {
  margin: 0 0 4px;
  font-size: 15px;
}

.privacy-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.status-pill {
  border-radius: 999px;
  background: #eef2f6;
  color: var(--muted);
  font-size: 12px;
  padding: 3px 9px;
  white-space: nowrap;
}

.status-pill.good {
  color: var(--good);
  background: var(--good-soft);
}

.danger-zone {
  display: grid;
}

.outline-danger {
  min-height: 38px;
  border: 1px solid #ffc9c1;
  border-radius: 8px;
  background: #fff8f6;
  color: var(--danger);
}

.bottom-nav {
  height: calc(72px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(255,255,255,.96);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  padding: 7px 8px calc(9px + env(safe-area-inset-bottom));
}

.bottom-nav button {
  background: transparent;
  color: var(--muted);
  display: grid;
  gap: 2px;
  place-items: center;
  font-size: 11px;
}

.bottom-nav b {
  font-size: 18px;
  line-height: 1;
}

.bottom-nav button.active {
  color: var(--accent);
  font-weight: 700;
}

.hidden {
  display: none;
}

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(16,24,40,.38);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease;
}

.scrim.open {
  opacity: 1;
  pointer-events: auto;
}

.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  width: min(440px, 100%);
  transform: translate(-50%, 110%);
  background: var(--panel);
  border-radius: 20px 20px 0 0;
  border: 1px solid var(--line);
  padding: 10px 16px calc(16px + env(safe-area-inset-bottom));
  box-shadow: 0 -18px 42px rgba(16,24,40,.18);
  transition: transform .18s ease;
  z-index: 3;
  max-height: 78vh;
  overflow: auto;
}

.sheet.open {
  transform: translate(-50%, 0);
}

.sheet-handle {
  width: 42px;
  height: 4px;
  border-radius: 999px;
  background: #ccd3dd;
  margin: 0 auto 12px;
}

.sheet h2 {
  margin: 0 0 10px;
  font-size: 18px;
}

.sheet-row {
  display: grid;
  grid-template-columns: 108px 1fr;
  gap: 8px;
  border-top: 1px solid #edf0f4;
  padding: 9px 0;
  font-size: 13px;
}

.sheet-row span:first-child {
  color: var(--muted);
}

.sheet-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 88px;
  transform: translate(-50%, 20px);
  width: min(392px, calc(100% - 28px));
  background: #17202a;
  color: #fff;
  border-radius: 8px;
  padding: 11px 13px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity .16s ease, transform .16s ease;
  z-index: 4;
  font-size: 13px;
}

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

.legal-page {
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.legal-page h1 {
  margin: 0;
  font-size: 28px;
}

.legal-page h2 {
  margin: 0 0 8px;
  font-size: 18px;
}

@media (min-width: 700px) {
  body {
    padding: 24px;
  }

  .shell {
    min-height: min(880px, calc(100vh - 48px));
    max-height: 880px;
    border: 10px solid #101820;
    border-radius: 34px;
  }
}
