@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");

:root {
  --bg: #000000;
  --bg-elevated: #0a0a0a;
  --panel: #121212;
  --panel-sub: #1a1a1a;
  --border: #262626;
  --border-subtle: #1f1f1f;
  --text: #fafafa;
  --muted: #737373;
  --accent: #00ff88;
  --accent-dim: rgba(0, 255, 136, 0.1);
  --accent-glow: rgba(0, 255, 136, 0.35);
  --warm: #d4a574;
  --warm-dim: rgba(212, 165, 116, 0.12);
  --good: #00ff88;
  --warn: #fbbf24;
  --bad: #ff4757;
  --sidebar-w: 56px;
  --topbar-h: 52px;
  --radius: 12px;
  --radius-sm: 8px;
}

* {
  box-sizing: border-box;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

*::-webkit-scrollbar {
  display: none;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: #66ffb3;
}

.icon {
  width: 16px;
  height: 16px;
  stroke-width: 1.75;
  flex-shrink: 0;
}

.icon-sm {
  width: 13px;
  height: 13px;
}

.sidebar .nav-item svg,
.sidebar .nav-item .icon {
  width: 15px;
  height: 15px;
  stroke-width: 1.65;
}

.brand-logo img {
  width: 22px;
  height: 22px;
}

/* App shell */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
  overflow: hidden;
}

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

  .sidebar {
    display: none;
  }
}

/* Sidebar */
.sidebar {
  background: var(--bg-elevated);
  border-right: 1px solid var(--border-subtle);
  padding: 12px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  height: 100vh;
}

.brand-logo {
  width: 36px;
  height: 36px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-logo img,
.brand-logo svg {
  width: 28px;
  height: 28px;
  display: block;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex: 1;
  width: 100%;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.nav-item:hover {
  background: var(--accent-dim);
  color: var(--text);
}

.nav-item.active {
  color: var(--accent);
  background: var(--accent-dim);
  box-shadow: inset 0 0 0 1px rgba(0, 255, 136, 0.25);
}

.nav-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  background: var(--bad);
  color: #fff;
  font-size: 0.6rem;
  padding: 0 4px;
  border-radius: 999px;
  min-width: 14px;
  height: 14px;
  line-height: 14px;
  text-align: center;
  font-weight: 700;
}

.nav-badge.hidden {
  display: none;
}

.nav-item-with-bar {
  height: auto;
  min-height: 36px;
  padding: 5px 0 4px;
}

.nav-item-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
}

.nav-scan-bar {
  width: 22px;
  height: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.nav-scan-bar.hidden {
  display: none;
}

.nav-scan-bar-fill {
  display: block;
  height: 100%;
  width: 45%;
  border-radius: inherit;
  background: linear-gradient(90deg, #00ff88, #00cc6a, #a7ffdf, #00ff88);
  background-size: 220% 100%;
  animation: nav-scan-shimmer 1.35s linear infinite;
}

.nav-scan-bar.has-progress .nav-scan-bar-fill {
  width: var(--scan-pct, 20%);
  min-width: 18%;
}

@keyframes nav-scan-shimmer {
  0% { background-position: 120% 0; }
  100% { background-position: -120% 0; }
}

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

/* Main area */
.main-area {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
  overflow: hidden;
}

.topbar {
  height: var(--topbar-h);
  padding: 0 20px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.topbar-logo-mobile {
  display: none;
}

@media (max-width: 768px) {
  .topbar-logo-mobile {
    display: flex;
  }
}

.topbar-title {
  font-size: 0.92rem;
  font-weight: 600;
  margin-right: auto;
  letter-spacing: -0.01em;
}

.topbar-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-group label {
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0;
  white-space: nowrap;
}

.content {
  padding: 20px 24px 32px;
  flex: 1;
  overflow: auto;
}

.tab-panel[hidden] {
  display: none !important;
}

/* Cards */
.card {
  background: var(--panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 16px;
}

.card h2 {
  margin: 0 0 12px;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.card-header h2 {
  margin: 0;
  line-height: 1.2;
}

.card-header-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.card-header .mode-tabs {
  margin-bottom: 0;
}

.content-shell {
  background: var(--panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 4px;
  min-height: 0;
}

.perceive-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
  align-items: start;
}

.scan-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.scan-actions button {
  margin-bottom: 0;
}

.filter-toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.term-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  cursor: pointer;
  user-select: none;
  font-size: 0.82rem;
  color: var(--text);
}

.term-check span {
  line-height: 1;
}

.term-check input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  min-width: 14px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--accent);
  border-radius: 0;
  background: #000;
  color: var(--accent);
  font-family: "SF Mono", Consolas, "Courier New", monospace;
  font-size: 10px;
  line-height: 12px;
  text-align: center;
  cursor: pointer;
}

.term-check input[type="checkbox"]:checked::after {
  content: "×";
  display: block;
  color: var(--accent);
  font-weight: 700;
  transform: translateY(-1px);
}

.term-check input[type="checkbox"]:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 2px;
}

@media (max-width: 1100px) {
  .perceive-grid {
    grid-template-columns: 1fr;
  }
}

/* Form controls */
label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 4px;
}

