:root {
  --bg: #061226;
  --surface: #07182f;
  --surface-strong: #0b1d38;
  --ink: #f4f7ff;
  --muted: #92a2ba;
  --line: #213657;
  --teal: #37d8e8;
  --teal-dark: #84f3ff;
  --coral: #ff675d;
  --gold: #e3a524;
  --green: #24d18d;
  --blue: #3868ff;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(90deg, rgba(55, 216, 232, 0.12) 1px, transparent 1px),
    linear-gradient(180deg, rgba(55, 216, 232, 0.07) 1px, transparent 1px),
    radial-gradient(circle at 18% 0%, rgba(56, 104, 255, 0.22), transparent 34%),
    radial-gradient(circle at 92% 8%, rgba(55, 216, 232, 0.14), transparent 32%),
    linear-gradient(145deg, #081a34 0%, var(--bg) 46%, #030917 100%);
  background-size:
    36px 36px,
    36px 36px,
    auto,
    auto,
    auto;
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  width: min(1500px, calc(100vw - 40px));
  margin: 0 auto;
  padding: 24px 0 36px;
}

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

.brand,
.wallet-area,
.provider-list,
.controls,
.search-wrap,
.toggle,
.panel-header,
.asset-cell,
.status-pill,
.wallet-chip,
.intent-box {
  display: flex;
  align-items: center;
}

.brand {
  gap: 14px;
}

.brand-mark {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 1px solid rgba(55, 216, 232, 0.28);
  border-radius: 8px;
  background: #0b1d38;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.24);
}

.brand-mark svg {
  width: 34px;
  height: 34px;
  fill: none;
  stroke: var(--teal);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--teal-dark);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.35rem, 3vw, 1.9rem);
}

h2 {
  margin-bottom: 0;
  font-size: 1.35rem;
}

h3 {
  margin-bottom: 8px;
  font-size: 1rem;
}

.wallet-area {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.provider-list {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.provider-option {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #0b1d38;
  color: var(--muted);
  padding: 8px 11px;
  font-size: 0.84rem;
}

.provider-option.active {
  border-color: rgba(55, 216, 232, 0.55);
  background: rgba(55, 216, 232, 0.11);
  color: var(--teal-dark);
}

.primary-button,
.secondary-button {
  min-height: 42px;
  border-radius: 8px;
  padding: 0 16px;
  font-weight: 800;
}

.primary-button {
  border: 0;
  background: linear-gradient(180deg, #4c78ff, var(--blue));
  color: #fff;
  box-shadow: 0 14px 26px rgba(56, 104, 255, 0.24);
}

.wallet-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 154px;
  white-space: nowrap;
}

.wallet-button.connected {
  min-width: 150px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: #101827;
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.28);
  padding: 0 12px;
}

.wallet-logo {
  display: inline-grid;
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  place-items: center;
  border-radius: 6px;
}

.wallet-logo svg {
  width: 22px;
  height: 22px;
}

.metamask-logo {
  background: #f6851b;
}

.metamask-logo svg {
  fill: #ffffff;
}

.rabby-logo {
  background: #6c7cff;
}

.rabby-logo svg,
.generic-logo svg {
  fill: none;
  stroke: #ffffff;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.generic-logo {
  background: var(--teal);
}

.wallet-address {
  display: inline-block;
  max-width: 112px;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.86rem;
}

.secondary-button {
  border: 1px solid var(--line);
  background: #0b1d38;
  color: var(--ink);
}

.module-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: -6px 0 18px;
}

.module-tab {
  display: flex;
  min-width: 0;
  min-height: 58px;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(7, 24, 47, 0.86);
  color: var(--muted);
  padding: 12px;
  text-align: left;
  transition:
    transform 120ms ease,
    border-color 120ms ease,
    background 120ms ease,
    box-shadow 120ms ease,
    color 120ms ease;
}

.module-tab:hover {
  border-color: rgba(55, 216, 232, 0.36);
  color: #dbe7ff;
}

.module-tab:active {
  transform: translateY(1px);
}

