:root {
  color-scheme: dark;
  --bg: #101112;
  --surface: #17191b;
  --surface-2: #1d2023;
  --line: #2a2f34;
  --line-soft: rgba(255, 255, 255, 0.07);
  --text: #eef1f3;
  --muted: #8f989f;
  --muted-2: #6d767e;
  --green: #58d68d;
  --amber: #d8b35a;
  --focus: rgba(88, 214, 141, 0.24);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 28rem),
    var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(1080px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 26px 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 44px;
  margin-bottom: 52px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #dfe4e7;
  font-size: 14px;
  font-weight: 650;
}

.brand-mark {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #151719;
}

.brand-mark svg {
  width: 15px;
  height: 15px;
  fill: var(--green);
}

.nav-tabs {
  display: flex;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
}

.nav-tab {
  min-width: 72px;
  height: 30px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.nav-tab.active {
  background: var(--surface-2);
  color: var(--text);
}

.nav-tab:disabled {
  cursor: default;
  opacity: 0.48;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 520px) minmax(300px, 380px);
  justify-content: center;
  align-items: start;
  gap: 16px;
}

.access-panel {
  display: grid;
  min-height: 380px;
  place-items: center;
}

.access-card {
  display: grid;
  gap: 16px;
  width: min(420px, 100%);
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}

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

.primary-button {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #191c1f;
  color: var(--muted);
  cursor: not-allowed;
  font-weight: 700;
}

.primary-button:not(:disabled) {
  border-color: rgba(88, 214, 141, 0.36);
  background: rgba(88, 214, 141, 0.14);
  color: var(--text);
  cursor: pointer;
}

.primary-button:not(:disabled):hover {
  border-color: rgba(88, 214, 141, 0.58);
  background: rgba(88, 214, 141, 0.2);
}

.access-actions {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.telegram-token-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 38px;
  border: 1px solid rgba(88, 214, 141, 0.34);
  border-radius: 8px;
  background: rgba(88, 214, 141, 0.08);
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    color 160ms ease;
}

.telegram-token-button:hover {
  border-color: rgba(88, 214, 141, 0.62);
  background: rgba(88, 214, 141, 0.14);
  color: var(--green);
}

.telegram-token-button svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.access-hint {
  min-height: 16px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.left-stack {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.tracker {
  width: 100%;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}

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

.eyebrow {
  margin: 0 0 3px;
  color: var(--muted-2);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 720;
  letter-spacing: 0;
}

h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 720;
  letter-spacing: 0;
}

h3 {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 26px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--muted-2);
}

.live-pill.is-live {
  color: var(--green);
  border-color: rgba(88, 214, 141, 0.22);
}

.live-pill.is-live .status-dot {
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(88, 214, 141, 0.12);
}

.controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  min-width: 0;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

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

.field input {
  width: 100%;
  min-width: 0;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  background: #121416;
  color: var(--text);
  padding: 0 11px;
  font-family:
    "SFMono-Regular", Consolas, "Liberation Mono", ui-monospace, monospace;
  font-size: 12px;
}

.field input:focus {
  border-color: rgba(88, 214, 141, 0.46);
  box-shadow: 0 0 0 3px var(--focus);
}

.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
}

.ghost-button svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
}

.metric-panel {
  display: grid;
  gap: 14px;
  margin-top: 18px;
  padding: 16px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #141618;
}

.primary-metric {
  display: grid;
  gap: 5px;
}

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

.primary-metric strong {
  color: var(--text);
  font-size: clamp(24px, 5vw, 30px);
  line-height: 1.1;
  font-weight: 760;
  letter-spacing: 0;
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.metric-item {
  min-width: 0;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
}

.metric-item strong {
  display: block;
  margin-top: 5px;
  overflow-wrap: anywhere;
  font-size: 15px;
  font-weight: 720;
}

.tracker-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  min-height: 32px;
  margin-top: 12px;
  color: var(--muted-2);
  font-size: 12px;
}

.hedge-card {
  width: 100%;
  padding: 16px 18px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 18px 52px rgba(0, 0, 0, 0.2);
}

.hedge-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.hedge-grid {
  display: grid;
  gap: 14px;
}

.hedge-group {
  display: grid;
  gap: 9px;
}

.hedge-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(86px, 0.8fr) minmax(82px, 0.64fr);
  gap: 8px;
  align-items: end;
}

.inline-spread {
  display: grid;
  gap: 6px;
  min-width: 0;
}

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

.inline-spread strong {
  display: flex;
  align-items: center;
  min-height: 34px;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 14px;
  font-weight: 760;
}

.inline-spread strong.is-positive {
  color: var(--green);
}