input, select {
  width: 100%;
  padding: 8px 10px;
  margin-bottom: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--panel-sub);
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
}

input:focus, select:focus {
  outline: none;
  border-color: rgba(0, 255, 136, 0.45);
  box-shadow: 0 0 0 2px var(--accent-dim);
}

.topbar-group input {
  width: 110px;
  padding: 6px 8px;
  margin: 0;
  font-size: 0.85rem;
}

button {
  cursor: pointer;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-weight: 600;
  font-family: inherit;
  background: var(--accent);
  color: #000;
  width: 100%;
  transition: filter 0.15s ease;
}

button:hover:not(:disabled) {
  filter: brightness(1.08);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

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

button.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}

button.ghost:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--border);
  filter: none;
  background: var(--panel-sub);
}

.topbar-group button {
  width: auto;
  padding: 6px 12px;
  font-size: 0.82rem;
}

button.secondary.no-mt {
  margin-top: 0;
}

/* Stats */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

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

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

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

.stats-10 .stat {
  padding: 12px 10px;
  min-width: 0;
}

.stats-10 .stat .value {
  font-size: 1.15rem;
}

.stats-10 .stat .label {
  font-size: 0.62rem;
  line-height: 1.3;
}

@media (max-width: 1400px) {
  .stats-10 {
    grid-template-columns: repeat(10, minmax(72px, 1fr));
    overflow-x: auto;
  }
}

@media (max-width: 1100px) {
  .stats-6 {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 700px) {
  .stats, .stats-3, .stats-6, .stats-10 {
    grid-template-columns: repeat(2, 1fr);
  }
}

.stat {
  background: var(--panel-sub);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  border: 1px solid var(--border-subtle);
  text-align: left;
}

.stat .value {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.stat .label {
  color: var(--muted);
  font-size: 0.72rem;
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

th, td {
  border-bottom: 1px solid var(--border-subtle);
  padding: 10px 12px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  position: sticky;
  top: 0;
  background: var(--panel);
  z-index: 1;
}

th.sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

th.sortable:hover {
  color: var(--accent);
}

th.sortable::after {
  content: "↕";
  margin-left: 4px;
  font-size: 0.62rem;
  opacity: 0.35;
}

th.sortable.sort-asc::after {
  content: "↑";
  opacity: 1;
  color: var(--accent);
}

th.sortable.sort-desc::after {
  content: "↓";
  opacity: 1;
  color: var(--accent);
}

tr:hover td {
  background: rgba(0, 255, 136, 0.03);
}

code {
  font-family: "SF Mono", Consolas, "Courier New", monospace;
  font-size: 0.76rem;
  word-break: break-all;
}

.good {
  color: var(--good);
  font-weight: 600;
}

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

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

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  max-height: 480px;
}

.table-wrap.tall {
  max-height: 640px;
}

/* Bar cells */
.bar-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 120px;
}

.bar-cell-track {
  flex: 1;
  height: 6px;
  background: var(--panel-sub);
  border-radius: 999px;
  overflow: hidden;
  min-width: 48px;
}

.bar-cell-fill {
  height: 100%;
  background: linear-gradient(90deg, rgba(0, 255, 136, 0.45), var(--accent));
  border-radius: 999px;
  transition: width 0.3s ease;
}

.bar-cell-fill.warm {
  background: linear-gradient(90deg, rgba(212, 165, 116, 0.45), var(--warm));
}

.bar-cell-value {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  min-width: 52px;
  text-align: right;
  font-size: 0.8rem;
}

/* Status pills */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid transparent;
}

