:root {
  color-scheme: light;
  --bg: #eaf2f8;
  --panel: rgba(255, 255, 255, 0.62);
  --panel-strong: rgba(255, 255, 255, 0.78);
  --line: rgba(78, 118, 150, 0.18);
  --line-strong: rgba(49, 127, 177, 0.28);
  --text: #0c1d30;
  --muted: #60758a;
  --blue: #1976d2;
  --cyan: #00a6c8;
  --green: #00896b;
  --red: #e03b3b;
  --income-up-bg: #ffd1d1;
  --income-up-border: #ff4d4f;
  --income-down-bg: #b7eadf;
  --income-down-border: #12a884;
  --shadow: 0 24px 70px rgba(36, 71, 102, 0.18);
  --radius: 18px;
  --font: Inter, "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #07111f;
  --panel: rgba(15, 28, 45, 0.6);
  --panel-strong: rgba(19, 36, 58, 0.76);
  --line: rgba(140, 210, 255, 0.16);
  --line-strong: rgba(90, 193, 255, 0.32);
  --text: #edf7ff;
  --muted: #93a8bd;
  --blue: #64b5ff;
  --cyan: #3ce4ff;
  --green: #32d296;
  --red: #ff6565;
  --income-up-bg: rgba(255, 78, 80, 0.34);
  --income-up-border: rgba(255, 105, 105, 0.9);
  --income-down-bg: rgba(18, 168, 132, 0.34);
  --income-down-border: rgba(52, 224, 181, 0.88);
  --shadow: 0 26px 80px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

body {
  min-width: 1120px;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  background:
    radial-gradient(circle at 12% 8%, rgba(50, 150, 255, 0.24), transparent 32%),
    radial-gradient(circle at 92% 14%, rgba(20, 210, 185, 0.2), transparent 30%),
    linear-gradient(135deg, var(--bg), color-mix(in srgb, var(--bg) 78%, #ffffff));
}

body.modal-open {
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.ambient {
  position: fixed;
  pointer-events: none;
  filter: blur(4px);
}

.ambient-a {
  inset: 80px auto auto 4%;
  width: 220px;
  height: 220px;
  border-radius: 999px;
  background: rgba(0, 166, 200, 0.16);
}

.ambient-b {
  right: 8%;
  bottom: 6%;
  width: 280px;
  height: 280px;
  border-radius: 999px;
  background: rgba(25, 118, 210, 0.14);
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
  padding: 12px 0 22px;
}

.glass {
  border: 1px solid var(--line);
  background: linear-gradient(135deg, var(--panel-strong), var(--panel));
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
}

.topbar {
  position: sticky;
  top: 8px;
  z-index: 120;
  display: grid;
  grid-template-columns: 230px minmax(300px, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-radius: 16px;
}

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

.brand img {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border: 1px solid color-mix(in srgb, var(--line-strong) 76%, transparent);
  border-radius: 12px;
  background: color-mix(in srgb, var(--panel-strong) 82%, transparent);
  box-shadow: 0 10px 24px rgba(36, 71, 102, 0.12);
  object-fit: cover;
}

.brand div {
  min-width: 0;
}

.brand span {
  display: block;
  color: var(--cyan);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.brand strong {
  display: block;
  margin-top: 4px;
  font-size: 19px;
}

.search-box,
.filter-box {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: color-mix(in srgb, var(--panel-strong) 82%, transparent);
}

.search-box {
  z-index: 130;
}

.search-box:focus-within,
.filter-box:focus-within {
  border-color: var(--cyan);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--cyan) 16%, transparent);
}

.search-box svg,
.filter-box svg {
  width: 18px;
  height: 18px;
  color: var(--cyan);
}

input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.top-actions,
.dialog-actions,
.row-actions,
.section-head,
.layout-toggle {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.icon-btn,
.soft-btn,
.primary-btn,
.tabs button,
.layout-toggle button,
.sort-menu > button,
select {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--panel-strong) 78%, transparent);
  color: var(--text);
  white-space: nowrap;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.icon-btn {
  width: 36px;
  padding: 0;
}

.icon-btn.ghost {
  width: 30px;
  height: 30px;
  border: 0;
  background: transparent;
}

.soft-btn,
.primary-btn,
.tabs button {
  padding: 0 14px;
}

.primary-btn {
  border-color: transparent;
  background: linear-gradient(135deg, var(--blue), var(--cyan));
  color: #fff;
  font-weight: 900;
}

.icon-btn:hover,
.soft-btn:hover,
.tabs button:hover,
.layout-toggle button:hover,
.sort-menu > button:hover,
select:hover {
  transform: translateY(-1px);
  border-color: var(--cyan);
}

button:disabled,
.sort-options button:disabled {
  cursor: not-allowed;
  opacity: 0.46;
  filter: grayscale(0.45);
}

button:disabled:hover,
.sort-options button:disabled:hover {
  transform: none;
  border-color: var(--line);
  background: color-mix(in srgb, var(--panel-strong) 78%, transparent);
  color: var(--muted);
}

.refresh-menu[data-locked="true"] > button {
  border-color: var(--line);
  background: color-mix(in srgb, var(--panel-strong) 48%, transparent);
  color: var(--muted);
  box-shadow: none;
}

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

button svg,
label svg {
  width: 17px;
  height: 17px;
}

.file-import input {
  display: none;
}

.search-panel {
  position: absolute;
  z-index: 220;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  max-height: min(360px, calc(100vh - 150px));
  overflow: auto;
  padding: 8px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--bg) 88%, #ffffff);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.search-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.search-item:hover {
  background: color-mix(in srgb, var(--cyan) 12%, transparent);
}

.search-item strong,
.search-item small {
  display: block;
}

.search-item small,
.search-state {
  color: var(--muted);
  font-size: 12px;
}

.search-item b {
  flex: 0 0 auto;
  color: var(--text);
  font-size: 12px;
}

.search-item span:first-child {
  min-width: 0;
}

.search-item strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-state {
  padding: 12px;
}

.workspace {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

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

.metric-card {
  min-height: 92px;
  padding: 14px;
  border-radius: 16px;
  overflow: hidden;
}

.metric-card span,
.metric-card small {
  color: var(--muted);
  font-size: 13px;
}

#todayRate {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.metric-card .countdown-badge {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 7px;
  border: 1px solid color-mix(in srgb, var(--cyan) 36%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--cyan) 12%, transparent);
  color: var(--cyan);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.metric-card strong {
  display: block;
  margin: 8px 0 5px;
  font-size: 25px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.control-panel {
  position: relative;
  z-index: 30;
  display: grid;
  grid-template-columns: auto minmax(260px, 1fr) 170px 150px auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 16px;
}

.tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--panel-strong) 54%, transparent);
  overflow: auto;
}

.tabs button {
  position: relative;
  height: 34px;
  border-color: transparent;
  border-radius: 10px;
  background: transparent;
}

.tabs button:hover {
  transform: none;
  border-color: color-mix(in srgb, var(--cyan) 42%, transparent);
  background: color-mix(in srgb, var(--cyan) 10%, transparent);
  color: var(--cyan);
}

.tabs button.active {
  z-index: 1;
  border-color: var(--cyan);
  background: color-mix(in srgb, var(--cyan) 16%, var(--panel-strong));
  color: var(--cyan);
  font-weight: 900;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--cyan) 24%, transparent);
}

