* {
  box-sizing: border-box;
}

:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #667085;
  --line: #d9e0e8;
  --blue: #2457d6;
  --green: #087443;
  --red: #b42318;
  --amber: #b54708;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.5;
}

a {
  color: var(--blue);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px clamp(18px, 4vw, 44px);
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(30px, 5vw, 48px);
  line-height: 1.05;
}

h2 {
  margin-bottom: 0;
  font-size: 22px;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--amber);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

.nav-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.user-chip {
  max-width: 180px;
  overflow: hidden;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.button.primary {
  border-color: var(--blue);
  background: var(--blue);
  color: #ffffff;
}

.button.ghost {
  background: #ffffff;
}

.layout {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 26px 0 48px;
}

.market-strip,
.summary-grid,
.workbench,
.lower-grid {
  display: grid;
  gap: 16px;
}

.market-strip {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 18px;
}

.quote-tile,
.summary-grid article,
.panel,
.intro-panel,
.auth-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.quote-tile {
  display: flex;
  min-height: 112px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
}

.quote-tile h2 {
  font-size: 30px;
}

.quote-tile p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 18px;
  font-weight: 700;
}

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

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

.intro-panel {
  display: grid;
  grid-template-columns: minmax(220px, 320px) minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  padding: 22px;
}

.intro-panel h2 {
  font-size: clamp(28px, 4vw, 42px);
}

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

.summary-grid article {
  padding: 16px;
}

.summary-grid span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

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

.workbench {
  grid-template-columns: 320px minmax(320px, 0.7fr) minmax(0, 1fr);
  margin-bottom: 16px;
}

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

.panel {
  min-width: 0;
  padding: 18px;
}

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

.trade-form,
.stack {
  display: grid;
  gap: 10px;
}

label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 42px;
  padding: 9px 10px;
  border: 1px solid #b8c2cc;
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  font: inherit;
}

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

.stock-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 14px;
}

.stock-meta div {
  min-width: 0;
}

.stock-meta dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.stock-meta dd {
  margin: 2px 0 0;
  overflow-wrap: anywhere;
  font-weight: 700;
}

.chart-wrap {
  width: 100%;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
}

.chart-wrap canvas {
  display: block;
  width: 100%;
  height: auto;
}

table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
}

th,
td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

td {
  font-size: 14px;
}

.message {
  padding: 11px 13px;
  border-radius: 6px;
  font-weight: 700;
}

.message.success {
  border: 1px solid #98d8b7;
  background: #ecfdf3;
  color: var(--green);
}

.message.error {
  border: 1px solid #f1a7a1;
  background: #fff1f0;
  color: var(--red);
}

.auth-shell {
  width: min(480px, calc(100% - 32px));
  margin: 0 auto;
  padding: 44px 0;
}

.auth-panel {
  padding: 24px;
}

.back-link {
  display: inline-flex;
  margin-bottom: 14px;
  font-weight: 700;
  text-decoration: none;
}

@media (max-width: 860px) {
  .topbar,
  .intro-panel,
  .workbench,
  .lower-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .nav-actions {
    justify-content: flex-start;
  }

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

@media (max-width: 560px) {
  .summary-grid,
  .market-strip {
    grid-template-columns: 1fr;
  }

  .quote-tile {
    min-height: 88px;
  }
}
