/* ── LazyGhost font ── */
@font-face {
  font-family: 'LazyGhost';
  src: url('/static/LazyGhost.woff2') format('woff2'),
       url('/static/LazyGhost-yYexZ.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

.brand {
  font-family: 'LazyGhost', sans-serif;
  letter-spacing: 0.06em;
  background: linear-gradient(175deg, #d4ff3a 0%, #8bc34a 45%, #4a9c1e 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

#main-nav .brand {
  font-size: 1.5rem;
}

.login-header .brand {
  font-size: 2rem;
}

/* ── Pico CSS v2 Light-Green Theme ── */
[data-theme="light"],
:root:not([data-theme="dark"]) {
  --pico-primary: #5a8a28;
  --pico-primary-background: #7cb342;
  --pico-primary-underline: rgba(124, 179, 66, 0.5);
  --pico-primary-hover: #4a7a1e;
  --pico-primary-hover-background: #689f38;
  --pico-primary-focus: rgba(124, 179, 66, 0.25);
  --pico-primary-inverse: #FFF;
}

@media only screen and (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --pico-primary: #8bc34a;
    --pico-primary-background: #7cb342;
    --pico-primary-underline: rgba(124, 179, 66, 0.5);
    --pico-primary-hover: #9ccc65;
    --pico-primary-hover-background: #8bc34a;
    --pico-primary-focus: rgba(124, 179, 66, 0.375);
    --pico-primary-inverse: #FFF;
  }
}

[data-theme="dark"] {
  --pico-primary: #8bc34a;
  --pico-primary-background: #7cb342;
  --pico-primary-underline: rgba(124, 179, 66, 0.5);
  --pico-primary-hover: #9ccc65;
  --pico-primary-hover-background: #8bc34a;
  --pico-primary-focus: rgba(124, 179, 66, 0.375);
  --pico-primary-inverse: #FFF;
}

:root {
  --mono: ui-monospace, 'Cascadia Code', 'Source Code Pro', 'Menlo', monospace;
}

/* ── Nav ── */
#main-nav strong {
  font-size: 1.1rem;
}

#et-clock {
  font-family: var(--mono);
  font-size: 0.78em;
  letter-spacing: 0.04em;
}

/* ── Tables ── */
table {
  font-size: 0.875rem;
}

table thead th {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--pico-muted-color);
}

table td {
  padding: 0.45rem 0.75rem;
  font-variant-numeric: tabular-nums;
}

table th {
  padding: 0.5rem 0.75rem;
}

table tbody tr:hover td {
  background: rgba(124, 179, 66, 0.06);
}

/* Ticker symbols */
table tbody td strong {
  font-family: var(--mono);
  font-size: 0.9em;
  letter-spacing: 0.05em;
  color: var(--pico-primary);
}

table tbody td a {
  text-decoration: none;
}

table tbody td a:hover strong {
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 0.2em;
}

/* ── P&L Summary ── */
.pnl-summary {
  display: flex;
  gap: 2.5rem;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  padding: 0.75rem 1.25rem;
  background: var(--pico-card-background-color);
  border-radius: var(--pico-border-radius);
  border: 1px solid var(--pico-muted-border-color);
  align-items: baseline;
}

.pnl-summary span {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.pnl-summary strong {
  font-size: 1.3em;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

/* ── Error / utility ── */
.error {
  color: var(--pico-color-red-500);
}

/* ── Login ── */
.login-container {
  max-width: 400px;
  margin-top: 10vh;
}

.login-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding-bottom: 0.5rem;
}

.login-avatar {
  width: min(300px, 50vw);
  height: auto;
  display: block;
}

/* ── Toast ── */
.login-toast {
  position: fixed;
  top: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--pico-color-red-500);
  color: #fff;
  padding: 0.65rem 1.25rem;
  border-radius: 0.4rem;
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0,0,0,0.35);
  animation: toast-in-out 4s ease forwards;
  z-index: 1000;
}

