:root {
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-2: #eef3f4;
  --ink: #17201f;
  --muted: #66736f;
  --soft: #899692;
  --line: #d9e1de;
  --line-strong: #c5d0cc;
  --teal: #147d7f;
  --teal-dark: #0d4f52;
  --blue: #3267b1;
  --green: #12845f;
  --red: #c23b4a;
  --amber: #b97918;
  --shadow: 0 16px 40px rgba(22, 32, 31, .08);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(20, 125, 127, .08), rgba(245, 247, 248, 0) 320px),
    var(--bg);
  color: var(--ink);
  font: 15px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.eyebrow {
  margin: 0;
  color: var(--teal);
  font-size: .78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.muted {
  color: var(--muted);
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    linear-gradient(90deg, #f7faf9 0%, #eef4f4 54%, #ffffff 54%, #ffffff 100%);
}

.login-shell {
  width: min(1080px, 100%);
  min-height: min(720px, calc(100vh - 56px));
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(360px, .88fr);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-intro {
  display: grid;
  align-content: space-between;
  gap: 28px;
  min-width: 0;
  min-height: 560px;
  padding: 42px;
  background: #123437;
  color: #f4fbfa;
}

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

.brand-mark {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #d6f1ec;
  color: #0e3b3e;
  font-weight: 900;
}

.brand-lockup strong,
.brand strong,
.brand-lockup small,
.brand small {
  display: block;
}

.brand-lockup strong,
.brand strong {
  font-size: 1rem;
}

.brand-lockup small,
.brand small {
  color: var(--muted);
  font-size: .82rem;
}

.brand-lockup small {
  color: rgba(244, 251, 250, .7);
}

.login-copy {
  max-width: 560px;
}

.login-copy .eyebrow {
  color: #9ee4d7;
}

.login-copy h1 {
  margin: 10px 0 14px;
  max-width: 560px;
  overflow-wrap: break-word;
  font-size: clamp(2.05rem, 4vw, 3.35rem);
  line-height: 1.04;
}

.login-copy p:last-child {
  margin: 0;
  max-width: 460px;
  color: rgba(244, 251, 250, .76);
  font-size: 1.02rem;
}

.login-snapshot {
  max-width: 520px;
  padding: 18px;
  border: 1px solid rgba(214, 241, 236, .22);
  border-radius: 8px;
  background: rgba(255, 255, 255, .08);
}

.snapshot-head,
.snapshot-grid,
.bar-label,
.queue-row,
.mover-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.snapshot-head span,
.snapshot-grid small {
  color: rgba(244, 251, 250, .68);
}

.snapshot-head strong {
  color: #98eccf;
  font-size: 1.28rem;
}

.sparkline {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  align-items: end;
  gap: 8px;
  height: 118px;
  margin: 18px 0;
  padding: 12px;
  border-radius: 8px;
  background: rgba(5, 21, 23, .35);
}

.sparkline span {
  min-height: 18px;
  border-radius: 6px 6px 2px 2px;
  background: #d6f1ec;
}

.snapshot-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}

.snapshot-grid span {
  padding-top: 12px;
  border-top: 1px solid rgba(214, 241, 236, .18);
}

.snapshot-grid small,
.snapshot-grid strong {
  display: block;
}

.login-card {
  display: grid;
  align-content: center;
  gap: 15px;
  min-width: 0;
  padding: 48px;
  background: var(--surface);
}

.login-card h2 {
  margin: 0;
  font-size: 2rem;
}

.form-note {
  margin: -8px 0 8px;
  color: var(--muted);
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: .9rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  outline: 0;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(20, 125, 127, .16);
}

input:disabled,
textarea:disabled,
button:disabled {
  cursor: not-allowed;
  opacity: .56;
}

button {
  min-height: 40px;
  padding: 9px 14px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  font-weight: 800;
  transition: background .16s ease, border-color .16s ease, color .16s ease, transform .16s ease;
}

button:hover {
  background: var(--surface-2);
}

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

.login-submit,
.primary {
  color: #ffffff;
  background: var(--teal);
  border-color: var(--teal);
}

.login-submit:hover,
.primary:hover {
  background: var(--teal-dark);
  border-color: var(--teal-dark);
}

.ghost {
  color: var(--muted);
  background: transparent;
}

.danger {
  color: var(--red);
  border-color: rgba(194, 59, 74, .28);
}

.danger:hover {
  background: rgba(194, 59, 74, .08);
}

.error {
  min-height: 1.25em;
  color: var(--red);
  font-weight: 700;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr) minmax(420px, auto);
  gap: 18px;
  align-items: center;
  padding: 14px 24px;
  background: rgba(255, 255, 255, .94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.brand .brand-mark {
  background: #123437;
  color: #e7f7f4;
}

.account-rail {
  min-width: 0;
}

.accounts {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  justify-content: center;
  padding: 3px;
}

.pill {
  flex: 0 0 auto;
  min-height: 38px;
  color: var(--muted);
  background: #f7faf9;
}

.pill.active {
  color: #ffffff;
  background: #123437;
  border-color: #123437;
}

.top-actions {
  display: grid;
  grid-template-columns: minmax(170px, 260px) auto auto;
  align-items: center;
  gap: 8px;
}

.account-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.account-form input {
  min-height: 40px;
  background: #f7faf9;
}

.user-chip {
  max-width: 210px;
  min-height: 36px;
  padding: 8px 10px;
  overflow: hidden;
  color: var(--teal-dark);
  background: #e7f5f2;
  border: 1px solid #c5e4df;
  border-radius: 8px;
  font-size: .82rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-chip:empty {
  display: none;
}

.app-main {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 24px 24px 56px;
}

.page-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.page-head h1 {
  margin: 6px 0 5px;
  font-size: clamp(1.8rem, 3vw, 2.55rem);
  line-height: 1.05;
}

.page-head p:last-child {
  margin: 0;
  max-width: 720px;
  color: var(--muted);
}

.market-status {
  min-width: 230px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(22, 32, 31, .05);
}

.market-status span,
.market-status strong {
  display: block;
}

.market-status span {
  color: var(--muted);
  font-size: .8rem;
}

.market-status strong {
  margin-top: 2px;
}

.summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.card,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(22, 32, 31, .045);
}

.card {
  min-height: 116px;
  padding: 16px;
}

.card span {
  display: block;
  color: var(--muted);
  font-size: .76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.card strong {
  display: block;
  margin-top: 9px;
  overflow-wrap: anywhere;
  font-size: clamp(1.12rem, 1.7vw, 1.42rem);
  line-height: 1.15;
}

.card small {
  display: block;
  margin-top: 8px;
  color: var(--soft);
}

.notice {
  margin: 0 0 14px;
  padding: 12px 14px;
  color: #7d4f08;
  background: #fff7e9;
  border: 1px solid #edd3a5;
  border-radius: 8px;
}

.mode-hint {
  margin: 0;
  padding: 10px 12px;
  color: #7d4f08;
  background: #fff7e9;
  border: 1px solid #edd3a5;
  border-radius: 8px;
  font-weight: 800;
}

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-bottom: 16px;
  padding: 6px;
  background: #eaf0ef;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.tabs button {
  flex: 0 0 auto;
  min-height: 38px;
  color: var(--muted);
  background: transparent;
  border-color: transparent;
}

.tabs button.active {
  color: #ffffff;
  background: #123437;
  border-color: #123437;
}

.grid3 {
  display: grid;
  grid-template-columns: 1.18fr .88fr .94fr;
  gap: 14px;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(310px, .4fr);
  gap: 14px;
}

.stack {
  display: grid;
  gap: 12px;
}

.panel {
  padding: 16px;
}

.panel h2 {
  margin: 0 0 14px;
  font-size: 1.02rem;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-head select {
  max-width: 180px;
}

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

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  background: var(--surface);
}

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

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

th {
  color: var(--muted);
  background: #f7faf9;
  font-size: .74rem;
  font-weight: 900;
  text-transform: uppercase;
}

tbody tr:hover {
  background: #fbfdfc;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.sym {
  color: var(--ink);
  font-weight: 900;
}

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

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

.quote-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 8px;
  font-size: .78rem;
  font-weight: 900;
}

.quote-badge.live {
  color: var(--teal-dark);
  background: #e7f5f2;
}

.quote-badge.unavailable {
  color: #7d4f08;
  background: #fff7e9;
}

.bar-row {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

.bar-label {
  align-items: center;
  font-weight: 800;
}

.bar-label strong {
  color: var(--muted);
  font-size: .88rem;
}

.bar {
  height: 10px;
  overflow: hidden;
  background: #e8eeee;
  border-radius: 8px;
}

.bar div {
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--blue), var(--amber));
}

.queue-row,
.mover-row {
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.queue-row:last-child,
.mover-row:last-child {
  border-bottom: 0;
}

.queue-row span,
.mover-row span {
  color: var(--muted);
}

.segment {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  background: #eaf0ef;
  border-radius: 8px;
}

.segment button {
  min-height: 38px;
  color: var(--muted);
  background: transparent;
  border: 0;
}

.segment button[data-action="buy"].active {
  color: #ffffff;
  background: var(--green);
}

.segment button[data-action="sell"].active {
  color: #ffffff;
  background: var(--red);
}

.full {
  width: 100%;
  margin-top: 12px;
}

textarea {
  min-height: 360px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

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

@media (max-width: 1180px) {
  .topbar {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .accounts {
    justify-content: flex-start;
  }

  .top-actions {
    grid-template-columns: minmax(0, 1fr) auto auto;
  }

  .grid3,
  .split {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 820px) {
  .login-screen {
    place-items: start center;
    overflow-y: auto;
    padding: 0;
    background: var(--surface);
  }

  .login-shell {
    min-height: 100vh;
    grid-template-columns: 1fr;
    border: 0;
    border-radius: 0;
  }

  .login-intro {
    align-content: start;
    min-height: auto;
    gap: 22px;
    padding: 28px;
  }

  .login-copy h1 {
    font-size: 2.25rem;
  }

  .login-snapshot {
    display: none;
  }

  .login-card {
    padding: 28px;
  }

  .page-head {
    align-items: stretch;
    flex-direction: column;
  }

  .market-status {
    min-width: 0;
  }
}

@media (max-width: 640px) {
  .topbar,
  .app-main {
    padding-left: 14px;
    padding-right: 14px;
  }

  .top-actions {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .account-form {
    grid-column: 1 / -1;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .user-chip {
    max-width: none;
  }

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

  .tabs {
    gap: 4px;
  }

  .tabs button,
  button {
    min-height: 42px;
  }
}
