/* ============ Tokens ============ */
:root {
  color-scheme: dark;
  --bg: #0b0d12;
  --bg-elev: #0f1218;
  --surface: #141821;
  --surface-2: #1a1f2a;
  --surface-3: #222836;
  --border: #252c39;
  --border-strong: #343d4e;
  --text: #edf0f5;
  --text-2: #a9b2c0;
  --text-3: #768194;
  --accent: #f3b33d;
  --accent-hover: #ffc257;
  --accent-ink: #1a1305;
  --accent-soft: rgba(243, 179, 61, 0.14);
  --buy: #5aa7ff;
  --buy-soft: rgba(90, 167, 255, 0.14);
  --sell: #b48cff;
  --sell-soft: rgba(180, 140, 255, 0.14);
  --success: #37c98b;
  --success-soft: rgba(55, 201, 139, 0.14);
  --warning: #f0a63a;
  --warning-soft: rgba(240, 166, 58, 0.14);
  --danger: #ff6b5e;
  --danger-soft: rgba(255, 107, 94, 0.14);
  --neutral-soft: rgba(118, 129, 148, 0.16);
  --overlay: rgba(4, 6, 10, 0.6);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
  --focus: 0 0 0 3px rgba(90, 167, 255, 0.35);

  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --sidebar-w: 252px;
  --tabbar-h: 62px;
  --topbar-h: 56px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f5f8;
  --bg-elev: #ffffff;
  --surface: #ffffff;
  --surface-2: #f5f7fa;
  --surface-3: #eceff4;
  --border: #e3e7ee;
  --border-strong: #cfd5df;
  --text: #121620;
  --text-2: #4a5465;
  --text-3: #7a8494;
  --accent: #eaa21c;
  --accent-hover: #f5b033;
  --accent-ink: #1d1400;
  --accent-soft: rgba(234, 162, 28, 0.14);
  --buy: #1f6fd6;
  --buy-soft: rgba(31, 111, 214, 0.1);
  --sell: #7a4fd6;
  --sell-soft: rgba(122, 79, 214, 0.1);
  --success: #12905c;
  --success-soft: rgba(18, 144, 92, 0.1);
  --warning: #b36b00;
  --warning-soft: rgba(214, 138, 0, 0.12);
  --danger: #d23b2e;
  --danger-soft: rgba(210, 59, 46, 0.1);
  --neutral-soft: rgba(122, 132, 148, 0.14);
  --overlay: rgba(18, 22, 32, 0.4);
  --shadow-sm: 0 1px 2px rgba(18, 22, 32, 0.06);
  --shadow: 0 16px 40px rgba(18, 22, 32, 0.14);
  --focus: 0 0 0 3px rgba(31, 111, 214, 0.25);
}

/* ============ Base ============ */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--text);
  background: var(--bg);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

a {
  color: var(--buy);
}

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

:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.num {
  font-variant-numeric: tabular-nums;
}

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

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

[hidden] {
  display: none !important;
}

/* ============ App shell ============ */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100dvh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
  height: 100dvh;
  padding: 20px 14px 16px;
  border-right: 1px solid var(--border);
  background: var(--bg-elev);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 2px 8px;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  flex: none;
  place-items: center;
  border-radius: 10px;
  color: var(--accent-ink);
  background: var(--accent);
  font-weight: 800;
  font-size: 16px;
}

.brand-text {
  display: grid;
  line-height: 1.2;
}

.brand-text strong {
  font-size: 15px;
}

.brand-text small {
  color: var(--text-3);
  font-size: 11px;
}

.nav {
  display: grid;
  gap: 2px;
}

.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 10px;
  color: var(--text-2);
  font-weight: 560;
  text-decoration: none;
  transition: background 120ms ease, color 120ms ease;
}

.nav-link:hover {
  color: var(--text);
  background: var(--surface-2);
}

.nav-link[aria-current="page"] {
  color: var(--text);
  background: var(--surface-3);
}

.nav-link svg {
  width: 19px;
  height: 19px;
  flex: none;
}

.nav-badge {
  min-width: 20px;
  height: 20px;
  margin-left: auto;
  padding: 0 6px;
  border-radius: 999px;
  color: var(--text-2);
  background: var(--surface-3);
  font-size: 11px;
  font-weight: 650;
  line-height: 20px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.nav-badge.danger {
  color: #fff;
  background: var(--danger);
}

.nav-badge.accent {
  color: var(--accent-ink);
  background: var(--accent);
}

.sidebar-footer {
  display: grid;
  gap: 12px;
  margin-top: auto;
}

.sidebar-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 4px;
}

.main {
  width: 100%;
  max-width: 1440px;
  padding: 28px 32px 56px;
}

.main:focus {
  box-shadow: none;
}

.topbar,
.tabbar {
  display: none;
}

/* ============ Connection & mode ============ */
.connection {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text-3);
  font-size: 12px;
}

.connection::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-3);
}

.connection[data-state="online"]::before {
  background: var(--success);
  box-shadow: 0 0 0 3px var(--success-soft);
}

.connection[data-state="reconnecting"]::before {
  background: var(--warning);
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.35;
  }
}

.mode-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}


.mode-dot {
  width: 10px;
  height: 10px;
  flex: none;
  border-radius: 50%;
  background: var(--text-3);
}

.mode-dot.live {
  background: var(--success);
  box-shadow: 0 0 0 4px var(--success-soft);
}

.mode-dot.dry {
  background: var(--buy);
  box-shadow: 0 0 0 4px var(--buy-soft);
}

.mode-dot.paused {
  background: var(--warning);
  box-shadow: 0 0 0 4px var(--warning-soft);
}

.mode-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

/* ============ Controls ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  background: var(--surface-2);
  cursor: pointer;
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
  transition: background 120ms ease, border-color 120ms ease, opacity 120ms ease;
}

.btn:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: var(--surface-3);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.btn svg {
  width: 17px;
  height: 17px;
  flex: none;
}

.btn-primary {
  border-color: transparent;
  color: var(--accent-ink);
  background: var(--accent);
}

.btn-primary:hover:not(:disabled) {
  border-color: transparent;
  background: var(--accent-hover);
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
}

.btn-danger {
  color: var(--danger);
}

.btn-sm {
  min-height: 32px;
  padding: 0 11px;
  border-radius: 8px;
  font-size: 13px;
}

.btn-icon {
  width: 38px;
  padding: 0;
}

.btn-block {
  width: 100%;
}

.btn.is-loading {
  position: relative;
  color: transparent;
  pointer-events: none;
}

.btn.is-loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid var(--text-3);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

.btn-primary.is-loading::after {
  border-color: rgba(0, 0, 0, 0.25);
  border-top-color: var(--accent-ink);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch-track {
  position: relative;
  width: 40px;
  height: 24px;
  flex: none;
  border-radius: 999px;
  background: var(--surface-3);
  box-shadow: inset 0 0 0 1px var(--border-strong);
  transition: background 150ms ease, box-shadow 150ms ease;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform 150ms ease;
}

.switch input:checked + .switch-track {
  background: var(--success);
  box-shadow: none;
}

.switch input:checked + .switch-track::after {
  transform: translateX(16px);
}

.switch input:focus-visible + .switch-track {
  box-shadow: var(--focus);
}

.switch input:disabled + .switch-track {
  opacity: 0.5;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.switch-row span:first-child {
  display: grid;
  font-size: 13px;
  font-weight: 600;
}

.switch-row small {
  color: var(--text-3);
  font-size: 11px;
  font-weight: 500;
}

/* Settings rows: label on the left, control on the right, divided by lines. */
.setting-rows {
  display: grid;
  gap: 14px;
}

.setting-list {
  display: grid;
}

.setting-list .setting-rows {
  gap: 0;
}

.setting-list .switch-row {
  min-height: 60px;
  padding: 10px 0;
}

.setting-list > .switch-row,
.setting-list .switch-row + .switch-row {
  border-top: 1px solid var(--border);
}

.setting-list .switch-row span:first-child {
  gap: 2px;
  font-size: 14px;
}

.setting-list .switch-row small {
  font-size: 12px;
}

.key-list {
  display: grid;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.key-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  padding: 8px 8px 8px 14px;
}

.key-row + .key-row {
  border-top: 1px solid var(--border);
}

.key-row code {
  font-family: ui-monospace, monospace;
}

.key-row .btn {
  margin-left: auto;
}

.feeds {
  display: grid;
  gap: 6px;
  margin: -4px 0 0;
  padding: 0 18px 14px;
  font-size: 13px;
}

.feeds > div {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 12px;
}

.feeds dt {
  color: var(--text-3);
  font-weight: 600;
}

.feeds dd {
  margin: 0;
  color: var(--text-2);
}

@media (max-width: 520px) {
  .feeds > div {
    grid-template-columns: 1fr;
    gap: 0;
  }
}

.card-note {
  margin-top: -4px;
  padding: 0 18px 12px;
  color: var(--text-3);
  font-size: 13px;
}

