:root {
  --bg: #f9f9f9;
  --surface: #ffffff;
  --surface-muted: #eeeeee;
  --ink: #000000;
  --ink-secondary: #5d5f5f;
  --orange: #ff5f1f;
  --error: #ba1a1a;
  --error-bg: #ffdad6;
  --success: #15803d;
  --border: 4px solid #000000;
  --shadow: 6px 6px 0px #000000;
  --shadow-hover: 2px 2px 0px #000000;
}

* {
  box-sizing: border-box;
  border-radius: 0px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Hanken Grotesk", system-ui, sans-serif;
  line-height: 1.5;
}

h1, h2, h3, .btn {
  font-family: "Anybody", system-ui, sans-serif;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  margin: 0;
}

.mono-meta, .chip, code, table td, .kpi-value {
  font-family: "JetBrains Mono", monospace;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  background: var(--surface);
  border-bottom: var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 48px;
  height: 48px;
  background: var(--orange);
  color: var(--ink);
  border: var(--border);
  font-family: "Anybody", sans-serif;
  font-weight: 900;
  font-size: 1.25rem;
  box-shadow: 4px 4px 0px #000000;
}

.brand h1 {
  font-size: 1.5rem;
  font-weight: 900;
}

.mono-meta {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--ink-secondary);
  margin: 0;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.container {
  max-width: 1360px;
  margin: 0 auto;
  padding: 24px;
  display: grid;
  gap: 24px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
}

.workspace-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 24px;
}

.card {
  background: var(--surface);
  border: var(--border);
  box-shadow: var(--shadow);
}

.kpi-card {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kpi-label {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--ink-secondary);
}

.kpi-value {
  font-size: 1.4rem;
  font-weight: 800;
}

.card-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: var(--border);
  background: var(--surface-muted);
}

.card-header h2 {
  font-size: 1.05rem;
  font-weight: 900;
}

.card-body {
  padding: 20px;
}

.chip {
  display: inline-block;
  padding: 4px 10px;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  border: 2px solid #000000;
  background: var(--surface);
  color: var(--ink);
}

.chip-orange {
  background: var(--orange);
}

.btn {
  padding: 10px 18px;
  font-size: 0.85rem;
  font-weight: 800;
  border: var(--border);
  box-shadow: 4px 4px 0px #000000;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.btn:hover {
  transform: translate(2px, 2px);
  box-shadow: var(--shadow-hover);
}

.btn:active {
  transform: translate(4px, 4px);
  box-shadow: 0px 0px 0px #000000;
}

.btn-white {
  background: var(--surface);
  color: var(--ink);
}

.btn-orange {
  background: var(--orange);
  color: var(--ink);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px;
}

.inline-form .field {
  flex: 1 1 160px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}

label {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.75rem;
  font-weight: 800;
}

.hint {
  font-size: 0.75rem;
  color: var(--ink-secondary);
}

input, select {
  padding: 10px 12px;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.9rem;
  font-weight: 600;
  background: var(--surface);
  color: var(--ink);
  border: 3px solid #000000;
}

input:focus, select:focus {
  outline: 3px solid var(--orange);
  outline-offset: 1px;
}

/* Validate only after user interaction */
:is(:user-invalid, .user-invalid-fallback) {
  border-color: var(--error);
  background: var(--error-bg);
}

.error-msg {
  display: none;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--error);
}

:is(:user-invalid, .user-invalid-fallback) + .error-msg {
  display: block;
}

:is(:user-valid, .user-valid-fallback) {
  border-color: var(--success);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 16px;
  cursor: pointer;
}

.checkbox-row input {
  width: 18px;
  height: 18px;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
}

.ai-output {
  margin-top: 18px;
  padding-top: 16px;
  border-top: var(--border);
}

.ai-verdict-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.ai-thesis {
  margin: 0 0 12px;
  font-weight: 600;
}

.opinions-list {
  display: grid;
  gap: 10px;
}

.opinion-item {
  padding: 10px 12px;
  background: var(--bg);
  border: 2px solid #000000;
}

.bt-results {
  margin-top: 18px;
  padding-top: 16px;
  border-top: var(--border);
}

.bt-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.bt-chart {
  width: 100%;
  height: 180px;
  background: var(--bg);
  border: 3px solid #000000;
}

/* Responsive accessible table */
.table-wrapper {
  overflow: auto;
  max-inline-size: 100%;
  max-block-size: min(420px, 70vh);
  container-type: inline-size;
  border: 3px solid #000000;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.85rem;
}

thead {
  position: sticky;
  inset-block-start: 0;
  z-index: 1;
  background: var(--ink);
  color: var(--surface);
}

th, td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 2px solid #000000;
  white-space: nowrap;
}

tbody th {
  position: sticky;
  inset-inline-start: 0;
  background: var(--surface);
  font-weight: 800;
}

.empty-cell {
  text-align: center;
  color: var(--ink-secondary);
  padding: 20px;
}

.pos-green { color: var(--success); font-weight: 800; }
.pos-red { color: var(--error); font-weight: 800; }

@container (width < 600px) {
  table, thead, tbody, tr, th, td {
    display: block;
  }

  thead {
    display: none;
  }

  tr {
    margin-block-end: 14px;
    border-bottom: 4px solid #000000;
  }

  tbody th {
    position: sticky;
    inset-block-start: 0;
    z-index: 2;
    background: var(--surface-muted);
  }

  #positions-table {
    --label-2: "CLASS";
    --label-3: "QTY";
    --label-4: "AVG COST";
    --label-5: "PRICE";
    --label-6: "VALUE";
    --label-7: "UNREALIZED PNL";
    --label-8: "WEIGHT";
  }

  #trades-table {
    --label-2: "SYMBOL";
    --label-3: "SIDE";
    --label-4: "QTY";
    --label-5: "FILL PRICE";
    --label-6: "FEE";
    --label-7: "REALIZED PNL";
    --label-8: "NOTE";
  }

  td:nth-child(2)::before { content: var(--label-2) ": "; font-weight: 800; }
  td:nth-child(3)::before { content: var(--label-3) ": "; font-weight: 800; }
  td:nth-child(4)::before { content: var(--label-4) ": "; font-weight: 800; }
  td:nth-child(5)::before { content: var(--label-5) ": "; font-weight: 800; }
  td:nth-child(6)::before { content: var(--label-6) ": "; font-weight: 800; }
  td:nth-child(7)::before { content: var(--label-7) ": "; font-weight: 800; }
  td:nth-child(8)::before { content: var(--label-8) ": "; font-weight: 800; }
}

.hidden {
  display: none;
}

.visually-hidden:where(:not(:focus-within, :active)) {
  position: absolute !important;
  clip-path: inset(50%) !important;
  overflow: hidden !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  border: 0 !important;
  white-space: nowrap !important;
}
