/* The one stylesheet for every Blue Nut page: the website and the bot's dashboard. */

/* ---- Basics ---------------------------------------------------------------------------------- */
:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1c1f24;
  --muted: #6b7280;
  --border: #e3e6ea;
  --accent: #0b8a5b;
  --error: #c0362c;
  --mock: #6d4bd1;   /* the bot's mock environment, so it's never mistaken for demo */
  --demo: #b45309;   /* the bot's demo environment */
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
/* Elements hidden with the `hidden` attribute stay hidden, even when a style gives them a display
   (e.g. .badge is inline-block); otherwise scripts can't hide them. */
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); }
a { color: var(--accent); }
code { font-size: 0.85em; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.error { color: var(--error); font-size: 0.9rem; }
.ok { color: var(--accent); font-weight: 600; }
.right { text-align: right; }
.center { text-align: center; }
.spacer { flex: 1; }
h1 { font-size: 1.3rem; }
h2 { font-size: 1.05rem; margin: 1.75rem 0 0.75rem; }
h3 { font-size: 0.95rem; margin: 1.25rem 0 0.5rem; }

/* ---- Forms and buttons ------------------------------------------------------------------------ */
label { display: grid; gap: 0.3rem; font-size: 0.9rem; }
input {
  padding: 0.6rem 0.7rem; border: 1px solid var(--border); border-radius: 6px; font: inherit;
}
input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea {
  padding: 0.6rem 0.7rem; border: 1px solid var(--border); border-radius: 6px; font: inherit; resize: vertical;
}
textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
button {
  padding: 0.65rem; border: 0; border-radius: 6px; background: var(--accent);
  color: #fff; font: inherit; font-weight: 600; cursor: pointer;
}
button.link { background: none; color: var(--accent); padding: 0; font-weight: 500; }
form.inline { margin: 0; }

/* ---- Layout ----------------------------------------------------------------------------------- */
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; padding: 0.8rem 1.5rem;
  background: var(--card); border-bottom: 1px solid var(--border);
}
.topbar form { margin: 0; }
.brand { font-weight: 700; color: inherit; text-decoration: none; }
.nav { display: flex; gap: 1rem; font-size: 0.9rem; }
.nav a { color: inherit; }
.pill { font-size: 0.75rem; padding: 0.15rem 0.55rem; border-radius: 999px; background: var(--border); }
.pill.ok { background: #d8f3e7; color: var(--accent); }
.pill.bad { background: #f9dedb; color: var(--error); }
.content { max-width: 960px; margin: 0 auto; padding: 1.5rem; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 1.25rem; }
.notice { background: #e8f6ef; border: 1px solid #b7e2cc; border-radius: 8px; padding: 0.6rem 0.9rem; }
.notice.failed { background: #fbeceb; border-color: #f0c4c0; }
.badge { display: inline-block; padding: 0.1rem 0.5rem; border-radius: 999px; font-size: 0.8rem; font-weight: 700; color: #fff; }

/* ---- Tables ----------------------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--border); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.65rem 0.9rem; border-bottom: 1px solid var(--border); white-space: nowrap; vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
th { text-align: left; font-size: 0.8rem; text-transform: uppercase; color: var(--muted); }
td.wrap { white-space: normal; }
/* Tappable table rows: each cell's link fills the cell, so the whole row is a target. */
.row-link td { padding: 0; }
.row-link a { display: block; padding: 0.65rem 0.9rem; color: inherit; text-decoration: none; }
.row-link:hover, .row-link:focus-within { background: var(--bg); cursor: pointer; }
.row-link a:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
/* Briefly highlight a dashboard row (or a bot page section) that just changed in a live update. */
@keyframes flash { from { background: #fff4c2; } to { background: transparent; } }
.row-link.flash, .updated .table-wrap { animation: flash 2s ease-out; }

/* ---- Website: login --------------------------------------------------------------------------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login .card { padding: 2rem; width: 100%; max-width: 360px; display: grid; gap: 0.9rem; }
.login .card h1 { margin: 0; font-size: 1.4rem; }
.login .card p { margin: 0; }

/* ---- Website: test games and trading lights --------------------------------------------------- */
.score { font-variant-numeric: tabular-nums; font-weight: 600; }
.win { font-weight: 600; }
.light { display: inline-flex; align-items: center; gap: 0.4rem; text-transform: capitalize; }
.light::before { content: ""; width: 0.6rem; height: 0.6rem; border-radius: 50%; }
.light.green::before { background: var(--accent); }
.light.red::before { background: var(--error); }
.light-panel {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem;
  background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 1rem 1.25rem;
}
.light.big { font-size: 1.15rem; font-weight: 600; text-transform: none; }
.light.big::before { width: 0.85rem; height: 0.85rem; }
.light-controls { display: flex; gap: 0.75rem; margin: 0; }
.light-btn {
  min-width: 6.5rem; padding: 0.75rem 1.25rem; font-size: 1rem; border-radius: 8px;
  background: var(--card); border: 2px solid currentColor;
}
.light-btn.red { color: var(--error); }
.light-btn.green { color: var(--accent); }
.light-btn.active.red { background: var(--error); border-color: var(--error); color: #fff; }
.light-btn.active.green { background: var(--accent); border-color: var(--accent); color: #fff; }
.light-btn:disabled { opacity: 0.6; cursor: progress; }
.reason-edit { margin-top: 0.25rem; }
.reason-edit summary { cursor: pointer; color: var(--accent); font-size: 0.85rem; list-style: none; }
.reason-edit summary::-webkit-details-marker { display: none; }
.reason-edit form { display: flex; gap: 0.5rem; margin: 0.5rem 0; }
.reason-edit input { flex: 1; min-width: 10rem; padding: 0.45rem 0.6rem; }
.reason-edit button { padding: 0.45rem 0.9rem; }
.reason-history { margin: 0.25rem 0 0; padding-left: 1.25rem; font-size: 0.85rem; }

/* ---- Website: Rosalytics (analysis of downloaded market data) ------------------------------- */
.content.wide { max-width: 1400px; }
.nowrap { white-space: nowrap; }
.gain { color: var(--accent); font-weight: 600; }
.loss { color: var(--error); font-weight: 600; }
.notice { background: #fff6dd; border: 1px solid #f0d58a; border-radius: 6px; padding: 0.5rem 0.75rem; }
form.search { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.5rem; }
form.search input { flex: 0 1 18rem; }
form.search button { padding: 0.55rem 1rem; }
table.analysis { font-size: 0.85rem; }
table.analysis th a { color: inherit; text-decoration: none; }
table.analysis tr.total td { font-weight: 600; border-top: 2px solid var(--border); }
table.analysis th.filtered, table.analysis td.filtered { background: #f3f8ff; }
table.analysis tr.focus td { background: #fff3c4; }
table.analysis details summary { cursor: pointer; color: var(--accent); }
table.analysis table.inner { margin: 0.3rem 0; font-size: 0.8rem; }
table.analysis table.inner th, table.analysis table.inner td { padding: 0.1rem 0.5rem; border: 0; }
.analysis-layout { display: grid; grid-template-columns: minmax(0, 1fr) 20rem; gap: 1.25rem; align-items: start; }
.analysis-side { position: sticky; top: 1rem; padding: 1rem; }
.analysis-side h2 { margin-top: 0; }
@media (max-width: 1000px) { .analysis-layout { grid-template-columns: 1fr; } .analysis-side { position: static; } }
ol.moments { list-style: none; margin: 0; padding: 0; max-height: 75vh; overflow-y: auto; font-size: 0.85rem; }
ol.moments li { border-top: 1px solid var(--border); }
ol.moments li a { display: block; padding: 0.45rem 0.25rem; color: inherit; text-decoration: none; }
ol.moments li a:hover, ol.moments li.current a { background: #fff3c4; }
form.filters { display: flex; flex-wrap: wrap; gap: 0.75rem 1.5rem; align-items: flex-start; }
form.filters fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 0.25rem; }
form.filters legend { font-weight: 600; font-size: 0.85rem; margin-bottom: 0.25rem; }
label.check { display: flex; gap: 0.4rem; align-items: center; font-size: 0.85rem; }
label.check input { padding: 0; }
.filter-actions { display: flex; gap: 1rem; align-items: center; align-self: flex-end; }
.filter-actions button { padding: 0.5rem 1.25rem; }
nav.pager { display: flex; gap: 1rem; justify-content: center; margin: 0.75rem 0; font-size: 0.9rem; }

/* ---- Lakitu (recording requests) ------------------------------------------------------------ */
form.recording-request { display: grid; gap: 0.6rem; max-width: 640px; }
form.recording-request button { justify-self: start; padding: 0.55rem 1.2rem; }
button.secondary { background: var(--card); color: var(--accent); border: 1px solid var(--accent); }
.pill.status-downloading, .pill.status-uploading { background: #dbe8fb; color: #1d4f91; }
.pill.status-done { background: #d8f3e7; color: var(--accent); }
.pill.status-failed { background: #f9dedb; color: var(--error); }

/* ---- Bot dashboard: exchanges bar ------------------------------------------------------------- */
/* Each exchange has its colour, on its name tag and (when the bot uses only one) the whole bar. */
.topbar.env-mock, .topbar.env-kalshi_demo { color: #fff; }
.topbar.env-mock { background: var(--mock); }
.topbar.env-kalshi_demo { background: var(--demo); }
.env-name { font-size: 0.8rem; padding: 0.15rem 0.6rem; border-radius: 999px; color: #fff; background: var(--muted); }
.env-name.env-mock { background: var(--mock); }
.env-name.env-kalshi_demo { background: var(--demo); }
.topbar .env-name { border: 1px solid rgba(255, 255, 255, 0.7); }
.env-note { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 0.75rem 1rem; font-size: 0.9rem; }

/* ---- Bot dashboard: order form and preview ---------------------------------------------------- */
.order-form { display: grid; gap: 1rem; max-width: 640px; }
.order-form input[type="range"] { width: 100%; padding: 0; border: 0; accent-color: var(--accent); }
.order-form input[type="radio"] { padding: 0; }
.order-form output { font-weight: 600; font-variant-numeric: tabular-nums; }
.order-form select {
  padding: 0.55rem 0.6rem; border: 1px solid var(--border); border-radius: 6px; font: inherit; background: #fff;
}
.order-form .row { display: flex; flex-wrap: wrap; gap: 1rem; }
.order-form .row label { flex: 1; min-width: 10rem; }
.order-form button { justify-self: start; padding: 0.65rem 1.2rem; }
.outcome { display: flex; gap: 1.25rem; border: 0; padding: 0; margin: 0; }
.outcome legend { font-size: 0.9rem; padding: 0; margin-bottom: 0.3rem; }
.outcome label { display: inline-flex; align-items: center; gap: 0.35rem; }
.order-cost { margin: 0; }
.order-preview { background: var(--bg); border-radius: 8px; padding: 0.6rem 0.9rem; }
.order-preview p { margin: 0.3rem 0; }
.badge.taker { background: var(--demo); }
.badge.maker { background: var(--accent); }
.badge.flips { background: var(--error); }
.badge.refused { background: var(--error); }
.badge.nothing { background: var(--muted); }
.liquidity { flex-direction: column; gap: 0.4rem; }

/* ---- Bot dashboard: open orders --------------------------------------------------------------- */
progress { display: block; width: 6rem; height: 0.4rem; margin-top: 0.3rem; accent-color: var(--accent); }
.order-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; }
form.decrease { display: inline-flex; align-items: center; gap: 0.4rem; }
form.decrease label { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.85rem; }
form.decrease input { width: 4.5rem; padding: 0.3rem 0.4rem; }
form.decrease button, button.cancel {
  padding: 0.35rem 0.7rem; border-radius: 6px; background: #fff; font-size: 0.85rem; font-weight: 500;
}
form.decrease button { border: 1px solid var(--border); color: var(--text); }
button.cancel { border: 1px solid var(--error); color: var(--error); }
form.simulate button { border-color: var(--mock); color: var(--mock); }
button.cancel:hover { background: var(--error); color: #fff; }

/* ---- Bot dashboard: positions ----------------------------------------------------------------- */
.profit { color: var(--accent); font-weight: 600; }
.loss { color: var(--error); font-weight: 600; }

/* ---- Bot dashboard: market cards and the mock market ------------------------------------------ */
.market-cards { display: flex; flex-wrap: wrap; gap: 0.75rem; border: 0; padding: 0; margin: 0; }
.market-cards legend { font-size: 0.9rem; padding: 0; margin-bottom: 0.4rem; }
.market-card { display: flex; gap: 0.5rem; align-items: flex-start; flex: 1; min-width: 11rem;
  border: 1px solid var(--border); border-radius: 8px; padding: 0.6rem 0.75rem; cursor: pointer; }
.market-card:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.market-card input { margin-top: 0.2rem; padding: 0; }
.market-card-body { display: grid; gap: 0.15rem; font-size: 0.9rem; }
.mock-market { display: grid; gap: 1rem; border-color: var(--mock); }
.mock-market-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: 0.5rem 1rem;
  border: 1px solid var(--border); border-radius: 8px; padding: 0.6rem 0.9rem; margin: 0; }
.mock-market-row legend { font-weight: 600; font-size: 0.9rem; padding: 0 0.3rem; }
.mock-market input[type="range"] { width: 100%; padding: 0; border: 0; accent-color: var(--mock); }
.mock-market output { font-weight: 600; font-variant-numeric: tabular-nums; }
.mock-market button { justify-self: start; padding: 0.55rem 1.1rem; background: var(--mock); }
