/* ============ Design tokens ============ */
:root,
html[data-theme="dark"] {
  --bg: #000000;
  --bg-elevated: #0c0c0e;
  --panel: #111113;
  --panel-border: #262629;
  --sidebar-bg: #000000;
  --input-bg: #0a0a0b;

  --text: #f2f2f3;
  --text-muted: #96969c;
  --text-faint: #616166;

  --accent: #7c6cf6;
  --accent-hover: #8f81f8;
  --accent-soft: rgba(124, 108, 246, 0.14);
  --accent-contrast: #ffffff;

  --success: #35d19a;
  --success-soft: rgba(53, 209, 154, 0.14);
  --danger: #f5577a;
  --danger-soft: rgba(245, 87, 122, 0.14);
  --warning: #f5b942;
  --warning-soft: rgba(245, 185, 66, 0.14);
  --info: #4f9dff;
  --info-soft: rgba(79, 157, 255, 0.14);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.24);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.32);
  --shadow-modal: 0 24px 64px rgba(0, 0, 0, 0.5);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
}

html[data-theme="light"] {
  --bg: #f4f5fa;
  --bg-elevated: #ffffff;
  --panel: #ffffff;
  --panel-border: #e6e8f0;
  --sidebar-bg: #ffffff;
  --input-bg: #f7f8fc;

  --text: #1c1e2a;
  --text-muted: #656c80;
  --text-faint: #9199ad;

  --accent: #6a4ff2;
  --accent-hover: #5b3fe0;
  --accent-soft: rgba(106, 79, 242, 0.1);
  --accent-contrast: #ffffff;

  --success: #12a97a;
  --success-soft: rgba(18, 169, 122, 0.1);
  --danger: #e0335f;
  --danger-soft: rgba(224, 51, 95, 0.1);
  --warning: #c98a12;
  --warning-soft: rgba(201, 138, 18, 0.12);
  --info: #2f6fe0;
  --info-soft: rgba(47, 111, 224, 0.1);

  --shadow-sm: 0 1px 2px rgba(30, 34, 60, 0.06);
  --shadow-md: 0 8px 24px rgba(30, 34, 60, 0.08);
  --shadow-modal: 0 24px 64px rgba(30, 34, 60, 0.18);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  transition: background 0.2s ease, color 0.2s ease;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select { font-family: inherit; }

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

/* ============ App shell ============ */
.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
  background: var(--sidebar-bg);
  border-right: 1px solid var(--panel-border);
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 28px;
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.brand:hover { background: var(--accent-soft); }

.sidebar-collapse-btn {
  margin-left: auto;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--text-muted);
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  pointer-events: none; /* the whole .brand row is the real click target */
}
.brand:hover .sidebar-collapse-btn { background: var(--accent-soft); color: var(--text); }

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #4fd6e8);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}

.brand-name {
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.02em;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  transition: color 0.2s ease, transform 0.15s ease;
}
/* Highlight lives on a layer behind the item so it can grow from the centre outward. */
.nav-item::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: var(--accent-soft);
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.2s ease, transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.nav-item:hover { color: var(--text); }
.nav-item:hover::before { opacity: 0.6; transform: scale(1); }
.nav-item.active { color: var(--accent); }
.nav-item.active::before { opacity: 1; transform: scale(1); }
.nav-item:active { transform: scale(0.95); }
.nav-item:focus:not(:focus-visible) { outline: none; }

.nav-item.nav-pop { animation: nav-pop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1); }
.nav-item.nav-pop .nav-ico { animation: nav-ico-pop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes nav-pop {
  0% { transform: scale(0.92); }
  60% { transform: scale(1.04); }
  100% { transform: scale(1); }
}
@keyframes nav-ico-pop {
  0% { transform: scale(0.7); }
  60% { transform: scale(1.3); }
  100% { transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .nav-item, .nav-item::before { transition: none; }
  .nav-item.nav-pop, .nav-item.nav-pop .nav-ico { animation: none; }
}

.nav-ico {
  display: inline-block;
  width: 18px;
  text-align: center;
  font-size: 14px;
}

.sidebar-footer {
  margin-top: auto;
}

/* ---- Collapsed sidebar ---- */
.app.sidebar-collapsed { grid-template-columns: 64px 1fr; }
.sidebar-collapsed .sidebar { padding: 22px 10px; }
.sidebar-collapsed .brand-name,
.sidebar-collapsed .nav-label,
.sidebar-collapsed .sidebar-footer { display: none; }
.sidebar-collapsed .brand { justify-content: center; padding: 4px 0 28px; }
.sidebar-collapsed .sidebar-collapse-btn { margin-left: 0; }
.sidebar-collapsed .nav-item { justify-content: center; padding: 10px 0; }
.sidebar-collapsed .sidebar-collapse-btn { transform: rotate(180deg); }

/* ---- Main / Topbar ---- */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--panel-border);
  position: sticky;
  top: var(--banner-h, 0px);
  background: var(--bg);
  z-index: 10;
}

.topbar-title h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.topbar-title p {
  margin: 2px 0 0;
  font-size: 13px;
}

.topbar-mtm {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  white-space: nowrap;
}

.topbar-mtm-sl {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 8px;
  padding-left: 14px;
  border-left: 1px solid var(--panel-border);
}
.topbar-mtm-sl label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-faint);
}
.topbar-mtm-sl input.sl-armed-pos {
  border-color: var(--success);
  color: var(--success);
  font-weight: 700;
}
.topbar-mtm-sl input.sl-armed {
  border-color: var(--danger);
  color: var(--danger);
  font-weight: 700;
}
.topbar-mtm-sl input.sl-disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}
.topbar-mtm-sl .switch { margin-left: 2px; }
.topbar-mtm-sl input#mtmSlInput {
  width: 112px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  height: 36px;
  box-sizing: border-box;
  background: var(--input-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  font-size: 13px;
  color: var(--text);
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 14px;
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 6px;
  border-radius: 6px;
}
.link-btn:hover { background: var(--accent-soft); }

.icon-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  padding: 6px;
  border-radius: 8px;
}
.icon-btn:hover { background: var(--accent-soft); color: var(--text); }

.only-mobile { display: none; }

/* Theme toggle */
.theme-toggle {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-icon {
  font-size: 15px;
  color: var(--text-faint);
}

/* ---- Content ---- */
.content {
  padding: 28px 32px 60px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* KPI cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
}

.kpi-card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: var(--shadow-sm);
}

.kpi-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.kpi-value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.kpi-foot {
  font-size: 12px;
  color: var(--text-faint);
}
.kpi-foot.success { color: var(--success); }

/* Panels */
.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--panel-border);
}

.panel-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

.panel-head p { margin: 4px 0 0; }

/* Buttons */
.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.05s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--accent);
  color: var(--accent-contrast);
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-ghost {
  background: var(--accent-soft);
  color: var(--accent);
}
.btn-ghost:hover:not(:disabled) { filter: brightness(1.08); }
.btn-ghost:disabled { opacity: 0.4; cursor: not-allowed; } /* e.g. Log in all when everyone is logged in */

.btn-icon {
  background: transparent;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 13px;
}
.btn-icon:hover { color: var(--text); border-color: var(--accent); }

/* Table */
.table-wrap { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.data-table thead th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  font-weight: 600;
  padding: 12px 22px;
  border-bottom: 1px solid var(--panel-border);
  white-space: nowrap;
}

.data-table tbody td {
  padding: 14px 22px;
  border-bottom: 1px solid var(--panel-border);
  vertical-align: middle;
  white-space: nowrap;
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--accent-soft); }

.acc-name-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
}

.acc-name-text { display: flex; flex-direction: column; line-height: 1.3; }
.acc-name-text strong { font-size: 13.5px; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-neutral { background: var(--accent-soft); color: var(--accent); }

.side-buy { color: var(--success); font-weight: 700; }
.side-sell { color: var(--danger); font-weight: 700; }

.pnl-pos { color: var(--success); font-weight: 600; }
.pnl-neg { color: var(--danger); font-weight: 600; }
.pnl-zero { color: var(--text-faint); }

/* Dots */
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-faint);
  display: inline-block;
  flex-shrink: 0;
}
.dot-live { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.dot-off { background: var(--text-faint); }
.dot-error { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }

/* Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 22px;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--panel-border);
  border-radius: 999px;
  transition: background-color 0.25s ease;
}
.slider::before {
  content: "";
  position: absolute;
  height: 16px;
  width: 16px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: var(--shadow-sm);
}
.switch input:checked + .slider { background: var(--success); }
.switch input:checked + .slider::before { transform: translateX(16px); }

.switch-lg { width: 42px; height: 24px; }
.switch-lg .slider::before { height: 18px; width: 18px; }
.switch-lg input:checked + .slider::before { transform: translateX(18px); }

/* Empty state */
.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  font-size: 13.5px;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 11, 16, 0.55);
  backdrop-filter: blur(3px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-modal);
  max-height: 90vh;
  overflow-y: auto;
}

.modal-wide { max-width: 560px; }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--panel-border);
}
.modal-head h3 { margin: 0; font-size: 15px; font-weight: 700; }

.modal-body {
  padding: 20px 22px 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-row label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.form-row input,
.form-row select {
  background: var(--input-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13.5px;
  color: var(--text);
  outline: none;
}
.form-row input:focus,
.form-row select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-grid-3 {
  grid-template-columns: 1fr 1fr 1fr;
}

.form-row-inline {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

.modal-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}
.spacer { flex: 1; }

/* Form sections (grouped fields inside the account modal) */
.form-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--panel-border);
}
.form-section:first-child {
  padding-top: 0;
  border-top: none;
}

.form-section-title {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
}
.form-section-title .small { text-transform: none; font-weight: 500; letter-spacing: 0; }

/* Multiplier calculator */
.calc-summary {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 600;
}

.calc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.calc-card {
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
}

.calc-card-label {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-faint);
}

.calc-card-value {
  font-size: 24px;
  font-weight: 700;
}
.calc-card-low .calc-card-value { color: var(--accent); }
.calc-card-high .calc-card-value { color: var(--warning); }

.calc-use-btn {
  margin-top: 8px;
  padding: 6px 12px;
  font-size: 12px;
}

.calc-note { margin: 0; }

