:root {
  --bg: #0f1115;
  --panel: rgba(24, 27, 33, 0.9);
  --panel-strong: rgba(31, 35, 42, 0.94);

  --text: #f4f4f5;
  --muted: #a1a1aa;

  --line: rgba(255,255,255,0.09);
  --field-bg: rgba(7,9,12,0.46);
  --field-focus: rgba(255,255,255,0.32);
  --button-bg: var(--text);
  --button-text: #050505;
  --danger-bg: rgba(239, 68, 68, 0.16);
  --danger-text: #fecaca;
  --danger-line: rgba(239, 68, 68, 0.25);
  --table-head: rgba(255,255,255,0.045);
  --table-current: rgba(255,255,255,0.075);
  --table-current-line: rgba(255,255,255,0.18);
  --shadow: rgba(0,0,0,0.35);
  --glow-inner: rgba(255,255,255,0.08);
  --glow-mid: rgba(255,255,255,0.03);

  --green: #22c55e;
  --red: #ef4444;

  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #eef0f3;
  --panel: rgba(242,244,247,0.94);
  --panel-strong: rgba(246,247,249,0.96);

  --text: #15171a;
  --muted: #5f6671;

  --line: rgba(21,23,26,0.12);
  --field-bg: rgba(255,255,255,0.88);
  --field-focus: rgba(21,23,26,0.34);
  --button-bg: #15171a;
  --button-text: #ffffff;
  --danger-bg: rgba(220, 38, 38, 0.08);
  --danger-text: #b91c1c;
  --danger-line: rgba(220, 38, 38, 0.22);
  --table-head: rgba(21,23,26,0.045);
  --table-current: rgba(21,23,26,0.065);
  --table-current-line: rgba(21,23,26,0.16);
  --shadow: rgba(24,28,35,0.12);
  --glow-inner: rgba(21,23,26,0.08);
  --glow-mid: rgba(21,23,26,0.03);

  --green: #15803d;
  --red: #dc2626;

  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  overscroll-behavior-x: none;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  min-height: 100vh;
  padding: 28px;
  position: relative;
  overflow-x: hidden;
}

.glow {
  position: fixed;
  inset: auto auto 50% 50%;
  width: 4rem;
  height: 4rem;
  transform: translate(-50%, 50%);
  border-radius: 999px;
  background: radial-gradient(
  circle,
  var(--glow-inner),
  var(--glow-mid) 38%,
  transparent 70%
  );
  pointer-events: none;
  filter: blur(8px);
  z-index: 0;
}

.container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 28px;
}

.brand {
  text-decoration: none;
  color: var(--text);
}

.logo {
  margin: 0;
  font-size: clamp(2.4rem, 8vw, 5.5rem);
  line-height: 0.9;
  letter-spacing: -0.08em;
  font-weight: 900;
  text-transform: lowercase;
}

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

.subtitle {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 15px;
}

.badge {
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255,255,255,0.04);
  white-space: nowrap;
  font-size: 14px;
}

.news-bubble {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: -8px 0 20px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel-strong);
  box-shadow: 0 14px 44px var(--shadow);
}

.news-label {
  flex: 0 0 auto;
  padding: 6px 9px;
  border-radius: 9px;
  background: var(--button-bg);
  color: var(--button-text);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.news-bubble p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.news-bubble a {
  color: var(--text);
  font-weight: 800;
  text-decoration: none;
}

.news-bubble a:hover,
.news-bubble a:focus-visible {
  text-decoration: underline;
}

.rns-panel {
  margin: 0 0 20px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: 0 14px 44px var(--shadow);
  backdrop-filter: blur(14px);
}

.rns-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 10px;
}

.rns-heading h2 {
  margin: 0;
  font-size: 16px;
}

.rns-updated {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

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

.rns-item {
  display: grid;
  grid-template-columns: minmax(86px, auto) 1fr;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.rns-date {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.rns-link {
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.35;
  text-decoration: none;
}

.rns-link:hover,
.rns-link:focus-visible {
  text-decoration: underline;
}

.rns-empty {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--text);
}

.support-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: var(--button-bg);
  color: var(--button-text);
  font-weight: 800;
  text-decoration: none;
}

.theme-icon {
  width: 1em;
  text-align: center;
}

h2 {
  margin: 0 0 16px;
  font-size: 20px;
  letter-spacing: -0.02em;
}

.card-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.card-heading h2 {
  margin-bottom: 0;
}

.export-section {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin: 18px 0 20px;
}

.export-section button,
.export-menu summary {
  padding: 12px 15px;
  font-size: 14px;
}

.export-menu {
  position: relative;
}

.export-menu summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 12px;
  background: var(--button-bg);
  color: var(--button-text);
  cursor: pointer;
  font-weight: 800;
  list-style: none;
  user-select: none;
}

.export-menu summary::-webkit-details-marker {
  display: none;
}

.export-menu summary::after {
  content: "";
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
}

.export-menu[open] summary::after {
  transform: rotate(180deg);
}

.export-menu-list {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  z-index: 5;
  display: grid;
  min-width: 132px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-strong);
  box-shadow: 0 16px 44px var(--shadow);
  transform: translateX(-50%);
}