.status-idle {
  background: var(--panel-sub);
  color: var(--muted);
  border-color: var(--border);
}

.status-running {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: rgba(0, 255, 136, 0.3);
}

.status-completed {
  background: rgba(0, 255, 136, 0.15);
  color: var(--good);
  border-color: rgba(0, 255, 136, 0.25);
}

.status-failed {
  background: rgba(255, 71, 87, 0.12);
  color: var(--bad);
  border-color: rgba(255, 71, 87, 0.25);
}

.hint, .meta {
  color: var(--muted);
  font-size: 0.82rem;
}

.hint {
  margin: 0 0 10px;
}

.meta {
  margin-top: 8px;
}

.empty-state {
  color: var(--muted);
  font-size: 0.88rem;
  padding: 32px 24px;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
}

.section-title {
  font-size: 0.85rem;
  font-weight: 600;
  margin: 16px 0 8px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Toolbar */
.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.toolbar label {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.toolbar input[type="checkbox"] {
  width: auto;
  margin: 0;
}

.toolbar select {
  width: auto;
  min-width: 160px;
  margin: 0;
}

.toolbar button {
  width: auto;
  padding: 6px 12px;
}

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

.btn-small {
  cursor: pointer;
  border: none;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.72rem;
  font-weight: 600;
  width: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-block {
  background: rgba(255, 71, 87, 0.15);
  color: #ff8a96;
  border: 1px solid rgba(255, 71, 87, 0.25);
}

.btn-follow {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(0, 255, 136, 0.3);
}

.btn-link {
  background: var(--warm-dim);
  color: var(--warm);
  border: 1px solid rgba(212, 165, 116, 0.25);
  text-decoration: none;
}

/* Exec pills */
.exec-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 600;
}

.exec-filled {
  background: rgba(0, 255, 136, 0.12);
  color: var(--good);
}

.exec-blocked, .exec-rejected, .exec-skipped {
  background: rgba(255, 71, 87, 0.12);
  color: #ff8a96;
}

.exec-partial, .exec-pending {
  background: rgba(251, 191, 36, 0.12);
  color: var(--warn);
}

.gate-reason {
  display: inline-block;
  max-width: 220px;
  font-size: 0.76rem;
  line-height: 1.35;
  word-break: break-word;
}

.gate-reason-clip {
  color: var(--warn);
  font-weight: 600;
}

.gate-reason-block {
  color: var(--bad);
  font-weight: 600;
}

.gate-reason-ok {
  color: var(--muted);
}

.reduce-tag {
  display: inline-block;
  margin-right: 4px;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 600;
  background: var(--warm-dim);
  color: var(--warm);
}

.exec-toggle-on {
  background: var(--accent-dim) !important;
  color: var(--accent) !important;
  border: 1px solid rgba(0, 255, 136, 0.35) !important;
}

.exec-toggle-off {
  background: var(--panel-sub) !important;
  color: var(--muted) !important;
  border: 1px solid var(--border) !important;
}

.exec-toggle-live-disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.dex-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  background: var(--panel-sub);
  color: var(--muted);
  border: 1px solid var(--border);
}

.dex-tag.xyz {
  background: rgba(212, 165, 116, 0.1);
  color: var(--warm);
  border-color: rgba(212, 165, 116, 0.25);
}

.freq-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}

.freq-badge.low {
  background: rgba(0, 255, 136, 0.1);
  color: #66ffb3;
  border-color: rgba(0, 255, 136, 0.25);
}

.freq-badge.medium {
  background: rgba(251, 191, 36, 0.1);
  color: var(--warn);
  border-color: rgba(251, 191, 36, 0.25);
}

.freq-badge.high {
  background: rgba(255, 71, 87, 0.1);
  color: #ff8a96;
  border-color: rgba(255, 71, 87, 0.25);
}

.race-details summary {
  cursor: pointer;
  color: var(--text);
  font-weight: 600;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.race-details summary i {
  transition: transform 0.15s ease;
}

.race-details[open] summary i {
  transform: rotate(90deg);
}

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

.race-list {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 0.85rem;
}

.race-list li {
  margin-bottom: 6px;
}

.blocklist-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.78rem;
}