/* Quick order popover (F1/+/B buy, F2/-/S sell) - a small card anchored next
   to the selected strike, not a centered/blurred full-screen modal. */
.qo-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
}
.qo-overlay.open { display: block; }

.qo-card {
  position: fixed;
  width: 340px;
  background: var(--bg-elevated);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-modal);
  max-height: 85vh;
  overflow-y: auto;
}

.qo-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 2px solid var(--panel-border);
}
.qo-head h3 { margin: 0; font-size: 14px; font-weight: 700; }
.qo-head.side-buy { border-bottom-color: var(--success); }
.qo-head.side-sell { border-bottom-color: var(--danger); }

.qo-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.qo-body .form-grid { gap: 10px; }
/* Commodities add a Lots box before Quantity: the two split Quantity's column, the card keeps its size */
.qo-qty-pair { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; min-width: 0; }
.qo-qty-pair.with-lots { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.qo-qty-pair input { width: 100%; min-width: 0; }
.qo-body .form-row input,
.qo-body .form-row select {
  padding: 8px 10px;
  font-size: 13px;
}

/* Custom Market/Limit toggle - avoids the native <select> popup so
   Up/Down (or Tab) just flips the value in place. */
.qo-toggle-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--input-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 13px;
  color: var(--text);
  text-align: left;
}
.qo-toggle-btn:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}
.qo-toggle-hint {
  font-size: 9px;
  color: var(--text-faint);
  letter-spacing: -2px;
}

.qo-summary {
  display: flex;
  gap: 8px;
  align-items: center;
  background: var(--accent-soft);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  flex-wrap: wrap;
}
.qo-summary strong { color: var(--text); }

.qo-disclaimer { margin: 0; font-size: 11px; }

.kbd-hint {
  font-size: 10px;
  opacity: 0.75;
  margin-left: 6px;
  border: 1px solid currentColor;
  padding: 1px 5px;
  border-radius: 4px;
}

.btn-buy { background: var(--success); color: #fff; }
.btn-buy:hover { filter: brightness(1.08); }
.btn-sell { background: var(--danger); color: #fff; }
.btn-sell:hover { filter: brightness(1.08); }

/* Row actions popover menu */
.row-menu {
  position: fixed;
  display: none;
  flex-direction: column;
  min-width: 190px;
  background: var(--bg-elevated);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-modal);
  padding: 6px;
  z-index: 150;
}
.row-menu.open { display: flex; }

.row-menu button {
  background: none;
  border: none;
  text-align: left;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text);
}
.row-menu button:hover:not(:disabled) { background: var(--accent-soft); color: var(--accent); }
.row-menu button:disabled { opacity: 0.4; cursor: not-allowed; }
.row-menu-danger { color: var(--danger) !important; }
.row-menu-danger:hover { background: var(--danger-soft) !important; color: var(--danger) !important; }

/* Primary account badge */
.primary-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 7px;
  border-radius: 999px;
  margin-left: 6px;
}

.token-btn {
  background: var(--accent-soft);
  color: var(--accent);
  border: none;
  border-radius: 7px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
}
.token-btn:hover { filter: brightness(1.1); }

/* ---------------- Terminal view ---------------- */

.term-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}

#termIndex { width: 206px; } /* fits the longest name, NATURAL GAS MINI (MCX) */
.term-controls select {
  height: 36px;
  box-sizing: border-box;
  background: var(--input-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  font-size: 13px;
  color: var(--text);
}

.term-field {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.term-field label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.range-reset-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
}
.range-reset-btn:hover { color: var(--accent); border-color: var(--accent); }
.term-field input {
  width: 72px;
  height: 36px;
  box-sizing: border-box;
  background: var(--input-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 13px;
  color: var(--text);
}

.info-tooltip {
  position: relative;
  display: inline-flex;
  align-self: center;
}
.info-icon {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--panel-border);
  color: var(--text-muted);
  font-size: 11px;
  font-style: italic;
  font-weight: 700;
  font-family: Georgia, serif;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: default;
}
.info-tooltip-text {
  position: absolute;
  top: 50%;
  left: calc(100% + 8px);
  transform: translateY(-50%);
  background: var(--bg-elevated);
  border: 1px solid var(--panel-border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease;
  z-index: 50;
  pointer-events: none;
}
.info-tooltip:hover .info-tooltip-text {
  opacity: 1;
  visibility: visible;
}

#terminalPanel { overflow: clip; }
.term-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px 0;
  padding: 10px 22px;
  border-bottom: 1px solid var(--panel-border);
  position: sticky;
  top: calc(var(--topbar-h, 0px) + var(--banner-h, 0px));
  z-index: 5;
  background: color-mix(in srgb, var(--accent) 9%, var(--panel));
  font-size: 14px;
  color: var(--text-muted);
}
.term-meta-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 0 14px;
  border-left: 1px solid color-mix(in srgb, var(--accent) 18%, var(--panel-border));
  flex: 0 0 auto;
}
.term-meta-group:first-child { padding-left: 0; border-left: none; }
.term-meta-group > span {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  height: 22px;
  line-height: 22px;
  white-space: nowrap;
}
/* Fixed value widths so a longer/shorter number never resizes its column. */
.term-meta strong {
  color: var(--text);
  font-size: 15.5px;
  font-variant-numeric: tabular-nums;
  font-family: 'Courier New', monospace;
  flex: none;
  width: 108px;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: right;
}
.term-meta-group:nth-child(1) strong { width: 144px; }
.term-meta-group:nth-child(3) strong { width: 112px; }
.term-meta strong.pnl-pos { color: var(--success); }
.term-meta strong.pnl-neg { color: var(--danger); }
#termSpotChange {
  font-size: 14px;
  font-family: inherit;
  font-weight: 600;
  letter-spacing: 0;
}
.term-meta-sep { color: var(--text-faint); }
.term-pnl-stack { padding-right: 0; }
.term-qty-stack strong { width: 56px; }
/* Centred in the free space between the Margin column and the CE/PE column. */
.term-meta-reconcile {
  margin: 0 auto;
  align-self: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.term-meta-reconcile .btn { padding: 7px 12px; }
.term-meta-reconcile .reconcile-ring { width: 30px; height: 30px; }
.reconcile-ring { position: relative; width: 36px; height: 36px; flex-shrink: 0; }
.reconcile-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.reconcile-ring circle { fill: none; stroke-width: 3; }
.reconcile-ring .ring-track { stroke: color-mix(in srgb, var(--accent) 18%, var(--panel-border)); }
.reconcile-ring .ring-progress {
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-dasharray: 97.4;
  animation: reconcile-countdown 5s linear forwards;
}
.reconcile-ring.failed .ring-progress { stroke: var(--danger); }
.reconcile-ring.off .ring-progress { display: none; }
.reconcile-ring span {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.reconcile-ring.failed span { color: var(--danger); }
.reconcile-ring.off span { color: var(--text-faint); font-size: 9.5px; }
@keyframes reconcile-countdown {
  from { stroke-dashoffset: 0; }
  to { stroke-dashoffset: 97.4; }
}

.ladder-contract {
  font-weight: 700;
  font-size: 16px;
}

.strike-edit-input {
  width: 76px;
  background: var(--input-bg);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 3px 6px;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  color: var(--text);
  vertical-align: middle;
}

.ladder-cell {
  font-variant-numeric: tabular-nums;
}

.ladder-ltp {
  font-weight: 600;
  transition: color 0.15s ease;
}
/* the last price change: a green block = it went up, a red block = it went down (stays until the next change) */
.ladder-ltp { transition: background-color 0.15s ease, color 0.15s ease; }
.ladder-ltp.ltp-up { background: color-mix(in srgb, var(--success) 13%, transparent); color: color-mix(in srgb, var(--success) 62%, var(--text)); }
.ladder-ltp.ltp-down { background: color-mix(in srgb, var(--danger) 13%, transparent); color: color-mix(in srgb, var(--danger) 62%, var(--text)); }
/* Spot: the same blocks (the padding is taken back by the margin, so nothing moves) */
#termSpot { padding: 2px 6px; margin: -2px -6px; border-radius: 5px; transition: background-color 0.15s ease, color 0.15s ease; }
#termSpot.ltp-up { background: color-mix(in srgb, var(--success) 13%, transparent); color: color-mix(in srgb, var(--success) 62%, var(--text)); }
#termSpot.ltp-down { background: color-mix(in srgb, var(--danger) 13%, transparent); color: color-mix(in srgb, var(--danger) 62%, var(--text)); }

.opt-tag {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 5px;
  margin-left: 6px;
  vertical-align: middle;
}
.opt-tag-ce { background: var(--info-soft); color: var(--info); }
.opt-tag-pe { background: var(--danger-soft); color: var(--danger); }

.add-strike-btn,
.remove-strike-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  vertical-align: middle;
}

.add-strike-slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  vertical-align: middle;
}

.add-strike-btn {
  background: var(--info-soft);
  color: var(--info);
}
.add-strike-btn:hover {
  background: var(--info);
  color: #fff;
}

.remove-strike-btn {
  margin-left: 6px;
  background: var(--info-soft);
  color: var(--info);
}
.remove-strike-btn:hover {
  background: var(--info);
  color: #fff;
}

.add-strike-btn:disabled,
.remove-strike-btn:disabled {
  background: transparent;
  color: var(--text-faint);
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.edit-strike-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-left: 4px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-faint);
  font-size: 11px;
  vertical-align: middle;
}
.edit-strike-btn:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.ladder-exit-btn {
  background: var(--danger-soft);
  color: var(--danger);
  border: none;
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
}
.ladder-exit-btn:hover {
  background: var(--danger);
  color: #fff;
}

.ladder-row-atm td { font-weight: 700; }

/* Rows with an open position are not filled (owner's choice, 14 Oct): the only highlighted row is the one the keyboard
   acts on (.ladder-row-selected). Their quantity / MTM / Exit cells already show the position. */

/* All hidden strikes in a section collapse into this one summary row,
   instead of each keeping its own full row. */
