:root {
  color-scheme: light;
  font-family: "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: #f5f7f7;
  color: #162927;
}

* { box-sizing: border-box; }

html,
body {
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
}

body { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }

button,
input { font: inherit; }

button { -webkit-tap-highlight-color: transparent; }

.app-shell {
  width: min(100%, 560px);
  margin: 0 auto;
  padding: 18px 16px 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 32px;
  margin-bottom: 20px;
}

.brand {
  color: #155d56;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: .02em;
}

.badge {
  border-radius: 999px;
  background: #dcefe9;
  color: #0d655b;
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 750;
}

.page { display: none; }
.page.active { display: block; }

.page-heading { margin-bottom: 18px; }

.page-heading h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.2;
  letter-spacing: -.025em;
}

.page-heading p {
  margin: 7px 0 0;
  color: #60736f;
  font-size: 15px;
  line-height: 1.5;
}

.card {
  margin-bottom: 12px;
  border: 1px solid #e1ebe9;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 3px 12px rgb(15 118 110 / 5%);
  padding: 17px;
}

.card h2 {
  margin: 3px 0 7px;
  font-size: 19px;
  line-height: 1.35;
}

.card p { margin: 5px 0; line-height: 1.55; }

.eyebrow,
.muted {
  margin: 0;
  color: #657773;
  font-size: 14px;
  line-height: 1.45;
}