.module-tab.active {
  border-color: rgba(55, 216, 232, 0.58);
  background:
    linear-gradient(180deg, rgba(56, 104, 255, 0.18), rgba(55, 216, 232, 0.08)),
    #0b1d38;
  box-shadow:
    inset 0 2px 6px rgba(0, 0, 0, 0.32),
    0 12px 30px rgba(0, 0, 0, 0.24);
  color: var(--ink);
  transform: translateY(2px);
}

.module-tab-mark {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  place-items: center;
  border: 1px solid rgba(55, 216, 232, 0.34);
  border-radius: 8px;
  background: rgba(55, 216, 232, 0.11);
  color: var(--teal-dark);
  font-size: 0.9rem;
  font-weight: 900;
}

.module-tab strong {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.98rem;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
}

.defi-module {
  display: grid;
  min-width: 0;
  gap: 14px;
}

.defi-module[hidden] {
  display: none;
}

.portfolio-panel,
.intent-panel,
.positions-panel {
  border: 1px solid rgba(55, 216, 232, 0.14);
  border-radius: 8px;
  background: rgba(7, 24, 47, 0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.portfolio-panel,
.positions-panel {
  min-width: 0;
  padding: 20px;
}

.panel-header {
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.wallet-chip {
  max-width: 360px;
  min-height: 38px;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 13px;
  color: var(--muted);
  background: #091a32;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.82rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.summary-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 13px;
}

.summary-item span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.79rem;
}

.summary-item strong {
  display: block;
  font-size: 1.22rem;
}

.controls {
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 13px;
}

.search-wrap {
  flex: 1 1 260px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #091a32;
  padding: 0 12px;
}

.search-wrap svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: var(--muted);
  stroke-linecap: round;
  stroke-width: 2;
}

.search-wrap input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  padding: 0 0 0 9px;
}

.search-wrap input::placeholder,
.intent-composer textarea::placeholder {
  color: #73849e;
}

select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #091a32;
  padding: 0 12px;
  color: var(--ink);
}

.toggle {
  min-height: 42px;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #091a32;
  padding: 0 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.status-pill {
  display: flex;
  align-items: center;
  min-width: 0;
  min-height: 38px;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #091a32;
  padding: 9px 10px;
  color: var(--muted);
  font-size: 0.78rem;
  text-align: left;
  transition:
    transform 120ms ease,
    border-color 120ms ease,
    background 120ms ease,
    box-shadow 120ms ease,
    color 120ms ease;
}

.status-pill:hover {
  border-color: rgba(55, 216, 232, 0.36);
}

.status-pill:active {
  transform: translateY(1px);
}

.status-pill.active {
  border-color: rgba(55, 216, 232, 0.62);
  background: rgba(55, 216, 232, 0.1);
  box-shadow:
    inset 0 2px 5px rgba(0, 0, 0, 0.26),
    0 1px 0 rgba(255, 255, 255, 0.06);
  color: var(--teal-dark);
  transform: translateY(2px);
}

.chain-logo {
  display: inline-grid;
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  place-items: center;
  border-radius: 50%;
  background: var(--chain-color);
  color: #fff;
  overflow: hidden;
}

.chain-logo svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.4;
}

.chain-logo-text {
  color: #fff;
  font-size: 0.62rem;
  font-weight: 900;
  line-height: 1;
}

.status-dot {
  width: 8px;
  height: 8px;
  margin-left: auto;
  flex: 0 0 8px;
  border-radius: 50%;
  background: #b7b0a4;
}

.status-pill.loading .status-dot {
  background: var(--gold);
}

.status-pill.done .status-dot {
  background: var(--green);
}

.status-pill.error .status-dot {
  background: var(--coral);
}

.status-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-wrap {
  position: relative;
  min-height: 420px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #07182f;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #0b1d38;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-align: left;
  text-transform: uppercase;
}

th,
td {
  border-bottom: 1px solid #172b49;
  padding: 13px 14px;
}

td {
  font-size: 0.93rem;
}

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

.numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.asset-cell {
  min-width: 190px;
  gap: 10px;
}

.asset-icon {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  place-items: center;
  border-radius: 50%;
  background: var(--asset-color, #087f7a);
  color: #fff;
  font-size: 0.76rem;
  font-weight: 900;
}

.asset-name {
  display: block;
  font-weight: 800;
}

.asset-symbol {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
}

.chain-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 9px;
  color: #dbe7ff;
  font-size: 0.82rem;
}

