* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  background: #0f1419;
  color: #e8eef4;
}

a {
  color: inherit;
}

button,
input,
select {
  font: inherit;
}

.shell {
  max-width: 1480px;
  margin: 0 auto;
  padding: 24px 20px 64px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.brand {
  font-weight: 650;
  letter-spacing: 0.04em;
  text-decoration: none;
}

nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

nav button,
nav a,
.secondary,
.primary {
  border: 1px solid #334155;
  background: #1b2430;
  color: #e8eef4;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
}

nav a,
a.primary,
a.secondary {
  display: inline-block;
}

nav button.active,
.secondary.active,
.primary {
  background: #d7e3cf;
  color: #102016;
  border-color: #d7e3cf;
}

button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.card {
  background: #171e27;
  border: 1px solid #2a3542;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
}

h1,
h2 {
  margin: 0 0 12px;
  font-weight: 600;
}

.section-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.carrot {
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid #93a4b8;
  transform: rotate(-90deg);
  transition: transform 0.15s ease;
}

.section-toggle[aria-expanded="true"] .carrot {
  transform: rotate(0deg);
}

.card.collapsed > h1 {
  margin-bottom: 0;
}

.card.collapsed .section-body {
  display: none;
}

#trade-controls {
  margin: 4px 0 12px;
}

#plan {
  margin: 8px 0 0;
}

.plan-accept-actions {
  margin: 12px 0 8px;
}

.plan-accept-results {
  margin: 8px 0 0;
}

.plan-accept-results ul {
  margin: 8px 0 0;
  padding-left: 1.2rem;
}

.plan-accept-results li.ok {
  color: #9dcfb0;
}

.plan-dry-run-call {
  margin: 12px 0;
  padding: 12px;
  background: #12181f;
  border-radius: 8px;
}

.plan-dry-run-call pre {
  margin: 8px 0 0;
  padding: 10px;
  overflow: auto;
  background: #0b1016;
  border-radius: 6px;
  font-size: 0.85rem;
  white-space: pre-wrap;
}

.totals {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin: 12px 0;
}

.totals div {
  background: #12181f;
  border-radius: 8px;
  padding: 12px;
}

.totals span {
  display: block;
  color: #93a4b8;
  font-size: 0.85rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

table.resizable {
  table-layout: fixed;
  width: max-content;
  min-width: 100%;
}

th,
td {
  text-align: left;
  padding: 8px 6px;
  border-bottom: 1px solid #2a3542;
}

table.resizable th,
table.resizable td {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

table.resizable td.actions-col,
table.resizable th.actions-col {
  overflow: visible;
}

th[data-key],
th[data-col] {
  position: relative;
}

th[data-key] {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

th[data-key]:hover {
  color: #d7e3cf;
}

.th-label {
  display: inline-block;
  max-width: calc(100% - 8px);
  overflow: hidden;
  text-overflow: ellipsis;
}

.col-resize {
  position: absolute;
  top: 0;
  right: 0;
  width: 8px;
  height: 100%;
  cursor: col-resize;
}

.row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 12px 0;
}

input[type="text"],
input[type="number"],
input[type="email"],
textarea {
  background: #12181f;
  border: 1px solid #334155;
  color: #e8eef4;
  padding: 8px 10px;
  border-radius: 8px;
  min-width: 140px;
}

textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  resize: vertical;
}

label {
  display: block;
  margin: 12px 0;
}

.schwab-accounts {
  margin-top: 16px;
  display: grid;
  gap: 12px;
}

.schwab-account-row {
  background: #12181f;
  border: 1px solid #2a3542;
  border-radius: 8px;
  padding: 12px;
}

.error {
  color: #f4b4b4;
  margin: 8px 0;
}

.muted {
  color: #93a4b8;
}

.login {
  max-width: 420px;
  margin: 12vh auto;
}

.login .row {
  flex-direction: column;
}

.login input {
  width: 100%;
}

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

tr.clickable {
  cursor: pointer;
}

tr.clickable:hover {
  background: #1f2833;
}

.row-menu {
  position: relative;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid transparent;
  background: transparent;
  color: #93a4b8;
  border-radius: 8px;
  cursor: pointer;
}

.icon-button:hover,
.icon-button:focus-visible {
  color: #e8eef4;
  background: #1b2430;
  border-color: #334155;
}

.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 8;
  min-width: 168px;
  padding: 4px;
  border: 1px solid #334155;
  border-radius: 8px;
  background: #1b2430;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
}

.menu[hidden] {
  display: none;
}

.menu button {
  border: 0;
  background: transparent;
  color: #e8eef4;
  text-align: left;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
}

.menu button:hover {
  background: #243040;
}

dialog {
  background: #171e27;
  color: #e8eef4;
  border: 1px solid #2a3542;
  border-radius: 12px;
  padding: 20px;
}

dialog::backdrop {
  background: rgba(8, 12, 16, 0.72);
}

dialog h2 {
  margin-bottom: 4px;
}