.status-card { border-left: 5px solid #0f766e; }

.money {
  margin: 2px 0 0 !important;
  color: #0d7469;
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -.05em;
}

.home-watchlist-link {
  display: grid;
  width: 100%;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 12px;
  color: #155d56;
  text-align: left;
  cursor: pointer;
  background: #ecf8f5;
  border-color: #cbe3de;
}

.home-watchlist-link strong {
  align-self: center;
  font-size: 18px;
}

.home-watchlist-link small {
  grid-column: 1 / -1;
  color: #4d7972;
  font-size: 14px;
}

.input-row {
  display: flex;
  gap: 10px;
  margin: 0 0 12px;
}

.input-row input {
  min-width: 0;
  flex: 1;
  height: 50px;
  border: 1px solid #bfcecb;
  border-radius: 12px;
  background: #fff;
  padding: 0 14px;
  color: inherit;
  font-size: 16px;
}

.input-row input:focus { outline: 3px solid #bfe2db; border-color: #0f766e; }

.input-row button,
.watchlist button {
  min-height: 48px;
  border: 0;
  border-radius: 12px;
  background: #0f766e;
  color: #fff;
  padding: 10px 16px;
  font-weight: 750;
  cursor: pointer;
}

.input-row button:active,
.watchlist button:active,
.home-watchlist-link:active { transform: translateY(1px); }

.demo {
  margin: 0;
  border-radius: 10px;
  background: #fff5df;
  color: #845000;
  padding: 10px 12px;
  font-size: 14px;
}

.watchlist {
  margin: 12px 0 0;
  padding: 0 0 12px;
  list-style: none;
}

.watchlist li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
  border: 1px solid #e3ecea;
  border-radius: 13px;
  background: #fff;
  padding: 13px;
}

.watchlist li > div:first-child { min-width: 0; }

.watchlist strong,
.watchlist small { display: block; }

.watchlist strong { font-size: 17px; letter-spacing: .04em; }

.watchlist small { margin-top: 3px; color: #667874; font-size: 14px; }

.watchlist-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 7px;
  align-items: center;
}

.watchlist button {
  min-height: 40px;
  border: 1px solid #d5e2df;
  background: #eef4f3;
  color: #35514d;
  padding: 7px 11px;
  font-size: 14px;
}

.watchlist button.confirm-delete { border-color: #a63d1e; background: #ad3a17; color: #fff; }
.watchlist button.cancel-delete { background: #fff; }

.empty-watchlist {
  display: grid !important;
  justify-content: start !important;
  gap: 4px;
  min-height: 100px;
  align-content: center;
  color: #536662;
}

.disabled { background: #f8faf9; }

.placeholder-table {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.placeholder-table span {
  border-radius: 10px;
  background: #eaf1f0;
  padding: 12px;
  color: #62736f;
  font-size: 14px;
}

.research-list { margin: 0; }

.research-list div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid #edf2f1;
  padding: 10px 0;
}

.research-list div:last-child { border-bottom: 0; }
.research-list dt { flex: 0 0 82px; color: #647571; }
.research-list dd { margin: 0; text-align: right; font-weight: 650; }
.details dd { max-width: 65%; }

summary { cursor: pointer; font-size: 17px; font-weight: 750; }

.bottom-nav {
  position: fixed;
  z-index: 10;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 3px;
  border-top: 1px solid #dfe9e7;
  background: rgb(255 255 255 / 96%);
  padding: 8px max(8px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  backdrop-filter: blur(10px);
}

.nav-item {
  min-width: 0;
  min-height: 48px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #667773;
  padding: 9px 3px;
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
}

.nav-item.active { background: #e6f4f1; color: #0f766e; font-weight: 800; }

.toast {
  position: fixed;
  z-index: 20;
  right: 16px;
  bottom: calc(84px + env(safe-area-inset-bottom));
  left: 16px;
  width: min(calc(100% - 32px), 528px);
  margin: 0 auto;
  border: 1px solid #c8e0db;
  border-radius: 12px;
  background: #effaf7;
  box-shadow: 0 8px 24px rgb(20 51 47 / 16%);
  color: #145a52;
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.45;
}

.toast[data-tone="error"] { border-color: #f0c7bc; background: #fff1ee; color: #8b301d; }
.toast[data-tone="notice"] { border-color: #efddab; background: #fff8e8; color: #7a5800; }

.home-portfolio-summary {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: -1px 3px 13px;
  color: #647571;
  font-size: 14px;
}

.home-portfolio-summary strong { color: #1f4842; }
.home-portfolio-summary span { text-align: right; }

.manual-ledger-note {
  margin: 4px 0 15px !important;
  color: #617470;
  font-size: 14px;
}

.position-form,
.cash-form {
  display: grid;
  gap: 10px;
}

.position-form label,
.cash-form label {
  display: grid;
  gap: 6px;
  color: #4f625e;
  font-size: 14px;
  font-weight: 700;
}

.position-form input,
.cash-form input {
  width: 100%;
  min-width: 0;
  height: 48px;
  border: 1px solid #bfcecb;
  border-radius: 12px;
  background: #fff;
  padding: 0 13px;
  color: inherit;
  font-size: 16px;
}

.position-form input:focus,
.cash-form input:focus { outline: 3px solid #bfe2db; border-color: #0f766e; }

.position-form input[readonly] { background: #f0f5f4; color: #61736f; }

.form-actions,
.portfolio-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.form-actions button,
.cash-card > button,
.portfolio-actions button {
  min-height: 44px;
  border: 0;
  border-radius: 11px;
  background: #0f766e;
  color: #fff;
  padding: 9px 13px;
  font-weight: 750;
  cursor: pointer;
}

.secondary-button,
.portfolio-actions .secondary-button {
  border: 1px solid #d2e0dd !important;
  background: #eef4f3 !important;
  color: #35514d !important;
}

.portfolio-actions .confirm-delete {
  border-color: #a63d1e !important;
  background: #ad3a17 !important;
  color: #fff !important;
}

.portfolio-list {
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.portfolio-list > li {
  margin-top: 10px;
  border: 1px solid #e3ecea;
  border-radius: 13px;
  background: #fff;
  padding: 14px;
}

.position-heading { display: flex; justify-content: space-between; gap: 12px; }
.position-heading strong { color: #1d3733; font-size: 18px; letter-spacing: .04em; }

.position-details {
  display: grid;
  gap: 7px;
  margin: 12px 0;
}

.position-details div { display: flex; justify-content: space-between; gap: 12px; }
.position-details dt { color: #697b77; font-size: 14px; }
.position-details dd { margin: 0; text-align: right; font-weight: 700; }

.lot-notice {
  border-radius: 8px;
  background: #fff5df;
  color: #845000;
  padding: 7px 9px;
  font-size: 13px;
}

.empty-portfolio {
  display: grid;
  min-height: 92px;
  align-content: center;
  gap: 4px;
  color: #536662;
}

.empty-portfolio small { color: #667874; }

.cash-card { display: grid; gap: 8px; }

.cash-amount {
  color: #0d7469;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -.04em;
}

.cash-card > button { justify-self: start; }

.logout-button {
  min-height: 42px;
  margin-top: 14px;
  border: 1px solid #d2e0dd;
  border-radius: 11px;
  background: #eef4f3;
  color: #35514d;
  padding: 8px 13px;
  font-weight: 750;
  cursor: pointer;
}

.login-body {
  display: grid;
  min-height: 100vh;
  padding: 20px 16px;
  background: #f5f7f7;
  place-items: center;
}

.login-shell { width: min(100%, 400px); }

.login-card {
  border: 1px solid #e1ebe9;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 7px 24px rgb(15 118 110 / 8%);
  padding: 22px;
}

.login-card h1 { margin: 6px 0; font-size: 28px; }
.login-card > p:not(.brand):not(.login-error) { margin: 0 0 18px; color: #60736f; line-height: 1.55; }

.login-form { display: grid; gap: 13px; }

.login-form label {
  display: grid;
  gap: 6px;
  color: #4f625e;
  font-size: 14px;
  font-weight: 700;
}

.login-form input {
  width: 100%;
  min-width: 0;
  height: 48px;
  border: 1px solid #bfcecb;
  border-radius: 12px;
  padding: 0 13px;
  font-size: 16px;
}

.login-form input:focus { outline: 3px solid #bfe2db; border-color: #0f766e; }

.login-form button {
  min-height: 48px;
  border: 0;
  border-radius: 12px;
  background: #0f766e;
  color: #fff;
  font-weight: 750;
  cursor: pointer;
}

.login-error {
  margin: 0 0 14px;
  border-radius: 10px;
  background: #fff1ee;
  color: #8b301d;
  padding: 10px 12px;
  font-size: 14px;
}

@media (max-width: 430px) {
  .app-shell { padding-inline: 15px; }
}

@media (max-width: 390px) {
  .app-shell { padding-inline: 14px; }
  .page-heading h1 { font-size: 27px; }
  .money { font-size: 34px; }
}

@media (max-width: 375px) {
  .app-shell { padding-inline: 12px; }
  .bottom-nav { gap: 1px; }
  .nav-item { font-size: 13px; }
  .research-list div { gap: 10px; }
  .research-list dt { flex-basis: 72px; }
  .research-list dd { font-size: 14px; }
}

@media (max-width: 320px) {
  .app-shell { padding-inline: 10px; }
  .topbar { margin-bottom: 16px; }
  .page-heading h1 { font-size: 25px; }
  .page-heading p { font-size: 14px; }
  .input-row { flex-direction: column; }
  .input-row button { width: 100%; }
  .placeholder-table { grid-template-columns: 1fr; }
  .watchlist li { align-items: flex-start; flex-direction: column; }
  .watchlist-actions { width: 100%; }
  .watchlist-actions button { flex: 1; }
  .home-portfolio-summary { align-items: flex-start; flex-direction: column; gap: 3px; }
  .home-portfolio-summary span { text-align: left; }
  .portfolio-actions { width: 100%; }
  .portfolio-actions button { flex: 1; }
  .nav-item { padding-inline: 1px; font-size: 12px; }
}
