:root {
  color-scheme: light;
  --bg: #f4f7f9;
  --panel: rgba(255, 255, 255, 0.94);
  --panel-soft: #f7fafc;
  --ink: #111418;
  --muted: #667085;
  --line: #dce4ec;
  --accent: #2f66d8;
  --accent-dark: #244fac;
  --accent-soft: #edf4ff;
  --good: #067647;
  --bad: #d92d20;
  --warn: #b54708;
  --sidebar: #0b1110;
  --sidebar-soft: #151d1b;
  --sidebar-line: rgba(255, 255, 255, 0.08);
  --shadow: 0 18px 45px rgba(21, 31, 45, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(135deg, rgba(47, 102, 216, 0.09), transparent 34%),
    linear-gradient(315deg, rgba(6, 118, 71, 0.08), transparent 28%),
    var(--bg);
  color: var(--ink);
  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: 286px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  border-right: 1px solid var(--sidebar-line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 24%),
    linear-gradient(180deg, #0b1110 0%, #111715 100%);
  color: #f8fafc;
  padding: 22px 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  margin-bottom: 26px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: linear-gradient(135deg, #ffffff, #d7f7e6);
  color: #0c1714;
  font-weight: 800;
}

.brand-title {
  font-size: 18px;
  font-weight: 800;
}

.profile-link {
  color: #b9c5d1;
  text-decoration: none;
  font-size: 13px;
}

.profile-link:hover {
  color: #ffffff;
}

.category-block {
  display: grid;
  gap: 8px;
}

.category-row,
.city-row {
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.category-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
  border-radius: 8px;
  padding: 0 12px;
  font-weight: 750;
  transition:
    background 140ms ease,
    color 140ms ease;
}

.category-row.active {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  box-shadow: inset 0 0 0 1px var(--sidebar-line);
}

.city-list {
  display: grid;
  gap: 2px;
}

.city-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  border-radius: 8px;
  padding: 0 10px 0 18px;
  color: #e7edf3;
  transition:
    background 140ms ease,
    box-shadow 140ms ease;
}

.city-row:hover,
.city-row.selected {
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 3px 0 0 #34d399;
}

.city-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.city-meta {
  display: block;
  color: #99a6b4;
  font-size: 12px;
  margin-top: 2px;
}

.city-pnl-stack {
  display: grid;
  justify-items: end;
  min-width: 82px;
  gap: 4px;
  font-variant-numeric: tabular-nums;
}

.city-pnl-stack.total {
  min-width: auto;
}

.city-bar {
  display: block;
  width: 58px;
  height: 3px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.11);
}

.city-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #9ca3af;
}

.city-bar .positive {
  background: linear-gradient(90deg, #34d399, #10b981);
}

.city-bar .negative {
  background: linear-gradient(90deg, #fb7185, #ef4444);
}

.workspace {
  min-width: 0;
  padding: 26px;
  background:
    radial-gradient(circle at 20% 0%, rgba(47, 102, 216, 0.11), transparent 28%),
    radial-gradient(circle at 80% 8%, rgba(6, 118, 71, 0.09), transparent 26%),
    transparent;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

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

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: 32px;
  line-height: 1.1;
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
  letter-spacing: 0;
}

.top-actions,
.controls,
.account-form,
.chips {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--ink);
  cursor: pointer;
  padding: 0 13px;
  font-weight: 700;
  box-shadow: 0 1px 2px rgba(17, 24, 39, 0.06);
  transition:
    transform 120ms ease,
    border-color 120ms ease,
    background 120ms ease,
    box-shadow 120ms ease;
}

.button:hover {
  border-color: #b7c3d0;
  box-shadow: 0 8px 18px rgba(23, 37, 84, 0.1);
  transform: translateY(-1px);
}

.button:disabled {
  cursor: wait;
  opacity: 0.68;
  transform: none;
}

.button.primary {
  border-color: var(--accent);
  background: linear-gradient(135deg, var(--accent), #0f766e);
  color: #fff;
}

.button.primary:hover {
  background: linear-gradient(135deg, var(--accent-dark), #0d645e);
}

.input,
.select {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  padding: 0 11px;
  outline: none;
  transition:
    border-color 120ms ease,
    box-shadow 120ms ease;
}

.input:focus,
.select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 102, 216, 0.13);
}

.address-input {
  width: min(430px, 100%);
}

.input.compact {
  width: 180px;
}

.account-strip,
.metric-grid,
.panel,
.error-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.account-strip {
  display: grid;
  gap: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #eef7f4;
  color: #1e4b43;
  padding: 0 7px 0 11px;
  font-size: 13px;
}

.chip button {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
}

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

.metric {
  min-width: 0;
  padding: 19px;
  border-right: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.4), transparent),
    rgba(255, 255, 255, 0.48);
}