.chain-swatch {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--chain-color);
}

.empty-state {
  display: grid;
  position: absolute;
  inset: 0;
  place-items: center;
  align-content: center;
  padding: 26px;
  text-align: center;
}

.empty-state.hidden {
  display: none;
}

.empty-state p {
  max-width: 520px;
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.5;
}

.empty-visual {
  width: 180px;
  margin-bottom: 16px;
}

.empty-visual svg {
  width: 100%;
  fill: none;
  stroke: var(--teal);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 5;
}

.intent-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 420px);
  align-items: stretch;
  gap: 14px;
  min-height: 420px;
  padding: 14px;
  overflow: hidden;
}

.intent-chat-column {
  display: grid;
  min-width: 0;
  min-height: 392px;
  grid-template-rows: auto minmax(190px, 1fr) auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #061326;
}

.intent-console-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 58px;
  border-bottom: 1px solid var(--line);
  background: #091a32;
  padding: 10px 14px;
}

.intent-panel p {
  color: var(--muted);
  line-height: 1.55;
}

.parser-status {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  border: 1px solid rgba(55, 216, 232, 0.32);
  border-radius: 999px;
  background: rgba(55, 216, 232, 0.1);
  color: var(--teal-dark);
  padding: 0 10px;
  font-size: 0.76rem;
  font-weight: 800;
  white-space: nowrap;
}

.intent-chat-log {
  display: flex;
  min-height: 0;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  border: 0;
  background:
    linear-gradient(180deg, rgba(56, 104, 255, 0.06), transparent 120px),
    #061326;
  padding: 14px;
}

.intent-message {
  display: flex;
  max-width: 92%;
  flex-direction: column;
  gap: 8px;
}

.intent-message-user {
  align-self: flex-end;
}

.intent-message-assistant {
  align-self: flex-start;
}

.intent-message-body {
  border-radius: 8px;
  padding: 10px 11px;
  color: #dbe7ff;
  font-size: 0.88rem;
  line-height: 1.45;
}

.intent-message-assistant .intent-message-body {
  background: #111f38;
  border: 1px solid #1f3457;
}

.intent-message-user .intent-message-body {
  background: #3868ff;
  color: #fff;
}

.intent-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.intent-suggestion {
  border: 1px solid rgba(55, 216, 232, 0.34);
  border-radius: 999px;
  background: rgba(55, 216, 232, 0.1);
  color: var(--teal-dark);
  padding: 7px 9px;
  font-size: 0.78rem;
  font-weight: 800;
}

.intent-result {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  margin-top: 0;
  border: 1px solid rgba(55, 216, 232, 0.2);
  border-radius: 8px;
  background: #07182f;
  min-height: 392px;
  max-height: 520px;
  overflow: hidden;
}

.intent-result-scroll {
  min-height: 0;
  overflow-y: auto;
  padding: 12px;
}

