/* ============================================================================
   Nifty_AlgoPro — mobile-first control surface
   Prussian Merge: #08090C base, #3E8098 teal accent, #D4513A warm signal.
   Built for a phone first; widens gracefully on bigger screens.
   ============================================================================ */

:root {
  --bg:        #08090c;
  --surface:   #0f1116;
  --surface-2: #141821;
  --line:      #20242e;
  --text:      #e8eaee;
  --text-dim:  #9aa0ab;
  --text-mute: #5f6571;

  --accent:    #3e8098;   /* teal */
  --accent-2:  #58a6c2;
  --accent-dk: #1d3d49;
  --warm:      #d4513a;   /* warm signal */

  --bull: #5fb286;
  --bear: #e0584a;
  --warn: #f0a93a;

  --radius: 16px;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Manrope", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
}

/* top progress bar --------------------------------------------------------- */
#edgebar {
  position: fixed; top: 0; left: 0; height: 2px; width: 0%;
  background: linear-gradient(90deg, var(--accent-dk), var(--accent), var(--accent-2));
  box-shadow: 0 0 12px var(--accent); z-index: 90; transition: width .15s ease-out;
}
/* desktop reticle (no-op on touch) ----------------------------------------- */
#reticle { position: fixed; width: 20px; height: 20px; margin: -10px 0 0 -10px;
  border: 1.5px solid var(--accent); border-radius: 4px; pointer-events: none;
  z-index: 100; opacity: 0; transition: opacity .2s, width .12s, height .12s; }
@media (pointer: fine) { html.has-reticle, html.has-reticle * { cursor: none; } }

/* header ------------------------------------------------------------------- */
header.top {
  position: sticky; top: 0; z-index: 80;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 16px;
  padding-top: calc(14px + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand .mark { font-family: var(--mono); font-weight: 700; font-size: 17px; letter-spacing: -.5px; }
.brand .mark b { color: var(--accent); }
nav.tabs { display: flex; gap: 6px; }
nav.tabs a {
  color: var(--text-dim); text-decoration: none; font-size: 14px; font-weight: 700;
  padding: 9px 16px; border-radius: 11px; border: 1px solid transparent;
}
nav.tabs a.active {
  color: var(--accent-2); border-color: var(--accent-dk);
  background: color-mix(in srgb, var(--accent-dk) 45%, transparent);
}

/* layout ------------------------------------------------------------------- */
.wrap {
  max-width: 620px; margin: 0 auto;
  padding: 16px 16px calc(40px + env(safe-area-inset-bottom));
}

/* cards -------------------------------------------------------------------- */
.card {
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
}
.card h2 {
  font-size: 12px; text-transform: uppercase; letter-spacing: 1.4px;
  color: var(--text-mute); margin: 0 0 14px; font-weight: 700;
}
.run-card { padding: 16px; }

/* status pills ------------------------------------------------------------- */
.pillrow { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.pill {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--mono); font-size: 11.5px; font-weight: 600;
  padding: 7px 11px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text-dim);
}
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-mute); }
.pill.on   { color: var(--bull); border-color: color-mix(in srgb, var(--bull) 45%, transparent); }
.pill.on .dot { background: var(--bull); box-shadow: 0 0 8px var(--bull); }
.pill.off  { color: var(--text-mute); }
.pill.bad  { color: var(--bear); border-color: color-mix(in srgb, var(--bear) 45%, transparent); }
.pill.bad .dot { background: var(--bear); box-shadow: 0 0 8px var(--bear); }
.pill.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.pill.warn .dot { background: var(--warn); box-shadow: 0 0 8px var(--warn); }

