/* Shop Book: white, soft-structural, one blue accent with a blue-to-teal gradient. */
:root {
  color-scheme: light;
  --page: #f6f7fb;
  --card: #ffffff;
  --ink: #0f172a;
  --ink-2: #475569;
  --muted: #64748b;
  --hair: rgba(15, 23, 42, 0.06);
  --field: #f3f5f9;
  --field-hover: #eef1f7;
  --accent: #1d4ed8;
  --accent-soft: #e8eefc;
  --grad: linear-gradient(140deg, #0b1f4d 0%, #1d4ed8 55%, #0f766e 110%);
  --grad-soft: linear-gradient(140deg, #eef3ff 0%, #e9f7f4 100%);
  --danger: #c0262d;
  --good: #047857;
  --series-balance: #2a78d6;
  --series-expense: #eb6834;
  --r-shell: 26px;
  --r-core: 20px;
  --r-field: 14px;
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 18px 40px -24px rgba(15, 23, 42, 0.18);
  --tabs-space: 96px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--page);
  color: var(--ink);
  font: 17px/1.45 "SF Pro Text", "Segoe UI Variable Text", system-ui, -apple-system, "Segoe UI", sans-serif;
  letter-spacing: -0.005em;
  padding-bottom: calc(var(--tabs-space) + env(safe-area-inset-bottom));
}
/* Soft colour wash behind everything; fixed so it never repaints on scroll */
body::before {
  content: "";
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(900px 420px at 0% -8%, rgba(29, 78, 216, 0.10), transparent 60%),
    radial-gradient(700px 380px at 100% -4%, rgba(15, 118, 110, 0.09), transparent 60%);
}
main { max-width: 620px; margin: 0 auto; padding: max(14px, env(safe-area-inset-top)) 16px 90px; }
/* the floating day bar positions itself with transform, so it must not take the entrance animation */
main > *:not(.daybar) { animation: rise 240ms var(--ease) both; }
main > *:nth-child(2) { animation-delay: 40ms; }
main > *:nth-child(3) { animation-delay: 80ms; }
main > *:nth-child(4) { animation-delay: 120ms; }
main > *:nth-child(n + 5) { animation-delay: 160ms; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

h1, h2 { margin: 0; line-height: 1.15; letter-spacing: -0.02em; }
h2 { font-size: 17px; font-weight: 650; }
button, input { font: inherit; color: inherit; }
a { color: var(--accent); text-underline-offset: 3px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }

/* ---------- Gradient hero ---------- */
.hero {
  position: relative; overflow: hidden;
  border-radius: var(--r-shell);
  padding: 18px 18px 20px;
  margin-bottom: 16px;
  color: #fff;
  background: var(--grad);
  box-shadow: 0 24px 48px -28px rgba(29, 78, 216, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.hero::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(420px 220px at 85% -20%, rgba(255, 255, 255, 0.22), transparent 70%);
}
.hero > * { position: relative; z-index: 1; }
.hero-nav { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; gap: 8px; }
.hero-nav .title { text-align: center; }
.hero-nav h1 { font-size: 21px; font-weight: 700; }
.hero-nav .sub { display: block; font-size: 14px; opacity: 0.78; margin-top: 2px; }
.round {
  width: 44px; height: 44px; border-radius: 999px;
  display: grid; place-items: center; text-decoration: none;
  color: #fff; font-size: 24px; line-height: 1;
  background: rgba(255, 255, 255, 0.14);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
  transition: transform 300ms var(--ease), background 300ms var(--ease);
}
.round:active { transform: scale(0.94); background: rgba(255, 255, 255, 0.22); }
.round.ghost { visibility: hidden; }
/* Chevron drawn from two borders of a rotated square, so it sits on the circle's
   exact centre. A text "‹" sits on the font's baseline and looks off. The 2px
   nudge moves the chevron's visual centre (not its box) to the middle. */
.chev {
  width: 11px; height: 11px;
  border-left: 2.5px solid currentColor; border-bottom: 2.5px solid currentColor;
  border-radius: 1.5px;
  transform: translateX(2px) rotate(45deg);
}
.chev.right { transform: translateX(-2px) rotate(-135deg); }

/* Two equal glass tiles, so the numbers line up with each other and the card edges */
.hero-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.stat {
  padding: 12px 14px 13px; border-radius: 16px; min-width: 0;
  background: rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.stat small { display: block; font-size: 13px; font-weight: 600; opacity: 0.82; }
.stat strong { display: block; margin-top: 4px; font-size: 26px; font-weight: 750; letter-spacing: -0.02em; line-height: 1.1; }
.hero-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; }
.hero-foot:not(:has(> :not([hidden]))) { display: none; }
.hero-foot .today-link { margin: 0 0 0 auto; }
.hero-big small { font-size: 14px; opacity: 0.8; font-weight: 500; }
.hero-big strong { display: block; font-size: 42px; font-weight: 750; letter-spacing: -0.03em; margin: 2px 0 10px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: rgba(255, 255, 255, 0.16); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}
.today-link { display: block; text-align: center; color: #fff; font-size: 14px; font-weight: 600; opacity: 0.9; }

/* ---------- Double-bezel cards ---------- */
.shell {
  padding: 5px; margin-bottom: 16px;
  border-radius: var(--r-shell);
  background: rgba(15, 23, 42, 0.025);
  box-shadow: inset 0 0 0 1px var(--hair);
}
.core {
  background: var(--card);
  border-radius: var(--r-core);
  padding: 16px;
  box-shadow: var(--shadow), inset 0 1px 0 #fff;
}
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-head .unit { font-size: 13px; color: var(--muted); font-weight: 600; }

/* ---------- Fields ---------- */
label { display: block; font-size: 15px; font-weight: 600; color: var(--ink); }
input:not([type]), input[type="text"], input[type="password"] {
  width: 100%; min-height: 50px; padding: 12px 14px;
  border: 1px solid transparent; border-radius: var(--r-field);
  background: var(--field);
  transition: background 250ms var(--ease), box-shadow 250ms var(--ease), border-color 250ms var(--ease);
}
input::placeholder { color: #8a94a6; }
input:hover { background: var(--field-hover); }
input:focus { outline: none; background: #fff; border-color: rgba(29, 78, 216, 0.55); box-shadow: 0 0 0 4px rgba(29, 78, 216, 0.12); }
a:focus-visible, button:focus-visible { outline: 3px solid rgba(29, 78, 216, 0.45); outline-offset: 2px; }
input.amount { text-align: right; font-variant-numeric: tabular-nums; font-weight: 650; }
input[aria-invalid="true"] { background: #fff5f5; border-color: var(--danger); box-shadow: 0 0 0 4px rgba(192, 38, 45, 0.1); }

.lines { display: grid; gap: 8px; }
.line { display: grid; grid-template-columns: 1fr 104px 36px; gap: 8px; align-items: center; }
.line input { padding-left: 12px; padding-right: 12px; }
.line input[data-field="item"] { font-weight: 550; }
.remove {
  width: 36px; height: 40px; border: 0; border-radius: 999px; background: none;
  color: #94a3b8; font-size: 22px; cursor: pointer;
  transition: background 250ms var(--ease), color 250ms var(--ease);
}
.remove:hover, .remove:active { background: #fdecec; color: var(--danger); }

.add-line {
  width: 100%; min-height: 50px; margin-top: 10px;
  border: 1.5px dashed rgba(29, 78, 216, 0.3); border-radius: var(--r-field);
  background: rgba(29, 78, 216, 0.03); color: var(--accent); font-weight: 650; cursor: pointer;
  transition: background 250ms var(--ease), transform 250ms var(--ease);
}
.add-line:active { transform: scale(0.98); background: rgba(29, 78, 216, 0.07); }

.chips-label { font-size: 13px; color: var(--muted); font-weight: 600; margin: 16px 0 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 42px; padding: 0 14px 0 6px; border-radius: 999px; cursor: pointer;
  border: 0; background: #fff; font-size: 15px; font-weight: 550;
  box-shadow: 0 0 0 1px var(--hair), 0 4px 12px -6px rgba(15, 23, 42, 0.18);
  transition: transform 250ms var(--ease), box-shadow 250ms var(--ease);
}
.chip i {
  width: 30px; height: 30px; border-radius: 999px; display: grid; place-items: center;
  font-style: normal; font-weight: 700; color: var(--accent); background: var(--accent-soft);
  transition: transform 300ms var(--ease);
}
.chip:active { transform: scale(0.96); }
.chip:hover i { transform: scale(1.08); }

.sales { display: grid; gap: 10px; }
.sales .row { display: grid; grid-template-columns: 1fr 140px; align-items: center; gap: 12px; }
.hint { display: block; font-size: 13px; color: var(--muted); font-weight: 400; }

/* ---------- Floating day bar (appears once the hero scrolls away) ---------- */
.daybar {
  position: fixed; left: 50%; z-index: 20;
  bottom: calc(84px + env(safe-area-inset-bottom));
  width: min(588px, calc(100% - 32px));
  display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; align-items: center;
  padding: 10px 16px; border-radius: 20px;
  background: rgba(255, 255, 255, 0.86);
  -webkit-backdrop-filter: blur(16px) saturate(160%); backdrop-filter: blur(16px) saturate(160%);
  box-shadow: 0 0 0 1px var(--hair), 0 16px 36px -18px rgba(15, 23, 42, 0.35);
  transform: translate(-50%, 140%); opacity: 0;
  transition: transform 450ms var(--ease), opacity 300ms var(--ease);
}
.daybar.show { transform: translate(-50%, 0); opacity: 1; }
.daybar small { display: block; font-size: 12px; color: var(--muted); font-weight: 600; }
.daybar strong { font-size: 18px; font-weight: 700; }

.status { font-size: 13px; font-weight: 600; text-align: right; min-width: 70px; white-space: nowrap; }
.status.saved { color: var(--good); }
.status.err { color: var(--danger); }
.hero .status { text-align: left; min-width: 0; color: #fff; }
.hero .status.saved, .hero .status.err { color: #fff; }

/* ---------- Floating tab island ---------- */
.tabs {
  position: fixed; left: 50%; z-index: 30;
  bottom: calc(14px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  width: min(360px, calc(100% - 32px));
  padding: 5px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  -webkit-backdrop-filter: blur(18px) saturate(170%); backdrop-filter: blur(18px) saturate(170%);
  box-shadow: 0 0 0 1px var(--hair), 0 18px 40px -16px rgba(15, 23, 42, 0.35);
}
.tabs a {
  display: grid; place-items: center; min-height: 50px; border-radius: 999px;
  text-decoration: none; color: var(--ink-2); font-weight: 650; font-size: 15px;
  transition: color 300ms var(--ease), background 300ms var(--ease), transform 250ms var(--ease);
}
.tabs a:active { transform: scale(0.97); }
.tabs a[aria-current="page"] { color: #fff; background: var(--grad); box-shadow: 0 8px 18px -10px rgba(29, 78, 216, 0.8); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 52px; padding: 0 8px 0 22px; border: 0; border-radius: 999px;
  font-weight: 650; cursor: pointer; text-decoration: none;
  background: var(--grad); color: #fff;
  box-shadow: 0 14px 28px -16px rgba(29, 78, 216, 0.85);
  transition: transform 250ms var(--ease), box-shadow 250ms var(--ease);
}
.btn .ico {
  width: 36px; height: 36px; border-radius: 999px; display: grid; place-items: center;
  background: rgba(255, 255, 255, 0.18); font-size: 17px;
  transition: transform 350ms var(--ease);
}
.btn:hover .ico { transform: translate(2px, 1px) scale(1.05); }
.btn:active { transform: scale(0.98); }
.btn.wide { width: 100%; }
.btn.plain { padding: 0 22px; }

/* ---------- Dashboard ---------- */
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.kpi {
  background: var(--card); border-radius: var(--r-core); padding: 14px 16px;
  box-shadow: 0 0 0 1px var(--hair), var(--shadow);
}
.kpi small { display: block; font-size: 13px; color: var(--muted); font-weight: 600; }
.kpi strong { display: block; font-size: 22px; font-weight: 700; letter-spacing: -0.02em; margin-top: 4px; }
.kpi.wide { grid-column: 1 / -1; background: var(--grad-soft); }
.kpi.wide strong { font-size: 26px; }

.report {
  display: grid; gap: 14px;
  background: var(--grad-soft);
}
.report p { margin: 4px 0 0; color: var(--ink-2); font-size: 15px; }

.legend { display: flex; gap: 16px; font-size: 13px; color: var(--ink-2); font-weight: 550; margin-bottom: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .bar { cursor: pointer; outline: none; }
.chart .bar rect, .chart .bar path { transition: opacity 250ms var(--ease); }
.chart-detail { min-height: 44px; margin-top: 10px; font-size: 14px; color: var(--ink-2); }
.chart-detail b { color: var(--ink); }

table { width: 100%; border-collapse: collapse; font-size: 15px; }
th { text-align: right; font-size: 12px; color: var(--muted); font-weight: 650; padding: 0 4px 8px; text-transform: none; }
th:first-child, td:first-child { text-align: left; }
td { text-align: right; padding: 11px 4px; border-top: 1px solid #eef1f5; font-variant-numeric: tabular-nums; }
tr.link { cursor: pointer; transition: background 200ms var(--ease); }
tr.link:active { background: #f5f7fb; }
tr.total td { font-weight: 700; border-top: 1px solid #dfe4ec; }
td a { font-weight: 600; text-decoration: none; }

.items { display: grid; gap: 12px; }
.item-row { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; font-size: 15px; font-weight: 550; }
.item-row .bar { grid-column: 1 / -1; height: 8px; border-radius: 0 4px 4px 0; background: var(--series-expense); min-width: 3px; }

.empty { text-align: center; padding: 30px 10px; color: var(--ink-2); display: grid; gap: 14px; justify-items: center; }
.banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px; margin-bottom: 14px; border-radius: 16px;
  background: #fff; box-shadow: 0 0 0 1px var(--hair), var(--shadow); font-size: 14px;
}
.banner.warn { background: #fff8eb; box-shadow: 0 0 0 1px #f5d9a8; color: #7a4b00; }
.banner a { font-weight: 650; white-space: nowrap; }

/* ---------- Login ---------- */
.login { min-height: 80dvh; display: grid; align-content: center; gap: 18px; max-width: 380px; margin: 0 auto; }
.login .hero { padding: 26px 22px; }
.login .hero h1 { font-size: 30px; }
.login .hero p { margin: 6px 0 0; opacity: 0.82; }
.login input { font-size: 26px; letter-spacing: 0.4em; text-align: center; margin-top: 8px; }
.error { color: var(--danger); font-size: 14px; margin-top: 8px; min-height: 20px; }

/* ---------- In-app number keypad ---------- */
.keypad {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  max-width: 620px; margin: 0 auto;
  padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
  border-radius: 26px 26px 0 0;
  background: rgba(248, 250, 253, 0.94);
  -webkit-backdrop-filter: blur(20px) saturate(170%); backdrop-filter: blur(20px) saturate(170%);
  box-shadow: 0 -1px 0 var(--hair), 0 -24px 48px -24px rgba(15, 23, 42, 0.35);
  transform: translateY(105%);
  transition: transform 260ms var(--ease);
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
.keypad.open { transform: translateY(0); }
.kp-stage { margin: 0 0 10px; border-radius: 18px; background: #fff; box-shadow: 0 0 0 1px var(--hair); overflow: hidden; }
.kp-cur { display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 14px; background: linear-gradient(180deg, rgba(29, 78, 216, 0.07), rgba(29, 78, 216, 0.02)); }
.kp-name { min-width: 0; flex: 1; }
.kp-name small { display: block; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); }
.kp-name strong { display: block; font-size: 18px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kp-val { display: flex; align-items: baseline; gap: 4px; }
.kp-val b { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kp-val b.dim { color: #b6bdcc; }
.kp-val em { font-style: normal; font-size: 12px; font-weight: 700; color: var(--muted); }
.kp-nxt { display: flex; align-items: center; gap: 10px; padding: 9px 14px; border-top: 1px solid var(--hair); color: var(--muted); font-size: 15px; font-weight: 550; }
.kp-nxt small { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; min-width: 34px; }
.kp-nxt-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink); opacity: 0.75; }
.kp-nxt-val { font-variant-numeric: tabular-nums; }
.kp-nxt.warn .kp-nxt-name { color: var(--danger); opacity: 1; }
.kp-nxt.end .kp-nxt-name { opacity: 0.55; font-weight: 500; }
.kp-done {
  border: 0; border-radius: 999px; padding: 9px 16px; cursor: pointer;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 15px;
}
.kp-grid { display: grid; grid-template-columns: repeat(4, 1fr); grid-auto-rows: 56px; gap: 8px; }
.kp-grid button {
  border: 0; border-radius: 16px; cursor: pointer;
  background: #fff; color: var(--ink);
  font-size: 25px; font-weight: 600; font-variant-numeric: tabular-nums;
  box-shadow: 0 0 0 1px var(--hair), 0 2px 0 rgba(15, 23, 42, 0.06);
  transition: transform 90ms ease-out, background 90ms ease-out;
  touch-action: manipulation;
}
.kp-grid button:active { transform: scale(0.95); background: #eef1f7; }
.kp-grid .kp-fn { font-size: 22px; background: #eef1f7; }
.kp-grid .kp-zero { grid-column: span 2; }
.kp-grid .kp-next {
  grid-column: 4; grid-row: 2 / span 3;
  display: grid; place-content: center; gap: 4px;
  background: var(--grad); color: #fff; font-size: 18px; font-weight: 700;
  box-shadow: 0 12px 24px -14px rgba(29, 78, 216, 0.9);
}
.kp-grid .kp-next span { font-size: 22px; }
.kp-grid .kp-next:active { background: var(--grad); filter: brightness(1.08); }
/* the field being typed into */
input.pad-active { background: #fff; border-color: rgba(29, 78, 216, 0.6); box-shadow: 0 0 0 4px rgba(29, 78, 216, 0.14); }
/* make room so the last fields can scroll above the pad, and get the bars out of the way */
body.kp-open main { padding-bottom: 420px; }
body.kp-open .tabs, body.kp-open .daybar { opacity: 0; pointer-events: none; transform: translate(-50%, 140%); }

/* ---------- By week ---------- */
.weeks { display: grid; gap: 10px; }
.week {
  padding: 14px; border-radius: 18px;
  background: #fbfcfe; box-shadow: inset 0 0 0 1px #e6eaf1;
}
.week-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.week-name { font-weight: 700; font-size: 16px; }
.week-name span { color: var(--muted); font-weight: 500; font-size: 14px; margin-left: 6px; }
.badge {
  font-size: 12.5px; font-weight: 650; color: var(--ink-2); white-space: nowrap;
  padding: 3px 10px; border-radius: 999px; background: #fff; box-shadow: inset 0 0 0 1px #e1e6ee;
}
.split { display: flex; gap: 2px; height: 10px; margin-bottom: 12px; }
.split i { display: block; min-width: 3px; }
.split i:first-child { border-radius: 5px 0 0 5px; }
.split i:last-child { border-radius: 0 5px 5px 0; }
.split .e { background: var(--series-expense); }
.split .b { background: var(--series-balance); }
.figs { display: grid; grid-template-columns: repeat(3, 1fr); }
.figs > div { padding: 0 10px; min-width: 0; }
.figs > div:first-child { padding-left: 0; }
.figs > div + div { border-left: 1px solid #e3e7ee; }
.figs small { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 650; }
.figs small i { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.figs b { display: block; margin-top: 3px; font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.week.total { background: var(--grad-soft); box-shadow: inset 0 0 0 1px #d9e3f5; }
.week.total .figs b { font-size: 17px; }
th { white-space: nowrap; border-bottom: 1px solid #e3e7ee; }

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