:root {
  --bg: #f2f5fa;
  --panel: #ffffff;
  --ink: #101828;
  --muted: #6b7a90;
  --line: #e3e9f2;
  --blue: #1f6bff;
  --blue-dark: #1250d6;
  --red: #d92d20;
  --green: #0f9d58;
  --shadow: 0 10px 26px rgba(32, 61, 108, 0.1);
  --radius: 16px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  padding-bottom: env(safe-area-inset-bottom);
}

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

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: 14px 14px 32px;
}

/* 顶栏 */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 2px 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  box-shadow: 0 6px 14px rgba(18, 104, 244, 0.24);
}

.brand strong {
  display: block;
  font-size: 19px;
  font-weight: 800;
  color: var(--blue);
  line-height: 1.15;
}

.brand small {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.btn {
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  font-weight: 700;
  cursor: pointer;
}

.btn.primary {
  border-color: var(--blue);
  color: #fff;
  background: var(--blue);
  box-shadow: 0 6px 16px rgba(31, 107, 255, 0.26);
}

.btn.primary:active {
  background: var(--blue-dark);
}

.btn.wide {
  width: 100%;
}

.btn.small {
  min-height: 32px;
  padding: 0 10px;
  border-radius: 9px;
  font-size: 13px;
  color: var(--blue);
  border-color: #c3d6fb;
}

.btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

/* 顶部总览卡片 */
.hero {
  border-radius: 20px;
  padding: 18px;
  color: #fff;
  background: linear-gradient(135deg, #2a7bff 0%, #1250d6 100%);
  box-shadow: 0 14px 30px rgba(24, 82, 214, 0.28);
}

.hero-label {
  font-size: 12px;
  opacity: 0.88;
}

.hero-value {
  display: block;
  margin: 4px 0 2px;
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
}

.hero-sub {
  font-size: 11px;
  opacity: 0.8;
}

.hero-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.22);
}

.hero-grid span {
  display: block;
  font-size: 10px;
  opacity: 0.82;
}

.hero-grid strong {
  display: block;
  margin-top: 3px;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

/* 标签页 */
.tabs {
  display: flex;
  gap: 8px;
  margin: 16px 0 10px;
  padding: 4px;
  border-radius: 12px;
  background: #e7ecf5;
}

.tab {
  flex: 1;
  min-height: 38px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #46536b;
  font-weight: 700;
  cursor: pointer;
}

.tab.active {
  background: #fff;
  color: var(--blue);
  box-shadow: 0 2px 8px rgba(32, 61, 108, 0.1);
}

.status-line {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
  min-height: 16px;
}

/* 产品卡片 */
.cards {
  display: grid;
  gap: 12px;
}

.card {
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card.alert {
  box-shadow: 0 0 0 1.5px rgba(217, 45, 32, 0.32), var(--shadow);
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 14px 10px;
}

.card-code {
  font-size: 16px;
  font-weight: 800;
}

.card-name {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.card-nav {
  text-align: right;
  white-space: nowrap;
}

.card-nav strong {
  font-size: 17px;
  font-variant-numeric: tabular-nums;
}

.card-nav span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

/* 收益区 */
.profit-box {
  margin: 0 14px 10px;
  border-radius: 12px;
  padding: 12px;
  background: #f5f8fe;
}

.profit-main {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.profit-main span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.profit-main strong {
  display: block;
  margin-top: 3px;
  font-size: 20px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.profit-meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

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

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

/* 万份/年化 四格 */
.rates {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin: 0 14px 12px;
}

.rate-cell {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 6px;
  text-align: center;
}

.rate-cell span {
  display: block;
  color: var(--muted);
  font-size: 9.5px;
  white-space: nowrap;
}

.rate-cell strong {
  display: block;
  margin-top: 3px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.rate-cell.low strong {
  color: var(--red);
}

/* 净值明细折叠 */
.series {
  border-top: 1px solid var(--line);
}

.series summary {
  padding: 11px 14px;
  color: var(--blue);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}

.series summary::-webkit-details-marker {
  display: none;
}

.series summary::after {
  content: " ›";
}

.series[open] summary::after {
  content: " ⌄";
}

.series-rows {
  max-height: 216px;
  overflow-y: auto;
  padding: 0 14px 12px;
  -webkit-overflow-scrolling: touch;
}

.series-row {
  display: flex;
  justify-content: space-between;
  padding: 5px 6px;
  border-radius: 6px;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

.series-row:nth-child(odd) {
  background: #f7f9fd;
}

.tag-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 0 14px 12px;
}

.tag {
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 700;
}

.tag.ok {
  color: var(--green);
  background: #e7f7ee;
}

.tag.warn {
  color: #9a6100;
  background: #fff3d6;
}

.tag.bad {
  color: var(--red);
  background: #ffecea;
}

/* 面板 */
.panel {
  border-radius: var(--radius);
  padding: 14px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.view {
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
}

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

label {
  display: block;
  margin-bottom: 6px;
  color: #344054;
  font-size: 12.5px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #d3dbe8;
  border-radius: 10px;
  padding: 10px 11px;
  background: #fff;
  font-size: 15px;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(31, 107, 255, 0.24);
  border-color: var(--blue);
}

select {
  width: auto;
  padding: 7px 10px;
  font-size: 13px;
}

.add-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.error {
  min-height: 16px;
  margin: 6px 0 0;
  color: var(--red);
  font-size: 12px;
}

.hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

/* 产品管理列表 */
.list {
  display: grid;
  gap: 10px;
}

.item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.item-code {
  font-weight: 800;
}

.item-meta {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
}

.item-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.item-actions button {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  font-size: 12.5px;
  cursor: pointer;
}

.item-actions .danger {
  color: var(--red);
  border-color: #f3c9c5;
}

/* 导出 */
.export-panel textarea {
  min-height: 92px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  line-height: 1.5;
  white-space: pre;
  overflow: auto;
}

.export-panel .btn {
  margin-top: 10px;
}

.empty {
  padding: 40px 16px;
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

.foot {
  margin-top: 18px;
  color: #9aa6b8;
  font-size: 11px;
  text-align: center;
  line-height: 1.6;
}

/* 弹窗 */
dialog {
  width: min(520px, calc(100vw - 20px));
  max-height: 90vh;
  border: 0;
  border-radius: 18px;
  padding: 0;
  box-shadow: 0 24px 60px rgba(16, 24, 40, 0.3);
}

dialog::backdrop {
  background: rgba(16, 24, 40, 0.45);
}

dialog form {
  padding: 16px;
  max-height: 90vh;
  overflow-y: auto;
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.dialog-head h2 {
  margin: 0;
  font-size: 17px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 9px;
  background: #f1f4f9;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

dialog label {
  margin-top: 10px;
}

.holding-block {
  margin-top: 14px;
  border: 1px dashed #ccd8ea;
  border-radius: 12px;
  padding: 10px;
  background: #f7faff;
}

.holding-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 700;
}

.holding-rows {
  display: grid;
  gap: 7px;
  margin-top: 8px;
}

.holding-row {
  display: grid;
  grid-template-columns: 1fr 1.2fr 32px;
  gap: 6px;
  align-items: center;
}

.holding-row input {
  padding: 9px;
  font-size: 14px;
}

.holding-row button {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: #eef2f8;
  color: var(--muted);
  font-size: 17px;
  cursor: pointer;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

.dialog-actions button {
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
  font-weight: 700;
  cursor: pointer;
}

@media (min-width: 600px) {
  .app {
    padding-top: 24px;
  }
}