.ladder-row-excluded td {
  padding: 7px 22px;
  background: var(--bg-elevated);
  white-space: normal;
}
.ladder-row-excluded .small {
  margin-right: 8px;
}
.restore-strike-btn {
  display: inline-flex;
  align-items: center;
  background: var(--success-soft);
  color: var(--success);
  border: none;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
  margin: 2px 4px 2px 0;
}
.restore-strike-btn:hover {
  background: var(--success);
  color: #fff;
}

/* The row the keyboard acts on (↑ / ↓, Q / W, Delete): a solid accent band with a thick bar on the left, so it can be
   found at a glance. The LTP keeps its green / red block. */
.ladder-row-selected {
  --row-select: #facc15; /* yellow (owner, 14 Oct) */
  box-shadow: inset 0 0 0 2px var(--row-select);
  cursor: default;
}
.ladder-row-selected td:not(.ladder-ltp) { background: color-mix(in srgb, var(--row-select) 24%, var(--panel)); }
.ladder-row-selected td:first-child { box-shadow: inset 7px 0 0 var(--row-select); }
.ladder-row-selected td.ladder-contract { color: var(--text); font-weight: 800; }

.ladder-section td {
  background: var(--bg-elevated);
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 8px 22px;
}

.ladder-table {
  table-layout: fixed;
  font-size: 15px;
}


.seg-toggle {
  display: inline-flex;
  background: var(--input-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
}
.seg-toggle button {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 6px;
}
.seg-toggle button:hover { color: var(--text); }
.seg-toggle button.active {
  background: var(--accent);
  color: var(--accent-contrast);
}

/* The chain's column headings stay in view under the Spot / Straddle strip while the page scrolls (the wrapper must not
   be a scroll box of its own, or they would stick to it instead) */
#terminalPanel .table-wrap { overflow: visible; }
.ladder-table thead th {
  position: sticky;
  top: calc(var(--topbar-h, 0px) + var(--banner-h, 0px) + var(--term-meta-h, 0px));
  z-index: 4;
  background: var(--panel);
  box-shadow: inset 0 -1px 0 var(--panel-border);
}

/* ↑ / ↓ scroll the selected row into view below the fixed bars and headings, not under them */
#ladderBody tr {
  scroll-margin-top: calc(var(--topbar-h, 0px) + var(--banner-h, 0px) + var(--term-meta-h, 0px) + var(--ladder-head-h, 34px) + 6px);
  scroll-margin-bottom: 6px;
}

/* Tighter rows in the ladder so more strikes fit without scrolling */
.ladder-table thead th {
  padding: 7px 12px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ladder-table tbody td {
  padding: 5px 12px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.term-feed-status {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 4px 10px;
  border-radius: 999px;
}
.term-feed-live { background: var(--success-soft); color: var(--success); }
.term-feed-off { background: var(--warning-soft); color: var(--warning); }

.leg-btns {
  display: inline-flex;
  gap: 4px;
}

.leg-btn {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  border: none;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}
.leg-btn-buy { background: var(--success); }
.leg-btn-buy:hover { filter: brightness(1.1); }
.leg-btn-sell { background: var(--danger); }
.leg-btn-sell:hover { filter: brightness(1.1); }

.qty-btn-group {
  display: inline-flex;
  gap: 4px;
}

.qty-btn {
  border: 1px solid var(--panel-border);
  background: var(--bg-elevated);
  color: var(--text-muted);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 600;
}
.qty-btn:hover { border-color: var(--accent); color: var(--accent); }
.qty-btn-exit:hover { border-color: var(--danger); color: var(--danger); }

.side-tag {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}
.side-tag-long { background: var(--success-soft); color: var(--success); }
.side-tag-short { background: var(--danger-soft); color: var(--danger); }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-elevated);
  border: 1px solid var(--panel-border);
  color: var(--text);
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: var(--shadow-modal);
  opacity: 0;
  pointer-events: none;
  transition: 0.2s ease;
  z-index: 200;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Responsive */
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: 220px;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 50;
  }
  .sidebar.open { transform: translateX(0); }
  .only-mobile { display: inline-flex; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .topbar { padding: 16px; }
  .content { padding: 20px 16px 40px; }
}

@media (max-width: 520px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}

/* Confirm popover — anchored next to the element that opened it */
.confirm-pop-overlay { position: fixed; inset: 0; z-index: 2999; }
.confirm-pop {
  position: fixed;
  z-index: 3000;
  max-width: 300px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 14px;
  box-shadow: var(--shadow-md);
  animation: confirm-pop-in 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.confirm-pop p { margin: 0 0 12px; font-size: 13.5px; color: var(--text); white-space: pre-line; } /* \n = a new line (warnings) */
.confirm-pop-actions { display: flex; justify-content: flex-end; gap: 8px; }
.confirm-pop-actions .btn { padding: 7px 14px; }
@keyframes confirm-pop-in {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); }

.acc-sl-cell {
  display: flex;
  gap: 8px;
  align-items: center;
  white-space: nowrap;
}
.acc-sl-value { font-weight: 600; }
.acc-sl-value.pnl-zero { color: var(--text); }
/* Fixed-width value slots keep the ✎ buttons in a straight column. */
.acc-sl-slot {
  display: inline-block;
  width: 120px;
  text-align: left;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
}
.acc-multiplier-value {
  display: inline-block;
  width: 56px;
  text-align: left;
  font-variant-numeric: tabular-nums;
}
.acc-sl-dialog {
  position: fixed;
  z-index: 2000;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 12px;
  box-shadow: var(--shadow-md);
}
.acc-sl-input {
  width: 96px;
  height: 32px;
  box-sizing: border-box;
  padding: 4px 8px;
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  background: var(--input-bg);
  color: var(--text);
}

.orders-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 18px 36px; /* row gap / space between the filters (their ✕ buttons hang off the right edge) */
  padding: 8px 22px 16px;
}
/* Outlined select with its label sitting on the border */
.status-filter {
  position: relative;
  display: flex;
  align-items: center;
  width: 250px;
  height: 40px;
  border: 1.5px solid var(--panel-border);
  border-radius: 8px;
  background: var(--panel);
  transition: border-color 0.15s ease;
}
.status-filter:focus-within, .status-filter.active { border-color: var(--accent); }
.status-filter-label {
  position: absolute;
  top: -9px;
  left: 10px;
  padding: 0 4px;
  background: var(--panel);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
}
.status-filter select {
  flex: 1 1 0;
  min-width: 0; /* a long option (e.g. an account name) must not push the ✕ out of the box */
  text-overflow: ellipsis;
  height: 100%;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 13.5px;
  padding: 0 10px;
  outline: none;
  cursor: pointer;
}
.status-filter-clear {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  padding: 0 8px;
  cursor: pointer;
}
.status-filter-clear:hover { color: var(--text); }
.orders-group { border-top: 1px solid var(--panel-border); }
.orders-group-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 22px;
  background: color-mix(in srgb, var(--accent) 5%, var(--panel));
}
.orders-group-meta { margin-left: auto; }
.orders-group-head { cursor: pointer; user-select: none; transition: background 0.15s ease; }
.orders-group-head:hover { background: color-mix(in srgb, var(--accent) 10%, var(--panel)); }
/* Same column widths in every account's table so they line up down the page. */
.orders-table { table-layout: fixed; min-width: 1540px; } /* narrow screens scroll sideways instead of squeezing Instrument away */
/* columns: 1 Time · 2 Instrument · 3 Strike · 4 Type · 5 Action · 6 Lots · 7 Qty · 8 Price · 9 Status · 10 Latency · 11 Order ID */
.orders-table th:nth-child(1) { width: 150px; }
.orders-table th:nth-child(3) { width: 100px; }
.orders-table th:nth-child(4) { width: 84px; }
.orders-table th:nth-child(5) { width: 112px; }
.orders-table th:nth-child(6) { width: 84px; }
.orders-table th:nth-child(7) { width: 92px; }
.orders-table th:nth-child(8) { width: 100px; }
.orders-table th:nth-child(9) { width: 190px; }
.orders-table th:nth-child(10) { width: 100px; }
.orders-table th:nth-child(11) { width: 140px; }
.orders-table th.ord-act-th { width: 44px; text-align: center; padding-left: 0; padding-right: 0; }
.orders-table td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.orders-table td:nth-last-child(-n + 3) { text-align: center; padding-left: 0; padding-right: 0; }
.orders-instrument { font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; }
.badge-buy { background: var(--success-soft); color: var(--success); }
.badge-sell { background: var(--danger-soft); color: var(--danger); }
.badge-muted { background: color-mix(in srgb, var(--text-muted) 18%, transparent); color: var(--text-muted); }
.ord-act {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: transparent;
  font-size: 15px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}
.ord-act:hover:not(:disabled) { background: var(--accent-soft); }
.ord-act:active:not(:disabled) { transform: scale(0.9); }
.ord-act:disabled { opacity: 0.3; cursor: not-allowed; }
.ord-modify { color: var(--info); }
.ord-cancel { color: #f0663a; }
.ord-retry { color: var(--success); font-weight: 700; }

.reconcile-controls { display: flex; align-items: center; gap: 12px; }
.reconcile-status { white-space: nowrap; font-variant-numeric: tabular-nums; }
/* Order stream switch: dot = live (green) / connecting or waiting (amber) / error (red) / off (grey) */
.stream-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); flex-shrink: 0; }
.stream-dot.live { background: var(--success); box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 22%, transparent); }
.stream-dot.connecting, .stream-dot.waiting { background: #e0a100; }
.stream-dot.error { background: var(--danger); }
.reconcile-auto {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}
.orders-group-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 16px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
}