@keyframes toast-in-out {
  0%   { opacity: 0; top: 0.25rem; }
  12%  { opacity: 1; top: 1.25rem; }
  75%  { opacity: 1; top: 1.25rem; }
  100% { opacity: 0; top: 0.25rem; }
}

/* ── Typography helpers ── */
.muted {
  color: var(--pico-muted-color);
  font-size: 0.9em;
}

.mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

/* ── P&L Colors ── */
.positive {
  color: var(--pico-primary);
}

.negative {
  color: var(--pico-color-red-500);
}

.buy {
  color: var(--pico-primary);
  font-weight: 700;
  font-family: var(--mono);
  font-size: 0.8em;
  letter-spacing: 0.08em;
}

.sell {
  color: var(--pico-color-red-500);
  font-weight: 700;
  font-family: var(--mono);
  font-size: 0.8em;
  letter-spacing: 0.08em;
}

/* ── Early close banner ── */
.early-close-banner {
  background: var(--pico-color-amber-550);
  color: var(--pico-color-amber-50);
  padding: 0.75rem 1rem;
  border-radius: var(--pico-border-radius);
  margin-bottom: 1rem;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* ── Halt banner ── */
.halt-banner {
  background: var(--pico-color-red-500);
  color: #fff;
  padding: 0.75rem 1rem;
  border-radius: var(--pico-border-radius);
  margin-bottom: 1rem;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.halt-banner a {
  color: #fff;
  text-decoration: underline;
  margin-left: 0.5rem;
}

/* ── System status bar ── */
.status-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2rem;
  margin-bottom: 1rem;
}

.status-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.status-group-label {
  font-size: 0.65em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--pico-muted-color);
}

.status-group-pills {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.status-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.28rem 0.7rem;
  border-radius: var(--pico-border-radius);
  font-size: 0.78em;
  font-weight: 600;
  min-width: 8.5rem;
  letter-spacing: 0.02em;
}

.status-item.healthy {
  background: var(--pico-color-green-550);
  color: var(--pico-color-green-50);
}

.status-item.warning {
  background: var(--pico-color-amber-550);
  color: var(--pico-color-amber-50);
}

.status-item.unhealthy {
  background: var(--pico-color-red-550);
  color: var(--pico-color-red-50);
}

.status-item.info {
  background: transparent;
  color: var(--pico-muted-color);
  border: 1px solid var(--pico-muted-border-color);
}

.status-item small {
  font-weight: normal;
  opacity: 0.75;
  font-family: var(--mono);
  font-size: 0.9em;
}

/* ── Pipeline section ── */
.strategy-pipeline {
  flex-basis: 100%;
}

.pipeline-table {
  width: 100%;
  border-collapse: collapse;
}

.pipeline-table td {
  padding: 0.18rem 0.5rem 0.18rem 0;
  vertical-align: middle;
  border: none;
  font-size: 1rem; /* reset from global table td override */
}

.pipeline-table td:last-child {
  padding-right: 0;
}

.pipeline-table tbody tr:hover td {
  background: none;
}

.pipeline-id {
  font-family: var(--mono);
  font-size: 0.78em;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  color: var(--pico-color);
  text-decoration: none;
}

a.pipeline-id:hover {
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 0.2em;
}

.pipeline-state {
  justify-content: flex-start;
}

.pipeline-result {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: var(--pico-border-radius);
  font-size: 0.72em;
  font-weight: 700;
  letter-spacing: 0.05em;
  font-family: var(--mono);
  text-transform: uppercase;
  white-space: nowrap;
}

.pipeline-result.healthy {
  background: var(--pico-color-green-550);
  color: var(--pico-color-green-50);
}

.pipeline-result.warning {
  background: var(--pico-color-amber-550);
  color: var(--pico-color-amber-50);
}

.pipeline-result.unhealthy {
  background: var(--pico-color-red-550);
  color: var(--pico-color-red-50);
}

.pipeline-result.info {
  background: transparent;
  color: var(--pico-muted-color);
  border: 1px solid var(--pico-muted-border-color);
}

