.trades-v9-sell-button {
  color: var(--green);
}

#trades-v9-history {
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 28%, var(--panel));
}

.trades-v9-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 21px 23px 15px;
}

.trades-v9-heading h3 {
  margin: 0;
  color: var(--ink);
  font-family: Georgia, "Songti SC", serif;
  font-size: 18px;
  font-weight: 500;
}

.trades-v9-heading p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 9px;
}

.trades-v9-total {
  flex: none;
  text-align: right;
}

.trades-v9-total span,
.trades-v9-total small {
  display: block;
  color: var(--muted);
  font-size: 8px;
}

.trades-v9-total strong {
  display: block;
  margin: 3px 0;
  font-family: Georgia, serif;
  font-size: 20px;
  font-weight: 600;
}

.trades-v9-list {
  max-height: 360px;
  overflow-y: auto;
  border-top: 1px solid var(--line);
}

.trades-v9-list article {
  display: grid;
  grid-template-columns: 34px minmax(170px, 1.25fr) minmax(150px, 0.9fr) minmax(100px, 0.65fr) minmax(110px, 0.65fr) auto;
  align-items: center;
  gap: 12px;
  padding: 13px 18px;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
  background: var(--panel);
}

.trades-v9-list article:last-child {
  border-bottom: 0;
}

.trades-v9-list article > i {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--green-soft);
  color: var(--green);
  font-family: Georgia, serif;
  font-size: 11px;
  font-style: normal;
}

.trades-v9-list article > i.loss {
  background: color-mix(in srgb, var(--red) 12%, var(--panel));
  color: var(--red);
}

.trades-v9-list article > span {
  min-width: 0;
}

.trades-v9-list article span strong,
.trades-v9-list article span small {
  display: block;
}

.trades-v9-list article span strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 10px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trades-v9-list article span small {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 8px;
}

.trades-v9-name small {
  margin-top: 3px;
  margin-bottom: 0 !important;
}

.trades-v9-list article > button {
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  color: var(--green);
  font-size: 9px;
  font-weight: 700;
  cursor: pointer;
}

.trades-v9-empty {
  display: grid;
  place-items: center;
  min-height: 112px;
  padding: 24px;
  border-top: 1px solid var(--line);
  text-align: center;
}

.trades-v9-empty strong {
  color: var(--ink);
  font-size: 12px;
}

.trades-v9-empty span {
  margin-top: 6px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.6;
}

.trades-v9-note {
  margin: 0;
  padding: 11px 18px;
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--green-soft) 45%, var(--panel));
  color: var(--muted);
  font-size: 9px;
  line-height: 1.65;
}

.trades-v9-backdrop {
  position: fixed;
  z-index: 17000;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  overflow: auto;
  background: rgb(20 20 18 / 64%);
  backdrop-filter: blur(7px);
}

.trades-v9-dialog-shell {
  width: min(650px, 100%);
  max-height: calc(100svh - 36px);
  padding: 25px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 21px;
  background: var(--panel);
  box-shadow: 0 28px 90px rgb(20 18 15 / 34%);
}

.trades-v9-dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.trades-v9-dialog-heading span {
  display: block;
  margin-bottom: 6px;
  color: var(--green);
  font-family: ui-monospace, monospace;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.trades-v9-dialog-heading h2 {
  margin: 0;
  color: var(--ink);
  font-family: Georgia, "Songti SC", serif;
  font-size: 24px;
  font-weight: 500;
}

.trades-v9-dialog-heading > button {
  display: grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--green-soft);
  color: var(--ink);
  font-size: 22px;
  cursor: pointer;
}

.trades-v9-form {
  display: grid;
  gap: 13px;
  margin-top: 20px;
}

.trades-v9-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 11px;
}

.trades-v9-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
}

.trades-v9-form label > small {
  color: var(--muted);
  font-size: 8px;
  font-weight: 400;
  line-height: 1.55;
}

.trades-v9-form input,
.trades-v9-form select {
  width: 100%;
  height: 42px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: none;
  background: color-mix(in srgb, var(--panel) 93%, white);
  color: var(--ink);
  font-size: 12px;
}

.trades-v9-form input:focus,
.trades-v9-form select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 13%, transparent);
}

.trades-v9-preview {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 11px;
  border: 1px solid color-mix(in srgb, var(--green) 24%, var(--line));
  border-radius: 12px;
  background: color-mix(in srgb, var(--green-soft) 58%, var(--panel));
}

.trades-v9-preview.compact {
  grid-template-columns: 1fr 1fr;
}

