﻿/* Clean white and silver, glossy green: a cool-to-the-touch, slightly skeuomorphic look. */
:root {
  --ink:        #18352a;
  --ink-soft:   #5d7268;
  --white:      #ffffff;
  --mist:       #f4faf7;
  --silver-1:   #ffffff;
  --silver-2:   #e9eef0;
  --silver-3:   #c9d3d6;
  --silver-edge:#b7c3c7;
  --green-hi:   #6fe39c;
  --green:      #22b25c;
  --green-lo:   #13863f;
  --green-edge: #0e6e33;
  --red-hi:     #ff8a8a;
  --red:        #e03b3b;
  --red-lo:     #b51f1f;
  --red-edge:   #921717;
  --money:      #129a4b;
  --none:       #d22a2a;
  --focus:      rgba(34, 178, 92, .35);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
::selection { background: var(--green); color: var(--white); }
body {
  margin: 0;
  color: var(--ink);
  font: 14px/1.4 "Segoe UI", "Segoe UI Variable", Frutiger, "Frutiger Linotype", "Helvetica Neue", Arial, sans-serif;
  background:
    radial-gradient(1200px 520px at 50% -160px, #ffffff 0%, rgba(255,255,255,0) 70%),
    radial-gradient(900px 600px at 105% 110%, rgba(111, 227, 156, .22) 0%, rgba(111, 227, 156, 0) 60%),
    radial-gradient(700px 500px at -10% 100%, rgba(166, 214, 232, .22) 0%, rgba(166, 214, 232, 0) 60%),
    linear-gradient(180deg, #ffffff 0%, var(--mist) 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }

/* ---- glass card --------------------------------------------------------- */
.card {
  position: relative;
  background: linear-gradient(180deg, rgba(255,255,255,.98) 0%, rgba(248,251,250,.96) 55%, rgba(238,244,242,.96) 100%);
  border: 1px solid var(--silver-edge);
  border-radius: 18px;
  box-shadow:
    inset 0 1px 0 #ffffff,
    inset 0 -1px 0 rgba(183, 195, 199, .35),
    0 1px 2px rgba(20, 60, 40, .08),
    0 12px 32px rgba(20, 60, 40, .12);
}
.card::before {                               /* the glass sheen across the top */
  content: "";
  position: absolute;
  inset: 1px 1px 55% 1px;
  border-radius: 17px 17px 40% 40% / 17px 17px 18px 18px;
  background: linear-gradient(180deg, rgba(255,255,255,.9), rgba(255,255,255,0));
  pointer-events: none;
}
.card > * { position: relative; }

/* ---- buttons: glossy, raised, they click down ---------------------------- */
.btn {
  --hi: var(--green-hi); --mid: var(--green); --lo: var(--green-lo); --edge: var(--green-edge);
  position: relative;
  min-width: 96px;
  height: 36px;
  padding: 0 20px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: .02em;
  color: #ffffff;
  text-shadow: 0 -1px 0 rgba(0, 0, 0, .25);
  background: linear-gradient(180deg, var(--hi) 0%, var(--mid) 52%, var(--lo) 100%);
  border: 1px solid var(--edge);
  border-radius: 10px;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.55),
    inset 0 -2px 3px rgba(0,0,0,.12),
    0 3px 0 var(--edge),
    0 5px 10px rgba(0, 0, 0, .14);
  cursor: pointer;
  user-select: none;
  transition: transform .06s ease, box-shadow .06s ease, filter .12s ease;
}
.btn::after {                                 /* the gloss on the upper half */
  content: "";
  position: absolute;
  left: 2px; right: 2px; top: 1px;
  height: 48%;
  border-radius: 8px 8px 12px 12px / 8px 8px 6px 6px;
  background: linear-gradient(180deg, rgba(255,255,255,.55), rgba(255,255,255,.08));
  pointer-events: none;
}
.btn:hover:not(:disabled) { filter: brightness(1.06) saturate(1.05); }
.btn:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.35),
    inset 0 2px 5px rgba(0,0,0,.2),
    0 0 0 var(--edge),
    0 1px 3px rgba(0, 0, 0, .14);
}
.btn:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--focus), inset 0 1px 0 rgba(255,255,255,.55), 0 3px 0 var(--edge); }
.btn:disabled { filter: grayscale(.6) opacity(.6); cursor: default; }
.btn.red { --hi: var(--red-hi); --mid: var(--red); --lo: var(--red-lo); --edge: var(--red-edge); }
.btn.red:focus-visible { box-shadow: 0 0 0 4px rgba(224, 59, 59, .3), inset 0 1px 0 rgba(255,255,255,.55), 0 3px 0 var(--edge); }
.btn.silver {
  --edge: var(--silver-edge);
  color: var(--ink);
  text-shadow: 0 1px 0 #ffffff;
  background: linear-gradient(180deg, #ffffff 0%, var(--silver-2) 55%, var(--silver-3) 100%);
}
.btn.small { min-width: 76px; height: 32px; padding: 0 14px; font-size: 13px; }
.btn.block { width: 100%; }
.btn.busy { pointer-events: none; animation: breathe 1s ease-in-out infinite; }
@keyframes breathe { 50% { filter: brightness(1.15) saturate(.8); } }

/* ---- text fields: pressed into the surface ------------------------------ */
input[type="text"] {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  background: linear-gradient(180deg, #f3f6f7 0%, #ffffff 40%);
  border: 1px solid var(--silver-edge);
  border-top-color: #a9b6ba;
  border-radius: 10px;
  box-shadow: inset 0 2px 3px rgba(20, 50, 40, .09), 0 1px 0 #ffffff;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input[type="text"]:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: inset 0 2px 3px rgba(20, 50, 40, .08), 0 0 0 4px var(--focus);
}

.actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }

/* A wrong answer: the card shakes and the fields glow red for a moment. */
.bad { animation: shake .42s cubic-bezier(.36,.07,.19,.97); }
.bad input[type="text"], input[type="text"].bad {
  border-color: var(--red);
  box-shadow: inset 0 2px 3px rgba(80, 20, 20, .08), 0 0 0 4px rgba(224, 59, 59, .25);
}
@keyframes shake {
  15%, 85% { transform: translateX(-2px); }
  30%, 70% { transform: translateX(5px); }
  45%      { transform: translateX(-7px); }
  58%      { transform: translateX(7px); }
}

/* ---- sign in ------------------------------------------------------------ */
#loginScreen {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.login { width: 360px; max-width: 100%; padding: 28px 28px 26px; }
.logo {
  display: block;
  width: 64px; height: 64px;
  margin: 0 auto 22px;
  filter: drop-shadow(0 4px 6px rgba(19, 134, 63, .3));
}
.fields {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  column-gap: 12px;
  row-gap: 12px;
  margin-bottom: 24px;
}
.fields label {
  min-width: 30px;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: .06em;
  color: var(--green-lo);
  text-shadow: 0 1px 0 #ffffff;
}

/* ---- signed in: raised white plates, hard edges ------------------------- */
#appScreen { min-height: 100%; padding-bottom: 40px; }
.plate {
  background: linear-gradient(180deg, #ffffff 0%, #f8fafa 100%);
  border: 1px solid #d3dbde;
  border-radius: 16px;
  box-shadow:
    inset 0 1px 0 #ffffff,
    inset 0 -1px 0 rgba(170, 185, 190, .3),
    0 1px 0 #c8d2d5,
    0 2px 0 #dde4e6,
    0 16px 30px -14px rgba(20, 50, 40, .22);
}

/* the top menu: central, with a slot each side (a logo later on the left, the cog on the right) */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) 64px;
  align-items: center;
  gap: 16px;
  max-width: 1360px;
  margin: 0 auto;
  padding: 16px 16px 0;
}
.slot { display: flex; justify-content: center; }
.slot.right { position: relative; }
.menu {
  height: 66px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 9px;
}
.tab {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 50px;
  padding: 0 18px 0 6px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 13px;
  cursor: pointer;
}
.tab .disc {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--ink-soft);
  background: linear-gradient(180deg, #ffffff, #e6ecee);
  border: 1px solid #c6d0d3;
  box-shadow: inset 0 1px 0 #ffffff, 0 1px 0 #c8d2d5;
}
.tab .disc svg { width: 22px; height: 22px; fill: currentColor; }
.tab:hover:not(.active) { color: var(--ink); }
/* the open panel's tab: set into the bar, its disc lit green */
.tab.active {
  color: var(--green-lo);
  background: linear-gradient(180deg, #edf5f0 0%, #f6faf8 100%);
  border-color: #d2e3d9;
  box-shadow: inset 0 2px 4px rgba(20, 70, 40, .1), 0 1px 0 #ffffff;
}
.tab.active .disc {
  color: #ffffff;
  background: radial-gradient(circle at 50% 28%, var(--green-hi) 0%, var(--green) 55%, var(--green-lo) 100%);
  border-color: var(--green-edge);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.55), 0 0 0 3px rgba(34, 178, 92, .16);
}
.tab.active .disc svg { filter: drop-shadow(0 -1px 0 rgba(0,0,0,.18)); }
.tab:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus); }