.intent-result-title {
  margin-bottom: 9px;
  color: var(--teal-dark);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.intent-result-grid {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  gap: 8px 10px;
  margin: 0;
}

.intent-result-grid dt {
  color: var(--muted);
  font-size: 0.78rem;
}

.intent-result-grid dd {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.intent-empty-review {
  display: grid;
  min-height: 200px;
  align-content: center;
  gap: 8px;
  border: 1px dashed #284267;
  border-radius: 8px;
  background: rgba(17, 31, 56, 0.56);
  padding: 18px;
}

.intent-empty-review strong {
  color: #dbe7ff;
  font-size: 0.95rem;
}

.intent-empty-review span {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.preflight {
  margin-top: 12px;
  border-top: 1px solid #172b49;
  padding-top: 12px;
}

.preflight-title {
  margin-bottom: 9px;
  color: #dbe7ff;
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.preflight-list {
  display: grid;
  gap: 8px;
}

.preflight-item {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
}

.preflight-dot {
  width: 8px;
  height: 8px;
  margin-top: 6px;
  border-radius: 50%;
  background: #b7b0a4;
}

.preflight-item strong {
  display: block;
  color: var(--ink);
  font-size: 0.8rem;
}

.preflight-item span span {
  display: block;
  color: var(--muted);
  font-size: 0.77rem;
  line-height: 1.35;
}

.preflight-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 7px;
}

.preflight-suggestion {
  border: 1px solid rgba(55, 216, 232, 0.34);
  border-radius: 999px;
  background: rgba(55, 216, 232, 0.1);
  color: var(--teal-dark);
  padding: 6px 8px;
  font-size: 0.74rem;
  font-weight: 800;
}

.preflight-pass .preflight-dot {
  background: var(--green);
}

.preflight-warn .preflight-dot {
  background: var(--gold);
}

.preflight-fail .preflight-dot {
  background: var(--coral);
}

.preflight-pending .preflight-dot {
  background: #8b8377;
}

.quote-card {
  margin-top: 12px;
  border-top: 1px solid #172b49;
  padding-top: 12px;
}

.quote-card-title {
  margin-bottom: 9px;
  color: #dbe7ff;
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.quote-grid {
  grid-template-columns: 78px minmax(0, 1fr);
}

.quote-warnings {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.quote-warnings p {
  margin: 0;
  border: 1px solid rgba(227, 165, 36, 0.28);
  border-radius: 8px;
  background: rgba(227, 165, 36, 0.1);
  color: #ffd987;
  padding: 8px 9px;
  font-size: 0.76rem;
  line-height: 1.35;
}

.intent-action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.intent-action-row .primary-button,
.intent-action-row .secondary-button {
  min-height: 38px;
  padding: 0 10px;
  font-size: 0.82rem;
}

.intent-action-note {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.4;
}

.intent-action-dock {
  border-top: 1px solid #172b49;
  background: #091a32;
  padding: 12px;
  box-shadow: 0 -12px 24px rgba(3, 9, 23, 0.32);
}

.intent-composer {
  margin-top: 0;
  border-top: 1px solid var(--line);
  background: #091a32;
  padding: 12px;
}

.intent-composer textarea {
  width: 100%;
  min-height: 86px;
  max-height: 180px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
  background: #061326;
  color: var(--ink);
  padding: 11px;
  line-height: 1.45;
}

.intent-composer textarea:focus {
  border-color: rgba(55, 216, 232, 0.58);
  box-shadow: 0 0 0 3px rgba(55, 216, 232, 0.12);
}

.intent-composer textarea:disabled {
  cursor: not-allowed;
  opacity: 0.68;
}

.intent-composer-footer {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 9px;
}

.intent-composer-footer .primary-button,
.intent-composer-footer .secondary-button {
  min-height: 38px;
}

.intent-box {
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #091a32;
  padding: 12px;
}

.intent-box span {
  color: #dbe7ff;
  font-size: 0.88rem;
}

.intent-box button {
  flex: 0 0 auto;
  border: 0;
  border-radius: 8px;
  background: rgba(55, 216, 232, 0.12);
  color: var(--teal-dark);
  padding: 9px 10px;
  font-weight: 800;
}

.roadmap-list {
  margin: 16px 0 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.7;
}

.positions-table-wrap {
  min-height: 300px;
}

.module-empty-state {
  display: grid;
  position: absolute;
  inset: 0;
  place-items: center;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 800;
}

.loading-row td,
.error-row td {
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1120px) {
  .intent-panel {
    grid-template-columns: minmax(0, 1fr);
  }

  .intent-chat-log {
    min-height: 280px;
  }

  .intent-result {
    margin-top: 0;
    max-height: none;
  }
}

@media (max-width: 840px) {
  .app-shell {
    width: min(100% - 24px, 1500px);
    padding-top: 14px;
  }

  .topbar,
  .panel-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .wallet-area,
  .provider-list {
    width: 100%;
    justify-content: flex-start;
  }

  .module-tabs {
    grid-template-columns: 1fr;
  }

  .primary-button {
    width: 100%;
  }

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

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

  table {
    min-width: 760px;
  }
}

@media (max-width: 520px) {
  .portfolio-panel,
  .positions-panel,
  .intent-panel {
    padding: 14px;
  }

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