*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a0a14;
  --bg-2: #14142a;
  --card: #0f0f20;
  --border: rgba(255,255,255,0.08);
  --fg: #f5f3ff;
  --muted: #8a87a8;
  --accent: #ffd24a;
  --accent-soft: rgba(255,210,74,0.12);
  --good: #5ee2a0;
  --bad: #ff5a72;
  --pos: #5ee2a0;
  --neg: #ff5a72;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --radius: 14px;
}

html { background: #05050c; }
html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  background: radial-gradient(ellipse at top, #1a1a35 0%, var(--bg) 60%);
  min-height: 100vh;
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "tnum" 1;
}

[hidden] { display: none !important; }

/* Header */
.bar {
  display: flex; align-items: center;
  max-width: 900px; margin: 0 auto; padding: 24px 24px 8px;
}
.wordmark {
  font-weight: 900; letter-spacing: -0.02em; font-size: 20px;
  background: linear-gradient(135deg, var(--accent), #ff9f4a);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}

main { max-width: 900px; margin: 0 auto; padding: 14px 24px 80px; }

/* Today panel */
.today {
  display: grid; grid-template-columns: minmax(200px, 1fr) 2fr; gap: 24px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px 26px; margin-bottom: 18px;
}
@media (max-width: 640px) { .today { grid-template-columns: 1fr; gap: 18px; } }

.today-week { border-right: 1px solid var(--border); padding-right: 24px; }
@media (max-width: 640px) {
  .today-week { border-right: none; border-bottom: 1px solid var(--border); padding: 0 0 18px; }
}

.today-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
@media (max-width: 520px) { .today-stats { grid-template-columns: 1fr 1fr; } }

.kicker {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--muted); margin-bottom: 8px;
}

.big {
  font-size: 56px; font-weight: 900; letter-spacing: -0.03em;
  line-height: 1; color: var(--accent); font-variant-numeric: tabular-nums;
}

.num {
  font-size: 22px; font-weight: 700; letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums; color: var(--accent);
}

.muted { color: var(--muted); }
.muted.small { font-size: 12px; margin-top: 4px; }

.bar-bg {
  height: 4px; background: rgba(255,255,255,0.08); border-radius: 999px;
  margin: 8px 0 4px; overflow: hidden;
}
.bar-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--good), var(--accent));
  transition: width .4s ease;
}

/* Ad slot */
.ad-slot {
  width: 100%; min-height: 90px; margin: 0 0 18px;
  border-radius: var(--radius);
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  overflow: hidden;
}

/* Grid */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
@media (max-width: 680px) { .grid { grid-template-columns: 1fr; } }

/* Cards */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px 16px;
}
.card h2 {
  margin: 0 0 14px; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted);
}

.row {
  display: grid; grid-template-columns: 80px 1fr;
  align-items: center; gap: 10px; margin-bottom: 8px;
}
.row > span { font-size: 13px; color: var(--muted); }

input[type="date"], input[type="number"], input[type="text"] {
  width: 100%; padding: 9px 12px; font: inherit; font-size: 14px;
  background: rgba(255,255,255,0.04); color: var(--fg);
  border: 1px solid var(--border); border-radius: 10px;
  font-variant-numeric: tabular-nums; outline: none;
}
input[type="date"] { font-family: var(--mono); font-size: 13px; }
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* Segmented control */
.seg {
  display: inline-flex; margin: 6px 0 4px;
  border: 1px solid var(--border); border-radius: 8px; padding: 2px;
}
.seg button {
  background: transparent; border: 0; color: var(--muted);
  padding: 5px 12px; font: inherit; font-size: 12px; cursor: pointer; border-radius: 6px;
}
.seg button.on { background: var(--accent-soft); color: var(--accent); }

/* Result output */
.result {
  display: block; margin-top: 12px; padding: 12px 14px;
  background: rgba(255,255,255,0.03); border: 1px solid var(--border);
  border-radius: 10px; font-size: 14px; font-variant-numeric: tabular-nums;
  cursor: copy; user-select: none; position: relative; transition: border-color .15s;
}
.result:hover, .result:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.result .primary { font-weight: 700; font-size: 18px; letter-spacing: -0.01em; color: var(--accent); }
.result .secondary { color: var(--muted); font-size: 13px; margin-top: 2px; }
.result .pos { color: var(--pos); }
.result .neg { color: var(--neg); }
.result.copied::after {
  content: "copied"; position: absolute; right: 12px; top: 50%;
  transform: translateY(-50%); font-size: 10px; color: var(--accent);
  letter-spacing: 0.08em; text-transform: uppercase;
}

/* Footer */
.foot { margin-top: 40px; }

.legal {
  font-size: 11px; color: rgba(255,255,255,0.25);
  text-align: center; letter-spacing: 0.01em; line-height: 1.8;
}

.kofi-inline {
  color: rgba(255,255,255,0.25); text-decoration: none;
  transition: color .15s;
}
.kofi-inline:hover { color: var(--accent); }
.linklike {
  background: none; border: 0; padding: 0; font: inherit;
  color: rgba(255,255,255,0.25); cursor: pointer;
  text-decoration: underline; text-decoration-color: rgba(255,255,255,0.12);
}
.linklike:hover { color: var(--accent); }

/* Modals */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  display: flex; justify-content: center; align-items: center;
  z-index: 50; padding: 4vh 4vw; backdrop-filter: blur(6px);
}
.modal-box {
  position: relative; width: min(520px, 100%); height: min(720px, 90vh);
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 30px 80px rgba(0,0,0,0.6);
  overflow: hidden;
}
.modal-close {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  background: rgba(255,255,255,0.08); border: none;
  width: 32px; height: 32px; border-radius: 50%;
  cursor: pointer; font-size: 20px; line-height: 1; color: var(--fg);
}
.modal-close:hover { background: rgba(255,255,255,0.15); }
.modal iframe { width: 100%; height: 100%; border: 0; }
.modal-text { height: auto; max-height: 90vh; }
.modal-scroll {
  padding: 32px 28px 28px; overflow-y: auto;
  max-height: 90vh; font-size: 14px; line-height: 1.6;
}
.modal-scroll h2 { margin: 0 0 4px; font-size: 17px; font-weight: 700; color: var(--fg); }
.modal-scroll h3 {
  margin: 22px 0 6px; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted);
}
.modal-scroll p { margin: 0 0 10px; color: var(--muted); }
.modal-scroll .updated { font-size: 12px; color: var(--muted); margin-bottom: 16px; }
.modal-scroll a { color: var(--accent); text-decoration: none; }
.modal-scroll a:hover { text-decoration: underline; }