.inline-spread strong.is-negative {
  color: #e06f6f;
}

.hedge-results {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
  gap: 8px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
}

.hedge-result {
  min-width: 0;
}

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

.hedge-result strong {
  display: block;
  margin-top: 5px;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 15px;
  font-weight: 760;
}

.hedge-result.is-total strong {
  font-size: 17px;
}

.hedge-result strong.is-positive {
  color: var(--green);
}

.hedge-result strong.is-negative {
  color: #e06f6f;
}

.purchase-panel {
  display: grid;
  gap: 14px;
  width: 100%;
  min-height: 384px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.22);
}

.purchase-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.selected-pill {
  min-height: 24px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.date-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.compact-field input {
  height: 34px;
  color-scheme: dark;
}

.purchase-list {
  display: grid;
  gap: 8px;
  max-height: 284px;
  overflow: auto;
  padding-right: 2px;
}

.purchase-row {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) 74px 96px;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 9px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #141618;
}

.purchase-columns {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) 74px 96px;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  padding: 0 9px;
  color: var(--muted-2);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.purchase-columns span {
  text-align: right;
}

.purchase-columns span:first-of-type {
  text-align: left;
}

.master-check {
  display: grid;
  place-items: center;
}

.master-check input,
.purchase-row input {
  width: 15px;
  height: 15px;
  accent-color: var(--green);
}

.purchase-main {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.purchase-tx {
  overflow: hidden;
  color: var(--text);
  font-family:
    "SFMono-Regular", Consolas, "Liberation Mono", ui-monospace, monospace;
  font-size: 12px;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.purchase-tx:hover {
  color: var(--green);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.purchase-time {
  color: var(--muted-2);
  font-size: 11px;
}

.purchase-coins {
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.purchase-usdt {
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  font-weight: 720;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty-state {
  margin: 18px 0;
  color: var(--muted-2);
  font-size: 13px;
  text-align: center;
}

.ghost-button {
  width: 30px;
  height: 30px;
  background: transparent;
  color: var(--muted);
}

.ghost-button:hover {
  border-color: var(--line);
  color: var(--text);
}

.is-invalid {
  border-color: rgba(216, 90, 90, 0.7) !important;
  box-shadow: 0 0 0 3px rgba(216, 90, 90, 0.15) !important;
}

.telegram-float {
  position: fixed;
  left: 22px;
  bottom: 22px;
  z-index: 20;
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(88, 214, 141, 0.34);
  border-radius: 50%;
  background: #101719;
  box-shadow:
    0 18px 42px rgba(0, 0, 0, 0.34),
    0 0 0 5px rgba(88, 214, 141, 0.08);
  color: var(--green);
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.telegram-float::after {
  position: absolute;
  inset: -18px;
  content: "";
  background: linear-gradient(
    115deg,
    transparent 32%,
    rgba(255, 255, 255, 0.36) 46%,
    rgba(255, 255, 255, 0.08) 52%,
    transparent 66%
  );
  transform: translateX(-130%) rotate(12deg);
  animation: telegram-glint 4.8s ease-in-out infinite;
}

.telegram-float:hover {
  border-color: rgba(88, 214, 141, 0.66);
  box-shadow:
    0 20px 48px rgba(0, 0, 0, 0.42),
    0 0 0 6px rgba(88, 214, 141, 0.12);
  transform: translateY(-2px);
}

.telegram-float svg {
  position: relative;
  z-index: 1;
  width: 24px;
  height: 24px;
  fill: currentColor;
}

@keyframes telegram-glint {
  0%,
  62% {
    transform: translateX(-130%) rotate(12deg);
  }

  78%,
  100% {
    transform: translateX(130%) rotate(12deg);
  }
}

@media (min-width: 720px) {
  .controls {
    grid-template-columns: 1fr 1fr;
    align-items: end;
  }
}

@media (max-width: 620px) {
  .app-shell {
    width: calc(100% - 24px);
    padding: 16px 0;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    margin-bottom: 26px;
  }

  .tracker {
    width: 100%;
    padding: 14px;
  }

  .tracker-header {
    flex-direction: column;
    gap: 8px;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .purchase-panel {
    padding: 14px;
  }

  .hedge-card {
    padding: 14px;
  }

  .hedge-fields,
  .hedge-results {
    grid-template-columns: 1fr;
  }

  .field input {
    font-size: 11px;
  }

  .primary-metric strong {
    font-size: 27px;
  }

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

  .date-grid {
    grid-template-columns: 1fr;
  }

  .telegram-float {
    left: 14px;
    bottom: 14px;
    width: 48px;
    height: 48px;
  }
}