.snipe-actions {
  display: flex;
  flex: none;
  align-items: center;
  gap: 16px;
}

.snipe-roi {
  display: grid;
  justify-items: end;
  gap: 2px;
}

.snipe-roi small {
  color: var(--text-3);
  font-size: 11px;
  font-weight: 600;
}

.segmented {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}

.segmented button {
  min-height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: 7px;
  color: var(--text-2);
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.segmented button[aria-pressed="true"] {
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.segmented-compact button {
  display: grid;
  width: 30px;
  padding: 0;
  place-items: center;
}

.segmented-compact svg {
  width: 16px;
  height: 16px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-2);
  background: var(--surface);
  cursor: pointer;
  font-size: 13px;
  font-weight: 560;
  white-space: nowrap;
}

.chip[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--text);
  background: var(--accent-soft);
}

.chip .count {
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.input,
.select {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  background: var(--surface);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.input:focus,
.select:focus {
  border-color: var(--buy);
  box-shadow: var(--focus);
}

.input::placeholder {
  color: var(--text-3);
}

.select {
  padding-right: 32px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23768194' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-position: right 11px center;
  background-repeat: no-repeat;
  cursor: pointer;
}

.search {
  position: relative;
  flex: 1 1 260px;
  min-width: 0;
}

.search svg {
  position: absolute;
  top: 50%;
  left: 12px;
  width: 16px;
  height: 16px;
  color: var(--text-3);
  transform: translateY(-50%);
  pointer-events: none;
}

.search .input {
  padding-left: 36px;
}

.search kbd {
  position: absolute;
  top: 50%;
  right: 10px;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-3);
  font-family: inherit;
  font-size: 11px;
  transform: translateY(-50%);
}

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

.field-label {
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
}

.field-hint {
  color: var(--text-3);
  font-size: 11px;
}

.field-error {
  color: var(--danger);
  font-size: 12px;
}

.field-error:empty {
  display: none;
}

.input-affix {
  position: relative;
}

.input-affix .input {
  padding-right: 52px;
}

.input-affix span {
  position: absolute;
  top: 50%;
  right: 12px;
  color: var(--text-3);
  font-size: 12px;
  transform: translateY(-50%);
  pointer-events: none;
}

.field.has-error .input {
  border-color: var(--danger);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px;
}

/* The maximum of a buy order as a slider, with the ROI it leaves. */
.limit-slider {
  display: grid;
  gap: 8px;
}

.limit-slider input[type="range"] {
  width: 100%;
  height: 28px;
  margin: 0;
  accent-color: var(--accent);
}

.limit-scale {
  display: flex;
  justify-content: space-between;
  margin-top: -6px;
  color: var(--text-3);
  font-size: 11px;
}

.roi-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.checkbox {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  font-size: 13px;
}

.checkbox input {
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
  flex: none;
  accent-color: var(--accent);
}

/* ============ Pills & tags ============ */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  color: var(--text-2);
  background: var(--neutral-soft);
  font-size: 12px;
  font-weight: 620;
  white-space: nowrap;
}

.pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.pill.plain::before {
  display: none;
}

.pill.success {
  color: var(--success);
  background: var(--success-soft);
}

.pill.warning {
  color: var(--warning);
  background: var(--warning-soft);
}

.pill.danger {
  color: var(--danger);
  background: var(--danger-soft);
}

.pill.info {
  color: var(--buy);
  background: var(--buy-soft);
}

.pill.purple {
  color: var(--sell);
  background: var(--sell-soft);
}