.error-box {
  background: rgba(255, 71, 87, 0.1);
  border: 1px solid rgba(255, 71, 87, 0.3);
  color: #ff8a96;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  margin-top: 8px;
  display: none;
}

.workflow ol {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 0.82rem;
}

.workflow li {
  margin-bottom: 6px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  flex-wrap: wrap;
}

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

.page-buttons button {
  width: auto;
  min-width: 72px;
  padding: 8px 12px;
}

/* Log tabs */
.log-tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: wrap;
  padding: 3px;
  margin-bottom: 16px;
  background: var(--panel-sub);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.log-tab {
  width: auto;
  padding: 6px 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
}

.log-tab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
  filter: none;
}

.log-tab.active {
  color: var(--accent);
  background: var(--accent-dim);
  box-shadow: inset 0 0 0 1px rgba(0, 255, 136, 0.22);
}

/* Legacy chips (review page etc.) */
.filter-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.filter-chips .chip,
.chip {
  width: auto;
}

.chip {
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--panel-sub);
  color: var(--muted);
  cursor: pointer;
}

.chip.active {
  background: var(--accent-dim);
  border-color: rgba(0, 255, 136, 0.35);
  color: var(--accent);
}

.timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.timeline-item {
  display: grid;
  grid-template-columns: 140px 20px 1fr;
  gap: 0 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.timeline-time {
  font-family: "SF Mono", Consolas, monospace;
  font-size: 0.75rem;
  color: var(--muted);
  text-align: right;
  padding-top: 2px;
}

.timeline-rail {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.timeline-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  margin-top: 4px;
  flex-shrink: 0;
}

.timeline-item.level-warn .timeline-dot {
  background: var(--warn);
}

.timeline-item.level-error .timeline-dot {
  background: var(--bad);
}

.timeline-item.level-info .timeline-dot {
  background: var(--accent);
}

.timeline-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.timeline-meta .cat {
  font-size: 0.68rem;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--panel-sub);
  border: 1px solid var(--border);
}

.timeline-msg {
  font-size: 0.85rem;
}

