:root {
  --bg: #0b0f14;
  --fg: #e7edf3;
  --acc: #22c55e;
  --border: #374151;
  --muted: #6b7280;
  --card: #1f2937;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #ffffff;
    --fg: #0b0f14;
    --border: #e5e7eb;
    --muted: #6b7280;
    --card: #ffffff;
  }
}
body {
  margin: 0;
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--fg);
  min-height: 100vh;
}
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem;
}
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}
h1 {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0;
  color: var(--fg);
}
.actions {
  display: flex;
  gap: 0.5rem;
}
.btn {
  background: var(--card);
  color: var(--fg);
  border: 1px solid var(--border);
  padding: 0.5rem 1rem;
  border-radius: 0.25rem;
  cursor: pointer;
  font-size: 0.875rem;
}
.btn.icon {
  padding: 0.5rem;
  font-size: 1rem;
  color: var(--fg);
}
.btn.primary {
  background: var(--acc);
  border-color: var(--acc);
  color: #ffffff;
}
.btn.ghost {
  background: none;
  border-color: transparent;
  color: var(--fg);
}
.btn:hover {
  opacity: 0.9;
}
.muted {
  color: var(--muted);
}
.small {
  font-size: 0.75rem;
}
.toolbar {
  display: flex;
  gap: 1rem;
  margin: 0.5rem 0;
}
.badge {
  background: var(--card);
  border: 1px solid var(--border);
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.875rem;
  color: var(--fg);
}
.tables {
  display: grid;
  gap: 1rem;
}
@media (min-width: 768px) {
  .tables {
    grid-template-columns: 1fr 1fr;
  }
}
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0.25rem;
}
.card__header {
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--border);
}
.card__header h2 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--fg);
}
.tablewrap {
  overflow-x: auto;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table th,
.data-table td {
  padding: 0.5rem;
  border: 1px solid var(--border);
  font-size: 0.875rem;
  text-align: right;
  color: var(--fg);
}
.data-table th {
  background: var(--card);
  font-weight: 600;
}
.data-table th.left,
.data-table td.left {
  text-align: left;
}
.data-table th.filterable,
.data-table th.sortable {
  cursor: pointer;
}
.data-table th.filterable:hover,
.data-table th.sortable:hover {
  background: var(--border);
  color: var(--fg);
}
.data-table tr.empty td {
  text-align: center;
  color: var(--muted);
}
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  align-items: center;
  justify-content: center;
}
.modal.open {
  display: flex;
}
.modal__content {
  background: var(--card);
  padding: 1.5rem;
  border-radius: 0.25rem;
  max-width: 500px;
  width: 100%;
}
.modal__content h2 {
  margin: 0 0 1rem;
  font-size: 1.25rem;
  color: var(--fg);
}
.grid2 {
  display: grid;
  gap: 1rem;
  margin-bottom: 1rem;
}
@media (min-width: 400px) {
  .grid2 {
    grid-template-columns: 1fr 1fr;
  }
}
.modal__content label {
  display: block;
  font-size: 0.875rem;
  margin-bottom: 0.25rem;
  color: var(--fg);
}
.modal__content input,
.modal__content select {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 0.25rem;
  background: var(--card);
  color: var(--fg);
}
.modal__content input[type="color"] {
  padding: 0.25rem;
}
.modal__actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1rem;
}
.error {
  color: #ef4444;
  font-size: 0.75rem;
  margin-top: 0.5rem;
}
.loader {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  align-items: center;
  justify-content: center;
}
.loader.show {
  display: flex;
}
.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--acc);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* loginForm */
.loginPage {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 0 16px;
}
.loginForm * {
  box-sizing: border-box;
}
.loginForm {
  padding: 20px;
  max-width: 340px;
}
.loginForm h1 {
  margin: 0 0 20px;
}
.loginForm-field {
  margin: 0 0 20px;
}
.loginForm input {
  background: var(--bg);
  margin: 0;
  height: 44px;
}
.loginForm-errors {
  background: #f5d8d8;
  border: 1px solid #a51616;
  border-radius: 4px;
  color: #8f0808;
  font-size: 14px;
  margin-top: 20px;
  padding: 10px 15px;
  display: none;
}
.loginForm-btn {
  width: 100%;
  padding: 10px;
}


/* --- Table "zebra" styling --- */
.data-table tbody tr:nth-child(odd) {
  background: rgba(255,255,255,0.02); /* subtle for dark theme */
}
@media (prefers-color-scheme: light) {
  .data-table tbody tr:nth-child(odd) {
    background: rgba(0,0,0,0.03); /* subtle for light */
  }
}

/* Slightly stronger contrast for even rows (to create zebra) */
.data-table tbody tr:nth-child(even) {
  background: rgba(255,255,255,0.01);
}
@media (prefers-color-scheme: light) {
  .data-table tbody tr:nth-child(even) {
    background: rgba(0,0,0,0.01);
  }
}