.pipeline-time {
  font-family: var(--mono);
  font-size: 0.72em;
  color: var(--pico-muted-color);
  letter-spacing: 0.03em;
  text-align: right;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .pipeline-table,
  .pipeline-table tbody {
    display: block;
  }

  .pipeline-table tr {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.3rem 0.4rem;
    padding: 0.35rem 0;
    border-bottom: 1px solid var(--pico-muted-border-color);
  }

  .pipeline-table tr:last-child {
    border-bottom: none;
    padding-bottom: 0;
  }

  .pipeline-table td {
    display: inline-flex;
    align-items: center;
    padding: 0;
  }

  /* Strategy ID gets its own full-width line */
  .pipeline-table td:first-child {
    flex: 0 0 100%;
  }
}

/* ── Table wrapper ── */
.table-responsive {
  overflow-x: auto;
}

/* ── Pagination ── */
.pagination {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
  font-size: 0.875rem;
}

/* ── Controls page ── */
.status-halted {
  color: var(--pico-color-red-500);
  font-size: 1.15rem;
  letter-spacing: 0.02em;
}

.status-active {
  color: var(--pico-primary);
  font-size: 1.15rem;
  letter-spacing: 0.02em;
}

.controls-actions {
  display: flex;
  gap: 1rem;
}

/* ── Page watermark ── */
.page-watermark {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  opacity: 0.1;
  pointer-events: none;
  z-index: -1;
  user-select: none;
}

/* ── Mobile nav ── */
.nav-hamburger {
  display: none;
  padding: 0.25rem 0.6rem;
  margin: 0;
  font-size: 1.2rem;
  line-height: 1;
}

@media (max-width: 767px) {
  #main-nav {
    flex-wrap: wrap;
    align-items: center;
  }

  #main-nav > ul:first-child {
    flex: 1;
  }

  .nav-hamburger {
    display: inline-flex;
  }

  .nav-links {
    display: none;
    flex-direction: column;
    width: 100%;
    margin: 0;
    padding: 0.5rem 0 0;
    gap: 0.25rem;
  }

  .nav-links li {
    margin: 0;
  }

  #main-nav.nav-open .nav-links {
    display: flex;
  }
}

.btn-group-shrink {
  width: max-content;
}

/* ── Strategies YAML viewer ── */
.strategies-yaml {
  max-height: 32rem;
  overflow-y: auto;
  font-size: 0.78em;
  line-height: 1.5;
  background: var(--pico-card-sectionning-background-color);
  border-radius: var(--pico-border-radius);
  margin-top: 0.75rem;
}

/* ── Trade Calendar ── */
.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 22rem;
  margin-bottom: 0.5rem;
}

.cal-month-label {
  font-weight: 600;
  font-size: 0.9em;
  letter-spacing: 0.02em;
}

.cal-nav {
  padding: 0.1rem 0.55rem !important;
  font-size: 0.8em !important;
  line-height: 1.6 !important;
  margin: 0 !important;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  max-width: 22rem;
  margin-bottom: 1.5rem;
}

.cal-dow {
  text-align: center;
  font-size: 0.62em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--pico-muted-color);
  padding: 0.25rem 0;
}

.cal-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.3rem 0.1rem 0.25rem;
  border-radius: var(--pico-border-radius);
  cursor: pointer;
  min-height: 2.75rem;
  gap: 0.2rem;
  border: 1px solid transparent;
  transition: background 0.1s;
}

.cal-day--empty {
  cursor: default;
  pointer-events: none;
}

.cal-day:not(.cal-day--empty):hover {
  background: var(--pico-card-sectionning-background-color);
}

.cal-day-num {
  font-size: 0.78em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.cal-day--today .cal-day-num {
  color: var(--pico-primary);
  font-weight: 700;
}

.cal-day.selected {
  background: var(--pico-card-sectionning-background-color);
  border-color: var(--pico-primary);
}

.cal-dots {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 1.8rem;
}

.cal-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  flex-shrink: 0;
}

.cal-dot--green {
  background: var(--pico-color-green-550);
}

.cal-dot--red {
  background: var(--pico-color-red-550);
}

.trades-day-heading {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--pico-muted-color);
}