.tabs button.active:hover {
  border-color: var(--cyan);
  background: color-mix(in srgb, var(--cyan) 18%, var(--panel-strong));
  color: var(--cyan);
  transform: none;
}

.layout-toggle {
  display: none;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--panel-strong) 54%, transparent);
}

.layout-toggle button {
  width: 34px;
  height: 34px;
  padding: 0;
  border-color: transparent;
  border-radius: 10px;
  background: transparent;
}

.layout-toggle button:hover {
  transform: none;
  border-color: color-mix(in srgb, var(--cyan) 42%, transparent);
  background: color-mix(in srgb, var(--cyan) 10%, transparent);
  color: var(--cyan);
}

.layout-toggle button.active {
  border-color: var(--cyan);
  background: color-mix(in srgb, var(--cyan) 16%, var(--panel-strong));
  color: var(--cyan);
}

.sort-menu {
  position: relative;
  z-index: 40;
  min-width: 170px;
}

.refresh-menu {
  min-width: 150px;
}

.sort-menu > button {
  width: 100%;
  padding: 0 12px;
  justify-content: space-between;
}

.sort-menu > button[aria-expanded="true"] {
  border-color: var(--cyan);
  background: color-mix(in srgb, var(--cyan) 12%, var(--panel-strong));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--cyan) 14%, transparent);
}

