:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-soft: #eef3ef;
  --ink: #18201d;
  --muted: #64706b;
  --line: #d9dfda;
  --accent: #1d6f5f;
  --accent-strong: #124f46;
  --blue: #265d91;
  --gold: #a96f1d;
  --danger: #a33c32;
  --shadow: 0 16px 40px rgba(24, 32, 29, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(246, 247, 244, 0.92)),
    var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px;
  background: #16231f;
  color: #f6faf7;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 12px;
  align-items: center;
}

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.section-header h3,
.section-header p,
.panel h4 {
  margin: 0;
}

.brand h1 {
  font-size: 18px;
  font-weight: 720;
}

.brand p {
  margin-top: 3px;
  color: #aebdb6;
  font-size: 12px;
}

.brand-mark {
  display: grid;
  align-items: end;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  width: 46px;
  height: 46px;
  padding: 9px;
  background: #223832;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
}

.brand-mark span {
  display: block;
  width: 100%;
  background: #75c6a4;
  border-radius: 2px;
}

.brand-mark span:nth-child(1) {
  height: 14px;
}

.brand-mark span:nth-child(2) {
  height: 24px;
  background: #d6a24b;
}

.brand-mark span:nth-child(3) {
  height: 18px;
  background: #77a9d8;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-item,
.command-button {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 7px;
  cursor: pointer;
}

.nav-item {
  width: 100%;
  padding: 10px 12px;
  color: #dce8e2;
  background: transparent;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  color: #ffffff;
  background: #243c35;
  border-color: rgba(255, 255, 255, 0.12);
}

.command-button {
  width: 100%;
  padding: 10px;
  color: #11211d;
  background: #8ccfaf;
  border-color: #8ccfaf;
  font-weight: 700;
}

.workspace {
  min-width: 0;
  padding: 28px;
}

.topbar,
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  margin-bottom: 22px;
}

.topbar h2 {
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.1;
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  letter-spacing: 0;
  text-transform: uppercase;
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.topbar-controls {
  display: grid;
  justify-items: end;
  gap: 10px;
}

.run-picker {
  display: grid;
  grid-template-columns: minmax(260px, 360px) auto;
  gap: 8px;
  align-items: end;
}

.run-picker label {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  text-transform: uppercase;
}

.run-picker select {
  width: 100%;
  min-height: 40px;
  padding: 10px;
  color: #15201d;
  background: #f8fbf9;
  border: 1px solid #c8d4ce;
  border-radius: 7px;
}

.run-picker .command-button {
  width: auto;
  min-width: 108px;
}

.status-pill,
.private-chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 6px 10px;
  color: var(--accent-strong);
  background: #e4f4ec;
  border: 1px solid #b8dfca;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 720;
  white-space: nowrap;
}

.status-pill.neutral {
  color: #4d5d58;
  background: #edf0ee;
  border-color: #d3dbd7;
}

.private-chip {
  color: #6c4b16;
  background: #fff1d9;
  border-color: #e4c78d;
}

.error-banner {
  margin: 0 0 18px;
  padding: 12px 14px;
  color: #6d211b;
  background: #f9e3df;
  border: 1px solid #ebb5ae;
  border-radius: 7px;
}

.auth-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  margin: 0 0 18px;
  padding: 16px;
  background: #f8faf8;
  border: 1px solid #dce6df;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-panel h3,
.auth-panel p {
  margin: 0;
}

.auth-panel h3 {
  margin-top: 3px;
  font-size: 18px;
}

.auth-panel p {
  margin-top: 6px;
  color: var(--muted);
}

.auth-actions,
.mfa-panel,
.totp-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
}

.mfa-panel {
  grid-column: 1 / -1;
}

.totp-secret {
  display: grid;
  gap: 3px;
  min-width: 220px;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
}

.totp-qr {
  width: 148px;
  height: 148px;
  padding: 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.totp-secret span,
.totp-form label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
  text-transform: uppercase;
}

.totp-secret strong {
  font-size: 13px;
  overflow-wrap: anywhere;
}

.totp-form input {
  width: 150px;
  min-height: 38px;
  padding: 9px 11px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
}

.hidden {
  display: none !important;
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 18px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
}

.metric-tile,
.panel,
.table-wrap,
.access-row,
.trade-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric-tile {
  min-height: 106px;
  padding: 16px;
}

.metric-tile span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric-tile strong {
  display: block;
  margin-top: 14px;
  font-size: 22px;
  overflow-wrap: anywhere;
}

.two-column {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
}

.panel {
  padding: 16px;
}

.panel h4 {
  font-size: 15px;
}

.option-timeframe-group {
  display: grid;
  gap: 12px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.options-groups,
.option-ticker-groups {
  display: grid;
  gap: 14px;
}

.option-timeframe-heading,
.option-ticker-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  list-style: none;
}

.option-timeframe-heading::-webkit-details-marker,
.option-ticker-heading::-webkit-details-marker {
  display: none;
}

.option-timeframe-heading::before,
.option-ticker-heading::before {
  content: "▾";
  flex: 0 0 auto;
  color: var(--accent-strong);
  font-size: 13px;
}

.option-timeframe-group:not([open]) > .option-timeframe-heading::before,
.option-ticker-group:not([open]) > .option-ticker-heading::before {
  content: "▸";
}

.option-timeframe-heading > div,
.option-ticker-heading h5 {
  flex: 1 1 auto;
}

.option-timeframe-heading:focus-visible,
.option-ticker-heading:focus-visible {
  outline: 2px solid #75c6a4;
  outline-offset: 4px;
  border-radius: 6px;
}