.timeline-extra {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 2px;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-backdrop.open {
  display: flex;
}

.modal {
  width: min(720px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.modal h3 {
  margin: 0 0 12px;
}

.modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 700px) {
  .modal-grid {
    grid-template-columns: 1fr;
  }
}

.modal textarea {
  width: 100%;
  min-height: 180px;
  font-family: "SF Mono", Consolas, monospace;
  font-size: 0.78rem;
  background: var(--panel-sub);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  margin-top: 8px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.modal-actions button {
  width: auto;
  min-width: 120px;
}

.approve-modal {
  width: min(420px, 100%);
}

.approve-modal label {
  margin-top: 12px;
}

.approve-modal input {
  margin-top: 4px;
}

.approve-modal .warn-box {
  display: none;
  margin-top: 12px;
}

.warn-box {
  background: rgba(251, 191, 36, 0.08);
  border: 1px solid rgba(251, 191, 36, 0.25);
  color: #fde68a;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  margin-bottom: 10px;
  display: none;
}

.mode-tabs {
  display: inline-flex;
  gap: 2px;
  background: var(--panel-sub);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 3px;
  margin-bottom: 16px;
}

.mode-tab {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  width: auto;
  font-family: inherit;
}

.page-buttons button,
.card-header button,
.topbar-group button,
.toolbar button,
.modal-actions button,
.btn-small,
.log-tab {
  width: auto;
}

.mode-tab.active {
  background: var(--accent-dim);
  color: var(--accent);
}

.mode-tab:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.equity-chart {
  width: 100%;
  height: 260px;
  background: var(--panel-sub);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
}

.equity-chart .empty-state {
  border: none;
  margin: 0;
}

.equity-ohlc-legend {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: rgba(10, 10, 10, 0.82);
  border: 1px solid var(--border-subtle);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  pointer-events: none;
}

.equity-ohlc-legend .ohlc-time {
  color: var(--text-secondary);
  margin-right: 4px;
}

.equity-ohlc-legend span:not(.ohlc-time) {
  color: var(--text-primary);
}

.coin-cell {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.coin-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
  background: var(--panel-sub);
}

.coin-symbol {
  font-weight: 600;
  color: var(--text);
}

.side-badge {
  font-weight: 600;
  letter-spacing: 0.02em;
}

.side-badge.side-long {
  color: var(--accent);
}

.side-badge.side-short {
  color: #ff4466;
}

.stat .value.stat-animating {
  display: inline-block;
  will-change: transform, opacity;
}

.stat .value.stat-roll-up {
  animation: statRollUp 0.42s cubic-bezier(0.22, 1, 0.36, 1);
}

.stat .value.stat-roll-down {
  animation: statRollDown 0.42s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes statRollUp {
  0% { opacity: 0.35; transform: translateY(0.55em); }
  100% { opacity: 1; transform: translateY(0); }
}

@keyframes statRollDown {
  0% { opacity: 0.35; transform: translateY(-0.55em); }
  100% { opacity: 1; transform: translateY(0); }
}

.equity-chart .empty-state {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.analysis-report {
  margin: 12px 0;
  padding: 12px 14px;
  background: var(--panel-sub);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  line-height: 1.55;
}

.analysis-report h4 {
  margin: 0 0 8px;
  font-size: 0.9rem;
}

.analysis-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 16px;
}

.suit-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

.suit-badge.suitable {
  background: rgba(0, 255, 136, 0.12);
  color: var(--good);
}

.suit-badge.caution {
  background: rgba(251, 191, 36, 0.12);
  color: var(--warn);
}

.suit-badge.reject {
  background: rgba(255, 71, 87, 0.12);
  color: var(--bad);
}

.extra-coins-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 6px;
}

.extra-coins-list label {
  font-size: 0.8rem;
  cursor: pointer;
}

/* Review page (standalone) */
.review-page {
  height: auto;
  overflow: auto;
}

.review-page .app-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-elevated);
}

.review-page .app-header h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.review-page .review-content {
  padding: 24px;
  max-width: 1400px;
  margin: 0 auto;
}

.review-page section {
  margin-bottom: 32px;
}

.review-page section h2 {
  font-size: 0.95rem;
  margin: 0 0 12px;
  font-weight: 600;
}

.flag {
  color: var(--warn);
  font-weight: 600;
}

/* Leader open-position desktop toast */
.leader-open-toast-stack {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(380px, calc(100vw - 32px));
  pointer-events: none;
}

.leader-open-toast {
  pointer-events: auto;
  background: rgba(18, 18, 22, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-left: 3px solid #3dd68c;
  border-radius: 10px;
  padding: 12px 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  color: #f2f2f2;
  animation: leader-open-toast-in 0.22s ease-out;
}

.leader-open-toast--open { border-left-color: #3dd68c; }
.leader-open-toast--add { border-left-color: #5b8cff; }
.leader-open-toast--reduce { border-left-color: #f0b429; }
.leader-open-toast--close { border-left-color: #f07178; }

.leader-open-toast .toast-title {
  font-size: 0.92rem;
  font-weight: 650;
  margin: 0 0 4px;
}

.leader-open-toast .toast-meta {
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.65);
  margin: 0;
  line-height: 1.45;
}

.leader-open-toast .toast-actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
}

.leader-open-toast button {
  pointer-events: auto;
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 6px;
}

@keyframes leader-open-toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.topbar-sound-btn {
  width: 36px !important;
  height: 36px;
  padding: 0 !important;
  margin-top: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
}

.topbar-sound-btn svg {
  width: 18px;
  height: 18px;
}

.topbar-sound-btn.is-off {
  opacity: 0.38;
  color: var(--muted);
}

.topbar-sound-btn.is-on {
  opacity: 1;
  color: #3dd68c;
  border-color: rgba(61, 214, 140, 0.45);
}

.topbar-sound-btn:hover {
  background: var(--panel-sub);
}

.leader-open-sound-banner {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 10000;
  background: rgba(18, 18, 22, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  padding: 10px 12px;
  max-width: min(360px, calc(100vw - 32px));
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
  display: none;
}

.leader-open-sound-banner.visible {
  display: block;
}

.leader-open-sound-banner p {
  margin: 0 0 8px;
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.8);
}