.sort-options {
  position: absolute;
  z-index: 100;
  top: calc(100% + 8px);
  right: 0;
  width: 170px;
  min-width: 170px;
  max-width: 170px;
  padding: 6px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--bg) 88%, #ffffff);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.sort-options button {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.sort-options button:hover {
  background: color-mix(in srgb, var(--cyan) 14%, transparent);
  color: var(--cyan);
}

.fund-panel {
  position: relative;
  z-index: 1;
  border-radius: 22px;
  overflow: hidden;
}

.simple-mobile-head,
.simple-amount {
  display: none;
}

.table-scroll {
  overflow: auto;
}

table {
  width: 100%;
  min-width: 1380px;
  border-collapse: collapse;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  background: color-mix(in srgb, var(--panel-strong) 68%, transparent);
}

th.sortable {
  user-select: none;
}

th.draggable-column {
  cursor: grab;
}

th.draggable-column:active {
  cursor: grabbing;
}

th.draggable-column.is-dragging {
  opacity: 0.48;
}

th.draggable-column.is-drop-target {
  background: color-mix(in srgb, var(--cyan) 18%, var(--panel-strong));
  box-shadow: inset 3px 0 0 var(--cyan);
}

th.sortable button {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  max-width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: inherit;
  text-align: left;
}

th.sortable button::after {
  content: "↕";
  color: color-mix(in srgb, var(--muted) 60%, transparent);
  font-size: 11px;
  letter-spacing: 0;
}

th.sortable.is-sorted button {
  color: var(--cyan);
}

th.sortable.is-sorted[data-dir="asc"] button::after {
  content: "▲";
  color: var(--cyan);
  letter-spacing: 0;
}

th.sortable.is-sorted[data-dir="desc"] button::after {
  content: "▼";
  color: var(--cyan);
  letter-spacing: 0;
}

td strong,
td span {
  display: block;
}

td strong {
  font-variant-numeric: tabular-nums;
}

td span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

tbody tr:hover {
  background: color-mix(in srgb, var(--cyan) 9%, transparent);
}

.rank-col {
  width: 58px;
  text-align: center;
}

.rank {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 900;
}

.fund-link {
  display: block;
  width: 100%;
  max-width: 290px;
  min-width: 0;
  overflow: hidden;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.fund-link strong {
  display: block;
  width: 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fund-cell {
  display: grid;
  min-width: 0;
  max-width: 100%;
  gap: 4px;
}

.fund-meta {
  display: block;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fund-subrow {
  display: block;
}

.compact-inline-actions {
  display: none;
}

.row-actions {
  justify-content: flex-start;
}

@media (min-width: 901px) {
  table {
    table-layout: fixed;
  }

  th:nth-child(2),
  td:nth-child(2) {
    width: clamp(180px, 18vw, 300px);
    min-width: 180px;
  }

  td:nth-child(2) {
    max-width: 300px;
    overflow: hidden;
  }

  .fund-cell,
  .fund-subrow {
    min-width: 0;
    max-width: 100%;
  }

  .fund-link {
    display: block;
    width: 100%;
    max-width: 100%;
  }

  .fund-link strong,
  .fund-meta {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

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

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

.empty-state {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 260px;
  color: var(--muted);
}

.empty-state[hidden] {
  display: none !important;
}

.empty-state svg {
  width: 46px;
  height: 46px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 80;
  padding: 12px 16px;
  border-radius: 14px;
  color: var(--text);
}

.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(8, 16, 26, 0.42);
  backdrop-filter: blur(10px);
}

.modal-layer.is-front {
  z-index: 70;
}

.modal-layer[hidden] {
  display: none;
}

.dialog-frame {
  width: min(980px, calc(100vw - 36px));
  max-height: calc(100vh - 36px);
  overflow: auto;
  border-radius: 24px;
}

.dialog-frame.small {
  width: min(560px, calc(100vw - 36px));
}

.dialog-frame.mini {
  width: min(440px, calc(100vw - 36px));
}

.dialog-frame.is-shaking {
  animation: dialog-shake 0.24s ease;
}

@keyframes dialog-shake {
  0%, 100% { transform: translateX(0); }
  22% { transform: translateX(-8px); }
  44% { transform: translateX(7px); }
  66% { transform: translateX(-5px); }
  84% { transform: translateX(3px); }
}

.income-dialog {
  width: min(720px, calc(100vw - 36px));
}

.dialog-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel-strong) 88%, transparent);
  backdrop-filter: blur(18px);
}

.dialog-head span,
.dialog-head small,
.section-head {
  color: var(--muted);
  font-size: 12px;
}

.dialog-head strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
}