/* The cog rests pressed into the bar; a press sinks it further. */
.cog {
  width: 50px; height: 50px;
  display: grid; place-items: center;
  padding: 0;
  color: #ffffff;
  background: radial-gradient(circle at 50% 38%, #34c46d 0%, var(--green) 50%, var(--green-lo) 100%);
  border: 1px solid var(--green-edge);
  border-radius: 50%;
  box-shadow:
    inset 0 2px 5px rgba(0, 0, 0, .24),
    inset 0 -1px 0 rgba(255, 255, 255, .25),
    0 1px 0 #ffffff,
    0 0 0 4px #eef3f2,
    0 0 0 5px #d3dbde;
  cursor: pointer;
  transition: box-shadow .08s ease, filter .12s ease;
}
.cog svg { width: 25px; height: 25px; filter: drop-shadow(0 1px 0 rgba(0,0,0,.2)); transition: transform .35s ease; }
.cog[aria-expanded="true"] svg { transform: rotate(45deg); }
.cog:active, .cog[aria-expanded="true"] {
  filter: brightness(.94);
  box-shadow:
    inset 0 3px 7px rgba(0, 0, 0, .32),
    inset 0 -1px 0 rgba(255, 255, 255, .2),
    0 1px 0 #ffffff,
    0 0 0 4px #eef3f2,
    0 0 0 5px #d3dbde;
}
.cog:focus-visible { outline: none; box-shadow: inset 0 2px 5px rgba(0,0,0,.24), 0 0 0 4px var(--focus); }
.cog[aria-expanded="true"]:focus-visible { box-shadow: inset 0 3px 7px rgba(0,0,0,.32), inset 0 -1px 0 rgba(255,255,255,.2), 0 0 0 4px var(--focus); }

.panel {
  position: absolute;
  top: calc(100% + 16px);
  right: 0;
  width: 380px;
  max-width: calc(100vw - 32px);
  padding: 18px;
  transform-origin: top right;
  animation: pop .14s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(-6px) scale(.98); } }
