:root {
  color-scheme: light;
  --bg: #f6f7f3;
  --surface: #ffffff;
  --surface-2: #eef4f2;
  --ink: #17211e;
  --muted: #63706c;
  --line: #dbe2dd;
  --green: #0a7a55;
  --red: #b73736;
  --blue: #275f9f;
  --gold: #a56b1d;
  --shadow: 0 18px 45px rgba(26, 36, 32, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

[hidden] {
  display: none !important;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.auth-screen {
  position: relative;
  overflow: hidden;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(23, 33, 30, 0.05) 25%, transparent 25%) 0 0 / 22px 22px,
    linear-gradient(315deg, rgba(10, 122, 85, 0.05) 25%, transparent 25%) 0 0 / 26px 26px,
    #f3f6f1;
}

.auth-ambient {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(120deg, rgba(23, 33, 30, 0.93), rgba(31, 73, 63, 0.9)) top / 100% 42% no-repeat,
    linear-gradient(180deg, transparent 0, rgba(255, 255, 255, 0.34) 42%, transparent 100%);
  pointer-events: none;
}

.auth-card {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 24px 70px rgba(23, 33, 30, 0.2);
  padding: 20px;
  backdrop-filter: blur(16px);
}

.auth-brand {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}

.auth-brand img {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  box-shadow: 0 10px 24px rgba(23, 33, 30, 0.18);
}

.auth-brand h1 {
  font-size: 30px;
  margin-bottom: 5px;
}

.auth-brand p {
  color: var(--muted);
  font-weight: 700;
}

.auth-market-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.auth-market-strip span,
.auth-market-strip strong {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
}

.auth-market-strip strong {
  background: rgba(183, 55, 54, 0.1);
  color: var(--red);
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.auth-tabs button,
.auth-form button,
.text-btn {
  border-radius: 8px;
  min-height: 42px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  font-weight: 800;
}

.auth-tabs button {
  transition: background 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.auth-tabs button[aria-selected="true"],
.auth-form button {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.auth-form {
  display: grid;
  gap: 12px;
}

.auth-form label {
  display: grid;
  gap: 7px;
}

.auth-form label span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.auth-form input {
  min-height: 48px;
  background: #fbfcfb;
}

.auth-form input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(10, 122, 85, 0.12);
}

.auth-form button {
  min-height: 48px;
  margin-top: 2px;
  font-size: 16px;
}

.auth-form button:disabled {
  opacity: 0.68;
  cursor: wait;
}

.auth-message {
  margin-top: 12px;
  min-height: 22px;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.45;
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 104px;
  padding: 24px 0;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 48px);
  line-height: 1;
}

.topbar p {
  margin-top: 10px;
  color: var(--muted);
}

.topbar-note {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 0 16px;
  font-weight: 700;
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.mobile-tabbar {
  display: none;
}

.primary-btn,
.stack-form button,
.icon-btn {
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  min-height: 42px;
  padding: 0 18px;
}

.primary-btn {
  min-width: 132px;
  font-weight: 700;
}

.primary-btn:disabled {
  cursor: wait;
  opacity: 0.65;
}

.icon-btn:disabled {
  cursor: default;
  opacity: 0.58;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.summary-grid article,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.summary-grid article {
  min-height: 92px;
  padding: 18px;
}

.summary-grid span,
.field span,
.meta,
.news-source {
  color: var(--muted);
  font-size: 13px;
}

.summary-grid strong {
  display: block;
  margin-top: 10px;
  font-size: 24px;
}

.workspace {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.panel {
  padding: 18px;
}

.side-panel {
  position: sticky;
  top: 16px;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-title h2 {
  font-size: 20px;
}

.icon-btn {
  min-height: 34px;
  padding: 0 12px;
  background: var(--surface-2);
  color: var(--ink);
  border-color: var(--line);
}

.field,
.stack-form {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.account-user,
.mode-control,
.push-control {
  margin-bottom: 16px;
}

.account-user {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 12px;
}

.account-user span {
  color: var(--muted);
  font-size: 13px;
}

.account-user strong {
  font-size: 18px;
}

.account-user .text-btn {
  grid-row: span 2;
  padding: 0 12px;
}

.mode-control {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.mode-control legend {
  padding: 0 4px;
  color: var(--muted);
  font-size: 13px;
}

.mode-control label {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  border-radius: 8px;
  padding: 8px;
}

.mode-control label:has(input:checked) {
  background: var(--surface-2);
}

.mode-control input {
  width: auto;
  margin-top: 4px;
}

.mode-control span {
  display: grid;
  gap: 3px;
}

.mode-control small {
  color: var(--muted);
  line-height: 1.35;
}

.push-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.push-control div {
  display: grid;
  gap: 4px;
}

.push-control strong {
  font-size: 15px;
}

.push-control span {
  color: var(--muted);
  font-size: 13px;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
}

textarea {
  resize: vertical;
}

.stack-form {
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.stack-form h3 {
  font-size: 15px;
}

.stack-note {
  color: var(--muted);
  line-height: 1.5;
  font-size: 14px;
}

.main-column {
  display: grid;
  gap: 16px;
}

.two-column {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
}

.pill,
.action-pill,
.refresh-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.refresh-btn {
  border: 1px solid var(--line);
  font-weight: 800;
}

.refresh-btn:not(:disabled) {
  background: var(--ink);
  color: #fff;
}

.refresh-btn:disabled {
  cursor: wait;
  opacity: 0.68;
}

.recommendations,
.command-board,
.holdings-list,
.trade-list,
.news-list,
.market-box {
  display: grid;
  gap: 10px;
}

.rec-card,
.command-card,
.holding-row,
.trade-row,
.news-row,
.index-row,
.hexagram-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.command-card {
  display: grid;
  gap: 14px;
  border-width: 2px;
  padding: 22px;
}

.command-card h3 {
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.12;
  overflow-wrap: anywhere;
}

.initial-sync-card {
  display: grid;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 18px;
  box-shadow: 0 14px 32px rgba(26, 36, 32, 0.08);
}

.sync-head {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.sync-head span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.sync-head h3 {
  margin-top: 3px;
  font-size: 24px;
  line-height: 1.15;
}

.sync-spinner {
  width: 42px;
  height: 42px;
  border: 4px solid var(--surface-2);
  border-top-color: var(--green);
  border-right-color: var(--red);
  border-radius: 999px;
  animation: sync-spin 0.9s linear infinite;
}

.initial-sync-card p {
  color: var(--muted);
  line-height: 1.5;
}

.sync-progress {
  overflow: hidden;
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
}

.sync-progress i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--gold), var(--red));
  transition: width 0.3s ease;
}

.sync-log {
  display: grid;
  gap: 8px;
  max-height: 220px;
  overflow: auto;
  margin: 0;
  padding: 0;
  list-style: none;
}

.sync-log li {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  border: 1px solid rgba(23, 33, 30, 0.08);
  border-radius: 8px;
  background: rgba(238, 244, 242, 0.6);
  padding: 9px 10px;
}

.sync-log span {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.sync-log strong {
  color: var(--ink);
  font-size: 13px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.sync-log li.done {
  border-color: rgba(10, 122, 85, 0.18);
  background: rgba(10, 122, 85, 0.08);
}

.sync-log li.pending {
  border-color: rgba(165, 107, 29, 0.18);
  background: rgba(165, 107, 29, 0.08);
}

.sync-log li.error {
  border-color: rgba(183, 55, 54, 0.22);
  background: rgba(183, 55, 54, 0.08);
}

@keyframes sync-spin {
  to {
    transform: rotate(360deg);
  }
}

.command-label {
  width: fit-content;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 700;
}

.command-detail {
  color: var(--ink);
  font-size: 18px;
  line-height: 1.5;
}

.command-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.command-metrics div {
  min-height: 72px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(23, 33, 30, 0.1);
  padding: 12px;
}

.command-metrics span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.command-metrics strong {
  display: block;
  margin-top: 6px;
  font-size: 18px;
  overflow-wrap: anywhere;
}

.command-reason {
  display: grid;
  gap: 6px;
  color: var(--muted);
  line-height: 1.45;
}

.live-guide {
  display: grid;
  gap: 10px;
}

.guide-total,
.guide-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.guide-total {
  display: grid;
  gap: 6px;
}

.guide-total span,
.guide-total p {
  color: var(--muted);
}

.guide-total strong {
  font-size: 30px;
}

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

.command-section {
  display: grid;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid rgba(23, 33, 30, 0.12);
}

.command-section h4 {
  margin: 0;
  font-size: 18px;
}

.command-detail.small {
  font-size: 16px;
}

.order-list {
  display: grid;
  gap: 8px;
}

.order-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  border: 1px solid rgba(23, 33, 30, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.75);
  padding: 12px;
}

.order-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-weight: 700;
}

.order-main {
  display: grid;
  gap: 5px;
}

.order-main strong {
  font-size: 18px;
}

.order-main span {
  color: var(--muted);
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.order-action {
  align-self: center;
  min-width: 88px;
  min-height: 42px;
  border: 1px solid rgba(23, 33, 30, 0.12);
  border-radius: 8px;
  color: #fff;
  font-weight: 800;
  padding: 0 14px;
}

.order-action.BUY {
  background: var(--red);
  color: #fff;
}

.order-action.SELL {
  background: var(--green);
  color: #fff;
}

.order-action:disabled {
  background: #e3e9e5;
  color: var(--ink);
  border-color: #c4cec8;
  cursor: default;
}

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

.stock-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.stock-title strong {
  font-size: 18px;
}

.price-line,
.metrics,
.reason-list {
  margin-top: 10px;
}

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

.metric {
  min-height: 58px;
  border-radius: 8px;
  background: var(--surface-2);
  padding: 9px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  display: block;
  margin-top: 4px;
}

.reason-list {
  padding-left: 18px;
  color: var(--muted);
}

.reason-list li {
  margin: 5px 0;
}

.BUY {
  color: var(--red);
  background: rgba(183, 55, 54, 0.1);
}

.SELL {
  color: var(--green);
  background: rgba(10, 122, 85, 0.1);
}

.HOLD {
  color: var(--blue);
  background: rgba(39, 95, 159, 0.1);
}

.positive {
  color: var(--red);
}

.negative {
  color: var(--green);
}

.empty-state {
  color: var(--muted);
  min-height: 64px;
  align-content: center;
}

.news-row a {
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
}

.news-row p {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.news-row a,
.news-row strong,
.holding-row,
.trade-row,
.guide-row {
  overflow-wrap: anywhere;
}

.hexagram-box {
  border-color: rgba(165, 107, 29, 0.35);
  background: #fffaf1;
}

.hexagram-box strong {
  color: var(--gold);
}

@media (max-width: 1100px) {
  .workspace,
  .two-column {
    grid-template-columns: 1fr;
  }

  .side-panel {
    position: static;
  }
}

@media (max-width: 760px) {
  body {
    padding-bottom: calc(74px + env(safe-area-inset-bottom));
  }

  .app-shell {
    padding: 12px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
    min-height: 0;
    gap: 12px;
    padding: 10px 0 12px;
  }

  h1 {
    font-size: 30px;
  }

  .topbar p {
    margin-top: 6px;
    font-size: 13px;
    line-height: 1.35;
  }

  .topbar-actions {
    justify-content: stretch;
    gap: 8px;
  }

  .topbar-actions .icon-btn,
  .topbar-actions .topbar-note {
    flex: 1 1 148px;
    justify-content: center;
    min-height: 38px;
    padding-inline: 10px;
    font-size: 13px;
  }

  .primary-btn {
    width: 100%;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin: 0 -2px 10px;
    padding: 0 2px 8px;
    background: transparent;
  }

  .metrics,
  .command-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .panel,
  .summary-grid article {
    padding: 14px;
  }

  .command-card {
    padding: 16px;
  }

  .summary-grid article {
    min-height: 72px;
    padding: 12px;
    box-shadow: 0 10px 24px rgba(26, 36, 32, 0.06);
  }

  .summary-grid strong {
    margin-top: 6px;
    font-size: 18px;
    line-height: 1.15;
    overflow-wrap: anywhere;
  }

  .workspace {
    display: block;
  }

  .main-column {
    gap: 12px;
  }

  .two-column {
    display: block;
  }

  [data-mobile-panel] {
    display: none;
  }

  body[data-mobile-tab="daily"] [data-mobile-panel~="daily"],
  body[data-mobile-tab="portfolio"] [data-mobile-panel~="portfolio"],
  body[data-mobile-tab="account"] [data-mobile-panel~="account"],
  body[data-mobile-tab="market"] [data-mobile-panel~="market"],
  body[data-mobile-tab="records"] [data-mobile-panel~="records"] {
    display: block;
  }

  body[data-mobile-tab="daily"] .summary-grid[data-mobile-panel~="daily"] {
    display: grid;
  }

  body[data-mobile-tab="portfolio"] [data-mobile-panel~="portfolio"] + [data-mobile-panel~="portfolio"],
  body[data-mobile-tab="market"] [data-mobile-panel~="market"] + [data-mobile-panel~="market"] {
    margin-top: 12px;
  }

  .mobile-tabbar {
    position: fixed;
    right: 10px;
    bottom: calc(8px + env(safe-area-inset-bottom));
    left: 10px;
    z-index: 20;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
    min-height: 58px;
    border: 1px solid rgba(23, 33, 30, 0.12);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 12px 32px rgba(23, 33, 30, 0.18);
    padding: 7px;
    backdrop-filter: blur(16px);
  }

  .mobile-tabbar button {
    min-width: 0;
    min-height: 44px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
  }

  .mobile-tabbar button[aria-selected="true"] {
    background: var(--ink);
    color: #fff;
  }

  .command-card h3 {
    font-size: 26px;
  }

  .command-detail {
    font-size: 16px;
  }

  .command-section h4 {
    font-size: 16px;
  }

  .guide-row {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-width: 460px) {
  .metrics,
  .command-metrics {
    grid-template-columns: 1fr;
  }

  .rec-head,
  .row-head {
    align-items: stretch;
    flex-direction: column;
  }

  .order-row {
    grid-template-columns: 32px minmax(0, 1fr);
    align-items: stretch;
    padding: 10px;
  }

  .order-action {
    grid-column: 1 / -1;
    width: 100%;
    min-height: 44px;
  }

  .panel-title {
    align-items: stretch;
    flex-direction: column;
  }

  .panel-title .pill,
  .panel-title .icon-btn {
    width: 100%;
  }
}