.export-menu-list button {
  width: 100%;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.export-menu-list button:hover,
.export-menu-list button:focus-visible {
  background: var(--button-bg);
  color: var(--button-text);
}

.mcap-currency-menu,
.mcap-currency-menu summary {
  width: 100%;
}

.mcap-currency-menu summary {
  height: 47px;
  border: 1px solid var(--line);
  background: var(--field-bg);
  color: var(--text);
  font-size: 16px;
  font-weight: 400;
  justify-content: space-between;
}

.mcap-currency-menu .export-menu-list {
  left: 0;
  right: 0;
  transform: none;
}

.mcap-currency-menu .export-menu-list button {
  font-size: 16px;
  font-weight: 400;
}

.card:has(.export-menu[open]) {
  position: relative;
  z-index: 10;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 20px 80px var(--shadow);
  backdrop-filter: blur(14px);
}

label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 7px;
  color: var(--muted);
}

.price-label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.live-status {
  position: relative;
  display: none;
  align-items: center;
  gap: 5px;
  color: var(--green);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.live-status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: currentColor;
  box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 18%, transparent);
}

.live-status::after {
  content: attr(data-live-tooltip);
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  z-index: 10;
  width: max-content;
  max-width: min(260px, 70vw);
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--text);
  box-shadow: 0 12px 34px var(--shadow);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1.25;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-50%) translateX(-3px);
  transition: opacity 140ms ease 650ms, transform 140ms ease 650ms;
}

.live-status:hover::after,
.live-status:focus-visible::after {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

.live-status.is-live {
  display: inline-flex;
}

input,
select,
textarea {
  display: block;
  max-width: 100%;
  width: 100%;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 16px;
  line-height: 1.2;
  background: var(--field-bg);
  color: var(--text);
  outline: none;
}

select {
  height: 47px;
  border-radius: 12px;
  appearance: none;
  -webkit-appearance: none;
  padding-right: 36px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 50%,
    calc(100% - 13px) 50%;
  background-size:
    5px 5px,
    5px 5px;
  background-repeat: no-repeat;
}

input {
  height: 47px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--field-focus);
}

input::placeholder,
textarea::placeholder {
  color: var(--muted);
  opacity: 0.32;
}

.holding-price::placeholder {
  color: var(--muted);
  opacity: 0.32;
}

input:disabled {
  opacity: 0.7;
}

input[readonly] {
  cursor: default;
  opacity: 0.78;
}

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

.holding-row {
  display: grid;
  grid-template-columns: 1fr 1fr minmax(140px, 0.7fr) auto;
  gap: 12px;
  margin-bottom: 12px;
  align-items: end;
}

button {
  padding: 12px 15px;
  border: 0;
  border-radius: 12px;
  background: var(--button-bg);
  color: var(--button-text);
  cursor: pointer;
  font-size: 14px;
  font-weight: 800;
}

button.danger {
  background: var(--danger-bg);
  color: var(--danger-text);
  border: 1px solid var(--danger-line);
}

.holding-row button.danger {
  margin-bottom: 5px;
  padding: 9px 12px;
  font-size: 13px;
}

button.secondary {
  background: var(--panel-strong);
  color: var(--text);
  border: 1px solid var(--line);
}

.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}

.summary-box {
  background: var(--panel-strong);
  border: 1px solid var(--line);
  padding: 15px;
  border-radius: 16px;
}

.summary-box span {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 7px;
}

.summary-box strong {
  font-size: 21px;
  letter-spacing: -0.03em;
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  touch-action: pan-x pan-y;
  border: 1px solid var(--line);
  border-radius: 16px;
}

.table-controls {
  margin-top: 16px;
}

.target-editor {
  margin-top: 12px;
}

.table-controls textarea {
  min-height: 72px;
}

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

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  text-align: left;
}

th {
  background: var(--table-head);
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

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

tr.current-row td {
  background: var(--table-current);
  border-top: 1px solid var(--table-current-line);
  border-bottom: 1px solid var(--table-current-line);
}

.profit {
  color: var(--green);
  font-weight: 800;
}

.loss {
  color: var(--red);
  font-weight: 800;
}

footer {
  display: grid;
  justify-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 20px 0 8px;
}

.footer-copy {
  display: grid;
  gap: 5px;
}

.footer-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
}

.footer-actions .support-link,
.footer-actions .theme-toggle,
.footer-actions .reset-data {
  padding: 9px 12px;
  font-size: 12px;
}

@media (max-width: 760px) {
  html,
  body {
    position: relative;
    inline-size: 100%;
    max-inline-size: 100%;
  }

  body {
    padding: 14px;
  }

  header {
    display: block;
  }

  .badge {
    display: inline-block;
    margin-top: 18px;
  }

  .news-bubble {
    align-items: flex-start;
    flex-direction: column;
    margin-top: -10px;
  }

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

  .card {
    border-radius: 18px;
    padding: 16px;
  }

  .card-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .export-menu,
  .export-menu summary {
    width: 100%;
  }

  .export-menu summary {
    justify-content: center;
  }

  .mcap-currency-menu summary {
    justify-content: space-between;
  }

  .export-menu-list {
    left: 0;
    right: 0;
    transform: none;
  }

  table {
    min-width: 920px;
  }

  th,
  td {
    padding: 10px;
  }

  button.danger {
    width: 100%;
  }

  .holding-row button.danger {
    margin-bottom: 0;
  }

  .reset-data {
    width: auto;
  }

  .footer-actions .support-link,
  .footer-actions .theme-toggle,
  .footer-actions .reset-data {
    justify-content: center;
    width: 142px;
  }
}
