:root {
  color-scheme: light;
  --bg: #ffffff;
  --panel: #ffffff;
  --text: #171c2a;
  --muted: #697182;
  --faint: #9aa2b1;
  --line: #e8ebf0;
  --line-strong: #d9dee7;
  --row-hover: #f7f8fb;
  --accent: #2f6df6;
  --good: #059669;
  --bad: #f43f5e;
  --shadow: 0 18px 48px rgba(21, 28, 42, .12);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-width: 360px;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  padding: 0 13px;
}

button:hover { background: #f8fafc; }
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
button:disabled { opacity: .55; cursor: default; }

input {
  height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 0 11px;
}

textarea {
  min-height: 112px;
  resize: vertical;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 10px 11px;
}

.shell {
  width: 100%;
  margin: 0;
  padding: 0 20px 32px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 88px;
  gap: 20px;
  border-bottom: 1px solid var(--line);
}

.title-line {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 22px;
}

.title-line h1 {
  margin: 0;
  font-size: 36px;
  line-height: 1;
  font-weight: 760;
  letter-spacing: 0;
}

.asset-count,
.market-state {
  color: var(--muted);
  font-size: 15px;
  white-space: nowrap;
}

.market-state {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.market-state i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--good);
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 0;
  gap: 6px;
}

#syncExtensionButton {
  min-width: 88px;
}

.quick-add {
  display: flex;
  align-items: center;
  gap: 6px;
}

.quick-add input {
  width: 168px;
}

.search-box input {
  width: 120px;
}

.column-menu {
  position: relative;
}

#columnButton {
  min-width: 88px;
}

.column-panel {
  position: absolute;
  z-index: 20;
  top: 48px;
  right: 0;
  width: 178px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, .97);
  box-shadow: var(--shadow);
  padding: 14px 12px 10px;
  backdrop-filter: blur(16px);
}

.panel-title {
  padding: 0 4px 10px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
}

.column-options {
  display: grid;
  gap: 6px;
}

.column-option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
}
.column-option.is-dragging { opacity: .45; }
.column-option.is-drop-target { background: #f4f7ff; }
.column-option.is-fixed {
  color: var(--muted);
  cursor: default;
}
.column-drag-handle {
  width: 10px;
  height: 20px;
  flex: 0 0 auto;
  cursor: grab;
  opacity: .65;
  background: radial-gradient(circle, #939baa 1.2px, transparent 1.5px) 0 1px / 5px 6px;
}
.column-option.is-fixed .column-drag-handle {
  opacity: .25;
  cursor: default;
}

.column-option input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
}

.column-option:has(input:disabled) {
  color: var(--muted);
  cursor: default;
}

.panel-reset {
  width: 100%;
  height: 30px;
  margin-top: 10px;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  color: var(--faint);
  font-size: 12px;
}

.market-card { position: relative; width: 100%; background: var(--panel); }
.table-scroll { width: 100%; overflow-x: auto; }
.market-table {
  min-width: var(--market-min-width, 1060px);
  max-height: max(340px, calc(100vh - 156px));
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 12px;
  scrollbar-gutter: stable;
}
.table-row {
  display: grid;
  grid-template-columns: var(--market-columns, minmax(max-content, 1.6fr) minmax(86px, .5fr) minmax(130px, .85fr) minmax(92px, .65fr) repeat(4, 76px) minmax(104px, .75fr) 64px);
  gap: 8px;
  align-items: center;
  min-height: 50px;
  padding: 5px 12px 5px 10px;
}
.table-head {
  position: sticky;
  z-index: 2;
  top: 0;
  min-height: 44px;
  border-bottom: 1px solid var(--line-strong);
  background: #fff;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}
.table-head [data-column]:not([data-column="identity"]):not([data-column="typeInfo"]):not([data-column="exchange"]) { text-align: right; }
.table-head span { margin-left: 3px; color: var(--faint); font-size: 10px; font-weight: 500; }
.identity-head {
  display: flex;
  align-items: center;
  min-width: 0;
  padding-left: 38px;
}
.market-row {
  position: relative;
  border-bottom: 1px solid var(--line);
}
.market-row:hover { background: var(--row-hover); }

.market-row.is-dragging {
  opacity: .45;
}

.market-row.drop-before::before,
.market-row.drop-after::after {
  content: "";
  position: absolute;
  z-index: 4;
  right: 0;
  left: 0;
  height: 2px;
  background: var(--accent);
}

.market-row.drop-before::before { top: -1px; }
.market-row.drop-after::after { bottom: -1px; }

.identity { display: flex; align-items: center; min-width: max-content; gap: 10px; }
.logo-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  cursor: grab;
}
.logo-slot:active { cursor: grabbing; }
.logo {
  display: block;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: contain;
}
.identity-copy {
  display: grid;
  min-width: max-content;
  width: max-content;
  grid-template-columns: minmax(0, 1fr);
  gap: 3px;
  align-items: center;
  justify-items: start;
}
.symbol-line {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  min-width: max-content;
  width: max-content;
  gap: 6px;
  cursor: default;
}
.symbol {
  padding: 2px 7px;
  border-radius: 4px;
  background: #f0f1f4;
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
  white-space: nowrap;
}
.description-line {
  display: flex;
  align-items: center;
  min-width: max-content;
  width: max-content;
  gap: 3px;
}
.description {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.alias-display {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  white-space: nowrap;
  cursor: default;
}
.exchange,
.type-info {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.number {
  text-align: right;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.price {
  color: var(--text);
  font-weight: 500;
}
.currency {
  display: inline;
  margin: 0 0 0 4px;
  color: var(--muted);
  font-size: 9px;
}

.positive { color: var(--good) !important; }
.negative { color: var(--bad) !important; }

.empty-state {
  margin: 0;
  padding: 72px 20px;
  color: var(--muted);
  text-align: center;
}

.dialog-backdrop {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, .18);
}

.symbol-dialog {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 18px;
}

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

.dialog-head h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.dialog-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.icon-button {
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

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

.dialog-actions {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 8px;
  align-items: center;
  margin-top: 16px;
}

@media (max-width: 900px) {
  .shell {
    padding: 0 12px 28px;
  }

  .page-header {
    align-items: flex-start;
    flex-direction: column;
    padding: 18px 0;
  }

  .title-line {
    flex-wrap: wrap;
    gap: 10px 16px;
  }

  .title-line h1 {
    width: 100%;
    font-size: 32px;
  }

  .header-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .quick-add input,
  .search-box input {
    width: 160px;
  }

  .table-row {
    min-height: 70px;
  }
}