.trades-v9-preview > div {
  min-width: 0;
  padding: 8px 9px;
  border-radius: 9px;
  background: color-mix(in srgb, var(--panel) 82%, transparent);
}

.trades-v9-preview span,
.trades-v9-preview strong {
  display: block;
}

.trades-v9-preview span {
  color: var(--muted);
  font-size: 8px;
}

.trades-v9-preview strong {
  overflow: hidden;
  margin-top: 4px;
  color: var(--ink);
  font-family: Georgia, serif;
  font-size: 14px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trades-v9-preview > p {
  grid-column: 1 / -1;
  margin: 0;
  padding: 9px;
  color: var(--red);
  font-size: 10px;
  text-align: center;
}

.trades-v9-rule {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--paper) 55%, var(--panel));
  color: var(--muted);
  font-size: 9px;
  line-height: 1.65;
}

.trades-v9-rule strong {
  color: var(--ink);
  white-space: nowrap;
}

.trades-v9-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  padding-top: 4px;
}

.trades-v9-actions button {
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
  color: var(--ink);
  font-size: 11px;
  font-weight: 650;
  cursor: pointer;
}

.trades-v9-actions button[type="submit"] {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.trades-v9-transaction-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: color-mix(in srgb, var(--paper) 45%, var(--panel));
}

.trades-v9-transaction-card span strong,
.trades-v9-transaction-card span small {
  display: block;
}

.trades-v9-transaction-card span strong {
  color: var(--ink);
  font-size: 11px;
}

.trades-v9-transaction-card span small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 8px;
}

.trades-v9-transaction-card b {
  color: var(--green);
  font-size: 9px;
}

.trades-v9-toast {
  position: fixed;
  z-index: 19000;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(22px, env(safe-area-inset-bottom));
  max-width: min(460px, calc(100vw - 36px));
  padding: 12px 15px;
  border: 1px solid color-mix(in srgb, var(--green) 55%, var(--line));
  border-radius: 12px;
  background: var(--ink);
  color: var(--panel);
  box-shadow: 0 16px 42px rgb(0 0 0 / 22%);
  font-size: 12px;
  line-height: 1.5;
}

.trades-v9-toast.error {
  border-color: var(--red);
  background: #5d2921;
  color: #fff;
}

@media (max-width: 900px) {
  .trades-v9-list article {
    grid-template-columns: 34px minmax(150px, 1fr) minmax(130px, 0.8fr) minmax(100px, 0.65fr) auto;
  }

  .trades-v9-list article > span:nth-of-type(3) {
    display: none;
  }
}

@media (max-width: 760px) {
  .holdings-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .holding-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .holding-actions .button {
    min-width: 0;
    padding: 0 7px;
    font-size: 10px;
  }

  .trades-v9-heading {
    padding: 18px 16px 14px;
  }

  .trades-v9-list article {
    grid-template-columns: 32px minmax(0, 1fr) auto;
    gap: 9px;
    padding: 12px 14px;
  }

  .trades-v9-list article > i {
    grid-row: 1 / 3;
  }

  .trades-v9-list article > span:nth-of-type(3) {
    display: none;
  }

  .trades-v9-list article > span:nth-of-type(1) {
    grid-column: 2;
    grid-row: 1;
  }

  .trades-v9-list article > span:nth-of-type(2) {
    display: block;
    grid-column: 2;
    grid-row: 2;
  }

  .trades-v9-list article > span:nth-of-type(4) {
    grid-column: 3;
    grid-row: 1;
    text-align: right;
  }

  .trades-v9-list article > button {
    grid-column: 3;
    grid-row: 2;
    justify-self: end;
  }

  .trades-v9-backdrop {
    align-items: end;
    padding: 0;
  }

  .trades-v9-dialog-shell {
    width: 100%;
    max-height: calc(100svh - 14px);
    padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 22px 22px 0 0;
  }

  .trades-v9-form input,
  .trades-v9-form select {
    font-size: 16px;
  }
}

@media (max-width: 480px) {
  .trades-v9-heading {
    flex-direction: column;
  }

  .trades-v9-total {
    text-align: left;
  }

  .trades-v9-form-grid,
  .trades-v9-preview,
  .trades-v9-preview.compact {
    grid-template-columns: 1fr;
  }

  .trades-v9-preview > p {
    grid-column: auto;
  }

  .trades-v9-rule {
    grid-template-columns: 1fr;
  }

  .trades-v9-actions button {
    flex: 1;
  }

  .trades-v9-transaction-card {
    align-items: flex-start;
    flex-direction: column;
  }
}
