/* algotrade-plus — an instrument panel, not a landing page.
   Every number is monospace and tabular; every label is small, uppercase, quiet.
   The one loud thing on the page is the approach bar: how close the market is to
   giving the bot a trade. Most days that reads "not close", and it should. */

:root {
  --ink:    #10141c;
  --ink-2:  #171d28;
  --ink-3:  #1e2634;
  --line:   #26303f;
  --paper:  #e4e9f2;
  --mute:   #7c8aa3;
  --amber:  #e8a33d;
  --jade:   #3fbf8f;
  --clay:   #e0614b;

  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px 64px; }

/* ---------------------------------------------------------------- type roles */
.label {
  font-size: 10.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--mute);
  font-weight: 600;
}
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.up   { color: var(--jade); }
.down { color: var(--clay); }

/* ------------------------------------------------------------------- top bar */
.bar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 14px 20px;
  background: rgba(16, 20, 28, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.bar .brand {
  font-family: var(--mono); font-weight: 600; letter-spacing: -.02em;
  margin-right: auto;
}
.bar .brand span { color: var(--amber); }

.pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 11px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--ink-2);
  font-size: 11px; letter-spacing: .1em; text-transform: uppercase;
  font-weight: 600; color: var(--mute);
  white-space: nowrap;
}
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.on   { color: var(--jade);  border-color: #23503f; }
.pill.warn { color: var(--amber); border-color: #4d3a1a; }
.pill.off  { color: var(--mute); }
.pill.live { color: var(--clay);  border-color: #4d2620; }

@media (prefers-reduced-motion: no-preference) {
  .pill.on .dot { animation: pulse 2.4s ease-in-out infinite; }
}
@keyframes pulse { 50% { opacity: .3; } }

/* ------------------------------------------------- signature: approach bar */
.approach {
  margin: 28px 0 22px;
  padding: 22px 24px 20px;
  background: linear-gradient(180deg, var(--ink-2), var(--ink));
  border: 1px solid var(--line);
  border-radius: 12px;
}
.approach .head {
  display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap;
  margin-bottom: 18px;
}
.approach .sym {
  font-family: var(--mono); font-size: clamp(24px, 5vw, 34px);
  font-weight: 600; letter-spacing: -.02em; margin-right: auto;
}
.approach .gap {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: clamp(24px, 5vw, 34px); font-weight: 600; color: var(--amber);
}

.track { position: relative; height: 3px; background: var(--ink-3); border-radius: 2px; }
.track .fill {
  position: absolute; inset: 0 auto 0 0;
  background: linear-gradient(90deg, #2a3243, var(--amber));
  border-radius: 2px;
  transition: width .6s cubic-bezier(.22,.61,.36,1);
}
.track .tick {
  position: absolute; top: -6px; bottom: -6px; width: 1px;
  background: var(--clay);
}
.track .head-dot {
  position: absolute; top: 50%; width: 11px; height: 11px; margin: -5.5px 0 0 -5.5px;
  border-radius: 50%; background: var(--amber);
  box-shadow: 0 0 0 4px rgba(232, 163, 61, .16);
  transition: left .6s cubic-bezier(.22,.61,.36,1);
}
.scale {
  position: relative;
  display: flex; justify-content: space-between;
  margin-top: 10px; font-family: var(--mono); font-size: 11px; color: var(--mute);
}
/* Absolute, so it sits under its own tick rather than in the middle of the row --
   the label and the line it names must be the same place on the scale. */
.scale .trigger {
  position: absolute; top: 0; transform: translateX(-50%);
  color: var(--clay); white-space: nowrap;
}
.approach .foot { margin-top: 14px; font-size: 12.5px; color: var(--mute); }

@media (prefers-reduced-motion: reduce) {
  .track .fill, .track .head-dot { transition: none; }
}

/* ------------------------------------------------------------------ controls */
.controls { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 26px; }

.btn {
  font: inherit; font-size: 14px; font-weight: 600;
  padding: 11px 18px; border-radius: 9px; cursor: pointer;
  border: 1px solid var(--line); background: var(--ink-2); color: var(--paper);
  transition: background .15s, border-color .15s, transform .06s;
  /* Get token and Download logs are real links (one leaves the site, one downloads
     a file) but they are controls, so they must not read as body links. */
  text-decoration: none; display: inline-flex; align-items: center;
}
.btn:hover:not(:disabled) { background: var(--ink-3); border-color: #35415a; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.btn:disabled { opacity: .38; cursor: not-allowed; }
.btn--go   { background: var(--amber); border-color: var(--amber); color: #1a1204; }
.btn--go:hover:not(:disabled) { background: #f0b055; border-color: #f0b055; }
.btn--stop { border-color: #4d2620; color: var(--clay); }
.btn--stop:hover:not(:disabled) { background: #241a1a; border-color: #6b3229; }

/* The history button and its range picker are one control, so they are welded into
   one pill -- a separate floating dropdown reads as an unrelated setting. */
.btn-group { display: inline-flex; }
.btn-group .btn:first-child { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.btn--range {
  border-top-left-radius: 0; border-bottom-left-radius: 0; border-left: none;
  padding: 11px 12px; color: var(--muted); appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
  padding-right: 32px;
}
.btn--range option { background: var(--ink-2); color: var(--paper); }

/* --------------------------------------------------------------------- tiles */
.tiles {
  display: grid; gap: 1px; background: var(--line);
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin-bottom: 30px;
}
.tile { background: var(--ink-2); padding: 15px 18px; }
/* Five tiles in two columns leaves the last one orphaned beside an empty cell. */
@media (max-width: 560px) { .tiles .tile:nth-child(5) { grid-column: 1 / -1; } }
.tile .v {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: 21px; font-weight: 600; margin-top: 5px; letter-spacing: -.02em;
}
.tile .sub {
  margin-top: 4px; font-size: 11px; color: var(--mute); font-family: var(--mono);
}

/* ------------------------------------------------------------------ settings */
.settings {
  display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap;
  padding: 16px 18px; margin-bottom: 8px;
  background: var(--ink-2); border: 1px solid var(--line); border-radius: 12px;
}
.settings label { display: grid; gap: 7px; }
.settings input {
  font: inherit; font-family: var(--mono); font-variant-numeric: tabular-nums;
  width: 140px; padding: 10px 12px; border-radius: 9px;
  background: var(--ink); border: 1px solid var(--line); color: var(--paper);
}
.settings input:focus-visible { outline: 2px solid var(--amber); outline-offset: 1px; }
.settings .hint { flex-basis: 100%; margin: 2px 0 0; font-size: 12px; color: var(--mute); }

/* ----------------------------------------------------------------- positions */
h2.section {
  display: flex; align-items: baseline; gap: 10px;
  font-size: 12px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--mute); font-weight: 600;
  margin: 34px 0 14px; padding-bottom: 10px; border-bottom: 1px solid var(--line);
}
h2.section .count { color: var(--paper); font-family: var(--mono); }

.cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }

.card {
  background: var(--ink-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 16px 18px 18px;
}
.card .top { display: flex; align-items: baseline; gap: 12px; margin-bottom: 4px; }
.card .sym { font-family: var(--mono); font-size: 17px; font-weight: 600; margin-right: auto; }
.card .pnl { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 17px; font-weight: 600; }
.card .sub { font-size: 12px; color: var(--mute); font-family: var(--mono); margin-bottom: 16px; }
.card .legend {
  display: flex; justify-content: space-between; margin-top: 9px;
  font-family: var(--mono); font-size: 11px; color: var(--mute);
}
.card .legend .sl { color: var(--clay); }
.card .legend .tp { color: var(--jade); }
.card .track .fill { background: linear-gradient(90deg, var(--clay), var(--jade)); }
.card .track .head-dot { background: var(--paper); box-shadow: 0 0 0 3px rgba(228,233,242,.14); }

.empty {
  padding: 30px 22px; text-align: center; color: var(--mute); font-size: 13.5px;
  border: 1px dashed var(--line); border-radius: 12px;
}
.cards .empty { grid-column: 1 / -1; }

/* --------------------------------------------------------------------- table */
table.book { width: 100%; border-collapse: collapse; font-size: 13px; }
table.book th {
  text-align: left; padding: 8px 10px; font-size: 10.5px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--mute); font-weight: 600;
  border-bottom: 1px solid var(--line);
}
table.book td {
  padding: 9px 10px; border-bottom: 1px solid var(--ink-3);
  font-family: var(--mono); font-variant-numeric: tabular-nums;
}
.scroll-x { overflow-x: auto; }

/* ----------------------------------------------------------------- event log */
.log {
  background: var(--ink-2); border: 1px solid var(--line); border-radius: 12px;
  max-height: 380px; overflow-y: auto;
  font-family: var(--mono); font-size: 12px; line-height: 1.7;
}
.log .row {
  display: grid; grid-template-columns: 64px 84px 1fr; gap: 12px;
  padding: 4px 16px; border-bottom: 1px solid rgba(38, 48, 63, .5);
}
.log .row:last-child { border-bottom: 0; }
.log .t { color: var(--mute); }
.log .c { color: var(--mute); letter-spacing: .05em; font-size: 11px; }
.log .m { word-break: break-word; }
.log .row.WARNING  .m { color: var(--amber); }
.log .row.ERROR    .m,
.log .row.CRITICAL .m { color: var(--clay); }
.log .row.CRITICAL .c { color: var(--clay); }

.note { margin-top: 22px; font-size: 12px; color: var(--mute); line-height: 1.7; }
.note code { color: var(--paper); }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: var(--ink-3); border: 1px solid var(--line); color: var(--paper);
  padding: 11px 18px; border-radius: 9px; font-size: 13.5px;
  box-shadow: 0 10px 32px rgba(0,0,0,.5); max-width: min(92vw, 560px);
}
.toast.bad { border-color: #6b3229; color: var(--clay); }

/* --------------------------------------------------------------------- login */
.login {
  min-height: 100vh; display: grid; place-content: center; gap: 20px;
  text-align: center; padding: 20px;
}
.login h1 { font-family: var(--mono); font-size: 22px; font-weight: 600; margin: 0; }
.login h1 span { color: var(--amber); }
.login form { display: grid; gap: 10px; width: min(300px, 86vw); }
.login input {
  font: inherit; font-family: var(--mono); text-align: center; letter-spacing: .3em;
  padding: 13px; border-radius: 9px;
  background: var(--ink-2); border: 1px solid var(--line); color: var(--paper);
}
.login input:focus { outline: 2px solid var(--amber); outline-offset: 1px; }
.login .err { color: var(--clay); font-size: 13px; min-height: 20px; }