.option-timeframe-heading h4,
.option-ticker-heading h5 {
  margin: 0;
}

.option-timeframe-heading h4 {
  font-size: 16px;
}

.option-timeframe-heading span,
.option-ticker-heading span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.option-timeframe-heading strong {
  color: var(--accent-strong);
  font-size: 13px;
  white-space: nowrap;
}

.option-ticker-group {
  display: grid;
  gap: 8px;
}

.option-ticker-group:not([open]) {
  gap: 0;
}

.option-ticker-heading {
  padding: 0 2px;
}

.option-ticker-heading h5 {
  font-size: 14px;
}

.option-candidates-table {
  box-shadow: none;
}

.option-candidates-table table {
  min-width: 880px;
}

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

.market-events-panel {
  box-shadow: none;
}

.market-events-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr);
  gap: 14px;
}

.bar-list,
.plain-list {
  display: grid;
  gap: 10px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.bar-row {
  display: grid;
  grid-template-columns: 120px minmax(80px, 1fr) 58px;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}

.bar-track {
  height: 10px;
  overflow: hidden;
  background: #e5ebe7;
  border-radius: 999px;
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--blue));
  border-radius: inherit;
}

.plain-list li {
  padding: 10px 0;
  color: #33423d;
  border-bottom: 1px solid #eef2ef;
}

.event-list {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.plain-list .event-item {
  display: grid;
  gap: 4px;
  min-height: 62px;
  padding: 10px 12px;
  background: #f8faf8;
  border: 1px solid #e0e7e2;
  border-radius: 7px;
}

.event-item span {
  color: var(--muted);
  font-size: 12px;
}

.next-event-card {
  display: grid;
  gap: 6px;
  min-height: 72px;
  margin-top: 14px;
  padding: 12px;
  background: #f8faf8;
  border: 1px solid #e0e7e2;
  border-radius: 7px;
}

.next-event-card span {
  color: var(--muted);
  font-size: 12px;
}

.mini-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(96px, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.mini-metric {
  min-height: 62px;
  padding: 10px;
  background: var(--surface-soft);
  border: 1px solid #dce6df;
  border-radius: 7px;
}

.mini-metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.mini-metric strong {
  display: block;
  margin-top: 5px;
  font-size: 16px;
}

.filter-input {
  width: min(220px, 100%);
  min-height: 38px;
  padding: 9px 11px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
}

.table-wrap {
  overflow: auto;
}

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

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid #edf1ee;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  background: #f8faf8;
  font-size: 12px;
  font-weight: 760;
  text-transform: uppercase;
}

td {
  font-size: 13px;
}

.clamp {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 5px 8px;
  border-radius: 999px;
  background: #eef3ef;
  color: #31413b;
  font-size: 12px;
  font-weight: 720;
  white-space: nowrap;
}

.badge.buy,
.badge.bullish,
.badge.approved_for_paper {
  background: #e2f4ea;
  color: #15543e;
}

.badge.sell,
.badge.bearish,
.badge.blocked {
  background: #fae5e0;
  color: #7a2b25;
}

.badge.hold,
.badge.neutral,
.badge.review_only,
.badge.selected {
  background: #edf0f5;
  color: #2c4966;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 14px;
}

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

.trade-card h4 {
  margin: 0 0 10px;
  font-size: 17px;
}

.trade-card p {
  margin: 8px 0 0;
  color: #3d4e48;
  font-size: 13px;
  line-height: 1.45;
}

.history-card {
  display: grid;
  gap: 12px;
}

.sparkline {
  display: flex;
  align-items: end;
  gap: 3px;
  height: 72px;
  padding: 8px;
  background: #f4f7f5;
  border: 1px solid #e0e7e2;
  border-radius: 7px;
}

.sparkline span {
  flex: 1;
  min-width: 3px;
  background: var(--accent);
  border-radius: 3px 3px 0 0;
}

.compact-table {
  margin-top: 14px;
  box-shadow: none;
}

.compact-table table {
  min-width: 420px;
}

.access-grid {
  display: grid;
  gap: 10px;
}

.access-row {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  min-height: 72px;
  padding: 14px 16px;
}

.access-row span {
  color: var(--muted);
}

.stacked-form {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.stacked-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
  text-transform: uppercase;
}

.stacked-form input,
.stacked-form textarea {
  width: 100%;
  min-height: 38px;
  padding: 9px 11px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
  resize: vertical;
}

.inline-command {
  width: fit-content;
  min-width: 148px;
  padding-inline: 16px;
}

.form-message {
  min-height: 22px;
  color: var(--muted);
  font-size: 13px;
}

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

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    gap: 18px;
  }

  .nav-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .nav-item {
    text-align: center;
  }

  .run-picker {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
  }

  .run-picker label {
    grid-column: 1 / -1;
  }

  .command-button {
    min-width: 112px;
  }

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

@media (max-width: 680px) {
  .workspace,
  .sidebar {
    padding: 18px;
  }

  .topbar,
  .section-header,
  .topbar-controls,
  .two-column,
  .market-events-grid {
    display: grid;
    grid-template-columns: 1fr;
  }

  .topbar-controls,
  .status-strip {
    justify-items: start;
    justify-content: flex-start;
  }

  .nav-list,
  .metric-grid,
  .card-grid,
  .access-row {
    grid-template-columns: 1fr;
  }

  .bar-row {
    grid-template-columns: 86px minmax(70px, 1fr) 48px;
  }
}