.detail-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding: 16px 18px 0;
}

.detail-metrics article,
.position-card,
.record-item,
.empty-line {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: color-mix(in srgb, var(--panel-strong) 56%, transparent);
}

.detail-metrics article,
.position-card {
  padding: 14px;
}

.detail-metrics span,
.detail-metrics small,
.position-card span,
.position-card small,
.record-item span,
.record-item small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.detail-metrics strong,
.position-card strong {
  display: block;
  margin: 8px 0 4px;
  font-size: 22px;
}

.income-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 14px 14px 0;
}

.income-summary article {
  min-width: 0;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--panel-strong) 58%, transparent);
}

.income-summary span,
.income-summary small {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.income-summary strong {
  display: block;
  margin-top: 6px;
  overflow: hidden;
  font-size: 18px;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.income-toolbar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 10px 14px 0;
}

.income-tabs {
  width: 100%;
}

.income-tabs button {
  flex: 1;
}

.income-period-head {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 36px;
  align-items: center;
  gap: 10px;
  padding: 10px 14px 8px;
  text-align: center;
}

.income-period-head > div {
  min-width: 0;
}

.income-period-head strong,
.income-period-head span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.income-period-head strong {
  font-size: 20px;
}

.income-period-head span {
  margin-top: 3px;
  font-size: 24px;
  font-weight: 900;
}

.income-calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 5px;
  margin: 0 14px 14px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: color-mix(in srgb, var(--panel-strong) 48%, transparent);
}

.income-grid-compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.income-weekday {
  display: grid;
  place-items: center;
  min-height: 24px;
  color: var(--muted);
  font-weight: 800;
}

.income-cell {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 5px;
  min-width: 0;
  min-height: 58px;
  padding: 7px 5px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: color-mix(in srgb, var(--panel-strong) 72%, transparent);
  text-align: center;
}

.income-cell.is-wide {
  min-height: 74px;
}

.income-cell.has-value.down {
  border-color: var(--income-down-border);
  background: var(--income-down-bg);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--income-down-border) 36%, transparent);
}

.income-cell.has-value.up {
  border-color: var(--income-up-border);
  background: var(--income-up-bg);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--income-up-border) 36%, transparent);
}

.income-cell.is-today {
  border-color: var(--blue);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--blue) 48%, transparent);
}

.income-cell.is-blank {
  min-height: 58px;
  background: transparent;
}

.income-cell b,
.income-cell span {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.income-cell b {
  color: var(--blue);
  font-size: 15px;
}

.income-cell span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.income-cell.has-value.down b,
.income-cell.has-value.down span {
  color: color-mix(in srgb, var(--green) 86%, #003c35);
}

.income-cell.has-value.up b,
.income-cell.has-value.up span {
  color: color-mix(in srgb, var(--red) 90%, #7a0000);
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.85fr) minmax(340px, 1.15fr);
  gap: 14px;
  padding: 18px;
}

.trend-panel {
  margin: 14px 18px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: color-mix(in srgb, var(--panel-strong) 42%, transparent);
}

.detail-grid > article {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: color-mix(in srgb, var(--panel-strong) 42%, transparent);
}

.section-head {
  min-height: 38px;
  justify-content: space-between;
  margin-bottom: 10px;
}

.section-head strong {
  color: var(--text);
  font-size: 15px;
}

.section-head .soft-btn {
  flex: 0 0 auto;
}

.position-grid,
.record-list {
  display: grid;
  gap: 10px;
}

.trend-chart {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
  min-height: 174px;
}

.trend-meta {
  display: grid;
  gap: 8px;
}

.trend-meta > div {
  display: grid;
  gap: 3px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--panel-strong) 58%, transparent);
}

.trend-meta span,
.trend-meta small {
  color: var(--muted);
  font-size: 12px;
}

