:root {
  color-scheme: light;
  --bg: #f4f2ee;
  --panel: #ffffff;
  --panel-soft: #faf8f4;
  --ink: #1f2528;
  --muted: #657074;
  --line: #ded8cf;
  --green: #138a60;
  --red: #bf3d31;
  --teal: #0d7f8c;
  --gold: #b47b18;
  --blue: #3267b1;
  --shadow: 0 20px 45px rgba(35, 31, 26, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(135deg, rgba(13, 127, 140, 0.08), transparent 32rem),
    linear-gradient(315deg, rgba(180, 123, 24, 0.08), transparent 36rem),
    var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 17rem minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  height: 100vh;
  padding: 1.4rem;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(18px);
}

.brand,
.topbar,
.section-heading,
.donut-row,
.topbar-actions,
.form-actions {
  display: flex;
  align-items: center;
}

.brand {
  gap: 0.85rem;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  font-weight: 800;
}

.eyebrow {
  margin: 0 0 0.2rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: 1.05rem;
}

h2 {
  margin-bottom: 0;
  font-size: 1.7rem;
}

h3 {
  margin-bottom: 0;
  font-size: 1.05rem;
}

.nav-stack {
  display: grid;
  gap: 0.45rem;
}

.nav-item,
.primary-button,
.ghost-button,
.icon-button {
  min-height: 2.5rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
}

.nav-item {
  display: grid;
  grid-template-columns: 1.25rem 1fr;
  gap: 0.7rem;
  align-items: center;
  padding: 0 0.75rem;
  background: transparent;
  color: var(--muted);
  text-align: left;
}

.nav-item.active,
.nav-item:hover {
  background: #eef5f3;
  color: var(--ink);
}

.sidebar-panel,
.metric,
.allocation-panel,
.table-panel,
.editor-panel,
.dialog-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.sidebar-panel {
  margin-top: auto;
  padding: 1rem;
}

.sidebar-panel label,
.asset-form label,
.dialog-card label {
  display: grid;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.sidebar-panel p {
  margin: 0.7rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.55;
}

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

input,
select {
  height: 2.55rem;
  padding: 0 0.75rem;
}

textarea {
  resize: vertical;
  padding: 0.75rem;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(13, 127, 140, 0.14);
}

.workspace {
  display: grid;
  gap: 1.1rem;
  align-content: start;
  padding: 1.4rem;
}

.topbar {
  justify-content: space-between;
  gap: 1rem;
}

.topbar-actions {
  gap: 0.6rem;
}

.storage-status {
  display: inline-flex;
  align-items: center;
  min-height: 1.65rem;
  margin-top: 0.5rem;
  padding: 0 0.7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff7e8;
  color: var(--gold);
  font-size: 0.86rem;
  font-weight: 800;
}

.storage-status.online {
  background: #eef5f3;
  color: var(--teal);
}

.primary-button {
  padding: 0 1rem;
  background: var(--ink);
  color: #fff;
}

.ghost-button {
  padding: 0 0.85rem;
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 2.55rem;
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 1.05rem;
  text-decoration: none;
}

.file-button input {
  display: none;
}

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

.metric {
  display: grid;
  gap: 0.55rem;
  padding: 1rem;
}

.metric.primary {
  background: #20302d;
  color: #fff;
}

.metric span {
  color: inherit;
  opacity: 0.74;
  font-size: 0.82rem;
  font-weight: 700;
}

.metric strong {
  font-size: 1.5rem;
  line-height: 1.05;
  word-break: break-word;
}

.metric small {
  color: inherit;
  opacity: 0.68;
}

.visual-band {
  display: block;
}

.allocation-panel,
.table-panel,
.editor-panel {
  padding: 1rem;
}

.section-heading {
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.section-heading > span {
  color: var(--muted);
  font-size: 0.82rem;
}

.donut-row {
  gap: 1.2rem;
}

.donut {
  flex: 0 0 auto;
  width: 12rem;
  aspect-ratio: 1;
  border-radius: 50%;
  background: conic-gradient(var(--teal) 0 40%, var(--gold) 40% 70%, var(--blue) 70% 100%);
  position: relative;
}

.donut::after {
  content: "";
  position: absolute;
  inset: 2.35rem;
  border-radius: 50%;
  background: var(--panel);
}

.legend,
.rate-list {
  display: grid;
  gap: 0.65rem;
}

.legend-item,
.rate-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
}

.legend-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.swatch {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 999px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 22rem;
  gap: 1rem;
  align-items: start;
}

.search-wrap {
  display: grid;
  grid-template-columns: auto minmax(10rem, 17rem);
  align-items: center;
  gap: 0.35rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding-left: 0.75rem;
}

.search-wrap input {
  border: 0;
  box-shadow: none;
}

.asset-table {
  overflow-x: auto;
}

.asset-row {
  display: grid;
  grid-template-columns: minmax(12rem, 1.25fr) 6rem 7rem 7rem 8rem 8rem 5rem;
  gap: 0.75rem;
  align-items: center;
  min-width: 58rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--line);
}

.table-head {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.asset-main {
  display: grid;
  gap: 0.2rem;
}

.asset-main strong {
  font-size: 0.96rem;
}

.asset-main small,
.muted {
  color: var(--muted);
}

.price-cell {
  display: inline-grid;
  gap: 0.12rem;
  justify-items: start;
}

.price-cell small {
  color: var(--teal);
  font-size: 0.72rem;
  font-weight: 800;
}

.type-pill {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  min-height: 1.7rem;
  padding: 0 0.55rem;
  border-radius: 999px;
  background: #eef5f3;
  color: var(--teal);
  font-size: 0.8rem;
  font-weight: 800;
}

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

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

.row-actions {
  display: flex;
  gap: 0.35rem;
}

.row-actions .icon-button {
  width: 2rem;
  min-height: 2rem;
}

.asset-form {
  display: grid;
  gap: 0.85rem;
}

.form-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.form-actions {
  justify-content: flex-end;
  gap: 0.6rem;
}

dialog {
  width: min(31rem, calc(100vw - 2rem));
  padding: 0;
  border: 0;
  background: transparent;
}

dialog::backdrop {
  background: rgba(31, 37, 40, 0.36);
  backdrop-filter: blur(4px);
}

.dialog-card {
  display: grid;
  gap: 0.9rem;
  padding: 1rem;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 13rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding-bottom: 0.9rem;
  }

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

  .nav-item {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }

  .sidebar-panel {
    display: none;
  }

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

  .visual-band,
  .content-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .workspace,
  .sidebar {
    padding: 1rem;
  }

  .topbar,
  .section-heading,
  .donut-row {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    justify-content: stretch;
  }

  .topbar-actions .primary-button {
    width: 100%;
  }

  .summary-grid,
  .nav-stack,
  .form-pair {
    grid-template-columns: 1fr;
  }

  .donut {
    width: min(13rem, 100%);
    align-self: center;
  }

  .search-wrap {
    grid-template-columns: auto 1fr;
  }

  .asset-row {
    min-width: 0;
    grid-template-columns: 1fr;
    gap: 0.45rem;
    padding: 1rem 0;
  }

  .table-head {
    display: none;
  }

  .asset-row > span {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
  }

  .asset-row > span::before {
    content: attr(data-label);
    color: var(--muted);
    font-weight: 700;
  }

  .asset-row > span:first-child {
    display: block;
  }

  .asset-row > span:first-child::before {
    display: none;
  }

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