.metric:last-child {
  border-right: 0;
}

.metric-label,
.subline {
  color: var(--muted);
  font-size: 13px;
}

.metric-value {
  overflow: hidden;
  margin-top: 6px;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}

.metric-value.small {
  font-size: 17px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
}

.panel {
  min-width: 0;
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 17px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(255, 255, 255, 0.45)),
    var(--panel-soft);
}

.compact-head {
  align-items: center;
}

.table-wrap {
  overflow: auto;
  background: rgba(255, 255, 255, 0.56);
}

table {
  width: 100%;
  min-width: 1100px;
  border-collapse: separate;
  border-spacing: 0;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 13px 14px;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  color: #49515c;
  font-weight: 800;
}

.market-row:hover td {
  background: #fbfefd;
}

.title-line {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.pnl-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  background: #eef7f4;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}

td.num,
th.num {
  text-align: right;
}

.market-cell {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 10px;
}

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

.market-title {
  max-width: 380px;
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  white-space: nowrap;
}

.market-title-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 20px;
  min-width: 20px;
  max-width: 20px;
  height: 20px;
  min-height: 20px;
  max-height: 20px;
  overflow: hidden;
  border: 1px solid #cbd8e6;
  border-radius: 7px;
  background: #ffffff;
  color: #475569;
  line-height: 1;
  text-decoration: none;
  vertical-align: middle;
}

.icon-link:hover {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 4px 12px rgba(47, 102, 216, 0.14);
}

.icon-link svg {
  display: block;
  width: 12px !important;
  max-width: 12px !important;
  height: 12px !important;
  max-height: 12px !important;
  fill: currentColor;
  flex: 0 0 auto;
}

.market-url-link {
  color: #0f766e;
}

.tx-link {
  color: #4f46e5;
}

.fill-toggle {
  min-width: 72px;
  min-height: 26px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f0f9ff;
  color: #31527d;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  transition:
    background 120ms ease,
    border-color 120ms ease;
}

.fill-toggle:hover:not(:disabled) {
  border-color: #a8c6ee;
  background: #e7f2ff;
}

.fill-toggle:disabled {
  cursor: default;
  opacity: 0.42;
}

.detail-row td {
  background: #f8fafc;
  padding: 0;
}

.fill-grid {
  display: grid;
  gap: 1px;
  padding: 10px 14px 14px 110px;
}

.fill-item {
  display: grid;
  grid-template-columns: 120px 56px 90px 1fr 80px 92px 24px;
  gap: 12px;
  align-items: center;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 0 10px;
  color: #475569;
  font-size: 12px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}

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

.positive {
  color: var(--good);
}

.negative {
  color: var(--bad);
}

.warning {
  color: var(--warn);
}

.sidebar .positive {
  color: #34d399;
}

.sidebar .negative {
  color: #fb7185;
}

.sidebar .muted {
  color: #a8b3c1;
}

.activity-list {
  display: grid;
}

.activity-item {
  display: grid;
  gap: 5px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  background:
    linear-gradient(90deg, rgba(6, 118, 71, 0.05), transparent 52%),
    rgba(255, 255, 255, 0.5);
}

.activity-item:last-child {
  border-bottom: 0;
}

.activity-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.activity-actions {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-variant-numeric: tabular-nums;
}

.error-box {
  margin-bottom: 16px;
  padding: 12px 14px;
  color: #7d1f1f;
  background: #fff2f0;
}

.empty-state {
  padding: 34px 18px;
  color: var(--muted);
  text-align: center;
}

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

  .sidebar {
    position: static;
    height: auto;
    max-height: 48vh;
  }

  .content-grid,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .metric {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .metric:last-child {
    border-bottom: 0;
  }
}

@media (max-width: 620px) {
  .workspace {
    padding: 16px;
  }

  .topbar,
  .panel-head {
    display: grid;
  }

  h1 {
    font-size: 28px;
  }

  .input,
  .select,
  .button,
  .input.compact {
    width: 100%;
  }

  .market-cell {
    grid-template-columns: 1fr;
  }

  .market-title {
    max-width: 68vw;
  }

  .city-pnl-stack {
    min-width: 74px;
  }
}