.trend-meta strong {
  overflow: hidden;
  color: var(--text);
  font-size: 17px;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trend-svg {
  width: 100%;
  min-height: 174px;
  color: var(--cyan);
  overflow: visible;
}

.trend-grid {
  fill: none;
  stroke: color-mix(in srgb, var(--muted) 20%, transparent);
  stroke-width: 1;
}

.trend-area {
  fill: url(#trendFill);
  color: var(--cyan);
}

.trend-line {
  fill: none;
  stroke: var(--cyan);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3;
}

.trend-line.up {
  stroke: var(--red);
}

.trend-line.down {
  stroke: var(--green);
}

.trend-dot {
  fill: var(--panel-strong);
  stroke: currentColor;
  stroke-width: 3;
}

.trend-tick line {
  stroke: color-mix(in srgb, var(--muted) 34%, transparent);
  stroke-width: 1;
}

.trend-tick text {
  fill: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-anchor: middle;
}

.record-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
}

.empty-line {
  min-height: 86px;
  display: grid;
  place-items: center;
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 18px;
}

.form-grid label,
.system-body {
  display: grid;
  gap: 7px;
}

.form-grid label span {
  color: var(--muted);
  font-size: 12px;
}

.form-grid input,
.system-body input {
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--panel-strong) 64%, transparent);
  color: var(--text);
  outline: 0;
}

.form-grid input:focus,
.system-body input:focus {
  border-color: var(--cyan);
}

.system-body {
  padding: 18px;
}

.system-body p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.dialog-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 18px 18px;
  border-top: 1px solid var(--line);
}

