:root {
  --bg: #0f1216;
  --panel: #1a1f27;
  --panel-alt: #232a34;
  --border: #2b333f;
  --text: #e6e9ef;
  --muted: #8b95a7;
  --accent: #4ea1ff;
  --good: #4ad991;
  --warn: #ffbf47;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  line-height: 1.4;
  /* Dark at the top fading to lighter at the bottom. min-height keeps the
     gradient spanning the viewport on short pages, and a fixed attachment
     stops it repeating as the page scrolls. */
  min-height: 100vh;
  background: var(--bg);
  background: linear-gradient(180deg,
      rgba(13, 2, 2, 1) 0%,
      rgba(9, 9, 121, 1) 50%,
      rgba(0, 104, 125, 1) 100%);
  background-attachment: fixed;
}
main {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 16px 80px;
}
h1 {
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 20px;
}
h1 .sub {
  color: var(--muted);
  font-weight: 400;
  font-size: 13px;
  margin-left: 8px;
}
section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 16px;
}
section h2 {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 12px;
}
.row {
  display: grid;
  grid-template-columns: 1fr 160px;
  gap: 10px;
  align-items: center;
  padding: 8px 0;
}
.row + .row { border-top: 1px dashed var(--border); }
.row label { font-size: 14px; }
.row .hint {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}
input[type=number] {
  width: 100%;
  padding: 8px 10px;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
input[type=number]:focus {
  outline: none;
  border-color: var(--accent);
}
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button {
  -webkit-appearance: none; margin: 0;
}
input[type=number] { -moz-appearance: textfield; }

.out {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  padding: 8px 0;
  font-variant-numeric: tabular-nums;
}
.out + .out { border-top: 1px dashed var(--border); }
.out .val { font-size: 16px; font-weight: 600; }
.out.big .val { font-size: 22px; color: var(--good); }
.out .label { font-size: 14px; }
.out .label small { color: var(--muted); font-weight: 400; margin-left: 6px; font-size: 12px; }

.toggle {
  display: inline-flex;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}
.toggle button {
  background: transparent;
  color: var(--muted);
  border: none;
  padding: 6px 14px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
}
.toggle button.active {
  background: var(--accent);
  color: #0b1220;
}
.toggle.side button.active[data-side="long"]  { background: var(--good); color: #0b1220; }
.toggle.side button.active[data-side="short"] { background: #ff6b6b; color: #0b1220; }

.side-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  padding: 8px 0 12px;
}
.side-row label { font-size: 14px; font-weight: 500; }

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.error {
  color: var(--warn);
  font-size: 12px;
  margin-top: 8px;
  min-height: 16px;
}

/* Top navigation */
.topnav {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.topnav .brand {
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.02em;
}
.topnav .brand .dot {
  color: var(--accent);
  margin-right: 4px;
}
.topnav .tools {
  display: flex;
  gap: 4px;
}
.topnav .tools a {
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 6px;
}
.topnav .tools a:hover {
  background: var(--panel-alt);
  color: var(--text);
}
.topnav .tools a.active {
  background: var(--panel-alt);
  color: var(--text);
  font-weight: 500;
}

/* Chart */
.chart-wrap {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  overflow-x: auto;
}
.chart-wrap svg { display: block; width: 100%; height: auto; }
.chart-legend {
  display: flex;
  gap: 16px;
  justify-content: flex-end;
  padding-top: 8px;
  font-size: 12px;
  color: var(--muted);
}
.chart-legend .swatch {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 2px;
  margin-right: 6px;
  vertical-align: middle;
}

/* Table */
.table-wrap {
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}
table.drip {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}
table.drip th, table.drip td {
  padding: 6px 10px;
  text-align: right;
}
table.drip th {
  position: sticky;
  top: 0;
  background: var(--panel);
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
}
table.drip td:first-child, table.drip th:first-child { text-align: left; }
table.drip tr:nth-child(even) td { background: rgba(255,255,255,0.02); }
table.drip tr.payment td { color: var(--good); }


/* --- Login control (injected into the nav by auth.js) --------------------
   margin-left:auto pushes it to the right edge of whichever nav it lands in,
   so it needs no placeholder element in the six page templates. */
.authbox {
  display: flex; align-items: center; gap: 10px; margin-left: auto;
}
.topnav .authbox { font-size: 12.5px; }
.lp-nav .authbox { font-size: 13.5px; margin-left: 20px; }
.auth-user { display: flex; align-items: center; gap: 6px; color: var(--text); }
.auth-avatar {
  width: 20px; height: 20px; border-radius: 50%; display: block;
  background: var(--panel-alt);
}
.auth-name { max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.auth-link { color: var(--muted); text-decoration: none; }
.auth-link:hover { color: var(--text); }
.auth-link.auth-login {
  color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 4px 11px;
}
.auth-link.auth-login:hover { border-color: var(--accent); color: var(--accent); }
.auth-badge {
  font-size: 9px; font-weight: 700; letter-spacing: 0.06em;
  border: 1px solid var(--border); border-radius: 3px;
  padding: 2px 5px; color: var(--muted); text-decoration: none; line-height: 1;
}
.auth-badge.ok { color: var(--good); border-color: rgba(74,217,145,0.45); }
.auth-badge:hover { border-color: var(--accent); color: var(--accent); }
.auth-notice {
  background: rgba(255,191,71,0.15); color: var(--warn);
  padding: 9px 14px; font-size: 13px; text-align: center;
}