/* Row hover */
.data-table tbody tr:hover {
  background: rgba(34,197,94,0.06); /* faint greenish hover */
}
@media (prefers-color-scheme: light) {
  .data-table tbody tr:hover {
    background: rgba(34,197,94,0.06);
  }
}

/* Header styling */
.data-table thead th {
  background: linear-gradient(180deg, rgba(255,255,255,0.02), transparent);
  position: sticky;
  top: 0;
  z-index: 2;
}

/* Improve cell readability */
.data-table td, .data-table th {
  transition: background 120ms ease, color 120ms ease;
}

/* Ensure outlines (frames) are visible on top of zebra */
.data-table td.sum-frame,
.data-table td.vol-red,
.data-table td.both-frame {
  position: relative;
  z-index: 3;
}

/* Make sure outlines don't clip - add small padding to cells */
.data-table td.left, .data-table td.left.sum-frame, .data-table td.left.vol-red {
  padding-left: 0.6rem;
  padding-right: 0.6rem;
}

/* Keep numeric columns visually compact */
.data-table td.numeric {
  padding-left: 0.4rem;
  padding-right: 0.4rem;
}


/* Ensure strike highlighting is visible and takes precedence */
.data-table td.sum-frame {
  outline: 2px dashed rgba(124,58,237,0.95) !important;
  outline-offset: -4px !important;
  border-radius: 6px !important;
}

.data-table td.vol-red {
  color: #b91c1c !important;
  font-weight: 700 !important;
}

/* Combined */
.data-table td.sum-frame.vol-red, .data-table td.vol-red.sum-frame {
  outline: 2px dashed rgba(124,58,237,0.95) !important;
  color: #b91c1c !important;
  font-weight: 700 !important;
}


/* Ensure modal overlays all table content and outlines */
.modal {
  z-index: 100050 !important; /* very high */
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  align-items: center;
  justify-content: center;
}

/* Make modal content sit above modal overlay and table outlines */
.modal.open {
  display: flex;
}

.modal__content {
  z-index: 100051 !important;
  position: relative !important;
  box-shadow: 0 8px 24px rgba(2,6,23,0.6);
  max-width: 700px;
}

/* Ensure loader and other overlays don't exceed modal z-index */
.loader {
  z-index: 10000 !important;
}

/* If any table cells use z-index, keep them below modal */
.data-table td.sum-frame,
.data-table td.vol-red,
.data-table td.both-frame {
  z-index: 3 !important;
  position: relative !important;
}

/* For sticky headers (if used), ensure modal still above them */
.data-table thead th[style*="position: sticky"] {
  z-index: 2;
}


/* ===== FLOW UX EXTENSION ===== */
.market-bias {
  padding: 8px 12px;
  margin: 6px 0;
  border-radius: 6px;
  font-weight: 600;
}

.market-bias.bull {
  background: rgba(34,197,94,0.15);
  color: #22c55e;
}

.market-bias.bear {
  background: rgba(239,68,68,0.15);
  color: #ef4444;
}

.market-bias.neutral {
  background: rgba(148,163,184,0.12);
  color: #94a3b8;
}

tr.flow-positive { box-shadow: inset 4px 0 0 #22c55e; }
tr.flow-negative { box-shadow: inset 4px 0 0 #ef4444; }


/* =========================
   FLOW UI (PROD SAFE)
   ========================= */
.flow-ui #market-bias-bar {
  padding: 12px;
  font-size: 16px;
  border-radius: 8px;
  margin: 12px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.flow-ui .bias.neutral { background: #333; }
.flow-ui .bias.up { background: #0a3; }
.flow-ui .bias.down { background: #a00; }

.flow-ui #confidence {
  margin-left: 12px;
  font-size: 14px;
  opacity: 0.8;
}

.flow-ui .alerts-toggle {
  margin-bottom: 12px;
}

.flow-ui .switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 20px;
}
.flow-ui .switch input { display:none; }
.flow-ui .slider {
  position: absolute;
  inset: 0;
  background: #555;
  border-radius: 20px;
  cursor: pointer;
}
.flow-ui .slider:before {
  content: "";
  position: absolute;
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: .3s;
}
.flow-ui input:checked + .slider {
  background: var(--acc);
}
.flow-ui input:checked + .slider:before {
  transform: translateX(20px);
}

/* Toasts */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 100200;
}
.toast {
  background: #222;
  color: #eaeaea;
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 6px;
  animation: fade 4s forwards;
}
@keyframes fade {
  0% { opacity: 1; }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

/* Flow modal isolated */
#modal-alert.hidden,
#info-modal.hidden {
  display: none;
}
#modal-alert,
#info-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 100100;
  display: flex;
  align-items: center;
  justify-content: center;
}
#modal-alert .modal-box,
#info-modal .modal-box {
  background: #111;
  padding: 24px 30px;
  border-radius: 12px;
  color: #eaeaea;
}