@media (max-width: 900px) {
  body {
    min-width: 0;
    font-size: 12px;
  }

  .app-shell {
    width: min(100% - 12px, 720px);
    padding: 8px 0 14px;
  }

  .topbar {
    top: 8px;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    padding: 10px 8px 8px;
    border-radius: 14px;
  }

  .top-actions {
    grid-column: 2;
    grid-row: 1;
  }

  .brand {
    min-width: 0;
  }

  .brand img {
    width: 36px;
    height: 36px;
    flex-basis: 36px;
    border-radius: 10px;
  }

  .brand span {
    display: none;
  }

  .brand strong {
    margin: 0;
    overflow: hidden;
    font-size: 17px;
    line-height: 36px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .search-box {
    grid-column: 1 / -1;
    grid-row: 2;
    height: 36px;
  }

  .top-actions,
  .dialog-actions {
    justify-content: flex-end;
    overflow: auto;
    gap: 6px;
  }

  .top-actions {
    min-height: 40px;
    padding: 2px 0;
    align-items: center;
  }

  .top-actions .icon-btn:hover,
  .top-actions .soft-btn:hover {
    transform: none;
  }

  .top-actions .soft-btn {
    width: 36px;
    padding: 0;
  }

  .top-actions .soft-btn span {
    display: none;
  }

  .metric-card {
    min-height: 66px;
    padding: 9px 10px;
    border-radius: 14px;
  }

  .metric-card span,
  .metric-card small {
    font-size: 11px;
  }

  .metric-card strong {
    margin: 5px 0 3px;
    font-size: 18px;
  }

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

  .income-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 10px 10px 0;
  }

  .income-summary article {
    padding: 9px;
  }

  .income-summary strong {
    font-size: 15px;
    line-height: 1.15;
  }

  .income-summary span,
  .income-summary small {
    font-size: 11px;
  }

  .income-toolbar {
    grid-template-columns: 1fr;
    padding: 8px 10px 0;
  }

  .income-period-head {
    padding: 8px 10px 7px;
  }

  .income-period-head strong {
    font-size: 18px;
  }

  .income-period-head span {
    font-size: 20px;
  }

  .income-calendar {
    gap: 4px;
    margin: 0 10px 10px;
    padding: 6px;
  }

  .income-cell {
    min-height: 54px;
    padding: 6px 2px;
    border-radius: 8px;
  }

  .income-cell b {
    font-size: 14px;
  }

  .income-cell span {
    width: 100%;
    font-size: 10px;
    line-height: 1.1;
  }

  .detail-grid,
  .form-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .trend-panel {
    margin: 12px 14px 0;
    padding: 10px;
  }

  .trend-chart {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .trend-meta {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .trend-meta > div {
    min-width: 0;
    padding: 8px;
  }

  .trend-meta strong {
    font-size: 14px;
  }

  .trend-svg {
    min-height: 136px;
  }

  .control-panel {
    grid-template-columns: minmax(0, 1fr) minmax(112px, auto) 58px;
    gap: 8px;
    padding: 8px;
  }

  .tabs {
    grid-column: 1 / -1;
    order: 1;
  }

  .filter-box {
    order: 2;
    height: 36px;
  }

  .sort-menu {
    order: 3;
    min-width: 124px;
    z-index: 50;
  }

  .refresh-menu {
    order: 4;
    min-width: 58px;
  }

  .sort-menu > button {
    height: 36px;
  }

  .sort-menu > button span {
    max-width: 82px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .refresh-menu > button span {
    display: none;
  }

  .refresh-menu > button {
    justify-content: center;
    gap: 4px;
    padding: 0 8px;
  }

  .refresh-menu > button::before {
    content: attr(data-short-label);
    font-weight: 900;
  }

  .sort-options {
    width: 150px;
    min-width: 150px;
    max-width: 150px;
    left: auto;
    right: 0;
  }

  .sort-options button {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .layout-toggle {
    display: flex;
    grid-column: 1 / -1;
    order: 5;
    justify-content: stretch;
  }

  .layout-toggle button {
    flex: 1;
  }

  .fund-panel {
    background: transparent;
    border: 0;
    box-shadow: none;
  }

  .table-scroll {
    overflow: visible;
  }

  table,
  thead,
  tbody,
  tr,
  td {
    display: block;
    min-width: 0;
    width: 100%;
  }

  thead {
    display: none;
  }

  tbody {
    display: grid;
    gap: 10px;
  }

  tr {
    position: relative;
    padding: 8px 0;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: linear-gradient(135deg, var(--panel-strong), var(--panel));
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
  }

  td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 7px 12px;
    border-bottom: 0;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
  }

  td:last-child {
    display: none;
  }

  .rank-col {
    width: 100%;
    text-align: right;
  }

  .fund-link {
    max-width: min(60vw, 340px);
    text-align: right;
  }

  .row-actions {
    display: none;
  }

  .modal-layer {
    align-items: end;
    padding: 8px;
  }

  .dialog-frame,
  .dialog-frame.small,
  .dialog-frame.mini {
    width: 100%;
    max-height: 90vh;
    border-radius: 22px 22px 14px 14px;
  }

  .dialog-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 10px;
    padding: 14px;
  }

  .dialog-head > div:first-child {
    min-width: 0;
  }

  .dialog-head strong {
    margin-top: 3px;
    font-size: 17px;
    line-height: 1.22;
  }

  .dialog-head small {
    margin-top: 3px;
  }

  .dialog-actions {
    flex-shrink: 0;
    gap: 5px;
    overflow: visible;
  }

  .dialog-actions .soft-btn {
    height: 32px;
    padding: 0 9px;
    border-radius: 10px;
    font-size: 12px;
  }

  .dialog-actions .icon-btn {
    width: 32px;
    height: 32px;
    border-radius: 10px;
  }

  .fund-detail-dialog .dialog-head {
    grid-template-columns: 1fr;
    gap: 9px;
    padding-right: 58px;
  }

  .fund-detail-dialog .dialog-head strong {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-height: 1.25;
    word-break: break-word;
  }

  .fund-detail-dialog .dialog-actions {
    display: grid;
    grid-template-columns: 74px 64px 64px 32px;
    width: max-content;
    max-width: 100%;
  }

  .fund-detail-dialog .detail-close {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 3;
  }

  .fund-detail-dialog .dialog-actions .soft-btn {
    min-width: 0;
    padding: 0 7px;
  }

  .fund-detail-dialog .dialog-actions .soft-btn svg,
  .fund-detail-dialog .dialog-actions .icon-btn svg {
    flex: 0 0 auto;
  }

  [data-list-mode="compact"] .fund-panel {
    z-index: 1;
    border: 1px solid var(--line);
    background: linear-gradient(135deg, var(--panel-strong), var(--panel));
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
  }

  [data-list-mode="compact"] .table-scroll {
    overflow: auto;
  }

  [data-list-mode="compact"] table {
    display: table;
    min-width: 930px;
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
  }

  [data-list-mode="compact"] thead {
    display: table-header-group;
  }

  [data-list-mode="compact"] tbody {
    display: table-row-group;
  }

  [data-list-mode="compact"] tr {
    display: table-row;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
  }

  [data-list-mode="compact"] td,
  [data-list-mode="compact"] th {
    display: table-cell;
    width: 86px;
    padding: 3px;
    border-bottom: 1px solid var(--line);
    text-align: center;
    vertical-align: middle;
  }

  [data-list-mode="compact"] th {
    height: 44px;
    padding: 8px 4px;
  }

  [data-list-mode="compact"] th:nth-child(2),
  [data-list-mode="compact"] td:nth-child(2) {
    width: 190px;
    text-align: left;
  }

  [data-list-mode="compact"] th.sortable button {
    justify-content: center;
    width: 100%;
    text-align: center;
    white-space: nowrap;
  }

  [data-list-mode="compact"] td::before {
    content: none;
  }

  [data-list-mode="compact"] th:first-child,
  [data-list-mode="compact"] td:first-child {
    display: none;
  }

  [data-list-mode="compact"] .fund-link {
    display: block;
    width: 170px;
    max-width: 170px;
    min-width: 0;
    overflow: hidden;
    text-align: left;
  }

  [data-list-mode="compact"] .fund-cell {
    width: 190px;
    max-width: 190px;
    min-width: 0;
    display: grid;
    gap: 2px;
  }

  [data-list-mode="compact"] .fund-link strong {
    width: 100%;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  [data-list-mode="compact"] .compact-inline-actions {
    display: none;
    align-items: center;
    gap: 3px;
    margin-top: 0;
  }

  [data-list-mode="compact"] .fund-meta {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  [data-list-mode="compact"] .fund-subrow {
    display: flex;
    align-items: center;
    gap: 4px;
  }

  [data-list-mode="compact"] .compact-inline-actions .icon-btn {
    width: 24px;
    height: 24px;
    border-color: transparent;
    border-radius: 8px;
    background: transparent;
    box-shadow: none;
  }

  [data-list-mode="compact"] .compact-inline-actions .icon-btn:hover {
    border-color: color-mix(in srgb, var(--cyan) 36%, transparent);
    background: color-mix(in srgb, var(--cyan) 10%, transparent);
    transform: none;
  }

  [data-list-mode="compact"] .compact-inline-actions svg {
    width: 14px;
    height: 14px;
  }

  [data-list-mode="compact"] th:last-child,
  [data-list-mode="compact"] td:last-child {
    display: none;
  }

  [data-list-mode="compact"] .row-actions {
    display: none;
  }

  [data-list-mode="compact"] .icon-btn {
    width: 32px;
    height: 32px;
    border-radius: 10px;
  }

  [data-list-mode="compact"] .fund-cell .compact-inline-actions .icon-btn {
    width: 24px;
    height: 24px;
    border-color: transparent;
    border-radius: 8px;
    background: transparent;
    box-shadow: none;
  }

  [data-list-mode="simple"] .fund-panel {
    border: 1px solid var(--line);
    border-radius: 16px;
    background: color-mix(in srgb, var(--panel-strong) 84%, transparent);
    box-shadow: 0 16px 42px rgba(36, 71, 102, 0.12);
    overflow: hidden;
  }

  [data-list-mode="simple"] .simple-mobile-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 84px 82px;
    align-items: center;
    gap: 0;
    min-height: 52px;
    padding: 8px 0;
    border-bottom: 1px solid var(--line);
    background: color-mix(in srgb, var(--panel-strong) 92%, transparent);
  }

  .simple-mobile-tools {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    padding-left: 10px;
  }

  .simple-mobile-add,
  .simple-sort {
    border: 0;
    background: transparent;
    color: var(--muted);
  }

  .simple-mobile-add {
    display: inline-grid;
    place-items: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 999px;
  }

  .simple-mobile-add:hover,
  .simple-sort:hover,
  .simple-sort.is-sorted {
    color: var(--cyan);
    background: color-mix(in srgb, var(--cyan) 10%, transparent);
  }

  .simple-mobile-add svg {
    width: 22px;
    height: 22px;
  }

  .simple-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: 18px;
    font-weight: 700;
    line-height: 1;
  }

  .simple-count svg {
    width: 18px;
    height: 18px;
    stroke-width: 2.5;
  }

  .simple-sort {
    display: grid;
    justify-items: end;
    gap: 2px;
    width: 100%;
    min-width: 0;
    padding: 4px 8px 4px 0;
    border-radius: 10px;
    font-weight: 800;
    text-align: right;
  }

  .simple-sort span {
    position: relative;
    padding-right: 12px;
    font-size: 12px;
    line-height: 1.1;
  }

  .simple-sort span::after {
    content: "↕";
    position: absolute;
    right: 0;
    color: color-mix(in srgb, var(--muted) 55%, transparent);
    font-size: 11px;
    letter-spacing: 0;
  }

  .simple-sort.is-sorted[data-dir="asc"] span::after {
    content: "▲";
    color: var(--cyan);
    letter-spacing: 0;
  }

  .simple-sort.is-sorted[data-dir="desc"] span::after {
    content: "▼";
    color: var(--cyan);
    letter-spacing: 0;
  }

  .simple-sort small {
    color: color-mix(in srgb, var(--muted) 72%, transparent);
    font-size: 10px;
    font-weight: 700;
  }

  [data-list-mode="simple"] .table-scroll {
    overflow: visible;
  }

  [data-list-mode="simple"] table,
  [data-list-mode="simple"] tbody,
  [data-list-mode="simple"] tr,
  [data-list-mode="simple"] td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  [data-list-mode="simple"] table {
    border-collapse: collapse;
  }

  [data-list-mode="simple"] thead {
    display: none;
  }

  [data-list-mode="simple"] tbody {
    display: block;
  }

  [data-list-mode="simple"] tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 104px 60px;
    align-items: center;
    min-height: 58px;
    padding: 0;
    border: 0;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
  }

  [data-list-mode="simple"] tr:last-child {
    border-bottom: 0;
  }

  [data-list-mode="simple"] tr:hover {
    background: color-mix(in srgb, var(--cyan) 8%, transparent);
  }

  [data-list-mode="simple"] td {
    display: none;
    padding: 0;
    border: 0;
  }

  [data-list-mode="simple"] td::before {
    content: none;
  }

  [data-list-mode="simple"] td:nth-child(2),
  [data-list-mode="simple"] td[data-col="todayProfit"],
  [data-list-mode="simple"] td[data-col="todayGrowth"] {
    display: block;
  }

  [data-list-mode="simple"] td:nth-child(2) {
    min-width: 0;
    padding: 10px 8px 10px 12px;
  }

  [data-list-mode="simple"] td[data-col="todayProfit"] {
    padding: 0 5px 0 6px;
    text-align: right;
  }

  [data-list-mode="simple"] td[data-col="todayGrowth"] {
    padding: 0 5px 0 0;
    text-align: right;
  }

  [data-list-mode="simple"] .fund-cell {
    display: block;
    width: 100%;
    max-width: none;
  }

  [data-list-mode="simple"] .fund-link {
    display: block;
    width: 100%;
    max-width: 100%;
    text-align: left;
  }

  [data-list-mode="simple"] .fund-link strong {
    display: block;
    color: var(--text);
    font-size: 15px;
    font-weight: 800;
    line-height: 1.18;
  }

  [data-list-mode="simple"] .fund-subrow {
    display: block;
    margin-top: 2px;
  }

  [data-list-mode="simple"] .fund-meta,
  [data-list-mode="simple"] .compact-inline-actions {
    display: none;
  }

  [data-list-mode="simple"] .simple-amount {
    display: block;
    color: color-mix(in srgb, var(--muted) 78%, transparent);
    font-size: 13px;
    font-weight: 700;
    line-height: 1.1;
  }

  [data-list-mode="simple"] td[data-col="todayProfit"] strong {
    color: var(--text);
    font-size: 19px;
    font-weight: 900;
  }

  [data-list-mode="simple"] td[data-col="todayProfit"] strong.up {
    color: var(--red);
  }

  [data-list-mode="simple"] td[data-col="todayProfit"] strong.down {
    color: var(--green);
  }

  [data-list-mode="simple"] td[data-col="todayProfit"] span,
  [data-list-mode="simple"] td[data-col="todayGrowth"] span {
    display: none;
  }

  [data-list-mode="simple"] td[data-col="todayGrowth"] strong {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 54px;
    height: 32px;
    padding: 0 4px;
    border-radius: 6px;
    background: color-mix(in srgb, var(--muted) 18%, transparent);
    color: var(--text);
    font-size: 13px;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
  }

  [data-list-mode="simple"] td[data-col="todayGrowth"] strong.up {
    background: var(--red);
    color: #fff;
  }

  [data-list-mode="simple"] td[data-col="todayGrowth"] strong.down {
    background: var(--green);
    color: #fff;
  }
}