/* Rejection alerts: stacked bottom-left, just right of the sidebar */
.reject-stack {
  position: fixed;
  left: 16px;
  bottom: 96px;
  z-index: 1500;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 400px;
  pointer-events: none;
}
@media (max-width: 860px) {
  .reject-stack { left: 16px; width: min(400px, calc(100vw - 32px)); }
}
.alert-bar {
  pointer-events: auto;
  color: #fff;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 13px 16px;
  cursor: pointer;
  animation: alert-bar-in 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.alert-bar-error { background: var(--danger); }
.alert-bar-success { background: var(--success); }
.alert-bar-warn { background: #ffe08a; color: #3a2a00; } /* light yellow */
.alert-bar-warn .alert-bar-close { background: rgba(0, 0, 0, 0.12); color: #3a2a00; }
.alert-bar-warn .alert-bar-close:hover { background: rgba(0, 0, 0, 0.26); }
.alert-bar-warn .alert-bar-line { font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 14.5px; }
.alert-bar:hover { filter: brightness(1.06); }
.alert-bar-head { display: flex; align-items: center; gap: 8px; font-size: 16.5px; }
.alert-bar-close {
  margin-left: auto;
  border: none;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 13px;
  cursor: pointer;
  flex-shrink: 0;
}
.alert-bar-close:hover { background: rgba(255, 255, 255, 0.32); }
.alert-bar-line {
  margin-top: 6px;
  font-size: 14.5px;
  font-weight: 600;
  overflow-wrap: anywhere; /* long orders wrap instead of being cut off */
}
.alert-bar-error .alert-bar-line { font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 14.5px; }
.alert-bar-detail { margin-top: 4px; font-size: 14.5px; line-height: 1.35; opacity: 0.95; }
.alert-bar-detail:empty { display: none; }
/* action on an alert card (e.g. "Generate token" when an API key was used elsewhere): white on the coloured card */
.alert-bar-action { margin-top: 10px; background: #fff; color: #b4233c; border-color: #fff; font-weight: 600; }
.alert-bar-action:hover { background: #fff3f5; color: #9a1c31; }
@keyframes alert-bar-in {
  from { opacity: 0; transform: translateX(-16px); }
  to { opacity: 1; transform: translateX(0); }
}
.badge-reason { cursor: help; }
.orders-table tr.row-flash td { animation: row-flash 2.6s ease; }
@keyframes row-flash {
  0%, 60% { background: var(--danger-soft); }
  100% { background: transparent; }
}

.live-clock {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.15;
  white-space: nowrap;
}
.live-clock-time {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.live-clock-date { font-size: 11px; font-weight: 600; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.04em; }

/* Accounts (broker positions) page */
.positions-summary {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 16px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--panel-border);
  font-size: 13px;
  color: var(--text-muted);
}
.positions-summary strong { margin-left: 4px; color: var(--text); font-size: 14.5px; font-variant-numeric: tabular-nums; }
.positions-summary strong.pnl-pos { color: var(--success); }
.positions-summary strong.pnl-neg { color: var(--danger); }
.positions-table td { font-variant-numeric: tabular-nums; white-space: nowrap; }
.ps-row { cursor: pointer; transition: background 0.15s ease; }
.ps-row:hover { background: color-mix(in srgb, var(--accent) 6%, var(--panel)); }
.ps-chevron { display: inline-block; width: 12px; color: var(--text-faint); transition: transform 0.2s ease; font-weight: 700; }
.ps-row.open .ps-chevron { transform: rotate(90deg); color: var(--accent); }
.ps-badge {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 700;
  margin-right: 6px;
}
.ps-badge-p { background: var(--accent); color: var(--accent-contrast); }
.ps-badge-s { background: color-mix(in srgb, var(--text-muted) 22%, transparent); color: var(--text-muted); }
.ps-pct { font-size: 12px; opacity: 0.85; margin-left: 4px; }
.ps-detail > td { padding: 0 22px 14px 48px; background: color-mix(in srgb, var(--accent) 3%, var(--panel)); }
.ps-legs { margin-top: 6px; }
.ps-legs th, .ps-legs td { font-size: 12.5px; }

.quick-tip {
  position: fixed;
  z-index: 4000;
  max-width: 320px;
  padding: 7px 10px;
  border-radius: 8px;
  background: var(--text);
  color: var(--panel);
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.35;
  box-shadow: var(--shadow-md);
  pointer-events: none;
}
.ps-exit-btn { padding: 6px 12px; font-size: 12.5px; color: var(--danger); background: var(--danger-soft); }
.ps-exit-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.ps-cancel-btn:disabled { opacity: 0.35; cursor: not-allowed; } /* no open orders: greyed like Exit All */

/* Accounts page holds two panels (positions + broker setup) */
#viewPositions:not([hidden]) { display: flex; flex-direction: column; gap: 24px; }

/* Combined Accounts table: View / Manage */
.ps-manage-tools { display: flex; align-items: center; gap: 10px; }
.positions-summary .ps-mode { margin-left: 8px; } /* fixed spot after the totals in both views */
.ps-manage-tools[hidden] { display: none; }
.ps-name { display: flex; align-items: center; gap: 8px; }
.ps-name .acc-name-text { display: flex; flex-direction: column; line-height: 1.25; }
.ps-inline { display: flex; align-items: center; gap: 8px; }
.positions-table .btn-icon { padding: 2px 6px; font-size: 12px; }

/* Login column: green tick = logged in, red cross = not logged in */
.copy-status { width: 64px; }
.copy-icon { display: inline-grid; place-items: center; width: 22px; height: 22px; }
.copy-icon svg { width: 22px; height: 22px; }
.copy-icon circle { stroke: none; }
.copy-icon path { fill: none; stroke: #fff; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.copy-on circle { fill: var(--success); }
.copy-off circle { fill: var(--danger); }

/* Sidebar "Overall P&L" drawer: slides up at the bottom of the sidebar */
.pnl-drawer {
  margin-bottom: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.pnl-drawer-body {
  max-height: 0;
  overflow-y: auto;
  transition: max-height 0.28s ease;
}
.pnl-drawer.open .pnl-drawer-body {
  /* every account in view: as tall as the sidebar allows (the menu, the user box and the handle take ~430px); scrolls only beyond that */
  max-height: max(260px, calc(100vh - 430px));
  border-bottom: 1px solid var(--panel-border);
}
.pnl-drawer-handle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.pnl-drawer-handle strong { margin-left: auto; font-variant-numeric: tabular-nums; }
.pnl-drawer-chev { font-size: 10px; color: var(--text-faint); transition: transform 0.25s ease; }
.pnl-drawer.open .pnl-drawer-chev { transform: rotate(180deg); }
.pnl-drawer-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 5px 14px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  text-align: left;
}
.pnl-drawer-row:hover { background: var(--accent-soft); }
.pnl-drawer-row > span:not(.ripple-clip):nth-last-child(1 of :not(.ripple-clip)) { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; }
.pnl-drawer-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pnl-drawer-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); flex-shrink: 0; }
.pnl-drawer-dot.on { background: var(--success); }
.pnl-drawer-empty { padding: 10px 14px; font-size: 12.5px; color: var(--text-muted); }

/* Logged-out accounts: whole row greyed; Generate (log in) and a live Exit All stay usable */
.ps-row.ps-loggedout > td { opacity: 0.45; }
.ps-row.ps-loggedout > td.ps-keep { opacity: 1; }
.login-toggle { border: none; background: none; padding: 0; cursor: pointer; border-radius: 50%; transition: transform 0.12s ease, box-shadow 0.15s ease; }
.login-toggle:hover { transform: scale(1.12); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); }
.login-toggle:active { transform: scale(0.94); }
.pnl-drawer-p { width: 16px; height: 16px; font-size: 9.5px; margin-right: 0; border-radius: 4px; flex-shrink: 0; }

/* Centred, larger confirmation (Ctrl/Cmd + Shift + X "EXIT ALL ?") */
.confirm-pop-overlay-dim { background: rgba(0, 0, 0, 0.28); }
.confirm-pop-center { max-width: none; min-width: 340px; padding: 26px 30px 22px; text-align: center; }
.confirm-pop-center p { font-size: 22px; font-weight: 700; margin-bottom: 20px; letter-spacing: 0.02em; }
.confirm-pop-center .confirm-pop-actions { justify-content: center; gap: 12px; }
.confirm-pop-center .confirm-pop-actions .btn { padding: 11px 26px; font-size: 15px; }

/* "Total MTM" card in the top bar */
.mtm-card {
  display: flex;
  flex-direction: column;
  min-width: 142px;
  background: var(--info-soft);
  border: 1px solid color-mix(in srgb, var(--info) 55%, transparent);
  border-radius: 10px;
  overflow: hidden;
}
.mtm-card-label { padding: 5px 12px 0; font-size: 12px; line-height: 1.2; color: var(--info); font-weight: 600; }
.mtm-card-value {
  padding: 0 12px 4px;
  font-size: 21px;
  line-height: 1.2;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.mtm-card-value.pnl-zero { color: var(--text); }
.mtm-card-link {
  border: none;
  border-top: 1px solid color-mix(in srgb, var(--info) 45%, transparent);
  background: transparent;
  color: var(--info);
  font-size: 11.5px;
  padding: 4px 12px;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
}
.mtm-card-link:hover { background: color-mix(in srgb, var(--info) 12%, transparent); }
.mtm-card-link b { font-weight: 700; }

/* Today's MTM graph */
.mtm-graph-modal { max-width: 880px; }
.mtm-graph-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.mtm-graph-stats > div {
  background: var(--input-bg);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.mtm-graph-stats span { font-size: 11.5px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.mtm-graph-stats strong { font-size: 17px; font-variant-numeric: tabular-nums; color: var(--text); }
.mtm-graph-stats strong.pnl-pos { color: var(--success); }
.mtm-graph-stats strong.pnl-neg { color: var(--danger); }
.mtm-graph { position: relative; width: 100%; }
.mtm-graph svg { display: block; width: 100%; height: auto; }
.mtm-graph-empty { padding: 60px 20px; text-align: center; color: var(--text-muted); font-size: 13px; }
.mtm-graph-note { margin: 0; }
.mg-grid { stroke: var(--panel-border); stroke-width: 1; }
.mg-axis { fill: var(--text-faint); font-size: 11px; font-variant-numeric: tabular-nums; }
.mg-zero { stroke: var(--text-muted); stroke-width: 1; stroke-dasharray: 4 4; }
.mg-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.mg-area-pos { fill: var(--success-soft); }
.mg-area-neg { fill: var(--danger-soft); }
.mg-cross { stroke: var(--text-muted); stroke-width: 1; }
.mg-dot { fill: var(--accent); stroke: var(--bg-elevated); stroke-width: 2; }
.mg-hit { fill: transparent; cursor: crosshair; }
.mg-tip {
  position: absolute;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--panel);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  display: flex;
  gap: 8px;
  align-items: baseline;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
}
.mg-tip strong { font-size: 13px; color: var(--panel); }
.mg-tip strong.pnl-pos { color: #4fe0a8; }
.mg-tip strong.pnl-neg { color: #ff8aa6; }
.mtm-card-link b { font-weight: 700; }

/* Alerts toggle in the top bar */

/* MTM graph zoom */
.mtm-zoom { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 14px; }
.mtm-zoom-btns { display: flex; gap: 6px; }
.mtm-zoom-btns .btn-icon { width: 30px; height: 30px; font-size: 16px; line-height: 1; padding: 0; }
.mtm-zoom-range { font-variant-numeric: tabular-nums; font-weight: 600; }
.mtm-zoom-hint { margin-left: auto; }
.mg-select { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 1; pointer-events: none; }
.mg-pt { fill: var(--accent); stroke: var(--bg-elevated); stroke-width: 1; }

/* ---- Paper / Live mode ---- */
/* Phone alerts (Telegram) dialog */
.phone-steps { margin: 0 0 12px; padding-left: 18px; font-size: 12.5px; color: var(--text-muted); line-height: 1.55; }
.phone-status { font-size: 13px; font-weight: 600; margin: 0 0 10px; }
.phone-status.ok { color: var(--success); }
.phone-row { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.phone-row input[type="password"] { flex: 1; min-width: 180px; }
.phone-msg { font-size: 12.5px; min-height: 18px; margin: 4px 0 0; color: var(--text-muted); }
.phone-msg.bad { color: var(--danger); }
/* master switch: Trading ON / OFF */
.trading-switch { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--panel-border); border-radius: 999px; padding: 6px 13px; background: var(--input-bg); color: var(--text); font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.trading-switch .trading-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); }
.trading-switch.off { background: var(--danger); border-color: var(--danger); color: #fff; }
.trading-switch.off .trading-dot { background: #fff; }
.trading-off-bar { background: repeating-linear-gradient(135deg, var(--danger) 0 14px, color-mix(in srgb, var(--danger) 78%, #000) 14px 28px); color: #fff; font-size: 12px; font-weight: 800; letter-spacing: 0.03em; text-align: center; padding: 6px 12px; position: sticky; top: 0; z-index: 11; }
.trading-off-bar[hidden] { display: none; }
.mode-toggle { display: inline-flex; border: 1px solid var(--panel-border); border-radius: 999px; padding: 2px; background: var(--input-bg); }
.mode-toggle button { border: 0; background: transparent; color: var(--text-muted); font: inherit; font-size: 12px; font-weight: 600; padding: 5px 14px; border-radius: 999px; cursor: pointer; }
.mode-toggle button.active { background: var(--accent); color: var(--accent-contrast); }
.mode-toggle button[data-mode="live"].active { background: var(--danger); color: #fff; }
.mode-banner { display: flex; align-items: center; justify-content: center; gap: 12px; background: var(--danger); color: #fff; font-size: 12px; font-weight: 700; letter-spacing: 0.04em; padding: 5px 12px; position: sticky; top: 0; z-index: 11; }
.mode-banner[hidden] { display: none; }
.mode-banner.dry { background: var(--warning); color: #1c1400; }
.mode-banner .btn { padding: 2px 10px; font-size: 11px; color: inherit; border: 1px solid currentColor; }
body.mode-live .topbar { top: 28px; }
.badge-live { background: var(--danger-soft); color: var(--danger); }

.input-with-btn { display: flex; gap: 8px; }
.input-with-btn input { flex: 1; min-width: 0; }
.ip-ok { color: var(--success); }
.ip-bad { color: var(--danger); }

/* modify-order popover (inputs inside the confirm card) */
.confirm-pop .mod-fields { display: flex; gap: 10px; margin: 10px 0 4px; }
.confirm-pop .mod-fields label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-muted); flex: 1; }
.confirm-pop .mod-fields input { height: 36px; border: 1px solid var(--panel-border); border-radius: 8px; background: var(--input-bg); color: var(--text); padding: 0 10px; font-size: 14px; }

/* Cancel all (Orders toolbar): red when there is something to cancel, greyed out otherwise */
.btn-danger-soft { background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger); font-weight: 600; }
.btn-danger-soft:hover:not(:disabled) { background: var(--danger); color: #fff; }
.btn-danger-soft:disabled { background: transparent; color: var(--text-faint); border-color: var(--panel-border); cursor: not-allowed; opacity: 0.7; }

.cancel-all-btn { white-space: nowrap; }

.topbar-cancel-all { margin-left: 8px; padding: 6px 10px; font-size: 12px; line-height: 1.2; flex-shrink: 0; } /* compact: the top bar is crowded on smaller screens */
.topbar-cancel-all[hidden] { display: none; }
.topbar-exit-part { margin-left: 6px; } /* Exit 25% / Exit 50%, just before Exit all */

.alert-bar-detail { white-space: pre-line; } /* several reasons, one per line */

/* ---- Notification history ---- */
.nav-badge { margin-left: auto; min-width: 18px; padding: 1px 6px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; text-align: center; }
.nav-badge[hidden] { display: none; }
.notif-list { padding: 4px 22px 20px; display: flex; flex-direction: column; gap: 8px; }
.notif-item { display: grid; grid-template-columns: 6px 150px 1fr; gap: 14px; align-items: start; border: 1px solid var(--panel-border); border-radius: 10px; padding: 12px 14px 12px 0; background: var(--panel); overflow: hidden; }
.notif-bar { align-self: stretch; background: var(--danger); border-radius: 0 3px 3px 0; margin: -12px 0 -12px 0; }
.notif-item.kind-warn .notif-bar { background: var(--warning); }
.notif-item.kind-success .notif-bar { background: var(--success); }
.notif-when { font-size: 12.5px; color: var(--text-muted); white-space: nowrap; padding-top: 2px; }
.notif-title { font-weight: 700; font-size: 14.5px; }
.notif-line { margin-top: 3px; font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 13px; overflow-wrap: anywhere; }
.notif-detail { margin-top: 3px; font-size: 13px; color: var(--text-muted); white-space: pre-line; overflow-wrap: anywhere; }
.notif-item.is-new { box-shadow: 0 0 0 1.5px var(--accent) inset; }
@media (max-width: 760px) { .notif-item { grid-template-columns: 6px 1fr; } .notif-when { grid-column: 2; } .notif-item > div:last-child { grid-column: 2; } }

/* history entries look like the pop-up cards: solid red / yellow / green boxes */
.notif-item { border: none; padding: 13px 16px; grid-template-columns: 150px 1fr; color: #fff; }
.notif-item.kind-error { background: var(--danger); }
.notif-item.kind-warn { background: #ffe08a; color: #3a2a00; }
.notif-item.kind-success { background: var(--success); }
.notif-item.kind-info { background: var(--accent); } /* a Telegram message that is neither good nor bad news (15-min MTM report) */
.notif-item .notif-bar { display: none; }
.notif-item .notif-when { color: inherit; opacity: 0.85; }
.notif-item .notif-detail { color: inherit; opacity: 0.95; }
.notif-item.is-new { box-shadow: 0 0 0 2.5px var(--accent); }
@media (max-width: 760px) { .notif-item { grid-template-columns: 1fr; } .notif-when, .notif-item > div:last-child { grid-column: 1; } }

/* Feed connect / disconnect chip */
.feed-toggle { display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--panel-border); background: var(--input-bg); color: var(--text); font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.feed-toggle:hover { border-color: var(--accent); }
.feed-toggle .feed-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-faint); }
.feed-toggle.on .feed-dot { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.feed-toggle.connecting .feed-dot { background: var(--warning); animation: feed-pulse 1s ease-in-out infinite; }
.feed-toggle.off { color: var(--text-muted); }
@keyframes feed-pulse { 50% { opacity: 0.35; } }
/* "Prices" pill (where the prices come from): green = Kite, amber = the backup feed, red = stopped / backup not working */
.feed-toggle.price-feed.backup { border-color: var(--warning); }
.feed-toggle.price-feed.backup .feed-dot { background: var(--warning); box-shadow: 0 0 0 3px var(--warning-soft); }
.feed-toggle.price-feed.bad { border-color: var(--danger); color: var(--danger); }
.feed-toggle.price-feed.bad .feed-dot { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); animation: feed-pulse 1s ease-in-out infinite; }
.price-feed-pop .price-feed-acc { display: flex; align-items: center; gap: 10px; margin: 10px 0 8px; padding: 0 10px; font-size: 12.5px; color: var(--text-muted); }
.price-feed-pop .price-feed-acc select { flex: 1; min-width: 0; height: 30px; padding: 0 8px; border-radius: 8px; border: 1px solid var(--panel-border); background: var(--input-bg); color: var(--text); font: inherit; font-size: 12.5px; }
.price-feed-pop .price-feed-now { margin: 0; padding: 8px 10px 0; border-top: 1px solid var(--panel-border); font-size: 12px; line-height: 1.5; color: var(--text-muted); }
.price-feed-pop .price-feed-now strong { color: var(--text); font-weight: 600; }
.price-feed-pop .price-feed-now .bad { color: var(--danger); }

/* Top bar: never cut off the Feed / Paper-Live / theme controls when the window is narrow or zoomed in.
   The bar wraps instead of overflowing; on the Terminal (which has the most in it) the MTM block drops to a second row
   once the whole thing would not fit on one line. */
.topbar { flex-wrap: wrap; row-gap: 10px; }
.topbar-actions { flex-shrink: 0; }
/* wide-ish windows: Feed / Paper-Live / theme stay top-right, the MTM block sits on a second row */
@media (min-width: 1400px) and (max-width: 2250px) {
  .topbar:has(.term-controls:not([hidden])) .topbar-actions { order: 1; margin-left: auto; }
  .topbar:has(.term-controls:not([hidden])) .topbar-mtm { order: 2; flex-basis: 100%; margin-left: 0; }
}
/* narrower / zoomed-in windows: title + controls on the first row, MTM and the right-hand controls share the second */
@media (max-width: 1399px) {
  .topbar-mtm { margin-left: 0; }
  .topbar-actions { margin-left: auto; }
}

.sound-test { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding: 4px 22px 14px; }
.sound-test-title { font-weight: 600; font-size: 13px; margin-right: 4px; }
.sound-btn small { opacity: 0.7; font-weight: 400; margin-left: 6px; }
.sound-test-note { flex-basis: 100%; }

.sound-pick { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; }
.sound-pick select { height: 34px; border: 1px solid var(--panel-border); border-radius: 8px; background: var(--input-bg); color: var(--text); padding: 0 10px; font-size: 13px; }

.notif-mute-btn { font-weight: 600; margin-right: 8px; }
.notif-mute-btn.muted { background: var(--warning-soft); color: var(--warning); border-color: var(--warning); }

/* per-alert sound chooser */
.sound-test { display: block; padding: 4px 22px 14px; }
.sound-test-head { display: flex; align-items: center; gap: 12px; margin: 2px 0 10px; }
.sound-test-title { font-weight: 600; font-size: 13px; }
.sound-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 8px 14px; }
.sound-row { display: grid; grid-template-columns: 1fr 190px 40px; gap: 8px; align-items: center; font-size: 13px; }
.sound-row .sound-for small { display: block; color: var(--text-muted); font-size: 11.5px; }
.sound-row select { height: 34px; border: 1px solid var(--panel-border); border-radius: 8px; background: var(--input-bg); color: var(--text); padding: 0 8px; font-size: 13px; min-width: 0; }
.sound-row select.changed { border-color: var(--accent); }
.sound-row .sound-play { height: 34px; padding: 0; }

/* the two notification toggles are icon-only */
#notifCardsBtn, #notifMuteBtn { width: 40px; height: 40px; min-width: 40px; padding: 0; border-radius: 50%; font-size: 18px; line-height: 1; display: inline-flex; align-items: center; justify-content: center; flex: none; } /* round, equal width and height */
#termRangeUp, #termRangeDown, #termRangeUpLess, #termRangeDownLess { width: 42px; font-size: 13px; font-weight: 600; }

/* Paper mode and Live dry-run: a yellowish screen so a simulated session is never mistaken for real money. */
/* (the same yellow while the master switch is off: Trading OFF - no order is sent) */
body.sim-mode, body.trading-off { --bg: #1b1606; --bg-elevated: #241d09; --panel: #231c08; --panel-border: #3d3314; --sidebar-bg: #171204; --input-bg: #1a1505; }
html[data-theme="light"] body.sim-mode, html[data-theme="light"] body.trading-off { --bg: #fbf1c7; --bg-elevated: #fff8dc; --panel: #fff9e0; --panel-border: #ecd98f; --sidebar-bg: #fff6d0; --input-bg: #fffbe8; }

/* Real orders are being sent: the Live pill and the banner go green (red = live but halted / not ready). */
body.live-armed .mode-banner:not(.dry) { background: var(--success); color: #fff; }
body.live-armed .mode-toggle button[data-mode="live"].active { background: var(--success); color: #fff; }

/* Every dropdown: our own arrow, set in from the right edge (the browser's arrow sits flush against the border).
   Listed per container so this wins over each one's own padding / background rules above. */
select,
.term-controls select,
.status-filter select,
.form-row select,
.qo-body .form-row select,
.sound-row select,
.sound-pick select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 32px;
  background-image:
    linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 19px) 52%, calc(100% - 14px) 52%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

/* ⚙ MTM settings next to the MTM card: pick which instrument's MTM the Terminal shows */
.mtm-filter-btn { width: 30px; height: 30px; flex-shrink: 0; border-radius: 8px; border: 1px solid var(--panel-border); background: var(--input-bg); color: var(--text-muted); font-size: 15px; line-height: 1; padding: 0; cursor: pointer; }
.mtm-filter-btn:hover { color: var(--accent); border-color: var(--accent); }
.mtm-filter-btn.active { color: var(--accent-contrast); background: var(--accent); border-color: var(--accent); }
.mtm-filter-pop { width: 280px; max-width: none; padding: 12px; }
.mtm-filter-title { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-faint); margin: 0 0 8px; }
.mtm-filter-list { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; }
.mtm-filter-opt { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--text); font-size: 13px; text-align: left; cursor: pointer; }
.mtm-filter-opt:hover { background: var(--accent-soft); }
.mtm-filter-opt.active { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.mtm-filter-opt strong { margin-left: auto; font-variant-numeric: tabular-nums; white-space: nowrap; flex-shrink: 0; } /* "-₹22" stays on one line */
.mtm-filter-pop p { margin: 0; }
.mtm-filter-pop { width: 360px; }
.mtm-filter-opt > span { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.mtm-filter-opt small { font-size: 11.5px; font-weight: 400; color: var(--text-muted); white-space: normal; }
.mtm-filter-opt.indent { padding-left: 22px; }
.mtm-filter-sep { margin: 6px 0 2px; padding: 6px 10px 0; border-top: 1px solid var(--panel-border); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-faint); }

/* Gap between the option chain and the Open Legs panel (same spacing as between other panels) */
#terminalPositionsPanel { margin-top: 24px; }

/* Daily P&L page */
.pnl-table td, .pnl-table th { font-variant-numeric: tabular-nums; }
/* fixed columns: opening / closing a month or a day doesn't move them (auto layout re-sized to whatever rows show) */
.pnl-table { table-layout: fixed; min-width: 960px; }
.pnl-table th:first-child { width: 24%; }
.pnl-table td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pnl-table .pnl-today td { background: var(--accent-soft); }
.pnl-table .pnl-month-total td { font-weight: 700; background: color-mix(in srgb, var(--accent) 6%, var(--panel)); border-bottom: 2px solid var(--panel-border); }
.pnl-table .pnl-grand-total td { font-weight: 800; background: color-mix(in srgb, var(--accent) 12%, var(--panel)); }
.pnl-table tr.pnl-day { cursor: pointer; }
.pnl-table tr.pnl-day:hover td { background: color-mix(in srgb, var(--accent) 8%, var(--panel)); }
.pnl-chev { display: inline-block; width: 16px; color: var(--text-faint); transition: transform 0.15s ease; }
.pnl-table tr.pnl-day.open .pnl-chev { transform: rotate(90deg); color: var(--accent); }
.pnl-table tr.pnl-acct td { font-size: 12.5px; background: color-mix(in srgb, var(--accent) 3%, var(--panel)); }
.pnl-table tr.pnl-acct td:first-child { padding-left: 46px; color: var(--text-muted); }

/* Click ripple (app.js adds the spans on pointerdown) */
.ripple-clip {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: inherit;
  pointer-events: none;
  z-index: 0;
}
.ripple {
  position: absolute;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.28;
  transform: scale(0);
  animation: ripple-out 0.6s ease-out forwards;
}
@keyframes ripple-out {
  to { transform: scale(1); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .ripple { animation-duration: 0.01s; }
}
.nav-item > .ripple-clip { z-index: -1; } /* behind the label, above the hover highlight */
.ripple-overlay { position: fixed; inset: auto; z-index: 9999; }
.slider > .ripple-clip { z-index: 0; }

/* Multiplier calculator: copy a figure */
.calc-value-row { display: flex; align-items: center; gap: 10px; }
.calc-value-row .calc-card-value { cursor: copy; }
.calc-copy-btn { padding: 3px 9px; border-radius: 6px; border: 1px solid var(--panel-border); background: transparent; color: var(--text-muted); font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.calc-copy-btn:hover { color: var(--accent); border-color: var(--accent); }

/* Real child accounts in dry run: yellow, so copies that are NOT sent are obvious */
.ps-row.ps-row-dry > td { background: color-mix(in srgb, var(--warning) 22%, var(--panel)); }
.ps-row.ps-row-dry:hover > td { background: color-mix(in srgb, var(--warning) 30%, var(--panel)); }
.child-state { display: inline-block; margin-left: 4px; padding: 0 6px; border-radius: 4px; font-size: 10.5px; font-weight: 700; letter-spacing: 0.03em; }
.child-state-dry_run { background: var(--warning); color: #1c1400; }
.child-state-ready { background: color-mix(in srgb, var(--success) 18%, transparent); color: var(--success); }
.child-state-down { background: var(--danger); color: #fff; font-weight: 700; }
.child-state-not_configured, .child-state-error, .child-state-unknown, .child-state-kicked { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }
.mode-banner-childdry { background: var(--warning); color: #1c1400; padding: 1px 8px; border-radius: 4px; }
.mode-banner-childdry[hidden] { display: none; }
/* Bottom drawer: the amount never wraps ("-" and "₹3" on separate lines); a long name shortens instead */
.pnl-drawer-row > span:not(.ripple-clip):nth-last-child(1 of :not(.ripple-clip)) { white-space: nowrap; flex-shrink: 0; }
.pnl-drawer-row .pnl-drawer-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Orders page: per-account Cancel all in the group header */
.og-cancel-btn { padding: 5px 10px; font-size: 12px; line-height: 1.2; white-space: nowrap; margin-right: 12px; }

/* Sign-in gate */
.auth-gate { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: flex-start; justify-content: center; padding: 12vh 16px 16px; overflow-y: auto; background: var(--bg); }
.auth-gate[hidden] { display: none; }
.auth-card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius-lg); padding: 28px 26px 24px; box-shadow: var(--shadow-modal); }
.auth-brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; margin-bottom: 18px; }
.auth-card h2 { margin: 0 0 6px; font-size: 20px; }
.auth-card .subtle { margin: 0 0 16px; line-height: 1.45; }
.auth-enrol { margin: 4px 0 8px; }
.auth-msg.users-code { color: var(--text); user-select: all; }
.auth-qr { display: flex; justify-content: center; margin: 0 auto 8px; width: 190px; background: #fff; border-radius: 8px; }
.auth-qr svg { width: 100%; height: auto; display: block; }
.auth-enrol code { user-select: all; word-break: break-all; font-size: 12px; }
.auth-msg { min-height: 18px; margin: 6px 0 10px; color: var(--danger, #e5484d); font-size: 13px; }
.auth-submit { width: 100%; justify-content: center; }
.auth-submit:disabled { opacity: 0.6; cursor: default; }

/* Signed-in user (sidebar) */
.signed-in { display: flex; align-items: center; gap: 6px; padding: 6px 8px; margin-bottom: 8px; border: 1px solid var(--panel-border); border-radius: 10px; font-size: 13px; }
.signed-in[hidden] { display: none; }
.signed-in-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.sidebar-collapsed .signed-in-name, .sidebar-collapsed .signed-in .btn-icon { display: none; }

/* Users (admin) */
.users-list { display: flex; flex-direction: column; gap: 10px; margin: 12px 0 18px; }
.user-card { border: 1px solid var(--panel-border); border-radius: 10px; padding: 10px 12px; }
.user-card-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.user-card-head strong { font-size: 14px; }
.user-card-head .spacer { flex: 1; }
.user-accts { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; font-size: 13px; }
.user-accts label { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; }
.user-accts .subtle { font-size: 12px; }
.users-add { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.users-add input[type="text"], .users-add input[type="password"] { flex: 1 1 140px; min-width: 0; padding: 8px 10px; border: 1px solid var(--panel-border); border-radius: 8px; background: var(--bg); color: var(--text); }
.users-admin-check { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; }
.acc-inuse { color: var(--danger, #e5484d); font-weight: 600; }
.auth-card .form-row { margin-bottom: 12px; }

/* show / hide password */
.pw-wrap { position: relative; display: block; min-width: 0; }
.users-add .pw-wrap { flex: 1 1 140px; }
.pw-wrap > input { width: 100%; padding-right: 40px !important; box-sizing: border-box; }
.pw-eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; cursor: pointer; font-size: 15px; line-height: 1; padding: 4px 6px; border-radius: 6px; opacity: 0.75; }
.pw-eye:hover { opacity: 1; background: var(--panel-border); }
.btn-icon-only { padding-left: 12px; padding-right: 12px; font-size: 16px; }

/* Terminal: which side the range arrows change (one button, tap flips CE <-> PE) */
.range-side-btn { min-width: 44px; height: 36px; box-sizing: border-box; border: 1px solid var(--panel-border); border-radius: var(--radius-sm); font-size: 12px; font-weight: 700; letter-spacing: 0.03em; cursor: pointer; padding: 0 10px; }
.range-side-ce { background: var(--info-soft); color: var(--info); border-color: var(--info); }
.range-side-pe { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.range-side-btn:hover { filter: brightness(1.15); }
#changePassBtn[hidden] { display: none !important; }

/* Authenticator (Manage lock) */
.totp-qr { display: flex; justify-content: center; margin: 10px auto 12px; width: 200px; height: 200px; background: #fff; border-radius: 10px; padding: 6px; box-sizing: border-box; }
.totp-qr svg { width: 100%; height: 100%; }
.totp-key { display: block; text-align: center; font-size: 14px; letter-spacing: 0.06em; padding: 8px; margin: 4px 0 10px; border: 1px dashed var(--panel-border); border-radius: 8px; user-select: all; word-break: break-all; }
.totp-code { display: block; width: 100%; box-sizing: border-box; text-align: center; font-size: 26px; letter-spacing: 0.4em; padding: 10px; margin-top: 6px; border: 1px solid var(--panel-border); border-radius: 10px; background: var(--input-bg); color: var(--text); font-variant-numeric: tabular-nums; }
.totp-code:focus { outline: none; border-color: var(--accent); }

/* Accounts → Manage: ✎ at the right edge of the Broker ID column (one straight line down the table) */
.ps-name .acc-edit-inline { margin-left: auto; flex: none; }
.acc-edit-inline { width: 24px; height: 24px; font-size: 13px; opacity: 0.6; }
.acc-edit-inline:hover { opacity: 1; }
#brBrokerRow[hidden] { display: none; }

/* account form: broker section while its saved details are loading (nothing editable until they arrive) */
.br-loading-note { margin: 0 0 10px; padding: 8px 12px; border-radius: 8px; background: var(--warning-soft); color: var(--warning); border: 1px solid var(--warning); font-size: 13.5px; font-weight: 600; }
#brokerSection.br-loading > :not(.br-loading-note) { opacity: 0.45; pointer-events: none; }

/* live with an unconfirmed order: still live (green) - a warning stripe, trading is not blocked */
body.live-armed .mode-banner.unconfirmed:not(.dry) { background: repeating-linear-gradient(135deg, var(--success) 0 18px, #1f8f5a 18px 36px); box-shadow: inset 0 -3px 0 var(--warning); }

/* account form key boxes: 👁 show / ⧉ copy the saved key */
.key-wrap { position: relative; display: block; min-width: 0; }
.key-wrap > input { width: 100%; padding-right: 64px !important; box-sizing: border-box; }
.key-btn { position: absolute; top: 50%; transform: translateY(-50%); border: 0; background: transparent; cursor: pointer; font-size: 14px; line-height: 1; padding: 4px 5px; border-radius: 6px; opacity: 0.75; color: var(--text); }
.key-btn:hover { opacity: 1; background: var(--surface-2, rgba(127,127,127,0.12)); }
.key-show { right: 30px; }
.key-copy { right: 6px; }
.key-btn[hidden] { display: none; }
.key-wrap:has(.key-show[hidden]) .key-copy { right: 6px; }

/* Daily P&L: the 12-month calendar (one square per day) and the gross P&L strip under it */
.pnl-heat-wrap { position: relative; padding: 16px 22px 0; }
.pnl-heat-range { display: flex; align-items: center; justify-content: flex-end; gap: 6px; margin-bottom: 14px; font-size: 12.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.pnl-heat-nav { border: 1px solid var(--panel-border); background: none; color: var(--text-muted); border-radius: 6px; width: 24px; height: 24px; padding: 0; font-size: 15px; line-height: 1; cursor: pointer; }
.pnl-heat-nav:hover:not(:disabled) { color: var(--text); border-color: var(--accent); }
.pnl-heat-nav:disabled { opacity: 0.35; cursor: default; }
.pnl-heat-scroll { overflow-x: auto; padding: 3px 3px 6px; } /* room for the outline of today's / the hovered square */
.pnl-heat { display: flex; gap: 14px; min-width: 860px; max-width: 1320px; }
.pnl-heat-month { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; }
.pnl-heat-grid { display: grid; grid-template-rows: repeat(7, auto); grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; }
.pnl-heat-day { aspect-ratio: 1; min-width: 0; border-radius: 2px; background: color-mix(in srgb, var(--text) 7%, var(--panel)); }
.pnl-heat-day.flat { background: color-mix(in srgb, var(--text) 30%, var(--panel)); }
.pnl-heat-day.up.l1 { background: color-mix(in srgb, var(--success) 35%, var(--panel)); }
.pnl-heat-day.up.l2 { background: color-mix(in srgb, var(--success) 55%, var(--panel)); }
.pnl-heat-day.up.l3 { background: color-mix(in srgb, var(--success) 78%, var(--panel)); }
.pnl-heat-day.up.l4 { background: var(--success); }
.pnl-heat-day.down.l1 { background: color-mix(in srgb, var(--danger) 35%, var(--panel)); }
.pnl-heat-day.down.l2 { background: color-mix(in srgb, var(--danger) 55%, var(--panel)); }
.pnl-heat-day.down.l3 { background: color-mix(in srgb, var(--danger) 78%, var(--panel)); }
.pnl-heat-day.down.l4 { background: var(--danger); }
.pnl-heat-day.up, .pnl-heat-day.down, .pnl-heat-day.flat { cursor: pointer; }
.pnl-heat-day.today { outline: 1.5px solid var(--text-muted); outline-offset: 1px; }
.pnl-heat-day:hover { outline: 1.5px solid var(--text); outline-offset: 1px; }
.pnl-heat-label { margin-top: auto; padding-top: 10px; font-size: 11.5px; letter-spacing: 0.04em; color: var(--text-muted); white-space: nowrap; }
.pnl-heat-label small { font-size: 10.5px; color: var(--text-faint); }
.pnl-heat-tip { position: absolute; z-index: 5; pointer-events: none; padding: 8px 12px; border-radius: 6px; border: 1px solid var(--panel-border); background: var(--bg-elevated); box-shadow: var(--shadow-md); font-size: 12.5px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pnl-heat-tip div { display: flex; justify-content: space-between; gap: 18px; margin-top: 3px; color: var(--text-muted); }
.pnl-heat-tip div:first-of-type { margin-top: 7px; padding-top: 6px; border-top: 1px solid var(--panel-border); }
.pnl-stats { display: flex; flex-wrap: wrap; gap: 16px 64px; margin: 18px 22px 14px; padding: 20px 28px; border-radius: var(--radius-md); background: color-mix(in srgb, var(--text) 4%, var(--panel)); }
.pnl-stat span { display: block; margin-bottom: 8px; font-size: 12.5px; color: var(--text-muted); }
.pnl-stat strong { font-size: 24px; font-weight: 500; font-variant-numeric: tabular-nums; }
.pnl-stat strong.pnl-zero { color: var(--text); }

/* Liquidity page (from LIQUIDITY_TAB_KIT.md): per contract its liquidity label, churn %, bid, ask and last price; calls
   left, puts right. Everything is under .liq-root, with the kit's --liq-* colours mapped to this dashboard's palette
   (so it follows the dark / light theme and the yellow Paper / Trading-off screens). */
.liq-root {
  --liq-surface: var(--panel); --liq-surface-2: color-mix(in srgb, var(--text-muted) 14%, transparent); --liq-border: var(--panel-border);
  --liq-text: var(--text); --liq-muted: var(--text-muted); --liq-accent-wash: var(--accent-soft);
  --liq-good: var(--success); --liq-good-wash: var(--success-soft); --liq-mid: var(--warning); --liq-mid-wash: var(--warning-soft);
  --liq-bad: var(--danger); --liq-bad-wash: var(--danger-soft);
  padding: 18px 22px 20px; color: var(--liq-text); font-size: 14px;
}
.liq-toolbar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 10px; }
.liq-root .liq-select { font: inherit; font-size: 16px; font-weight: 600; padding: 6px 34px 6px 10px; border: 1px solid var(--liq-border); border-radius: 8px; background-color: var(--liq-surface); color: var(--liq-text); cursor: pointer; }
.liq-root #liqExpiry { font-size: 14px; }
.liq-head { font-weight: 600; background: var(--liq-accent-wash); padding: 5px 12px; border-radius: 999px; font-variant-numeric: tabular-nums; }
.liq-head:empty { display: none; }
.liq-feed { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--liq-border); background: var(--liq-surface); white-space: nowrap; }
.liq-feed i { width: 9px; height: 9px; border-radius: 50%; background: var(--liq-muted); flex: none; }
.liq-feed.ok i { background: var(--liq-good); }
.liq-feed.warn i { background: var(--liq-mid); }
.liq-feed.bad { border-color: var(--liq-bad); color: var(--liq-bad); }
.liq-feed.bad i { background: var(--liq-bad); }
.liq-legend { display: inline-flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.liq-hint, .liq-note { font-size: 12.5px; color: var(--liq-muted); margin-bottom: 10px; }
.liq-note { padding: 26px 0 16px; text-align: center; font-size: 13.5px; }
.liq-body { overflow-x: auto; }
.liq-badge { display: inline-block; min-width: 92px; text-align: center; padding: 4px 8px; border-radius: 4px; font-size: 10.5px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; white-space: nowrap; }
.liq-legend .liq-badge { min-width: 0; }
.liq-badge.high { background: var(--liq-good-wash); color: var(--liq-good); }
.liq-badge.mid { background: var(--liq-mid-wash); color: var(--liq-mid); }
.liq-badge.low { background: var(--liq-bad-wash); color: var(--liq-bad); }
.liq-badge.none { background: var(--liq-surface-2); color: var(--liq-muted); }
.liq-table { width: 100%; min-width: 860px; border-collapse: collapse; background: var(--liq-surface); font-variant-numeric: tabular-nums; }
.liq-table th { text-align: right; font-weight: 500; font-size: 11px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--liq-muted); padding: 8px 10px; border-bottom: 1px solid var(--liq-border); }
.liq-table td { text-align: right; padding: 0 10px; height: 32px; border-bottom: 1px solid var(--liq-border); color: var(--liq-muted); } /* (the kit's 40px rows, tightened: 21 strikes on one screen) */
.liq-table th:first-child, .liq-table td:first-child { text-align: left; }
.liq-table th.liq-side { text-align: center; font-size: 12px; letter-spacing: 0.1em; }
.liq-table th.liq-strike, .liq-table td.liq-strike { text-align: center; border-left: 1px solid var(--liq-border); border-right: 1px solid var(--liq-border); }
.liq-table td.liq-strike, .liq-table td.liq-ltp { color: var(--liq-text); font-weight: 600; }
.liq-table td.liq-strike small { color: var(--liq-muted); font-weight: 500; }
.liq-table tr.liq-atm td { background: var(--liq-accent-wash); }
.liq-table.stale .liq-badge { opacity: 0.35; }

/* a second CopyTrade tab: view-only (the first tab runs copying / trading) */
.view-only-bar { background: var(--info, #3b82f6); color: #fff; font-size: 12px; font-weight: 700; letter-spacing: 0.03em; text-align: center; padding: 5px 12px; position: sticky; top: 0; z-index: 11; }
.view-only-bar[hidden] { display: none; }
/* (every tab works the same now - nothing is dimmed) */

/* Daily P&L: a month's own row (its totals) opens / closes its days */
.pnl-table .pnl-month-head td { cursor: pointer; font-weight: 700; background: color-mix(in srgb, var(--accent) 6%, var(--panel)); border-bottom: 2px solid var(--panel-border); }
.pnl-table .pnl-month-head:hover td { background: color-mix(in srgb, var(--accent) 12%, var(--panel)); }
.pnl-month-head .pnl-chev { display: inline-block; width: 16px; }

/* Accounts → Manage has 13 columns: tighter spacing so the whole row (Exit buttons included) fits a laptop screen */
.positions-table.manage thead th { padding: 10px 6px; }
.positions-table.manage tbody td { padding: 10px 6px; }
.positions-table.manage thead th:first-child, .positions-table.manage tbody td:first-child { padding-left: 16px; }
.positions-table.manage { font-size: 12.5px; }
.positions-table.manage .ps-name .acc-name-text { white-space: normal; max-width: 150px; }
.positions-table.manage .ps-name .acc-name-text strong, .positions-table.manage .ps-name .acc-name-text b { overflow-wrap: anywhere; }
.positions-table.manage .acc-sl-slot { width: 84px; }
.positions-table.manage .acc-multiplier-value { width: 40px; }
.positions-table.manage .acc-sl-cell { gap: 4px; }
.positions-table.manage td .btn, .positions-table.manage .token-btn { padding-left: 8px; padding-right: 8px; }

/* A logged-out account's MTM: the last figure read before the logout (app.js lastMtm) - greyed, not live */
.mtm-frozen { opacity: 0.6; font-style: italic; }

/* "📱 Telegram" on a notification that was (also) sent to the user's Telegram */
.notif-tg { display: inline-block; margin-left: 10px; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 700; vertical-align: 2px; background: rgba(255, 255, 255, 0.25); color: inherit; }
.notif-item.kind-warn .notif-tg { background: rgba(0, 0, 0, 0.1); }
.notif-tg.failed { opacity: 0.8; }

/* Terminal: hide the top bar (▲ / ▼ tab on the middle of the Spot strip's top edge). Only while the Terminal is on screen; the
   LIVE banner stays. --topbar-h follows (0), so the strip and the chain's headings move up. */
/* hidden = a thin empty band (not gone): the ▼ tab on the strip always has room to stand in, even with the page
   scrolled, and never covers the LIVE banner */
body.term-top-hidden:has(#viewTerminal:not([hidden])) .topbar { height: 16px; min-height: 0; padding: 0; border-bottom: none; overflow: hidden; }
body.term-top-hidden:has(#viewTerminal:not([hidden])) .topbar > * { display: none; }
.term-top-toggle { /* a tab standing on the middle of the strip's top edge (the panel's top border) */
  position: absolute; left: 50%; bottom: 100%; transform: translateX(-50%);
  width: 52px; height: 15px; padding: 0; border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--panel-border)); border-bottom: none;
  border-radius: 9px 9px 0 0; background: color-mix(in srgb, var(--accent) 9%, var(--panel)); color: var(--accent); font-size: 8px; line-height: 14px; cursor: pointer;
}
/* so the tab can stand above the panel: the panel no longer clips (the strip rounds its own top corners), and the
   sticky strip is drawn above the top bar's bottom edge while the page is scrolled */
#terminalPanel { overflow: visible; }
#terminalPanel .term-meta { border-radius: var(--radius-lg) var(--radius-lg) 0 0; z-index: 10; }
/* (and the last row rounds its outer corners, so a highlighted last row doesn't stick out of the panel's corners) */
#terminalPanel #ladderBody tr:last-child td:first-child { border-bottom-left-radius: var(--radius-lg); }
#terminalPanel #ladderBody tr:last-child td:last-child { border-bottom-right-radius: var(--radius-lg); }
.term-top-toggle:hover { color: var(--accent); border-color: var(--accent); }
body.term-top-hidden .term-top-toggle { background: var(--accent); border-color: var(--accent); color: #fff; } /* hidden: easy to find */

/* Terminal: the MTM card in the Spot strip, halfway between Margin and Reconcile now (the auto margins share the room) */
.term-meta-mtm { margin-left: auto; align-self: center; display: flex; align-items: center; gap: 4px; position: relative; }
/* compact here, so the strip stays on one row on a laptop screen (it was already full: the Spot values column is
   narrower and the groups' spacing a little tighter on the Terminal to make room) */
#terminalPanel .term-meta { padding-left: 16px; padding-right: 16px; }
#terminalPanel .term-meta-group { padding: 0 9px; }
#terminalPanel .term-meta-group:first-child { padding-left: 0; }
#terminalPanel .term-meta-group > span { gap: 10px; }
#terminalPanel .term-meta-group:nth-child(1) strong { width: 132px; } /* Spot, and Chg "-1169.72 (-1.61%)" */
#terminalPanel .term-meta-group:nth-child(2) strong { width: 90px; } /* Straddle / Delta / Net Value */
#terminalPanel .term-pnl-stack strong { width: 100px; } /* CE / PE / Pos Value (-₹1,27,165) */
#terminalPanel .term-meta-group:nth-child(3) strong { width: 128px; } /* Margin Available in full (₹1,12,87,813) */
.term-meta-mtm .mtm-card-link b { display: none; } /* "MTM Graph →" */
.term-meta-mtm .mtm-filter-btn { position: absolute; top: -7px; right: -9px; z-index: 1; border-radius: 50%; background: var(--panel); }
.term-meta-mtm .mtm-card { min-width: 0; border-radius: 8px; }
.term-meta-mtm .mtm-card-label { padding: 3px 9px 0; font-size: 10.5px; }
.term-meta-mtm .mtm-card-value { padding: 0 9px 2px; font-size: 18px; }
.term-meta-mtm .mtm-card-link { padding: 2px 9px 3px; font-size: 10.5px; }
.term-meta-mtm .mtm-filter-btn { width: 22px; height: 22px; font-size: 11px; }

/* An armed MTM SL of another group than the box shows (e.g. Index after 3:45 PM): red chip next to the box */
.sl-hidden-chip { margin-left: 8px; padding: 3px 9px; border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent); border-radius: 999px; background: var(--danger-soft); color: var(--danger); font: inherit; font-size: 11px; font-weight: 700; white-space: nowrap; cursor: pointer; }
.sl-hidden-chip:hover { background: var(--danger); color: #fff; }
.sl-hidden-chip[hidden] { display: none; }

/* copytrade2 (a second CopyTrade on this Mac): its name in amber, so the two are never mixed up */
:root[data-instance] .brand-name,
:root[data-instance] .auth-brand-name {
  color: #d97706;
  font-weight: 700;
}

/* another tab whose positions are behind the main tab (31 Oct 2026) */
.sync-lag-chip { padding: 3px 10px; border: 1px solid color-mix(in srgb, var(--warning) 55%, transparent); border-radius: 999px; background: var(--warning-soft); color: var(--warning); font-size: 12px; font-weight: 700; white-space: nowrap; }
.sync-lag-chip[hidden] { display: none; }
body.positions-behind #termPositionsTable { outline: 2px solid color-mix(in srgb, var(--warning) 60%, transparent); outline-offset: 2px; }