/* buttons ------------------------------------------------------------------ */
.btn {
  font-family: var(--sans); font-size: 15px; font-weight: 700;
  min-height: 48px; padding: 0 20px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none; cursor: pointer; transition: .15s; width: auto;
}
.btn.big { font-size: 17px; min-height: 56px; flex: 1; }
.btn.block { display: flex; width: 100%; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #06121a; }
.btn.primary:active { background: var(--accent-2); }
.btn.danger { background: transparent; border-color: color-mix(in srgb, var(--bear) 55%, transparent); color: var(--bear); }
.btn.ghost { background: transparent; }
.btn:disabled, .btn.disabled { opacity: .38; pointer-events: none; }
.btnrow { display: flex; gap: 10px; }
form { margin: 0; }

/* token form --------------------------------------------------------------- */
.token-form { display: flex; gap: 8px; margin-top: 12px; }
.token-form input { flex: 1; }
.fut-form { display: flex; gap: 8px; }
.fut-form input[type=date] {
  flex: 1; font-family: var(--mono); font-size: 14px; min-height: 48px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
}
.fut-form input[type=date]:focus { outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.fut-key { font-family: var(--mono); font-size: 12px; color: var(--accent-2);
  margin: 12px 0 0; word-break: break-all; }
input[type=text], input[type=password] {
  width: 100%; font-family: var(--mono); font-size: 14px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px; padding: 13px 14px; min-height: 48px;
}
input:focus { outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }

/* ---- calendar ------------------------------------------------------------ */
.cal { position: relative; overflow: hidden; border-radius: 14px;
  border: 1px solid var(--line); background: var(--bg); padding: 14px;
  margin-bottom: 14px; }
.cal.is-locked { opacity: .5; pointer-events: none; }
.cal-deco {                       /* faint accent semicircle behind the header */
  position: absolute; top: -70px; left: 50%; transform: translateX(-50%);
  width: 240px; height: 240px; border-radius: 50%;
  background: radial-gradient(circle at 50% 100%, var(--accent) 0%, transparent 62%);
  opacity: .10; pointer-events: none; z-index: 0;
}
.cal-head, .cal-dow, .cal-grid { position: relative; z-index: 1; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.cal-title { font-family: var(--mono); font-weight: 700; font-size: 15px; letter-spacing: .3px; }
.cal-nav {
  width: 40px; height: 40px; border-radius: 11px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--accent-2);
  font-size: 22px; line-height: 1; display: flex; align-items: center; justify-content: center;
}
.cal-nav:active { background: var(--accent-dk); }
.cal-dow, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal-dow span { text-align: center; font-family: var(--mono); font-size: 10.5px;
  color: var(--text-mute); padding: 4px 0; text-transform: uppercase; letter-spacing: .5px; }
.cal-grid { margin-top: 5px; }
.cal-day {
  aspect-ratio: 1 / 1; display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 14px; color: var(--text);
  border-radius: 11px; border: 1px solid transparent; background: var(--surface);
  cursor: pointer; user-select: none;
}
.cal-day.blank { background: transparent; cursor: default; }
.cal-day.muted { color: var(--text-mute); }
.cal-day.today { border-color: var(--accent-dk); }
.cal-day.sel {
  background: var(--accent); color: #06121a; font-weight: 700;
  border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
.cal-day:active { border-color: var(--accent); }

/* selected expiry chips ---------------------------------------------------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 16px; }
.chips:empty { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  padding: 7px 11px; border-radius: 999px;
  background: color-mix(in srgb, var(--accent-dk) 55%, transparent);
  border: 1px solid var(--accent-dk); color: var(--accent-2);
}
.chip b { color: var(--accent-2); }
.chip .x { color: var(--text-mute); font-size: 15px; cursor: pointer; line-height: 1; }
.chip .x:active { color: var(--warm); }

/* logs --------------------------------------------------------------------- */
.logbar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.logbar button {
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  min-height: 38px; padding: 0 12px; border-radius: 9px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--text-dim);
}
.logbar button.active { color: var(--accent-2); border-color: var(--accent-dk);
  background: color-mix(in srgb, var(--accent-dk) 45%, transparent); }
pre.logview {
  margin: 0; max-height: 60vh; overflow: auto;
  background: #050608; border: 1px solid var(--line); border-radius: 12px;
  padding: 14px; font-family: var(--mono); font-size: 12px; line-height: 1.65;
  color: var(--accent-2); white-space: pre-wrap; word-break: break-word;
}
pre.logview .empty { color: var(--text-mute); }

/* flash -------------------------------------------------------------------- */
.flash {
  padding: 12px 15px; border-radius: 12px; margin-bottom: 14px; font-size: 14px;
  border: 1px solid var(--accent-dk);
  background: color-mix(in srgb, var(--accent-dk) 40%, transparent); color: var(--accent-2);
}

/* widen on desktop --------------------------------------------------------- */
@media (min-width: 700px) {
  .wrap { max-width: 720px; }
  .cal-day { font-size: 15px; }
}
