/* ═══════════════════════════════════════════════════════════════
   FLOCK — Dark-only design (Option C: #000000 page + #1C1C1E cards)
   Apple iOS dark system colors, OLED-friendly.
   No light mode. No @media prefers-color-scheme.
   ═══════════════════════════════════════════════════════════════ */

:root {
  /* ── Backgrounds (two-tier) ── */
  --bg-page:               #000000;          /* OLED true black */
  --bg-card:               #1C1C1E;          /* iOS grouped surface */
  --bg-elevated:           #2C2C2E;          /* elevated surface (order cards, inputs) */
  --bg-header:             rgba(0,0,0,0.88); /* header frost on scroll */
  --bg-overlay:            rgba(28,28,30,0.95); /* sheet/modal surface */

  /* ── Labels ── */
  --label-primary:         #FFFFFF;
  --label-secondary:       rgba(235,235,245,0.60);   /* ~#9696A0 */
  --label-tertiary:        rgba(235,235,245,0.30);   /* placeholder */
  --label-quaternary:      rgba(235,235,245,0.18);

  /* ── Separators ── */
  --separator:             rgba(255,255,255,0.10);   /* hairline on dark card */
  --separator-strong:      rgba(255,255,255,0.16);   /* slightly more visible */

  /* ── System accents (iOS dark-mode calibrated) ── */
  --sys-blue:              #0A84FF;
  --sys-green:             #30D158;
  --sys-orange:            #FF9F0A;
  --sys-red:               #FF453A;
  --sys-yellow:            #FFD60A;
  --sys-indigo:            #5E5CE6;

  /* ── Grays ── */
  --sys-gray:              #8E8E93;
  --sys-gray2:             #636366;
  --sys-gray3:             #48484A;
  --sys-gray4:             #3A3A3C;
  --sys-gray5:             #2C2C2E;
  --sys-gray6:             #1C1C1E;

  /* ── Interactive fills (overlay on dark surface) ── */
  --fill-hover:            rgba(255,255,255,0.06);
  --fill-pressed:          rgba(255,255,255,0.10);
  --fill-input:            rgba(255,255,255,0.07);

  /* ── Fonts ── */
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
               "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  /* ── Motion ── */
  --spring: cubic-bezier(0.32, 0.72, 0, 1);
}

/* ═══════════════════════════════════════════════════════════════
   Reset + base
   ═══════════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  background: var(--bg-page);
  color: var(--label-primary);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.47;
  font-weight: 400;
  -webkit-text-size-adjust: 100%;
  color-scheme: dark;
}

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg-page);
}

/* ═══════════════════════════════════════════════════════════════
   Header — sticky, frosted
   ═══════════════════════════════════════════════════════════════ */
header {
  position: sticky;
  top: 0;
  z-index: 200;
  background: var(--bg-header);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--separator);
  padding: 12px 20px 8px;
}

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

.header-price {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.token-name {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.022em;
  color: var(--label-primary);
  line-height: 1.1;
}

.hdr-price {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--label-secondary);
  letter-spacing: -0.01em;
}

/* ── Connection pill ── */
.conn-pill {
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-sans);
  padding: 4px 10px;
  border-radius: 20px;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

/* Connected: green tint — reads as "system healthy" */
.conn-pill.connected {
  background: rgba(48,209,88,0.18);
  color: var(--sys-green);
}

/* Disconnected: red tint with blinking dot */
.conn-pill.disconnected {
  background: rgba(255,69,58,0.18);
  color: var(--sys-red);
}
.conn-pill.disconnected::before {
  content: "● ";
  animation: blink 1.2s step-start infinite;
}

/* Reconnecting: orange */
.conn-pill.reconnecting {
  background: rgba(255,159,10,0.18);
  color: var(--sys-orange);
}

/* Error: same as disconnected */
.conn-pill.error {
  background: rgba(255,69,58,0.18);
  color: var(--sys-red);
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* ── Balance row ── */
.balance-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-top: 4px;
}

