:root {
  color-scheme: dark;
  --bg: #010207;
  --panel: #040a13;
  --panel-2: #071120;
  --text: #eef6ef;
  --muted: #92a3b7;
  --line: #14263b;
  --accent: #35d07f;
  --accent-2: #ffcc48;
  --danger: #ff5b6b;
  --green: #24c779;
  --red: #f05d6f;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid rgba(53, 208, 127, 0.45);
  background: #081522;
  color: var(--text);
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(53, 208, 127, 0.45);
  background: #081522;
  color: var(--text);
  border-radius: 8px;
  min-height: 42px;
  padding: 9px 14px;
  text-decoration: none;
}

.button-link:hover {
  border-color: var(--accent);
  background: #0b2030;
}

button:hover {
  border-color: var(--accent);
  background: #0b2030;
}

button:active {
  transform: translateY(1px);
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  background: #020710;
  color: var(--text);
  border-radius: 8px;
  min-height: 42px;
  padding: 9px 11px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(53, 208, 127, 0.12);
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  padding: 28px min(4vw, 42px) 18px;
}

.header-actions,
.panel-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.icon-button {
  padding: 4px 10px;
  min-height: 34px;
  font-size: 22px;
  line-height: 1;
}

.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(1, 2, 7, 0.82);
}

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

.auth-dialog {
  width: min(100%, 420px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 20px;
}

.auth-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.auth-heading h2 {
  margin: 0 0 6px;
  font-size: 22px;
}

.auth-heading p,
.auth-message {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.auth-tabs {
  display: flex;
  gap: 8px;
  margin: 20px 0 14px;
}

.auth-tabs button {
  flex: 1 1 0;
}

.auth-tabs button.active {
  border-color: var(--accent);
  background: #0b2030;
}

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

.auth-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.auth-message {
  min-height: 20px;
  margin-top: 12px;
}

.auth-message.warn {
  color: var(--accent-2);
}

.topbar h1 {
  margin: 0 0 8px;
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1.05;
  letter-spacing: 0;
}

.topbar p,
.panel-title p,
.delivery-box p {
  margin: 0;
  color: var(--muted);
}

.status-pill {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: rgba(1, 4, 10, 0.88);
  border-radius: 999px;
  padding: 9px 13px;
  color: var(--muted);
}

.status-pill.live {
  border-color: rgba(53, 208, 127, 0.55);
  color: var(--accent);
}

.status-pill.warn {
  border-color: rgba(255, 204, 72, 0.55);
  color: var(--accent-2);
}

.monitor-summary {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.layout {
  display: grid;
  grid-template-columns: minmax(460px, 1.25fr) minmax(340px, 0.75fr);
  gap: 16px;
  padding: 0 min(4vw, 42px) 36px;
}

.panel {
  border: 1px solid var(--line);
  background: rgba(4, 10, 19, 0.94);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.search-panel,
.monitor-panel {
  padding: 18px;
}

.search-panel {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: auto minmax(280px, 1fr) auto;
  gap: 10px 14px;
  align-items: center;
  min-height: 0;
  padding: 14px 18px;
}

.chart-panel {
  grid-column: 1;
  grid-row: 2;
  padding: 18px;
}

.monitor-panel {
  grid-column: 2;
  grid-row: 2;
}

.search-panel .panel-title {
  margin: 0;
  white-space: nowrap;
}

.search-panel .search-row {
  min-width: 0;
}

.search-panel > #notifyButton {
  white-space: nowrap;
}

.search-panel .results {
  grid-column: 1 / -1;
  width: 100%;
  margin-top: 0;
}

.search-panel .results.empty {
  display: none;
}

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

.panel-title h2,
.delivery-box h3 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}

.chart-title {
  align-items: flex-start;
}

.chart-freshness {
  min-height: 18px;
  margin: -6px 0 12px;
  color: var(--muted);
  font-size: 12px;
}

.chart-controls {
  display: flex;
  gap: 8px;
  min-width: 180px;
}

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

.results,
.watch-list {
  margin-top: 14px;
  display: grid;
  gap: 10px;
}

.empty {
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 16px;
}

.result-card,
.watch-card {
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 8px;
  padding: 12px;
}

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

.result-card button {
  justify-self: start;
}

.token-line,
.watch-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.token-line strong,
.watch-head strong {
  overflow-wrap: anywhere;
}

.meta,
.watch-meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.price-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 14px;
}

.price-strip div {
  padding: 12px;
  background: #030914;
  border-right: 1px solid var(--line);
}

.price-strip div:last-child {
  border-right: 0;
}

.price-strip span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.price-strip strong {
  font-size: 18px;
  overflow-wrap: anywhere;
}

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

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

.chart-shell {
  position: relative;
  width: 100%;
  height: min(58vh, 560px);
  min-height: 360px;
  background: #020710;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.dex-chart-frame {
  display: none;
  width: 100%;
  height: 100%;
  border: 0;
  background: #020710;
}

.dex-chart-frame.visible {
  display: block;
}

.chart-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 14px;
  pointer-events: none;
}