.type-tag {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.type-tag.buy {
  color: var(--buy);
  background: var(--buy-soft);
}

.type-tag.sell {
  color: var(--sell);
  background: var(--sell-soft);
}

.tag {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border-radius: 6px;
  color: var(--text-2);
  background: var(--surface-3);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.tag.accent {
  color: var(--accent);
  background: var(--accent-soft);
}

.tag.info {
  color: var(--buy);
  background: var(--buy-soft);
}

.tag.warning {
  color: var(--warning);
  background: var(--warning-soft);
}

.up {
  color: var(--success);
}

.down {
  color: var(--danger);
}

.roi {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 9px;
  border-radius: 8px;
  color: var(--success);
  background: var(--success-soft);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ============ Page layout ============ */
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.page-head h1 {
  font-size: 26px;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.page-head p {
  margin-top: 4px;
  color: var(--text-3);
  font-size: 13px;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 12px;
}

.card-head h2 {
  font-size: 15px;
  font-weight: 700;
}

.card-head a,
.link-button {
  border: 0;
  color: var(--text-3);
  background: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

.card-head a:hover,
.link-button:hover {
  color: var(--text);
}

.card-body {
  padding: 0 18px 18px;
}

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

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

.overview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 16px;
}

.overview-feed {
  grid-column: 1 / -1;
}

/* Forms read badly when stretched across a wide monitor. */
.settings-stack {
  max-width: 1240px;
}

/* Two columns only where there is room (wide monitors). */
.split-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: 16px;
}

.banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 13px;
}

.banner svg {
  width: 18px;
  height: 18px;
  flex: none;
}

.banner .btn {
  margin-left: auto;
}

.banner.info {
  border-color: color-mix(in srgb, var(--buy) 30%, transparent);
  color: var(--text);
  background: var(--buy-soft);
}

.banner.warning {
  border-color: color-mix(in srgb, var(--warning) 30%, transparent);
  color: var(--text);
  background: var(--warning-soft);
}

.banner.danger {
  border-color: color-mix(in srgb, var(--danger) 30%, transparent);
  color: var(--text);
  background: var(--danger-soft);
}

.banner-hint {
  display: block;
  margin-top: 4px;
  color: var(--text-2);
}

/* ============ KPI ============ */
.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

@media (min-width: 861px) {
  .kpis.kpis-six {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.kpi {
  display: grid;
  gap: 4px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: inherit;
  text-decoration: none;
}

a.kpi:hover {
  border-color: var(--border-strong);
}

.kpi-label {
  color: var(--text-3);
  font-size: 12px;
  font-weight: 600;
}

.kpi-value {
  font-size: 24px;
  font-weight: 750;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi-sub {
  color: var(--text-3);
  font-size: 12px;
}

/* ============ Lists ============ */
.list {
  display: grid;
}

.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 10px 18px;
  border-top: 1px solid var(--border);
  color: inherit;
  text-align: left;
  background: none;
  cursor: pointer;
  width: 100%;
  border-left: 0;
  border-right: 0;
  border-bottom: 0;
}

.list-row:hover {
  background: var(--surface-2);
}

.list-row:disabled {
  cursor: default;
  opacity: 0.65;
}

.list-row:disabled:hover {
  background: none;
}

.list-row .grow {
  display: grid;
  flex: 1;
  min-width: 0;
}

.list-row strong {
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-row small {
  display: -webkit-box;
  overflow: hidden;
  color: var(--text-3);
  font-size: 12px;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.list-row .end {
  display: grid;
  justify-items: end;
  gap: 2px;
  flex: none;
  text-align: right;
}

.empty {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 36px 20px;
  color: var(--text-3);
  text-align: center;
}

.empty strong {
  color: var(--text-2);
  font-size: 14px;
}

.empty svg {
  width: 28px;
  height: 28px;
  margin-bottom: 4px;
}

.empty.compact {
  padding: 22px 18px;
}

/* ============ Toolbar ============ */
.toolbar {
  position: sticky;
  z-index: 5;
  top: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: -6px -8px 14px;
  padding: 6px 8px 10px;
  background: var(--bg);
}

.toolbar .select {
  width: auto;
}

.toolbar-spacer {
  flex: 1;
}

/* ============ Data rows (orders & scanner) ============ */
.rows {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.rows-head,
.row {
  display: grid;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
}

.rows-head {
  min-height: 40px;
  border-bottom: 1px solid var(--border);
  color: var(--text-3);
  background: var(--surface-2);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.rows-head button {
  padding: 0;
  border: 0;
  color: inherit;
  background: none;
  cursor: pointer;
  font: inherit;
  letter-spacing: inherit;
  text-align: inherit;
  text-transform: inherit;
}

.rows-head button[aria-sort] {
  color: var(--text);
}

.row {
  min-height: 64px;
  border-top: 1px solid var(--border);
  cursor: pointer;
  transition: background 100ms ease;
}

.rows-head + .row {
  border-top: 0;
}

.row:hover {
  background: var(--surface-2);
}

.row.is-enabled {
  box-shadow: inset 3px 0 0 var(--success);
}

.row .cell {
  display: grid;
  min-width: 0;
  font-variant-numeric: tabular-nums;
}

.row .cell small {
  color: var(--text-3);
  font-size: 12px;
}

.row .cell.right,
.rows-head .right {
  justify-items: end;
  text-align: right;
}

.item-title {
  display: grid;
  gap: 4px;
  min-width: 0;
}

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

.item-title strong {
  overflow: hidden;
  font-weight: 620;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-title .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
  color: var(--text-3);
  font-size: 12px;
}

.orders-grid {
  grid-template-columns: minmax(220px, 2.6fr) repeat(5, minmax(96px, 1fr)) 150px 56px;
}

/* The orders table has more columns than a window with the sidebar holds
   below ~1200 px: it scrolls sideways there instead of losing its last
   columns. Not for the card layout of narrow screens. */
@media (min-width: 861px) {
  .orders-rows {
    overflow-x: auto;
  }

  .orders-rows > .orders-grid {
    min-width: min-content;
  }
}

.scanner-grid {
  grid-template-columns: minmax(220px, 2.4fr) repeat(4, minmax(92px, 1fr)) repeat(3, minmax(74px, 0.8fr));
}

.rows-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  color: var(--text-3);
  font-size: 13px;
}

/* ============ Progress ============ */
.progress-card {
  display: grid;
  gap: 12px;
  padding: 16px 18px;
}

.progress-line {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  font-size: 12px;
}

.progress-line span:first-child {
  color: var(--text-2);
  font-weight: 600;
}

.bar {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-3);
}

.bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 300ms ease;
}

.progress-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  color: var(--text-3);
  font-size: 12px;
}

.progress-meta.lanes {
  flex-direction: column;
  gap: 2px;
}

/* ============ Feed ============ */
.feed-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 12px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
}

.feed-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 10px;
  color: var(--text-2);
  background: var(--surface-3);
}

.feed-icon svg {
  width: 17px;
  height: 17px;
}

.feed-icon.success {
  color: var(--success);
  background: var(--success-soft);
}

.feed-icon.danger {
  color: var(--danger);
  background: var(--danger-soft);
}

.feed-icon.warning {
  color: var(--warning);
  background: var(--warning-soft);
}

.feed-icon.info {
  color: var(--buy);
  background: var(--buy-soft);
}

.feed-body {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.feed-body strong {
  overflow: hidden;
  font-size: 13px;
  font-weight: 620;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.feed-body p {
  color: var(--text-2);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.feed-body small,
.feed-time {
  color: var(--text-3);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.feed-time {
  white-space: nowrap;
}

/* ============ Sheet (drawer / bottom sheet) ============ */
.sheet {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(580px, 100vw);
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--border);
  color: var(--text);
  background: var(--bg-elev);
  box-shadow: var(--shadow);
}

.sheet[open] {
  display: flex;
  flex-direction: column;
  animation: sheet-in-right 180ms ease-out;
}

.sheet::backdrop {
  background: var(--overlay);
  backdrop-filter: blur(2px);
}

@keyframes sheet-in-right {
  from {
    transform: translateX(24px);
    opacity: 0;
  }
}

@keyframes sheet-in-up {
  from {
    transform: translateY(32px);
    opacity: 0;
  }
}

.sheet-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
}

.sheet-head .grow {
  display: grid;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.sheet-head h2 {
  font-size: 18px;
  font-weight: 720;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.sheet-head .meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  color: var(--text-3);
  font-size: 12px;
}

.sheet-body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 20px 24px;
}

.sheet-foot {
  display: flex;
  gap: 10px;
  padding: 14px 20px calc(14px + var(--safe-bottom));
  border-top: 1px solid var(--border);
  background: var(--bg-elev);
}

.sheet-foot .btn {
  flex: 1;
}

.sheet-grip {
  display: none;
}

.section {
  display: grid;
  gap: 12px;
}

.section + .section {
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

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

.section-title h3 {
  color: var(--text-2);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.stat {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-2);
}

.stat span {
  color: var(--text-3);
  font-size: 11px;
  font-weight: 600;
}

.stat strong {
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.stat small {
  color: var(--text-3);
  font-size: 11px;
  line-height: 1.35;
}

.sale-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.sale-option {
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.sale-option:hover {
  border-color: var(--text-3);
}

.sale-option.recommended {
  border-color: var(--accent);
}

.sale-option.active {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.sale-option-head {
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
}

.sale-option strong {
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}

.sale-option small {
  color: var(--text-3);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

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

.book-side {
  display: grid;
  align-content: start;
  gap: 2px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.book-side h4 {
  margin: 0 0 4px;
  color: var(--text-3);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.book-level {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 6px;
  overflow: hidden;
}

.book-level i {
  position: absolute;
  inset: 0 auto 0 0;
  z-index: 0;
  border-radius: inherit;
}

.book-level span {
  position: relative;
  z-index: 1;
}

.book-side.bids .book-level i {
  background: var(--buy-soft);
}

.book-side.asks .book-level i {
  background: var(--sell-soft);
}

.book-level.own {
  box-shadow: inset 0 0 0 1px var(--accent);
}

.book-level .count {
  color: var(--text-3);
}

.notes {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 12px 14px 12px 32px;
  border-radius: 10px;
  color: var(--text);
  background: var(--warning-soft);
  font-size: 13px;
}

.notes.ok {
  padding-left: 14px;
  list-style: none;
  background: var(--success-soft);
}

.callout {
  padding: 12px 14px;
  border-radius: 10px;
  color: var(--text-2);
  background: var(--surface-2);
  font-size: 13px;
}

.callout.warning {
  color: var(--text);
  background: var(--warning-soft);
}

.result {
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 13px;
}

.result.info {
  background: var(--buy-soft);
}

.result.success {
  background: var(--success-soft);
}

.result.error {
  background: var(--danger-soft);
}

/* ============ Chart ============ */
.chart {
  position: relative;
}

.chart svg {
  display: block;
  width: 100%;
  height: auto;
}

.chart-grid {
  stroke: var(--border);
  stroke-width: 1;
}

.chart-axis {
  fill: var(--text-3);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.chart-ref {
  stroke-width: 1.5;
  stroke-dasharray: 5 4;
}

.chart-ref.median {
  stroke: var(--text-3);
}

.chart-ref.sell {
  stroke: var(--sell);
}

.chart-ref.buy {
  stroke: var(--accent);
}

.chart-ref-label {
  fill: var(--text-2);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.chart-dot {
  fill: var(--buy);
  stroke: var(--bg-elev);
  stroke-width: 2;
}

.chart-dot.active {
  r: 6;
}

.chart-tooltip {
  position: absolute;
  z-index: 2;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
}

.chart-table summary {
  color: var(--text-3);
  cursor: pointer;
  font-size: 12px;
}

.mini-table {
  width: 100%;
  margin-top: 8px;
  border-collapse: collapse;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.mini-table td {
  padding: 5px 4px;
  border-top: 1px solid var(--border);
}

/* ============ Gift offers ============ */
.offers {
  display: grid;
  gap: 6px;
  max-height: 280px;
  overflow-y: auto;
}

.offer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  font-size: 13px;
}

label.offer {
  cursor: pointer;
}

.offer:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.offer input {
  accent-color: var(--accent);
}

.offer .grow {
  display: grid;
  flex: 1;
  min-width: 0;
}

.offer small {
  color: var(--text-3);
  font-size: 12px;
}

/* ============ Toasts ============ */
.toasts {
  position: fixed;
  z-index: 100;
  right: 20px;
  bottom: 20px;
  display: grid;
  gap: 8px;
  width: min(380px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 13px;
  pointer-events: auto;
  animation: toast-in 160ms ease-out;
}

.toast::before {
  content: "";
  width: 8px;
  height: 8px;
  margin-top: 6px;
  flex: none;
  border-radius: 50%;
  background: var(--buy);
}

.toast.success::before {
  background: var(--success);
}

.toast.warning::before {
  background: var(--warning);
}

.toast.error::before {
  background: var(--danger);
}

@keyframes toast-in {
  from {
    transform: translateY(8px);
    opacity: 0;
  }
}

/* ============ Skeleton ============ */
.skeleton {
  display: block;
  height: 14px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2));
  background-size: 200% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
}

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

/* ============ Inventory ============ */
.inv-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.inv-toolbar .search {
  flex: 1 1 260px;
}

.inv-toolbar .select {
  flex: 0 0 190px;
  width: auto;
}

@media (max-width: 520px) {
  .inv-toolbar .search {
    flex-basis: 100%;
  }

  .inv-toolbar .select {
    flex: 1 1 0;
  }
}

.inv-price.none {
  color: var(--text-3);
  font-size: 13px;
  font-weight: 600;
}

.inv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
}

.inv-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  color: inherit;
  background: var(--surface);
  text-align: left;
  cursor: pointer;
  transition: border-color 120ms ease, transform 120ms ease, background 120ms ease;
}

.inv-card:hover:not(:disabled) {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.inv-card:disabled {
  cursor: default;
  opacity: 0.6;
}

.inv-media {
  position: relative;
  display: grid;
  height: 128px;
  place-items: center;
  background: radial-gradient(circle at 50% 40%, var(--surface-3), var(--surface-2) 70%);
}

.inv-media img {
  max-width: 88%;
  max-height: 112px;
  object-fit: contain;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.35));
}

.inv-placeholder svg {
  width: 44px;
  height: 44px;
  color: var(--text-3);
}

.inv-badges {
  position: absolute;
  top: 8px;
  left: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.inv-badge {
  padding: 1px 6px;
  border-radius: 6px;
  color: var(--text-2);
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.inv-badge.stattrak {
  color: #ff9a57;
}

.inv-badge.souvenir {
  color: #f5c542;
}

.inv-badge.star {
  color: #c99bff;
}

.inv-body {
  display: grid;
  flex: 1;
  align-content: start;
  gap: 2px;
  padding: 10px 12px 8px;
  min-width: 0;
}

.inv-weapon {
  overflow: hidden;
  color: var(--text-3);
  font-size: 11px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inv-skin {
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inv-price {
  margin-top: 4px;
  font-size: 16px;
  font-weight: 750;
}

.inv-meta {
  overflow: hidden;
  color: var(--text-3);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inv-facts {
  overflow: hidden;
  color: var(--text-3);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inv-liquid.high {
  color: var(--buy);
}

.inv-liquid.low {
  color: var(--warning, var(--text-2));
}

.inv-count {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  color: var(--accent-ink);
  background: var(--accent);
  font-size: 12px;
  font-weight: 750;
}

.inv-summary {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.inv-action {
  margin: 4px 12px 12px;
  padding: 7px 0;
  border-radius: 9px;
  color: var(--accent-ink);
  background: var(--accent);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

.inv-card:disabled .inv-action {
  color: var(--text-3);
  background: var(--surface-2);
}

.inv-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.inv-card[aria-pressed="false"] .inv-action {
  color: var(--text);
  background: var(--surface-3);
}

.bulk-bar {
  position: sticky;
  top: 8px;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 13px;
}

.bulk-bar [data-bulk-count] {
  margin-right: auto;
  font-weight: 600;
}

.bulk-sell {
  display: grid;
  gap: 6px;
  margin: 12px 0;
}

.bulk-sell-head,
.bulk-sell-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 100px 100px;
  gap: 8px;
  align-items: center;
}

.bulk-sell-head {
  color: var(--text-2);
  font-size: 12px;
}

.bulk-sell-row .grow {
  display: grid;
  min-width: 0;
}

.bulk-sell-row strong {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bulk-sell-row small {
  color: var(--text-2);
  font-size: 12px;
}

.bulk-warning {
  display: block;
  margin-top: 4px;
}

@media (max-width: 520px) {
  .bulk-sell-head,
  .bulk-sell-row {
    grid-template-columns: minmax(0, 1fr) 84px 84px;
  }
}

@media (max-width: 520px) {
  .inv-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .inv-media {
    height: 104px;
  }
}

/* ============ Accounts & login ============ */
.account-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 6px 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.account-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--text);
  font-weight: 600;
}

.account-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-chip svg {
  width: 17px;
  height: 17px;
  flex: none;
  color: var(--text-3);
}

.account-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.login {
  display: grid;
  min-height: 100dvh;
  padding: 24px 16px;
  place-items: center;
}

.login-card {
  display: grid;
  gap: 16px;
  width: min(400px, 100%);
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}

.login-brand h1 {
  font-size: 20px;
  font-weight: 750;
}

.login-brand p {
  font-size: 13px;
}

.login-error:empty {
  display: none;
}

/* ============ Responsive ============ */
@media (max-width: 1280px) {
  .orders-grid {
    grid-template-columns: minmax(190px, 2fr) repeat(5, minmax(84px, 1fr)) 130px 52px;
  }

  .scanner-grid {
    grid-template-columns: minmax(200px, 2fr) repeat(4, minmax(86px, 1fr)) repeat(3, minmax(70px, 0.8fr));
  }
}

@media (max-width: 1023px) {
  .app {
    display: block;
  }

  .sidebar {
    display: none;
  }

  .topbar {
    position: sticky;
    z-index: 30;
    top: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    height: calc(var(--topbar-h) + var(--safe-top));
    padding: var(--safe-top) 16px 0;
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(14px);
  }

  .brand-compact {
    gap: 9px;
    padding: 0;
  }

  .brand-compact .brand-mark {
    width: 30px;
    height: 30px;
    font-size: 14px;
  }

  .topbar-actions {
    display: flex;
    align-items: center;
    gap: 6px;
  }

  .connection-compact {
    font-size: 0;
  }

  .tabbar {
    position: fixed;
    z-index: 30;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    height: calc(var(--tabbar-h) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    border-top: 1px solid var(--border);
    background: color-mix(in srgb, var(--bg-elev) 92%, transparent);
    backdrop-filter: blur(14px);
  }

  .tabbar .nav-link {
    position: relative;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    min-height: 0;
    padding: 0;
    border-radius: 0;
    font-size: 11px;
  }

  .tabbar .nav-link:hover {
    background: none;
  }

  .tabbar .nav-link[aria-current="page"] {
    color: var(--accent);
    background: none;
  }

  .tabbar .nav-link svg {
    width: 22px;
    height: 22px;
  }

  .tabbar .nav-badge {
    position: absolute;
    top: 6px;
    left: calc(50% + 6px);
    min-width: 18px;
    height: 18px;
    margin: 0;
    padding: 0 5px;
    font-size: 10px;
    line-height: 18px;
  }

  .tabbar .nav-badge:not(.danger):not(.accent) {
    display: none;
  }

  .main {
    padding: 18px 16px calc(var(--tabbar-h) + var(--safe-bottom) + 28px);
  }

  .page-head {
    margin-bottom: 16px;
  }

  .page-head h1 {
    font-size: 22px;
  }

  .toolbar {
    top: calc(var(--topbar-h) + var(--safe-top));
    margin: -6px -16px 12px;
    padding: 8px 16px 10px;
  }

  .toasts {
    right: 16px;
    bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 12px);
  }

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

  .grid-2,
  .overview-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  /* Rows become cards */
  .rows {
    overflow: visible;
    border: 0;
    background: none;
  }

  .rows-head {
    display: none;
  }

  .row {
    gap: 10px 12px;
    min-height: 0;
    margin-bottom: 10px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
  }

  .row.is-enabled {
    box-shadow: inset 3px 0 0 var(--success);
  }

  .row .cell[data-label]::before {
    content: attr(data-label);
    color: var(--text-3);
    font-size: 11px;
    font-weight: 600;
  }

  .row .cell.right {
    justify-items: start;
    text-align: left;
  }

  .item-title strong {
    white-space: normal;
  }

  .orders-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-areas:
      "item item auto"
      "own comp target"
      "limit profit status";
  }

  .orders-grid .c-auto::before,
  .orders-grid .c-status::before {
    display: none;
  }

  .orders-grid .c-status {
    align-self: end;
    justify-items: end;
  }

  .orders-grid .c-item { grid-area: item; }
  .orders-grid .c-own { grid-area: own; }
  .orders-grid .c-comp { grid-area: comp; }
  .orders-grid .c-target { grid-area: target; }
  .orders-grid .c-limit { grid-area: limit; }
  .orders-grid .c-profit { grid-area: profit; }
  .orders-grid .c-status { grid-area: status; }

  .orders-grid .c-auto {
    grid-area: auto;
    align-self: start;
    justify-items: end;
  }

  .scanner-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-areas:
      "item item roi"
      "buy sell profit"
      "daily sales days";
  }

  .scanner-grid .c-item { grid-area: item; }
  .scanner-grid .c-buy { grid-area: buy; }
  .scanner-grid .c-sell { grid-area: sell; }
  .scanner-grid .c-profit { grid-area: profit; }
  .scanner-grid .c-sales { grid-area: sales; }
  .scanner-grid .c-daily { grid-area: daily; }
  .scanner-grid .c-days { grid-area: days; }

  .scanner-grid .c-roi {
    grid-area: roi;
    align-self: start;
    justify-items: end;
  }

  .scanner-grid .c-roi::before {
    display: none;
  }

  .rows-foot {
    padding: 4px 0;
    border: 0;
  }

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

  .progress-line {
    grid-template-columns: 90px minmax(0, 1fr) auto;
  }

  /* Bottom sheet */
  .sheet {
    inset: auto 0 0 0;
    width: 100vw;
    height: auto;
    max-height: calc(100dvh - var(--safe-top) - 24px);
    border-top: 1px solid var(--border);
    border-left: 0;
    border-radius: 20px 20px 0 0;
  }

  .sheet[open] {
    animation: sheet-in-up 200ms ease-out;
  }

  .sheet-grip {
    display: block;
    width: 40px;
    height: 4px;
    margin: 8px auto 0;
    border-radius: 999px;
    background: var(--border-strong);
  }

  .sheet-head {
    padding: 10px 16px 12px;
  }

  .sheet-body {
    padding: 16px;
  }

  .sheet-foot {
    padding: 12px 16px calc(12px + var(--safe-bottom));
  }
}

@media (max-width: 520px) {
  .page-actions {
    width: 100%;
  }

  .page-actions .btn {
    flex: 1;
  }

  .kpi-value {
    font-size: 18px;
  }

  .hide-sm {
    display: none;
  }

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

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

  .banner {
    flex-wrap: wrap;
  }

  .banner .btn {
    margin-left: 0;
  }
}

/* Wide monitors (1080p and up): use the width instead of a narrow column. */
@media (min-width: 1680px) {
  :root {
    --sidebar-w: 268px;
  }

  .main {
    max-width: 1960px;
    padding: 32px 44px 64px;
  }

  .overview-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .overview-feed {
    grid-column: auto;
  }

  .split-grid {
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  }

  .orders-grid {
    grid-template-columns: minmax(280px, 2.8fr) repeat(5, minmax(110px, 1fr)) 170px 60px;
  }

  .scanner-grid {
    grid-template-columns: minmax(280px, 2.6fr) repeat(4, minmax(104px, 1fr)) repeat(3, minmax(88px, 0.8fr));
  }

  .sheet {
    width: min(660px, 100vw);
  }
}

/* 2K (2560×1440) and larger: a bit larger type so the page is not tiny. */
@media (min-width: 2200px) {
  :root {
    --sidebar-w: 288px;
  }

  body {
    font-size: 15px;
  }

  .main {
    max-width: 2360px;
    padding: 36px 56px 72px;
  }

  .page-head h1 {
    font-size: 30px;
  }

  .page-head p,
  .card-head a,
  .link-button,
  .banner {
    font-size: 14px;
  }

  .card-head h2 {
    font-size: 16px;
  }

  .nav-link {
    min-height: 44px;
    font-size: 15px;
  }

  .kpi {
    padding: 20px 22px;
  }

  .kpi-value {
    font-size: 28px;
  }

  .row {
    min-height: 70px;
  }

  .rows-head {
    font-size: 12px;
  }

  .list-row {
    min-height: 60px;
  }

  .stat strong {
    font-size: 16px;
  }

  .stat span,
  .stat small {
    font-size: 12px;
  }

  .sheet {
    width: min(720px, 100vw);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    transition-duration: 1ms !important;
  }
}

/* ============ Small helpers ============ */
.inline-icon {
  width: 13px;
  height: 13px;
  margin-right: 3px;
  vertical-align: -2px;
}

.cell.up,
.cell .up,
.stat .up {
  color: var(--success);
}

.cell.down,
.stat .down {
  color: var(--danger);
}

.page-actions .switch.btn {
  gap: 9px;
}

.sheet-head .meta a {
  display: inline-flex;
  align-items: center;
  font-weight: 600;
  text-decoration: none;
}

.link-btn {
  padding: 0;
  border: 0;
  margin-left: 8px;
  color: var(--text-3);
  background: none;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.link-btn:hover {
  color: var(--danger);
}

.notes li {
  overflow-wrap: anywhere;
}

.chips .chip:only-child {
  cursor: default;
}

.restart-notice {
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 10px 16px;
  color: #fff;
  background: var(--danger, #c0392b);
  font-size: 13px;
  line-height: 1.4;
}

.restart-notice code {
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.25);
}

.progress-more > summary {
  cursor: pointer;
  color: var(--text-3);
  font-size: 12px;
  list-style-position: inside;
}

.progress-more[open] > summary {
  margin-bottom: 8px;
}

.progress-more > :not(summary) + :not(summary) {
  margin-top: 8px;
}

.list-row.near-miss {
  opacity: 0.55;
  cursor: pointer;
}

.list-row.near-miss:hover,
.list-row.near-miss:focus-visible {
  opacity: 0.85;
}

.lot-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

.lot-notes {
  margin-top: 10px;
}

.lot-actions small {
  margin-right: auto;
}

.list-row.near-miss .roi {
  color: var(--text-2);
}

.label-short {
  display: none;
}

/* Chart guide labels drawn over the plot keep a halo of the background. */
.chart-ref-label.inside {
  paint-order: stroke;
  stroke: var(--bg-elev);
  stroke-width: 4px;
  stroke-linejoin: round;
}

/* Fields in a row share label, input, hint and error lines, so the inputs
   line up even when one label or hint is longer. */
@supports (grid-template-rows: subgrid) {
  .form-grid > .field {
    grid-row: span 4;
    display: grid;
    grid-template-rows: subgrid;
    row-gap: 6px;
  }

  .form-grid > .field > .field-label {
    align-self: end;
  }
}

/* An input with its buttons on one line (settings). */
.field-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.field-row .input {
  flex: 1 1 260px;
  min-width: 0;
}

.field-row .input-affix {
  flex: 1 1 200px;
  min-width: 0;
}

/* ============ Phones (reference: iPhone 16, 393 px) ============
   One grid for every screen: 16 px side gutter, 8/12 px gaps, 16 px card
   radius, 12 px for controls and tiles, round chips. Secondary page actions
   are equal tiles, stat tiles keep label / value / hint on fixed lines so
   numbers in a row line up, filter chips scroll in one row, and debug
   details stay on the desktop. */
@media (max-width: 520px) {
  .main {
    padding: 14px 16px calc(var(--tabbar-h) + var(--safe-bottom) + 24px);
  }

  .stack {
    gap: 12px;
  }

  /* Page head: title, one line of status, then the actions. */
  .page-head {
    gap: 12px;
    margin-bottom: 14px;
  }

  .page-head > div:first-child {
    min-width: 0;
    width: 100%;
  }

  .page-head h1 {
    font-size: 24px;
    line-height: 1.2;
  }

  .page-head p {
    overflow: hidden;
    margin-top: 2px;
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .page-head .page-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
  }

  .page-head .page-actions .btn {
    flex: 1 1 0;
  }

  /* The main action takes a full row above the tiles. */
  .page-head .page-actions .btn-primary {
    flex-basis: 100%;
    order: -1;
  }

  /* Secondary actions: icon over a short caption, all the same size. */
  .page-head .page-actions .btn[data-short] {
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    min-height: 58px;
    padding: 8px 4px;
    border-radius: var(--radius);
    font-size: 11px;
    font-weight: 600;
    line-height: 1.1;
  }

  .page-head .page-actions .btn[data-short] > span:not(.switch-track) {
    display: none;
  }

  .page-head .page-actions .btn[data-short]::after {
    content: attr(data-short);
    overflow: hidden;
    max-width: 100%;
    text-overflow: ellipsis;
  }

  .page-head .page-actions .btn[data-short] svg {
    width: 20px;
    height: 20px;
  }

  /* The switch sits in the same 20 px slot as the icons of other tiles. */
  .page-head .page-actions .btn.switch .switch-track {
    width: 34px;
    height: 20px;
  }

  .page-head .page-actions .btn.switch .switch-track::after {
    width: 14px;
    height: 14px;
  }

  .page-head .page-actions .btn.switch input:checked + .switch-track::after,
  .inv-toolbar .btn.switch input:checked + .switch-track::after {
    transform: translateX(14px);
  }

  .label-long {
    display: none;
  }

  .label-short {
    display: inline;
  }

  .btn {
    min-height: 44px;
    border-radius: var(--radius);
  }

  .btn-sm {
    min-height: 36px;
    border-radius: 10px;
  }

  .btn-icon.btn-sm {
    min-height: 36px;
  }

  .input,
  .select {
    min-height: 44px;
    border-radius: var(--radius);
    font-size: 16px;
  }

  .select {
    padding-right: 30px;
    padding-left: 12px;
    background-position: right 10px center;
  }

  .search kbd {
    display: none;
  }

  /* Cards */
  .card {
    border-radius: var(--radius-lg);
  }

  .card-head {
    padding: 14px 16px 10px;
  }

  .card-head h2 {
    overflow: hidden;
    min-width: 0;
    font-size: 16px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .card-head > :not(h2) {
    flex: none;
    font-size: 13px;
    white-space: nowrap;
  }

  .card-body {
    padding: 0 16px 16px;
  }

  .card-head .btn {
    min-height: 34px;
    padding: 0 12px;
    border-radius: 10px;
    font-size: 13px;
  }

  .list-row {
    min-height: 60px;
    padding: 12px 16px;
  }

  .empty {
    padding: 28px 16px;
  }

  /* Banners: icon on the left of the text, never above it. */
  .banner {
    display: grid;
    grid-template-columns: 20px minmax(0, 1fr);
    align-items: start;
    gap: 10px;
    padding: 12px 14px;
    line-height: 1.4;
  }

  .banner > svg {
    width: 20px;
    height: 20px;
    margin-top: 1px;
  }

  .banner > .btn {
    grid-column: 2;
    justify-self: start;
  }

  /* Stat tiles: label, value and a two-line hint on fixed lines. */
  .kpis,
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .kpi,
  .stat {
    align-content: start;
    gap: 4px;
    min-width: 0;
    padding: 12px 14px;
    border-radius: var(--radius);
  }

  .kpi-label,
  .stat > span:first-child {
    overflow: hidden;
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .kpi-value,
  .stat strong {
    overflow: hidden;
    font-size: 19px;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .kpi-sub,
  .stat small {
    display: -webkit-box;
    overflow: hidden;
    min-height: calc(2 * 1.35em);
    font-size: 12px;
    line-height: 1.35;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  /* An odd last tile takes the whole row instead of leaving a hole. */
  .kpis > :last-child:nth-child(odd),
  .stats > :last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }

  /* Filter chips: one row that scrolls sideways to the screen edge. */
  .chips.scroll-row {
    flex-wrap: nowrap;
    margin: 0 -16px;
    padding: 0 16px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .chips.scroll-row::-webkit-scrollbar {
    display: none;
  }

  .chips.scroll-row .chip {
    flex: none;
  }

  .segmented {
    display: flex;
    width: 100%;
    border-radius: var(--radius);
  }

  .segmented button {
    flex: 1 1 0;
    min-width: 0;
    min-height: 36px;
  }

  /* Toolbars are part of the page, not a sticky block over it. */
  .toolbar {
    position: static;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin: 0 0 12px;
    padding: 0;
    background: none;
  }

  .toolbar > .search,
  .toolbar > .chips {
    grid-column: 1 / -1;
  }

  /* Search and sorting alone: each on its own full row. */
  .toolbar:not(:has(.segmented)) > .select {
    grid-column: 1 / -1;
  }

  .toolbar .select {
    width: 100%;
    min-width: 0;
  }

  /* ---- Orders: one card layout for every order ---- */
  .row {
    margin-bottom: 8px;
    padding: 14px;
    border-radius: var(--radius-lg);
  }

  /* Name and switch, the state, then prices two by two, the profit last. */
  .orders-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    grid-template-areas:
      "item item auto"
      "status status status"
      "own comp comp"
      "limit target target"
      "profit profit profit";
    gap: 10px 12px;
  }

  .orders-grid .c-profit {
    justify-items: start;
    text-align: left;
  }

  .orders-grid .c-comp,
  .orders-grid .c-target {
    grid-column: 2 / -1;
  }

  .orders-grid .c-limit small {
    display: none;
  }

  .orders-grid .c-status {
    margin-top: -4px;
  }

  .orders-grid .c-status::before,
  .orders-grid .c-auto::before {
    display: none;
  }

  .orders-grid .c-status {
    justify-items: start;
  }

  .item-title .line {
    align-items: flex-start;
  }

  .item-title .line .type-tag {
    flex: none;
    margin-top: 1px;
  }

  .item-title strong {
    display: -webkit-box;
    overflow: hidden;
    white-space: normal;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .row .cell strong,
  .row .cell > span {
    overflow: hidden;
    max-width: 100%;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .row .cell .item-title strong {
    white-space: normal;
  }

  /* ---- Scanner ---- */
  .progress-host .progress-card {
    gap: 12px;
    padding: 14px 16px;
  }

  .progress-line {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px 12px;
    font-size: 13px;
  }

  .progress-line > .bar {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .progress-line > .num {
    grid-column: 2;
    grid-row: 1;
  }

  .progress-more,
  [data-snipes] .feeds,
  [data-snipes] .card-note {
    display: none;
  }

  [data-snipes] .card-head {
    padding-bottom: 12px;
  }

  [data-snipes] .list-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
  }

  [data-snipes] .list-row .grow {
    display: grid;
    gap: 2px;
    min-width: 0;
  }

  [data-snipes] .list-row strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  [data-snipes] .list-row small {
    display: -webkit-box;
    overflow: hidden;
    font-size: 12px;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .snipe-actions {
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
  }

  [data-snipes] .snipe-roi small,
  [data-snipes] .near-miss .pill {
    display: none;
  }

  .snipe-actions .btn,
  .snipe-actions .pill {
    min-width: 84px;
    justify-content: center;
  }

  .scanner-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-areas:
      "item item roi"
      "buy sell profit"
      "daily days sales";
    gap: 12px 10px;
  }

  .scanner-grid .cell small {
    display: none;
  }

  .scanner-grid .item-title .meta {
    overflow: hidden;
    flex-wrap: nowrap;
  }

  /* ---- Inventory ---- */
  .inv-toolbar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .inv-toolbar .search {
    grid-column: 1 / -1;
  }

  .inv-toolbar .select {
    width: 100%;
    min-width: 0;
  }

  .inv-toolbar .btn.switch {
    justify-content: flex-start;
    gap: 8px;
    min-width: 0;
    padding: 0 12px;
    font-size: 13px;
  }

  .inv-toolbar .btn.switch > span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .inv-toolbar .btn.switch .switch-track {
    width: 34px;
    height: 20px;
  }

  .inv-toolbar .btn.switch .switch-track::after {
    width: 14px;
    height: 14px;
  }

  .inv-grid {
    gap: 8px;
  }

  .inv-card {
    border-radius: var(--radius-lg);
  }

  .inv-media {
    height: 112px;
  }

  .inv-body {
    padding: 10px 12px 8px;
  }

  .inv-weapon,
  .inv-skin,
  .inv-price,
  .inv-meta,
  .inv-facts {
    min-height: 1.35em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .inv-action {
    margin: 4px 12px 12px;
    padding: 9px 0;
    border-radius: 10px;
  }

  .bulk-bar {
    top: calc(var(--topbar-h) + var(--safe-top) + 8px);
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .bulk-bar > span {
    grid-column: 1 / -1;
  }

  .bulk-bar .btn-primary {
    grid-column: 1 / -1;
  }

  /* ---- Sheets ---- */
  .sheet-foot {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .sheet-foot > .btn:only-child,
  .sheet-foot > .btn:first-child:nth-last-child(3) {
    grid-column: 1 / -1;
    margin: 0 !important;
  }

  .sale-option {
    position: relative;
    align-content: start;
  }

  /* The accent border marks the advice; the badge becomes a dot. */
  .sale-option .tag {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 8px;
    height: 8px;
    padding: 0;
    border-radius: 50%;
    background: var(--accent);
    font-size: 0;
  }

  .bulk-sell-head,
  .bulk-sell-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px 8px;
  }

  .bulk-sell-head > :first-child {
    display: none;
  }

  .bulk-sell-row > .grow {
    grid-column: 1 / -1;
  }

  .bulk-sell-row {
    padding: 10px 0;
    border-top: 1px solid var(--border);
  }

  .bulk-sell-row small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* ---- Settings ---- */
  .settings-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .field-row {
    gap: 8px;
  }

  .field-row .input,
  .field-row .input-affix {
    flex-basis: 100%;
  }

  .field-row .btn {
    flex: 1 1 0;
    min-width: 0;
  }

  .card-body.page-actions {
    display: grid;
    gap: 8px;
  }
}

@media (max-width: 1023px) {
  .grid-2,
  .overview-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Phones: the top bar holds the mode, the guide and the settings, so the
   logo keeps only its mark. */
@media (max-width: 440px) {
  .brand-compact strong {
    display: none;
  }
}

/* Narrow phones (iPhone SE, small Androids): same layout, tighter type. */
@media (max-width: 374px) {
  .main {
    padding-right: 12px;
    padding-left: 12px;
  }

  .chips.scroll-row {
    margin: 0 -12px;
    padding: 0 12px;
  }

  .kpi-value,
  .stat strong {
    font-size: 17px;
  }

  .tabbar .nav-link {
    font-size: 10px;
  }

  .inv-toolbar .btn.switch {
    gap: 6px;
    padding: 0 10px;
    font-size: 12px;
  }
}

/* Hidden item names are long: they wrap instead of widening the sheet. */
[data-hidden-items] .chip,
[data-targets] .chip {
  max-width: 100%;
  white-space: normal;
  text-align: left;
}

/* ============ Guide ============ */
.guide-text {
  display: grid;
  gap: 10px;
  font-size: 14px;
  line-height: 1.55;
}

.guide-text h3 {
  margin: 6px 0 0;
  font-size: 14px;
}

.guide-text p,
.guide-text ul,
.guide-text ol {
  margin: 0;
}

.guide-text ul,
.guide-text ol,
.guide-toc ol {
  display: grid;
  gap: 6px;
  padding-left: 22px;
}

.guide-toc ol {
  margin: 0;
  font-size: 14px;
}

.guide-toc a {
  font-weight: 600;
  text-decoration: none;
}

.guide-num {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin-right: 8px;
  border-radius: 50%;
  color: var(--accent-ink);
  background: var(--accent);
  font-size: 13px;
  vertical-align: 1px;
}

.guide .card {
  scroll-margin-top: 72px;
}

.guide-terms {
  display: grid;
  gap: 12px;
  margin: 0;
}

.guide-terms dt {
  font-weight: 700;
}

.guide-terms dd {
  margin: 2px 0 0;
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.5;
}

/* ============ Steam Guard ============ */
.guard {
  display: grid;
  gap: 12px;
  max-width: 520px;
}

.guard-card {
  position: relative;
  overflow: hidden;
  transition: border-color 120ms ease, background 120ms ease;
}

.guard-card.is-empty {
  border-style: dashed;
  border-color: var(--border-strong);
}

.guard-card.is-drop {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
}

.guard-card.is-busy {
  pointer-events: none;
  opacity: 0.6;
}

.guard-account {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 12px 0 18px;
}

.guard-who {
  display: grid;
  min-width: 0;
}

.guard-who strong {
  overflow: hidden;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.guard-who span {
  color: var(--text-3);
  font-size: 12px;
}

.guard-actions {
  display: flex;
  flex: none;
  gap: 2px;
}

.guard-actions .btn {
  color: var(--text-2);
}

.guard-actions .btn-danger:hover:not(:disabled) {
  color: var(--danger);
  background: var(--danger-soft);
}

/* The whole code is one button: a tap anywhere on it copies. */
.guard-code {
  display: grid;
  justify-items: center;
  gap: 14px;
  width: 100%;
  padding: 26px 18px 22px;
  border: 0;
  color: inherit;
  background: none;
  cursor: pointer;
}

.guard-code:disabled {
  cursor: default;
}

.guard-code:focus-visible {
  box-shadow: none;
}

.guard-code:focus-visible .guard-chars span {
  box-shadow: var(--focus);
}

.guard-chars {
  display: flex;
  gap: 8px;
}

.guard-chars span {
  display: grid;
  place-items: center;
  width: 58px;
  height: 72px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  font: 700 36px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  transition: border-color 120ms ease, background 120ms ease, color 120ms ease;
}

.guard-code:hover:not(:disabled) .guard-chars span {
  border-color: var(--border-strong);
  background: var(--surface-3);
}

.guard-code:disabled .guard-chars span {
  color: var(--text-3);
}

.guard-card.is-copied .guard-chars span {
  border-color: color-mix(in srgb, var(--success) 55%, transparent);
  background: var(--success-soft);
}

.guard-hint {
  color: var(--text-3);
  font-size: 13px;
}

.guard-hint.is-done {
  color: var(--success);
  font-weight: 600;
}

.guard-timer {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
}

.guard-bar {
  flex: 1;
  height: 4px;
  overflow: hidden;
  border-radius: 2px;
  background: var(--surface-3);
}

.guard-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transform-origin: left;
  transition: transform 250ms linear, background 200ms ease;
}

.guard-left {
  flex: none;
  min-width: 142px;
  color: var(--text-3);
  font-size: 13px;
  text-align: right;
}

.guard-card.is-hurry .guard-bar span {
  background: var(--danger);
}

.guard-card.is-hurry .guard-left {
  color: var(--danger);
}

.guard-state {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 40px 24px;
  color: var(--text-3);
  text-align: center;
}

.guard-state > svg {
  width: 30px;
  height: 30px;
  margin-bottom: 4px;
}

.guard-state strong {
  color: var(--text);
  font-size: 15px;
}

.guard-state p {
  max-width: 340px;
  font-size: 13px;
}

.guard-state .btn {
  margin-top: 10px;
}

.guard-skeleton-code {
  width: 322px;
  max-width: 100%;
  height: 72px;
  border-radius: var(--radius);
}

.guard-skeleton-line {
  width: 180px;
  margin: 8px 0 34px;
}

.guard-note {
  padding: 0 2px;
  color: var(--text-3);
  font-size: 12px;
}

.guard-note code {
  font-size: 11px;
}

@media (max-width: 440px) {
  .guard-chars {
    gap: 6px;
  }

  .guard-chars span {
    width: 50px;
    height: 64px;
    font-size: 31px;
  }

  .guard-account {
    padding-left: 14px;
  }

  .guard-timer {
    padding-inline: 14px;
  }

  .guard-left {
    min-width: 0;
  }
}

@media (min-width: 900px) {
  .guide-terms {
    grid-template-columns: 1fr 1fr;
    column-gap: 24px;
  }
}

/* ============ Market overview ============ */
.market-note {
  font-size: 12px;
}

.market-line {
  fill: none;
  stroke: var(--buy);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.market-crosshair {
  stroke: var(--border-strong);
  stroke-width: 1;
}

.market-days {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 4px 16px;
  padding-top: 10px;
  color: var(--text-3);
  font-size: 12px;
}

.market-days strong {
  color: var(--text);
  font-weight: 600;
}

/* Columns of the two-week price change; the falling side, the flat middle
   and the rising side differ in colour, the labels under them say which. */
.market-bars {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 2px;
  align-items: end;
}

.market-bar {
  display: grid;
  gap: 6px;
  justify-items: center;
  min-width: 0;
}

.market-bar-value {
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
}

.market-bar-track {
  display: flex;
  align-items: flex-end;
  width: 100%;
  height: 120px;
}

.market-bar-track i {
  display: block;
  width: 100%;
  border-radius: 4px 4px 0 0;
  background: var(--border-strong);
}

.market-bar.down .market-bar-track i,
.market-share-bar .down,
.market-legend .down {
  background: var(--danger);
}

.market-bar.up .market-bar-track i,
.market-share-bar .up,
.market-legend .up {
  background: var(--success);
}

.market-bar.flat .market-bar-track i,
.market-share-bar .flat,
.market-legend .flat {
  background: var(--border-strong);
}

.market-bar:hover .market-bar-track i {
  filter: brightness(1.12);
}

.market-bar-label {
  color: var(--text-3);
  font-size: 11px;
  text-align: center;
  white-space: nowrap;
}

.market-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-top: 12px;
  color: var(--text-3);
  font-size: 12px;
}

.market-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.market-legend i {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.market-table {
  display: grid;
}

.market-row {
  display: grid;
  grid-template-columns: minmax(150px, 1.5fr) 84px 76px 92px minmax(200px, 2fr) 120px 140px;
  gap: 14px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  font-size: 13px;
}

.market-row .right {
  text-align: right;
}

.market-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.market-head {
  border-top: 0;
  padding-top: 0;
  color: var(--text-3);
  font-size: 12px;
  font-weight: 600;
}

.market-share {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.market-share small {
  color: var(--text-3);
  font-size: 11px;
}

.market-share-bar {
  display: flex;
  gap: 2px;
  height: 8px;
}

.market-share-bar i {
  flex: 0 0 auto;
  min-width: 3px;
  border-radius: 4px;
}

.market-movers {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

@media (max-width: 1100px) {
  .market-row {
    grid-template-columns: minmax(120px, 1.4fr) 76px minmax(160px, 2fr);
  }

  .market-row > :nth-child(2),
  .market-row > :nth-child(4),
  .market-row > :nth-child(6),
  .market-row > :nth-child(7) {
    display: none;
  }
}

@media (max-width: 680px) {
  .market-movers {
    grid-template-columns: minmax(0, 1fr);
  }

  .market-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px 12px;
  }

  .market-row > .market-share {
    grid-column: 1 / -1;
  }

  .market-head > :nth-child(5) {
    display: none;
  }

  .market-bars {
    grid-template-columns: repeat(9, minmax(34px, 1fr));
    overflow-x: auto;
  }

  .market-bar-label {
    font-size: 10px;
    white-space: normal;
  }
}

/* ---------- Settings: tabs on the left (a strip on a phone), the chosen block on the right ---------- */

.settings-layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.settings-nav {
  position: sticky;
  top: 16px;
  display: grid;
  gap: 4px;
}

.settings-tab {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--text-2);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.settings-tab svg {
  flex: none;
  width: 18px;
  height: 18px;
}

.settings-tab span {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.settings-tab strong {
  color: var(--text);
  font-size: 14px;
  font-weight: 620;
}

.settings-tab small {
  color: var(--text-3);
  font-size: 12px;
}

.settings-tab:hover {
  background: var(--surface);
}

.settings-tab[aria-pressed="true"] {
  border-color: var(--border);
  color: var(--accent);
  background: var(--surface);
}

.settings-tab:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.settings-panel {
  min-width: 0;
}

.settings-block {
  display: grid;
  gap: 18px;
}

.settings-lead {
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.5;
}

.settings-group {
  display: grid;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.settings-group h3 {
  color: var(--text);
  font-size: 15px;
  font-weight: 650;
}

.settings-note {
  color: var(--text-3);
  font-size: 13px;
  line-height: 1.5;
}

.settings-explain {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border-radius: var(--radius);
  color: var(--text-2);
  background: var(--surface-2);
  font-size: 13px;
  line-height: 1.5;
}

.settings-explain strong {
  color: var(--text);
}

.settings-block .field-wide {
  grid-column: 1 / -1;
}

.settings-block .chip {
  white-space: normal;
  text-align: left;
}

.settings-savebar {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin: 0 -18px -18px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  background: var(--surface);
}

.settings-savebar [data-dirty] {
  margin-right: auto;
  font-size: 13px;
}

.settings-savebar .warning-text {
  color: var(--warning);
}

.sheet .settings-savebar {
  margin: 0;
  border-radius: var(--radius);
}

@media (max-width: 860px) {
  .settings-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .settings-nav {
    position: static;
    display: flex;
    gap: 6px;
    margin: 0 -16px;
    padding: 0 16px 4px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .settings-nav::-webkit-scrollbar {
    display: none;
  }

  .settings-tab {
    flex: none;
    width: auto;
    padding: 8px 12px;
    border-color: var(--border);
    border-radius: 999px;
  }

  .settings-tab small {
    display: none;
  }

  .settings-tab svg {
    width: 16px;
    height: 16px;
  }

  .settings-savebar {
    bottom: calc(var(--tabbar-h) + var(--safe-bottom));
  }
}

.settings-block .settings-grid {
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}

/* ---------- Item sheet: the deal at a glance, then the order form ---------- */

.deal-hero {
  display: grid;
  gap: 8px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
}

.deal-hero.success {
  border-color: color-mix(in srgb, var(--success) 40%, var(--border));
  background: linear-gradient(180deg, var(--success-soft), var(--surface-2) 70%);
}

.deal-hero.warning {
  border-color: color-mix(in srgb, var(--warning) 40%, var(--border));
  background: linear-gradient(180deg, var(--warning-soft), var(--surface-2) 70%);
}

.deal-hero.danger {
  border-color: color-mix(in srgb, var(--danger) 40%, var(--border));
  background: linear-gradient(180deg, var(--danger-soft), var(--surface-2) 70%);
}

.deal-hero-label {
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
}

.deal-hero-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.deal-hero-value {
  font-size: 30px;
  font-weight: 750;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.deal-hero.success .deal-hero-value { color: var(--success); }
.deal-hero.warning .deal-hero-value { color: var(--warning); }
.deal-hero.danger .deal-hero-value { color: var(--danger); }

.deal-hero p {
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.45;
}

.deal-flow {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.deal-flow > span {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.deal-flow small {
  color: var(--text-3);
  font-size: 11px;
}

.deal-flow b {
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.deal-arrow {
  color: var(--text-3);
}

.deal-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.deal-card h3 {
  font-size: 16px;
  font-weight: 680;
}

.order-form .max-price-field .input {
  font-size: 18px;
  font-weight: 650;
}

.qty-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.qty-stepper {
  display: flex;
  align-items: center;
  gap: 6px;
}

.qty-stepper .input {
  width: 64px;
  text-align: center;
}

.qty-stepper .btn {
  min-width: 40px;
  font-size: 18px;
}

.order-more > summary,
.deal-more > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 0;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 600;
  list-style: none;
  cursor: pointer;
}

.order-more > summary::-webkit-details-marker,
.deal-more > summary::-webkit-details-marker {
  display: none;
}

.order-more > summary::after,
.deal-more > summary::after {
  content: "›";
  color: var(--text-3);
  font-size: 18px;
  transition: transform 0.15s ease;
}

.order-more[open] > summary::after,
.deal-more[open] > summary::after {
  transform: rotate(90deg);
}

.order-more {
  border-top: 1px solid var(--border);
}

.deal-more {
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.deal-more[open] {
  padding-bottom: 16px;
}

.btn.is-armed {
  background: var(--warning);
  border-color: var(--warning);
  color: var(--accent-ink);
}

.sheet-body > .deal-hero,
.sheet-body > .deal-card,
.sheet-body > .deal-more,
.sheet-body > [data-checks] {
  margin-bottom: 12px;
}

.sheet-foot .btn {
  white-space: normal;
  line-height: 1.2;
}

.sheet-foot [data-close] {
  flex: 0 0 auto;
}

.settings-more {
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  color: var(--text-2);
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.settings-more:hover {
  color: var(--text);
  background: var(--surface);
}

.settings-nav-more {
  display: grid;
  gap: 4px;
}

.settings-group-first {
  padding-top: 0;
  border-top: 0;
}

.settings-help > summary {
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.settings-help p {
  margin-top: 8px;
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.5;
}

@media (max-width: 860px) {
  .settings-more {
    flex: none;
    margin-top: 0;
    padding: 8px 12px;
    border-radius: 999px;
    white-space: nowrap;
  }

  .settings-nav-more:not([hidden]) {
    display: contents;
  }
}

/* ---------- Scanner: what it looks for, and the finds as plain rows ---------- */

.scan-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  font-size: 14px;
}

.scan-summary .link-btn {
  margin-left: auto;
  color: var(--accent);
}

.find-grid {
  grid-template-columns: minmax(220px, 2.2fr) minmax(180px, 1.3fr) minmax(130px, 1fr) minmax(110px, 0.8fr) auto;
}

.find-grid .c-flow {
  display: grid;
  gap: 2px;
}

.find-grid .c-flow small {
  color: var(--text-3);
  font-size: 12px;
}

.find-grid .c-profit {
  display: grid;
  justify-items: end;
  gap: 4px;
}

.find-grid .c-profit strong {
  font-size: 16px;
}

.find-grid .c-cycle small {
  color: var(--text-3);
  font-size: 12px;
}

@media (max-width: 860px) {
  .rows-head.find-grid {
    display: none;
  }

  .row.find-grid {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "item item"
      "flow profit"
      "cycle action";
    gap: 10px 12px;
    padding: 14px 16px;
  }

  .find-grid .c-item { grid-area: item; }
  .find-grid .c-flow { grid-area: flow; }
  .find-grid .c-profit { grid-area: profit; }
  .find-grid .c-cycle {
    grid-area: cycle;
    justify-items: start;
    text-align: left;
  }
  .find-grid .c-action { grid-area: action; }

  .scan-summary .link-btn {
    margin-left: 0;
  }
}

/* ---------- Orders: six columns — the target and the bound live under the price ---------- */

.orders-grid.compact {
  grid-template-columns: minmax(220px, 2.4fr) repeat(3, minmax(110px, 1fr)) 170px 56px;
  grid-template-areas: none;
}

.orders-grid.compact .c-own small.up { color: var(--success); }
.orders-grid.compact .c-own small.down { color: var(--danger); }

@media (min-width: 861px) {
  .orders-grid.compact .c-item,
  .orders-grid.compact .c-own,
  .orders-grid.compact .c-comp,
  .orders-grid.compact .c-profit,
  .orders-grid.compact .c-status,
  .orders-grid.compact .c-auto {
    grid-area: auto;
  }
}

@media (max-width: 860px) {
  .orders-grid.compact {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-areas:
      "item item auto"
      "own comp profit"
      "status status status";
  }

  .orders-grid.compact .c-status {
    justify-items: start;
    align-self: start;
  }
}

@media (max-width: 520px) {
  .orders-grid.compact {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    grid-template-areas:
      "item item auto"
      "status status status"
      "own comp comp"
      "profit profit profit";
  }

  .orders-grid.compact .c-comp {
    grid-column: 2 / -1;
  }
}

/* ---------- "Ещё": rare page actions folded into one button ---------- */

.more-menu {
  position: relative;
}

.more-menu > summary {
  list-style: none;
}

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

.more-menu-list {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 30;
  display: grid;
  min-width: 260px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.more-menu-list .btn {
  justify-content: flex-start;
  width: 100%;
}

/* ---------- Order sheet: how the order holds the first place ---------- */

.contest-meter {
  display: grid;
  gap: 6px;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--surface-2);
}

.contest-meter-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 8px;
  font-size: 14px;
  font-weight: 650;
}

.contest-meter small {
  color: var(--text-3);
  font-size: 12px;
  font-weight: 500;
}

.contest-meter .bar {
  height: 8px;
}

.contest-meter.success .bar i { background: var(--success); }
.contest-meter.warning .bar i { background: var(--warning); }
.contest-meter.danger .bar i { background: var(--danger); }

.deal-more > summary small {
  margin-left: auto;
  font-weight: 500;
}

.deal-card .section-title h3 {
  color: var(--text);
  font-size: 16px;
  font-weight: 680;
  letter-spacing: normal;
  text-transform: none;
}

/* ---------- Market: the figures in one sentence ---------- */

.market-verdict {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  font-size: 14px;
}

.market-verdict span {
  color: var(--text-2);
  font-size: 13px;
}

.market-verdict.danger {
  border-color: color-mix(in srgb, var(--danger) 40%, var(--border));
  background: linear-gradient(180deg, var(--danger-soft), var(--surface) 80%);
}

.market-verdict.success {
  border-color: color-mix(in srgb, var(--success) 40%, var(--border));
  background: linear-gradient(180deg, var(--success-soft), var(--surface) 80%);
}

.journal-kinds {
  margin-bottom: 12px;
}