.bal-item {
  font-size: 13px;
  color: var(--label-secondary);
  font-weight: 400;
}

.bal-val {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--label-primary);
  font-size: 13px;
  font-weight: 500;
}

.bal-sep {
  width: 1px;
  height: 14px;
  background: var(--separator-strong);
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════
   Main container
   ═══════════════════════════════════════════════════════════════ */
main {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 20px 16px 40px;
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
  flex: 1;
}

/* ─── Two-column layout (AM left, MM right) on desktop ──────────────
   The `.layout-split` wrapper is always present in the DOM. By
   default it's a single-column flex stack (matches the historic
   layout). When AM is enabled, JS adds `.layout-split--two-cols`
   and at >=900px we switch to a 1:1 grid. Below 900px we always
   stack — AM on top, MM below. */
.layout-split {
  display: flex;
  flex-direction: column;
  gap: 28px;
  width: 100%;
}
.layout-col {
  display: flex;
  flex-direction: column;
  gap: 28px;
  min-width: 0; /* allow children to shrink inside grid cells */
}
@media (min-width: 900px) {
  /* Lift the page cap so the two columns have breathing room. */
  main {
    max-width: 1180px;
  }
  .layout-split--two-cols {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: start;
    gap: 28px;
  }
}

/* ═══════════════════════════════════════════════════════════════
   Section label (uppercase caption)
   ═══════════════════════════════════════════════════════════════ */
.section-label {
  font-size: 13px;
  font-weight: 400;
  color: var(--label-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0 4px 6px;
}

/* ═══════════════════════════════════════════════════════════════
   List card — elevated above #000000 page
   ═══════════════════════════════════════════════════════════════ */
.list-card {
  background: var(--bg-card);
  border-radius: 10px;
  overflow: hidden;
  /* Subtle border to define edge on pure black */
  border: 0.5px solid rgba(255,255,255,0.08);
}

.list-separator {
  height: 0.5px;
  background: var(--separator);
  margin-left: 68px;
}

/* ═══════════════════════════════════════════════════════════════
   List row
   ═══════════════════════════════════════════════════════════════ */
.list-row {
  display: flex;
  align-items: center;
  gap: 0;
  width: 100%;
  min-height: 64px;
  padding: 0 16px 0 0;
  background: none;
  border: none;
  color: var(--label-primary);
  font-family: var(--font-sans);
  cursor: pointer;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease;
  position: relative;
}

.list-row:active {
  background: var(--fill-pressed);
}

@media (hover: hover) {
  .list-row:hover {
    background: var(--fill-hover);
  }
}

.list-row:focus-visible {
  outline: 3px solid var(--sys-blue);
  outline-offset: -2px;
  border-radius: 2px;
}

/* ── Leading icon circle (mode badge) ── */
.row-icon {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  margin: 0 12px 0 16px;
  line-height: 1;
}

/*
  Mode badge colors — distinct per mode:
  Stealth Buy  ↗  blue   #0A84FF  (primary action)
  Stealth Sell ↘  yellow #FFD60A  (caution / asymmetric)
  Pump         ⇈  orange #FF9F0A  (warning)
  Dump         ⇊  red    #FF453A  (destructive)
*/
.row-icon--green   { background: rgba(10,132,255,0.20);  color: #0A84FF; }  /* Stealth Buy */
.row-icon--orange  { background: rgba(255,212,10,0.18);  color: #FFD60A; }  /* Stealth Sell */
.row-icon--red     { background: rgba(255,159,10,0.20);  color: #FF9F0A; }  /* Pump */
.row-icon--deepred { background: rgba(255,69,58,0.20);   color: #FF453A; }  /* Dump */

.row-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 14px 0;
  border-bottom: none;
  min-width: 0;
}

.row-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--label-primary);
  line-height: 1.3;
}

.row-sub {
  font-size: 13px;
  font-weight: 400;
  color: var(--label-secondary);
  line-height: 1.4;
}

/* Chevron — must be visible on #1C1C1E card bg */
.row-chevron {
  font-size: 18px;
  font-weight: 400;
  color: var(--sys-gray2);  /* #636366 — ~3:1 on #1C1C1E */
  flex-shrink: 0;
  margin-left: 4px;
}

/* ═══════════════════════════════════════════════════════════════
   Orders collapsible
   ═══════════════════════════════════════════════════════════════ */
.orders-toggle .row-chevron {
  transition: transform 0.2s ease;
}

.orders-toggle[aria-expanded="true"] .row-chevron {
  transform: rotate(90deg);
}

.orders-content {
  padding: 8px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ── Active order card (elevated above list-card) ── */
.order-card {
  background: var(--bg-elevated);      /* #2C2C2E — one tier above #1C1C1E */
  border-radius: 8px;
  padding: 12px;
  cursor: pointer;
  transition: opacity 0.15s ease;
  border: 0.5px solid rgba(255,255,255,0.10);
}

.order-card:active { opacity: 0.7; }

@media (hover: hover) {
  .order-card:hover { opacity: 0.85; }
}

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

/* ── Order mode badges (inside order cards) ── */
.order-mode-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-stealth-buy  { background: rgba(10,132,255,0.18);  color: #0A84FF; }
.badge-stealth-sell { background: rgba(255,212,10,0.18);  color: #FFD60A; }
.badge-pump         { background: rgba(255,159,10,0.18);  color: #FF9F0A; }
.badge-dump         { background: rgba(255,69,58,0.22);   color: #FF453A; }

/* ── Progress bar ── */
.order-progress-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.progress-wrap {
  flex: 1;
  height: 4px;
  background: rgba(255,255,255,0.12);  /* visible track on #2C2C2E */
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: 2px;
  transition: width 0.5s ease;
}

.bar-buy  { background: #0A84FF; }  /* blue for buy */
.bar-sell { background: #FFD60A; }  /* yellow for sell */
.bar-pump { background: #FF9F0A; }  /* orange for pump */
.bar-dump { background: #FF453A; }  /* red for dump */

.progress-pct {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--label-secondary);
  min-width: 40px;
  text-align: right;
}

.order-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--label-secondary);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.order-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

/* ── Small buttons inside order cards ── */
.btn-sm {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.16);
  background: var(--fill-input);
  color: var(--sys-blue);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-sans);
  cursor: pointer;
  min-height: 32px;
  transition: opacity 0.15s;
}

.btn-sm:hover   { opacity: 0.7; }
.btn-sm:active  { opacity: 0.5; }
.btn-sm:focus-visible {
  outline: 3px solid var(--sys-blue);
  outline-offset: 2px;
}

.btn-sm-danger {
  color: var(--sys-red);
  border-color: rgba(255,69,58,0.30);
  background: rgba(255,69,58,0.10);
}

.empty-msg {
  font-size: 15px;
  color: var(--label-secondary);
  text-align: center;
  padding: 16px 0;
}

/* ═══════════════════════════════════════════════════════════════
   Sheet (bottom modal / centered card on desktop)
   ═══════════════════════════════════════════════════════════════ */
dialog {
  border: none;
  padding: 0;
  background: transparent;
  color: var(--label-primary);
  z-index: 300;
}

dialog::backdrop {
  background: rgba(0,0,0,0.65);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.3s var(--spring);
}

dialog[open]::backdrop {
  opacity: 1;
}

/* Mobile: slides up from bottom */
.sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  max-width: 100%;
  max-height: 92dvh;
  margin: 0;
  background: var(--bg-card);                /* #1C1C1E — lifts above #000 page */
  border-radius: 20px 20px 0 0;
  overflow: hidden;
  transform: translateY(100%);
  transition: transform 0.3s var(--spring);
  border-top: 0.5px solid rgba(255,255,255,0.10);
}

.sheet[open] {
  transform: translateY(0);
}

.sheet--tall {
  max-height: 96dvh;
}

/* Desktop: centered card */
@media (min-width: 600px) {
  .sheet {
    position: fixed;
    inset: 0;
    bottom: auto;
    top: 50%;
    left: 50%;
    right: auto;
    width: min(520px, calc(100vw - 40px));
    max-width: min(520px, calc(100vw - 40px));
    border-radius: 14px;
    border: 0.5px solid rgba(255,255,255,0.12);
    transform: translate(-50%, -50%) scale(0.95);
    opacity: 0;
    transition: transform 0.3s var(--spring), opacity 0.25s ease;
    max-height: calc(100dvh - 80px);
  }

  .sheet[open] {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
}

.sheet-form {
  display: flex;
  flex-direction: column;
  max-height: inherit;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* Drag indicator */
.drag-indicator {
  width: 36px;
  height: 5px;
  background: rgba(255,255,255,0.20);
  border-radius: 3px;
  margin: 8px auto 0;
  flex-shrink: 0;
}

@media (min-width: 600px) {
  .drag-indicator { display: none; }
}

/* Sheet header */
.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 8px;
  flex-shrink: 0;
}

.sheet-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--label-primary);
  text-align: center;
  flex: 1;
}

.sheet-cancel {
  background: none;
  border: none;
  font-size: 17px;
  font-weight: 400;
  color: var(--sys-blue);
  cursor: pointer;
  padding: 4px 0;
  min-height: 44px;
  min-width: 44px;
  font-family: var(--font-sans);
}

.sheet-cancel:focus-visible {
  outline: 3px solid var(--sys-blue);
  outline-offset: 2px;
  border-radius: 4px;
}

.sheet-header-spacer {
  min-width: 44px;
}

/* Inline notice */
.inline-notice {
  margin: 0 16px 4px;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  flex-shrink: 0;
}

.inline-notice--orange {
  background: rgba(255,159,10,0.14);
  color: var(--sys-orange);
  border: 0.5px solid rgba(255,159,10,0.25);
}

.inline-notice--red {
  background: rgba(255,69,58,0.14);
  color: var(--sys-red);
  border: 0.5px solid rgba(255,69,58,0.25);
}

/* ═══════════════════════════════════════════════════════════════
   Form group (iOS inset grouped style)
   Inside sheet (#1C1C1E) → form bg = #2C2C2E (elevated)
   ═══════════════════════════════════════════════════════════════ */
.form-group {
  background: var(--bg-elevated);   /* #2C2C2E — elevated above #1C1C1E sheet */
  border-radius: 10px;
  margin: 8px 16px;
  overflow: hidden;
  border: 0.5px solid rgba(255,255,255,0.10);
  flex-shrink: 0;
}

.form-row {
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-separator {
  height: 0.5px;
  background: var(--separator);
  margin-left: 14px;
}

.form-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--label-secondary);
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}

.required-caption {
  font-size: 11px;
  font-weight: 400;
  color: var(--sys-red);
}

.form-input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--label-primary);
  font-size: 17px;
  font-family: var(--font-sans);
  padding: 2px 0;
  width: 100%;
  min-height: 28px;
  caret-color: var(--sys-blue);
}

.form-input--mono {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.1em;
}

.dump-confirm::placeholder {
  color: var(--label-tertiary);
  font-style: italic;
}

.form-input::placeholder {
  color: var(--label-tertiary);
}

.form-input.field-invalid {
  color: var(--sys-red);
}

.field-error {
  font-size: 12px;
  color: var(--sys-red);
  min-height: 0;
  display: block;
}

.field-error:not(:empty) {
  margin-top: 2px;
}

/* Sheet actions (bottom buttons) */
.sheet-actions {
  padding: 12px 16px 28px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

/* ── Pill button ── */
.pill-btn {
  width: 100%;
  height: 50px;
  border-radius: 12px;
  border: none;
  font-size: 17px;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: opacity 0.15s;
  color: #fff;
  -webkit-tap-highlight-color: transparent;
}

.pill-btn:focus-visible {
  outline: 3px solid var(--sys-blue);
  outline-offset: 2px;
}

.pill-btn:active:not(:disabled) { opacity: 0.75; }

/* Disabled — visible structure, clearly inactive */
.pill-btn:disabled {
  opacity: 1;  /* don't collapse shape */
  cursor: not-allowed;
  background: rgba(255,255,255,0.10) !important;
  color: rgba(235,235,245,0.30);
}

.pill-btn--blue   { background: var(--sys-blue); }
.pill-btn--orange { background: var(--sys-orange); }
.pill-btn--red    { background: var(--sys-red); }

.pill-btn--blue:hover:not(:disabled)   { opacity: 0.88; }
.pill-btn--orange:hover:not(:disabled) { opacity: 0.88; }
.pill-btn--red:hover:not(:disabled)    { opacity: 0.88; }

/* ═══════════════════════════════════════════════════════════════
   Parent detail content
   ═══════════════════════════════════════════════════════════════ */
.detail-content {
  padding: 0 16px 28px;
  overflow-y: auto;
  flex: 1;
}

.detail-section-title {
  font-size: 12px;
  color: var(--label-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 500;
  margin-bottom: 8px;
  margin-top: 16px;
}

.detail-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 8px;
  border: 0.5px solid var(--separator);
}

.detail-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.detail-table th {
  text-align: left;
  padding: 7px 10px;
  color: var(--label-secondary);
  font-size: 11px;
  font-weight: 600;
  border-bottom: 0.5px solid var(--separator);
  white-space: nowrap;
  background: var(--bg-elevated);
}

.detail-table td {
  padding: 6px 10px;
  border-bottom: 0.5px solid var(--separator);
  white-space: nowrap;
  color: var(--label-primary);
  background: var(--bg-card);
}

.detail-table tr:last-child td { border-bottom: none; }

.num { text-align: right; }

.maker-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 700;
  font-family: var(--font-sans);
}

.maker-badge.maker { background: rgba(48,209,88,0.18);  color: var(--sys-green); }
.maker-badge.taker { background: rgba(255,69,58,0.18);  color: var(--sys-red); }

/* ═══════════════════════════════════════════════════════════════
   Toast notifications
   ═══════════════════════════════════════════════════════════════ */
#toast-container {
  position: fixed;
  bottom: 32px;
  left: 16px;
  right: 16px;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 8px;
  z-index: 500;
  pointer-events: none;
}

.toast {
  background: var(--bg-elevated);     /* #2C2C2E — floats above #000 page */
  border-radius: 12px;
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 500;
  max-width: 340px;
  width: 100%;
  opacity: 0;
  transform: translateY(12px) scale(0.95);
  transition: opacity 0.25s ease, transform 0.25s var(--spring);
  pointer-events: auto;
  border: 0.5px solid rgba(255,255,255,0.12);
  color: var(--label-primary);
  text-align: center;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.toast-success { border-color: rgba(48,209,88,0.45); }
.toast-error   { border-color: rgba(255,69,58,0.45); }
.toast-info    { border-color: rgba(10,132,255,0.40); }

/* ═══════════════════════════════════════════════════════════════
   Desktop widening (≥600px)
   ═══════════════════════════════════════════════════════════════ */
@media (min-width: 600px) {
  main {
    padding: 28px 20px 48px;
  }

  #toast-container {
    left: auto;
    right: 24px;
    bottom: 36px;
    align-items: flex-end;
  }

  .sheet-actions {
    padding-bottom: 20px;
  }
}

/* ═══════════════════════════════════════════════════════════════
   Focus (global — Apple blue ring)
   ═══════════════════════════════════════════════════════════════ */
:focus-visible {
  outline: 3px solid var(--sys-blue);
  outline-offset: 2px;
}

button:focus:not(:focus-visible) { outline: none; }

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

/* ═══════════════════════════════════════════════════════════════
   Asset Management
   ═══════════════════════════════════════════════════════════════ */

#am-section { margin-bottom: 0; }

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

.list-header h2.section-label {
  padding: 0;
}

.icon-btn {
  background: transparent;
  border: 0;
  color: var(--label-secondary, #8E8E93);
  font-size: 18px;
  padding: 4px 8px;
  cursor: pointer;
  line-height: 1;
}
.icon-btn:active { opacity: 0.6; }

.am-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px 8px;
  font-size: 14px;
}

.am-status-dot {
  font-size: 14px;
  line-height: 1;
}
.am-status-dot[data-state="running"]       { color: var(--sys-green, #30D158); }
.am-status-dot[data-state="paused"],
.am-status-dot[data-state="auto_paused"]   { color: var(--sys-orange, #FF9F0A); }
.am-status-dot[data-state="halted"]        { color: var(--sys-red, #FF453A); }
.am-status-dot[data-state="stopped"],
.am-status-dot[data-state="uninitialized"] { color: var(--label-secondary, #8E8E93); }

.am-status-label {
  font-weight: 600;
  flex: 1;
  color: var(--label-primary);
}
.am-last-llm {
  font-size: 12px;
  color: var(--label-secondary, #8E8E93);
  font-family: var(--font-mono);
}

.am-section {
  padding: 10px 16px;
}
.am-section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--label-secondary, #8E8E93);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 6px;
}
.am-kv-row {
  display: grid;
  grid-template-columns: auto 1fr auto 1fr;
  gap: 6px 12px;
  align-items: center;
  font-size: 14px;
  padding: 4px 0;
}
.am-kv-row .kv-label {
  color: var(--label-secondary, #8E8E93);
  font-size: 12px;
}
.am-kv-row .kv-value {
  font-weight: 500;
  color: var(--label-primary);
}
.am-kv-row .kv-value.mono {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-variant-numeric: tabular-nums;
}
.kv-value.positive { color: var(--sys-green, #30D158); }
.kv-value.negative { color: var(--sys-red, #FF453A); }

.am-meta {
  font-size: 12px;
  color: var(--label-secondary, #8E8E93);
  font-family: var(--font-mono);
}

#am-alerts:empty { display: none; }
#am-alerts {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 6px;
}
#am-alerts .inline-notice {
  margin: 0;
}

.am-controls {
  display: flex;
  gap: 8px;
  padding: 12px 16px 16px;
}
.pill-btn--compact {
  flex: 1;
  padding: 0;
  height: 38px;
  font-size: 14px;
  border-radius: 10px;
}
.pill-btn--green {
  background: var(--sys-green, #30D158);
  color: #000;
}
.pill-btn--green:hover:not(:disabled) { opacity: 0.88; }

.list-card--halted {
  border: 0.5px solid var(--sys-red, #FF453A);
}

.header-summary {
  font-size: 12px;
  color: var(--label-secondary, #8E8E93);
  font-family: var(--font-mono, ui-monospace, monospace);
}
.list-header.collapsible {
  cursor: pointer;
  user-select: none;
}
.list-card.collapsed { display: none; }
.list-card:not([hidden]).collapsed { display: block; }

.am-trades-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.am-trade-row {
  padding: 10px 16px;
  border-bottom: 0.5px solid rgba(255,255,255,0.06);
  font-size: 13px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
}
.am-trade-row:last-child { border-bottom: 0; }
.am-trade-pnl.positive { color: var(--sys-green, #30D158); font-weight: 600; }
.am-trade-pnl.negative { color: var(--sys-red, #FF453A); font-weight: 600; }
.am-trade-detail {
  font-size: 12px;
  color: var(--label-secondary, #8E8E93);
  font-family: var(--font-mono);
}
.am-trade-duration {
  font-size: 12px;
  color: var(--label-secondary, #8E8E93);
}

@media (max-width: 340px) {
  .am-controls { flex-direction: column; }
}

/* ─── System master switch ────────────────────────────────────────── */

.system-banner {
  background: var(--sys-red, #FF453A);
  color: #fff;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 1000;
}
.system-banner[hidden] { display: none; }
.system-banner-icon { font-size: 16px; }
.system-banner-meta {
  font-size: 11px;
  opacity: 0.85;
  margin-left: 8px;
}

.system-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  position: relative;
}
.system-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}
.system-toggle-slider {
  display: inline-block;
  width: 40px;
  height: 24px;
  background: var(--sys-red, #FF453A);
  border-radius: 12px;
  position: relative;
  transition: background 0.15s ease;
  flex-shrink: 0;
}
.system-toggle-slider::after {
  content: "";
  position: absolute;
  left: 2px;
  top: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s ease;
}
.system-toggle input:checked + .system-toggle-slider {
  background: var(--sys-green, #30D158);
}
.system-toggle input:checked + .system-toggle-slider::after {
  transform: translateX(16px);
}
.system-toggle input:focus-visible + .system-toggle-slider {
  outline: 2px solid var(--sys-blue, #0A84FF);
  outline-offset: 2px;
}
.system-toggle-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.6px;
  opacity: 0.85;
  color: #fff;
}

/* When system is OFF, dim trade-action controls so it's obvious nothing
   will fire. Pure visual — the backend blocks creation regardless. */
body.system-off .mode-card,
body.system-off .pill-btn:not(.system-off-allowed) {
  opacity: 0.4;
  pointer-events: none;
}
body.system-off #am-status-dot { color: var(--sys-red, #FF453A) !important; }

/* ─── LLM decisions feed ────────────────────────────────────────── */

.am-llm-row {
  list-style: none;
  padding: 12px 16px;
  border-bottom: 0.5px solid rgba(255,255,255,0.06);
}
.am-llm-row:last-child { border-bottom: 0; }

.llm-row-head {
  display: grid;
  grid-template-columns: auto auto 1fr auto auto;
  gap: 8px;
  align-items: center;
  font-size: 12px;
  margin-bottom: 4px;
}

.llm-site {
  background: var(--bg-card-elevated, #2C2C2E);
  padding: 2px 8px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.llm-site--regime { background: rgba(10, 132, 255, 0.18); color: var(--sys-blue, #0A84FF); }
.llm-site--veto   { background: rgba(255, 214, 10, 0.18); color: var(--sys-yellow, #FFD60A); }
.llm-site--band_opt { background: rgba(48, 209, 88, 0.18); color: var(--sys-green, #30D158); }
.llm-site--critical { background: rgba(255, 69, 58, 0.18); color: var(--sys-red, #FF453A); }
.llm-site--review { background: rgba(191, 90, 242, 0.18); color: #BF5AF2; }

.llm-model {
  font-size: 11px;
  color: var(--label-secondary, #8E8E93);
  text-transform: lowercase;
}

.llm-time, .llm-cost {
  font-size: 11px;
  color: var(--label-secondary, #8E8E93);
}

.llm-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.4px;
}
.llm-badge--applied {
  background: rgba(48, 209, 88, 0.15);
  color: var(--sys-green, #30D158);
}
.llm-badge--overridden {
  background: rgba(255, 159, 10, 0.18);
  color: var(--sys-orange, #FF9F0A);
}

.llm-row-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 11px;
  color: var(--label-secondary, #8E8E93);
}
.llm-input, .llm-output {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Base class for any cost-meter widget — sets up the tabular-nums
   styling so future styles can target ``.cost-meter`` without
   reimplementing the font shape on each variant. */
.cost-meter {
  font-variant-numeric: tabular-nums;
}
.cost-meter--good { color: var(--sys-green, #30D158); }
.cost-meter--watch { color: var(--sys-orange, #FF9F0A); }
.cost-meter--alert { color: var(--sys-red, #FF453A); }