.caption {
  margin-bottom: 8px;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--green-lo);
  text-shadow: 0 1px 0 #ffffff;
}
.keyrow { display: flex; gap: 10px; align-items: center; }
.keybox { position: relative; flex: 1; min-width: 0; }
.keybox input { font-family: Consolas, "Cascadia Mono", monospace; font-size: 13px; }
.keybox .lock {
  display: none;
  position: absolute; right: 10px; top: 50%;
  width: 18px; height: 18px; margin-top: -9px;
  fill: none; stroke: var(--green-lo); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round;
}
.keybox.locked input {                        /* saved: shut, a hint only, under a lock */
  padding-right: 36px;
  color: var(--ink-soft);
  background: linear-gradient(180deg, #e9f2ee 0%, #f5faf8 100%);
  border-color: #9fc7b0;
  cursor: default;
}
.keybox.locked .lock { display: block; }
.divider {
  height: 2px;
  margin: 18px 0;
  background: linear-gradient(180deg, var(--silver-3) 0 1px, #ffffff 1px 2px);
}

/* ---- the board: the chart, the period beside it, room below for more ---- */
.board {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 292px;
  gap: 20px;
  align-items: start;
  max-width: 1360px;
  margin: 24px auto 0;
  padding: 0 16px;
}
.chart { padding: 20px 22px 14px; min-width: 0; }
.plate-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 10px; }
.plate-head h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--green-lo);
}
.sub { margin-top: 2px; font-size: 15px; font-weight: 600; color: var(--ink); }
.figure { font-size: 34px; font-weight: 700; line-height: 1; color: var(--ink); font-variant-numeric: tabular-nums; }
.chart-body { position: relative; height: 340px; }
#chartSvg { display: block; width: 100%; height: 100%; overflow: visible; transition: opacity .2s ease; }
.chart-body.loading #chartSvg { opacity: .35; }
.chart-body.empty #chartSvg { opacity: 0; }
.chart-state {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  pointer-events: none;
  font-size: clamp(36px, 6vw, 64px);
  font-weight: 700;
}
.chart-state.none {
  background: linear-gradient(180deg, #ff6464 0%, var(--none) 55%, #9e1414 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 1px 0 #ffffff) drop-shadow(0 6px 10px rgba(210, 42, 42, .18));
}
.chart-state.wait::before {                   /* three soft dots while Stripe answers */
  content: "";
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 22px 0 0 var(--green), -22px 0 0 var(--green);
  opacity: .5;
  animation: breathe-dot 1.1s ease-in-out infinite;
}
@keyframes breathe-dot { 50% { opacity: .15; } }
.grid-line { stroke: #e3e9eb; stroke-width: 1; shape-rendering: crispEdges; }
.base-line { stroke: #c3cdd0; stroke-width: 1; shape-rendering: crispEdges; }
.axis-text { font: 11px "Segoe UI", Arial, sans-serif; fill: #7b8d86; font-variant-numeric: tabular-nums; }
.axis-text.today { fill: var(--green-lo); font-weight: 700; }
.value-text { font: 600 10.5px "Segoe UI", Arial, sans-serif; fill: var(--green-lo); font-variant-numeric: tabular-nums; }

.switcher { padding: 18px; }
.stepper { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.year { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* hard-surface keys: white, a firm edge below, they press down */
.key {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  background: linear-gradient(180deg, #ffffff 0%, #eef2f3 100%);
  border: 1px solid #cbd4d7;
  border-radius: 9px;
  box-shadow: inset 0 1px 0 #ffffff, 0 2px 0 #cfd8db, 0 3px 6px rgba(20, 50, 40, .08);
  cursor: pointer;
  transition: transform .06s ease, box-shadow .06s ease;
}
.key:hover:not(:disabled):not(.on) { border-color: #9fc7b0; }
.key:active:not(:disabled) { transform: translateY(2px); box-shadow: inset 0 1px 3px rgba(20, 50, 40, .15), 0 0 0 #cfd8db; }
.key:disabled { opacity: .38; cursor: default; box-shadow: inset 0 1px 0 #ffffff; }
.key:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus), 0 2px 0 #cfd8db; }
.key.on {
  color: #ffffff;
  text-shadow: 0 -1px 0 rgba(0, 0, 0, .2);
  background: linear-gradient(180deg, #2fc46a 0%, var(--green) 55%, var(--green-lo) 100%);
  border-color: var(--green-edge);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, .2), inset 0 -1px 0 rgba(255, 255, 255, .15);
  transform: translateY(2px);
}
.step { width: 38px; height: 34px; display: grid; place-items: center; padding: 0; }
.step svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.months {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px 8px;
  margin: 18px 0 12px;
  padding-top: 16px;
  border-top: 1px solid #e3e9eb;
}
.months .key { height: 36px; }
.whole { width: 100%; height: 38px; }

@media (max-width: 860px) {
  .board { grid-template-columns: minmax(0, 1fr); }
  .chart-body { height: 260px; }
  .figure { font-size: 28px; }
}
@media (max-width: 480px) {
  .topbar { grid-template-columns: 0 minmax(0, 1fr) 54px; gap: 10px; }
  .chart { padding: 16px 14px 10px; }
}

/* ---- confirm dialog ------------------------------------------------------ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(230, 240, 236, .55);
  backdrop-filter: blur(3px);
}
.dialog { width: 360px; max-width: 100%; padding: 24px; animation: pop .14s ease-out; }
#messageText { margin: 0 0 20px; font-size: 15px; white-space: pre-line; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