.chart-empty.hidden {
  display: none;
}

.alert-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.alert-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.alert-form .target-value-field {
  grid-column: 1 / -1;
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(53, 208, 127, 0.45);
  border-radius: 8px;
  background: rgba(53, 208, 127, 0.06);
  color: var(--text);
  font-size: 14px;
}

.target-value-field input {
  min-height: 50px;
  border-color: rgba(53, 208, 127, 0.65);
  font-size: 16px;
}

.target-value-field input::placeholder {
  color: #738278;
  font-size: 13px;
}

.alert-form button {
  grid-column: 1 / -1;
}

.delivery-section {
  margin-top: 16px;
}

.delivery-toggle {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.delivery-toggle span:last-child {
  font-size: 20px;
  line-height: 1;
}

.delivery-settings {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.delivery-settings[hidden] {
  display: none;
}

.delivery-box {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #040b16;
}

.delivery-box label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.delivery-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.watch-card.triggered {
  border-color: rgba(255, 204, 72, 0.68);
}

.watch-card.paused {
  opacity: 0.62;
}

.watch-head span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
}

.watch-card.triggered .watch-head span {
  color: var(--accent-2);
}

.watch-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.watch-actions button {
  padding: 8px 10px;
}

.secondary {
  border-color: var(--line);
  color: var(--muted);
}

.portfolio-page {
  display: grid;
  gap: 16px;
  padding: 0 min(4vw, 42px) 36px;
}

.wallet-setup-panel {
  padding: 18px;
}

.wallet-form {
  display: grid;
  grid-template-columns: minmax(130px, 0.65fr) minmax(260px, 1.8fr) minmax(150px, 0.9fr) minmax(120px, 0.75fr);
  gap: 12px;
  align-items: end;
}

.wallet-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.field-hint {
  min-height: 18px;
  color: var(--muted);
  font-size: 12px;
}

.field-hint.ready {
  color: var(--green);
}

.field-hint.warning {
  color: #f0b44d;
}

.wallet-address-field {
  grid-column: span 2;
}

.wallet-form > button {
  min-height: 42px;
}

.input-suffix {
  position: relative;
}

.input-suffix input {
  padding-right: 36px;
}

.input-suffix span {
  position: absolute;
  right: 12px;
  top: 50%;
  color: var(--muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.wallet-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(4, 10, 19, 0.94);
}

.wallet-summary div {
  min-width: 0;
  padding: 14px 18px;
  border-right: 1px solid var(--line);
}

.wallet-summary div:last-child {
  border-right: 0;
}

.wallet-summary span,
.wallet-card-metrics span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.wallet-summary strong {
  font-size: 22px;
  overflow-wrap: anywhere;
}

.wallet-list-section {
  min-width: 0;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin: 4px 0 12px;
}

.section-heading h2 {
  margin: 0;
  font-size: 18px;
}

.section-heading span {
  color: var(--muted);
  font-size: 12px;
}

.wallet-monitor-list {
  display: grid;
  gap: 12px;
}

.wallet-monitor-card {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(4, 10, 19, 0.94);
  box-shadow: var(--shadow);
}

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

.wallet-card-head h3 {
  margin: 0 0 5px;
  font-size: 17px;
}

.wallet-card-head p,
.wallet-card-foot {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.wallet-state {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
}

.wallet-state.live {
  color: var(--accent);
}

.wallet-state.error {
  color: var(--danger);
}

.wallet-state.pending {
  color: var(--accent-2);
}

.wallet-card-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 14px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.wallet-card-metrics div {
  min-width: 0;
  padding: 12px;
  border-right: 1px solid var(--line);
}

.wallet-card-metrics div:last-child {
  border-right: 0;
}

.wallet-card-metrics strong {
  font-size: 14px;
  overflow-wrap: anywhere;
}

.holdings-table-wrap {
  width: 100%;
  overflow-x: auto;
}

.holdings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.holdings-table th,
.holdings-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

.holdings-table th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.holdings-table th:first-child,
.holdings-table td:first-child {
  text-align: left;
}

.holdings-table td:first-child span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.wallet-empty-row {
  padding: 18px 0;
  color: var(--muted);
  font-size: 13px;
}

.wallet-error {
  margin: 0 0 12px;
  color: var(--danger);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.wallet-events {
  margin-top: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.wallet-events summary {
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
}

.wallet-events ul {
  display: grid;
  gap: 8px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.wallet-events li {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: 12px;
  color: var(--text);
  font-size: 12px;
}

.wallet-events time {
  color: var(--muted);
}

.wallet-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.wallet-filter-editor {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr)) auto;
  gap: 10px;
  align-items: end;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.wallet-filter-editor label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.wallet-filter-editor button {
  min-height: 42px;
}

.wallet-card-actions button {
  padding: 8px 11px;
}

.wallet-card-foot {
  margin-top: 10px;
}

.converter-page {
  display: grid;
  gap: 16px;
  padding: 0 min(4vw, 42px) 40px;
}

.converter-upload-panel,
.converter-result-panel {
  min-width: 0;
}

.converter-controls {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) 160px auto;
  gap: 12px;
  align-items: end;
}

.converter-drop-zone {
  min-height: 92px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  padding: 16px;
  border: 1px dashed rgba(53, 208, 127, 0.55);
  border-radius: 8px;
  background: #020710;
  cursor: pointer;
}

.converter-drop-zone:hover,
.converter-drop-zone.dragging {
  border-color: var(--accent);
  background: #071525;
}

.converter-drop-zone span,
.converter-emoji-field,
.converter-message,
.converter-result-heading p {
  color: var(--muted);
  font-size: 13px;
}

.converter-emoji-field {
  display: grid;
  gap: 6px;
}

.converter-emoji-field input {
  text-align: center;
  font-size: 20px;
}

.converter-controls > button {
  min-height: 42px;
}

.converter-message {
  margin: 12px 0 0;
}

.converter-message.success {
  color: var(--accent);
}

.converter-message.error {
  color: var(--danger);
}

.converter-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(4, 10, 19, 0.94);
  overflow: hidden;
}

.converter-summary div {
  min-width: 0;
  padding: 14px 16px;
  border-right: 1px solid var(--line);
}

.converter-summary div:last-child {
  border-right: 0;
}

.converter-summary span,
.converter-summary strong {
  display: block;
}

.converter-summary span {
  color: var(--muted);
  font-size: 12px;
}

.converter-summary strong {
  margin-top: 4px;
  font-size: 22px;
}

.converter-result-heading p {
  margin: 4px 0 0;
}

.converter-table-wrap {
  max-height: 560px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.converter-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.converter-table th,
.converter-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

.converter-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.converter-table th:first-child,
.converter-table td:first-child {
  width: 56px;
  text-align: right;
}

.converter-table td:nth-child(2) {
  min-width: 160px;
}

.converter-table code {
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

.converter-empty {
  height: 120px;
  color: var(--muted);
  text-align: center !important;
}

@media (max-width: 980px) {
  .topbar {
    flex-direction: column;
  }

  .header-actions {
    width: 100%;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .chart-panel {
    grid-column: 1;
    grid-row: auto;
  }

  .monitor-panel {
    grid-column: 1;
    grid-row: auto;
  }

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

  .delivery-settings {
    grid-template-columns: 1fr;
  }

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

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

  .wallet-filter-editor button {
    grid-column: 1 / -1;
  }

  .wallet-address-field {
    grid-column: span 2;
  }

  .converter-controls {
    grid-template-columns: minmax(0, 1fr) 140px;
  }

  .converter-drop-zone {
    grid-column: 1 / -1;
  }
}

@media (max-width: 620px) {
  .topbar,
  .layout {
    padding-left: 14px;
    padding-right: 14px;
  }

  .panel-title,
  .token-line,
  .watch-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .panel-actions {
    width: 100%;
  }

  .panel-actions button {
    flex: 1 1 auto;
  }

  .converter-header .header-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .converter-header .header-actions > .button-link {
    min-width: 0;
  }

  .converter-header .status-pill {
    grid-column: 1 / -1;
    text-align: center;
    overflow-wrap: anywhere;
  }

  .search-row,
  .alert-form,
  .price-strip {
    grid-template-columns: 1fr;
  }

  .search-panel {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .search-panel .panel-title {
    white-space: normal;
  }

  .chart-controls {
    width: 100%;
  }

  .portfolio-page {
    padding-left: 14px;
    padding-right: 14px;
  }

  .wallet-form,
  .wallet-summary,
  .wallet-card-metrics {
    grid-template-columns: 1fr;
  }

  .wallet-address-field {
    grid-column: auto;
  }

  .wallet-summary div,
  .wallet-card-metrics div {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .wallet-summary div:last-child,
  .wallet-card-metrics div:last-child {
    border-bottom: 0;
  }

  .converter-page {
    padding-left: 14px;
    padding-right: 14px;
  }

  .converter-controls,
  .converter-summary {
    grid-template-columns: 1fr;
  }

  .converter-controls > button {
    width: 100%;
  }

  .converter-summary div,
  .converter-summary div:last-child {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .converter-summary div:last-child {
    border-bottom: 0;
  }

  .wallet-card-head,
  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .wallet-events li {
    grid-template-columns: 1fr;
    gap: 3px;
  }

  .wallet-filter-editor {
    grid-template-columns: 1fr;
  }

  .wallet-filter-editor button {
    grid-column: auto;
    width: 100%;
  }
}
